-
Notifications
You must be signed in to change notification settings - Fork 51
lint fixes #151
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
lint fixes #151
Changes from all commits
f2f526a
b5cb64d
18a9723
4d18bcf
9e9474a
7514a4d
0e2637e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,7 @@ | ||
| version: "2" | ||
| linters: | ||
| exclusions: | ||
| rules: | ||
| # Tests copied from the stdlib are not meant to be linted. | ||
| - path: 'golang_(.+_)?test\.go' | ||
| source: "^" # regex |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,6 +4,7 @@ import ( | |
| "encoding" | ||
| "encoding/json" | ||
| "fmt" | ||
| "maps" | ||
| "math/big" | ||
| "reflect" | ||
| "sort" | ||
|
|
@@ -73,12 +74,9 @@ func cacheLoad() map[unsafe.Pointer]codec { | |
|
|
||
| func cacheStore(typ reflect.Type, cod codec, oldCodecs map[unsafe.Pointer]codec) { | ||
| newCodecs := make(map[unsafe.Pointer]codec, len(oldCodecs)+1) | ||
| maps.Copy(newCodecs, oldCodecs) | ||
|
||
| newCodecs[typeid(typ)] = cod | ||
|
|
||
| for t, c := range oldCodecs { | ||
| newCodecs[t] = c | ||
| } | ||
|
|
||
| cache.Store(&newCodecs) | ||
| } | ||
|
|
||
|
|
@@ -205,7 +203,7 @@ func constructCodec(t reflect.Type, seen map[reflect.Type]*structType, canAddr b | |
| c = constructUnsupportedTypeCodec(t) | ||
| } | ||
|
|
||
| p := reflect.PtrTo(t) | ||
| p := reflect.PointerTo(t) | ||
|
|
||
| if canAddr { | ||
| switch { | ||
|
|
@@ -291,7 +289,7 @@ func constructSliceCodec(t reflect.Type, seen map[reflect.Type]*structType) code | |
| // Go 1.7+ behavior: slices of byte types (and aliases) may override the | ||
| // default encoding and decoding behaviors by implementing marshaler and | ||
| // unmarshaler interfaces. | ||
| p := reflect.PtrTo(e) | ||
| p := reflect.PointerTo(e) | ||
| c := codec{} | ||
|
|
||
| switch { | ||
|
|
@@ -391,7 +389,7 @@ func constructMapCodec(t reflect.Type, seen map[reflect.Type]*structType) codec | |
| kc := codec{} | ||
| vc := constructCodec(v, seen, false) | ||
|
|
||
| if k.Implements(textMarshalerType) || reflect.PtrTo(k).Implements(textUnmarshalerType) { | ||
| if k.Implements(textMarshalerType) || reflect.PointerTo(k).Implements(textUnmarshalerType) { | ||
| kc.encode = constructTextMarshalerEncodeFunc(k, false) | ||
| kc.decode = constructTextUnmarshalerDecodeFunc(k, true) | ||
|
|
||
|
|
@@ -972,7 +970,6 @@ type structType struct { | |
| ficaseIndex map[string]*structField | ||
| keyset []byte | ||
| typ reflect.Type | ||
| inlined bool | ||
| } | ||
|
|
||
| type structField struct { | ||
|
|
@@ -1095,10 +1092,10 @@ var ( | |
| timeType = reflect.TypeOf(time.Time{}) | ||
| rawMessageType = reflect.TypeOf(RawMessage(nil)) | ||
|
|
||
| numberPtrType = reflect.PtrTo(numberType) | ||
| durationPtrType = reflect.PtrTo(durationType) | ||
| timePtrType = reflect.PtrTo(timeType) | ||
| rawMessagePtrType = reflect.PtrTo(rawMessageType) | ||
| numberPtrType = reflect.PointerTo(numberType) | ||
| durationPtrType = reflect.PointerTo(durationType) | ||
| timePtrType = reflect.PointerTo(timeType) | ||
| rawMessagePtrType = reflect.PointerTo(rawMessageType) | ||
|
|
||
| sliceInterfaceType = reflect.TypeOf(([]any)(nil)) | ||
| sliceStringType = reflect.TypeOf(([]any)(nil)) | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -240,7 +240,7 @@ var testValues = [...]any{ | |
| A string `json:"name"` | ||
| B string `json:"-"` | ||
| C string `json:",omitempty"` | ||
| D map[string]any `json:",string"` | ||
| D map[string]any `json:",string"` //nolint:staticcheck // intentional | ||
| e string | ||
| }{A: "Luke", D: map[string]any{"answer": float64(42)}}, | ||
| struct{ point }{point{1, 2}}, | ||
|
|
@@ -880,12 +880,11 @@ func TestDecodeLines(t *testing.T) { | |
| t.Run(test.desc, func(t *testing.T) { | ||
| d := NewDecoder(test.reader) | ||
| var count int | ||
| var err error | ||
| for { | ||
| var o obj | ||
| err = d.Decode(&o) | ||
| err := d.Decode(&o) | ||
|
||
| if err != nil { | ||
| if err == io.EOF { | ||
| if errors.Is(err, io.EOF) { | ||
|
||
| break | ||
| } | ||
|
|
||
|
|
@@ -904,10 +903,6 @@ func TestDecodeLines(t *testing.T) { | |
| count++ | ||
| } | ||
|
|
||
| if err != nil && err != io.EOF { | ||
| t.Error(err) | ||
| } | ||
|
|
||
| if count != test.expectCount { | ||
| t.Errorf("expected %d objects, got %d", test.expectCount, count) | ||
| } | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.