Skip to content

Commit 9ac5db0

Browse files
json: partial lint fixes
1 parent 1c849dd commit 9ac5db0

File tree

3 files changed

+7
-12
lines changed

3 files changed

+7
-12
lines changed

json/decode.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1406,7 +1406,7 @@ func (d decoder) decodeMaybeEmptyInterface(b []byte, p unsafe.Pointer, t reflect
14061406
return d.decodeUnmarshalTypeError(b, p, t)
14071407
}
14081408

1409-
func (d decoder) decodeUnmarshalTypeError(b []byte, p unsafe.Pointer, t reflect.Type) ([]byte, error) {
1409+
func (d decoder) decodeUnmarshalTypeError(b []byte, _ unsafe.Pointer, t reflect.Type) ([]byte, error) {
14101410
v, b, _, err := d.parseValue(b)
14111411
if err != nil {
14121412
return b, err
@@ -1496,7 +1496,7 @@ func (d decoder) decodeTextUnmarshaler(b []byte, p unsafe.Pointer, t reflect.Typ
14961496
value = "array"
14971497
}
14981498

1499-
return b, &UnmarshalTypeError{Value: value, Type: reflect.PtrTo(t)}
1499+
return b, &UnmarshalTypeError{Value: value, Type: reflect.PointerTo(t)}
15001500
}
15011501

15021502
func (d decoder) prependField(key, field string) string {

json/json.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import (
1515
type Delim = json.Delim
1616

1717
// InvalidUTF8Error is documented at https://golang.org/pkg/encoding/json/#InvalidUTF8Error
18-
type InvalidUTF8Error = json.InvalidUTF8Error
18+
type InvalidUTF8Error = json.InvalidUTF8Error //nolint:staticcheck // compat.
1919

2020
// InvalidUnmarshalError is documented at https://golang.org/pkg/encoding/json/#InvalidUnmarshalError
2121
type InvalidUnmarshalError = json.InvalidUnmarshalError
@@ -39,7 +39,7 @@ type SyntaxError = json.SyntaxError
3939
type Token = json.Token
4040

4141
// UnmarshalFieldError is documented at https://golang.org/pkg/encoding/json/#UnmarshalFieldError
42-
type UnmarshalFieldError = json.UnmarshalFieldError
42+
type UnmarshalFieldError = json.UnmarshalFieldError //nolint:staticcheck // compat.
4343

4444
// UnmarshalTypeError is documented at https://golang.org/pkg/encoding/json/#UnmarshalTypeError
4545
type UnmarshalTypeError = json.UnmarshalTypeError

json/json_test.go

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -240,7 +240,7 @@ var testValues = [...]any{
240240
A string `json:"name"`
241241
B string `json:"-"`
242242
C string `json:",omitempty"`
243-
D map[string]any `json:",string"`
243+
D map[string]any `json:",string"` //nolint:staticcheck // intentional
244244
e string
245245
}{A: "Luke", D: map[string]any{"answer": float64(42)}},
246246
struct{ point }{point{1, 2}},
@@ -880,12 +880,11 @@ func TestDecodeLines(t *testing.T) {
880880
t.Run(test.desc, func(t *testing.T) {
881881
d := NewDecoder(test.reader)
882882
var count int
883-
var err error
884883
for {
885884
var o obj
886-
err = d.Decode(&o)
885+
err := d.Decode(&o)
887886
if err != nil {
888-
if err == io.EOF {
887+
if errors.Is(err, io.EOF) {
889888
break
890889
}
891890

@@ -904,10 +903,6 @@ func TestDecodeLines(t *testing.T) {
904903
count++
905904
}
906905

907-
if err != nil && err != io.EOF {
908-
t.Error(err)
909-
}
910-
911906
if count != test.expectCount {
912907
t.Errorf("expected %d objects, got %d", test.expectCount, count)
913908
}

0 commit comments

Comments
 (0)