Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit8b6ffca

Browse files
committed
Apply golangci-lint fixes
1 parent3c1c1fa commit8b6ffca

File tree

8 files changed

+19
-28
lines changed

8 files changed

+19
-28
lines changed

‎internal/decoder/error_context_test.go‎

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,9 @@ func BenchmarkWrapError_HappyPath(b *testing.B) {
7272
dd:=NewDataDecoder(buffer)
7373
decoder:=NewDecoder(dd,0)
7474

75-
b.ResetTimer()
7675
b.ReportAllocs()
7776

78-
forrangeb.N {
77+
forb.Loop() {
7978
err:=decoder.wrapError(nil)
8079
iferr!=nil {
8180
b.Fatal("unexpected error")
@@ -91,10 +90,9 @@ func BenchmarkWrapError_ErrorPath(b *testing.B) {
9190

9291
originalErr:=mmdberrors.NewInvalidDatabaseError("test error")
9392

94-
b.ResetTimer()
9593
b.ReportAllocs()
9694

97-
forrangeb.N {
95+
forb.Loop() {
9896
err:=decoder.wrapError(originalErr)
9997
iferr==nil {
10098
b.Fatal("expected error")

‎internal/decoder/performance_test.go‎

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,9 +25,7 @@ func BenchmarkStructDecoding(b *testing.B) {
2525
Enstring`maxminddb:"en"`// Simple field
2626
}
2727

28-
b.ResetTimer()
29-
30-
forrangeb.N {
28+
forb.Loop() {
3129
varresultTestStruct
3230
err:=decoder.Decode(0,&result)
3331
iferr!=nil {
@@ -51,9 +49,7 @@ func BenchmarkSimpleDecoding(b *testing.B) {
5149
Enstring`maxminddb:"en"`
5250
}
5351

54-
b.ResetTimer()
55-
56-
forrangeb.N {
52+
forb.Loop() {
5753
varresultTestStruct
5854
err:=decoder.Decode(0,&result)
5955
iferr!=nil {
@@ -85,9 +81,7 @@ func BenchmarkFieldLookup(b *testing.B) {
8581

8682
fieldNames:= []string{"f01","f02","f03","f04","f05","f06","f07","f08","f09","f10"}
8783

88-
b.ResetTimer()
89-
90-
forrangeb.N {
84+
forb.Loop() {
9185
// Test field lookup performance
9286
for_,name:=rangefieldNames {
9387
_,exists:=fields.namedFields[name]

‎internal/decoder/reflection.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,7 @@ func (d *ReflectionDecoder) unmarshalBool(
402402
returnnewOffset,mmdberrors.NewUnmarshalTypeError(value,result.Type())
403403
}
404404

405-
varsliceType=reflect.TypeOf([]byte{})
405+
varsliceType=reflect.TypeFor[[]byte]()
406406

407407
func (d*ReflectionDecoder)unmarshalBytes(
408408
size,offsetuint,
@@ -700,7 +700,7 @@ func (d *ReflectionDecoder) unmarshalUint(
700700
returnnewOffset,mmdberrors.NewUnmarshalTypeError(value,result.Type())
701701
}
702702

703-
varbigIntType=reflect.TypeOf(big.Int{})
703+
varbigIntType=reflect.TypeFor[big.Int]()
704704

705705
func (d*ReflectionDecoder)unmarshalUint128(
706706
size,offsetuint,resultaddressableValue,

‎internal/decoder/tag_validation_test.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ func TestValidateTag(t *testing.T) {
5858
// Create a mock struct field
5959
field:= reflect.StructField{
6060
Name:tt.fieldName,
61-
Type:reflect.TypeOf(""),
61+
Type:reflect.TypeFor[string](),
6262
}
6363

6464
err:=validateTag(field,tt.tag)
@@ -85,7 +85,7 @@ func TestTagValidationIntegration(t *testing.T) {
8585
}
8686

8787
// This should not panic even with invalid tags
88-
structType:=reflect.TypeOf(TestStruct{})
88+
structType:=reflect.TypeFor[TestStruct]()
8989
fields:=makeStructFields(structType)
9090

9191
// Verify that valid fields are still processed

‎internal/mmdberrors/context.go‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,8 @@ func (p *PathBuilder) ParseAndExtend(path string) {
127127
path=path[1:]
128128
}
129129

130-
segments:=strings.Split(path,"/")
131-
for_,segment:=rangesegments {
130+
segments:=strings.SplitSeq(path,"/")
131+
forsegment:=rangesegments {
132132
ifsegment!="" {
133133
p.segments=append(p.segments,segment)
134134
}

‎mmap_windows.go‎

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
//go:build windows && !appengine
2-
// +build windows,!appengine
32

43
package maxminddb
54

‎reader_test.go‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -835,7 +835,7 @@ func checkIpv6(t *testing.T, reader *Reader) {
835835
funcBenchmarkOpen(b*testing.B) {
836836
vardb*Reader
837837
varerrerror
838-
forrangeb.N {
838+
forb.Loop() {
839839
db,err=Open("GeoLite2-City.mmdb")
840840
iferr!=nil {
841841
b.Fatal(err)
@@ -854,7 +854,7 @@ func BenchmarkInterfaceLookup(b *testing.B) {
854854
varresultany
855855

856856
s:=make(net.IP,4)
857-
forrangeb.N {
857+
forb.Loop() {
858858
ip:=randomIPv4Address(r,s)
859859
err=db.Lookup(ip).Decode(&result)
860860
iferr!=nil {
@@ -872,7 +872,7 @@ func BenchmarkLookupNetwork(b *testing.B) {
872872
r:=rand.New(rand.NewSource(time.Now().UnixNano()))
873873

874874
s:=make(net.IP,4)
875-
forrangeb.N {
875+
forb.Loop() {
876876
ip:=randomIPv4Address(r,s)
877877
res:=db.Lookup(ip)
878878
iferr:=res.Err();err!=nil {
@@ -944,7 +944,7 @@ func BenchmarkCityLookup(b *testing.B) {
944944
varresultfullCity
945945

946946
s:=make(net.IP,4)
947-
forrangeb.N {
947+
forb.Loop() {
948948
ip:=randomIPv4Address(r,s)
949949
err=db.Lookup(ip).Decode(&result)
950950
iferr!=nil {
@@ -962,7 +962,7 @@ func BenchmarkCityLookupOnly(b *testing.B) {
962962
r:=rand.New(rand.NewSource(time.Now().UnixNano()))
963963

964964
s:=make(net.IP,4)
965-
forrangeb.N {
965+
forb.Loop() {
966966
ip:=randomIPv4Address(r,s)
967967
result:=db.Lookup(ip)
968968
iferr:=result.Err();err!=nil {
@@ -987,7 +987,7 @@ func BenchmarkDecodeCountryCodeWithStruct(b *testing.B) {
987987
varresultMinCountry
988988

989989
s:=make(net.IP,4)
990-
forrangeb.N {
990+
forb.Loop() {
991991
ip:=randomIPv4Address(r,s)
992992
err=db.Lookup(ip).Decode(&result)
993993
iferr!=nil {
@@ -1008,7 +1008,7 @@ func BenchmarkDecodePathCountryCode(b *testing.B) {
10081008
varresultstring
10091009

10101010
s:=make(net.IP,4)
1011-
forrangeb.N {
1011+
forb.Loop() {
10121012
ip:=randomIPv4Address(r,s)
10131013
err=db.Lookup(ip).DecodePath(&result,path...)
10141014
iferr!=nil {

‎traverse_test.go‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -391,7 +391,7 @@ func BenchmarkNetworks(b *testing.B) {
391391
db,err:=Open(testFile("GeoIP2-Country-Test.mmdb"))
392392
require.NoError(b,err)
393393

394-
forrangeb.N {
394+
forb.Loop() {
395395
forr:=rangedb.Networks() {
396396
varrecstruct{}
397397
err=r.Decode(&rec)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp