summaryrefslogtreecommitdiff
path: root/compat/json/borrowed_decode_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'compat/json/borrowed_decode_test.go')
-rw-r--r--compat/json/borrowed_decode_test.go30
1 files changed, 15 insertions, 15 deletions
diff --git a/compat/json/borrowed_decode_test.go b/compat/json/borrowed_decode_test.go
index 2c89d5d..dd9c344 100644
--- a/compat/json/borrowed_decode_test.go
+++ b/compat/json/borrowed_decode_test.go
@@ -77,7 +77,7 @@ var ifaceNumAsNumber = map[string]any{
}
type tx struct {
- x int
+ x int //nolint:unused // it is used, but only via reflection // MODIFIED: added nolint annotation
}
type u8 uint8
@@ -421,11 +421,11 @@ var unmarshalTests = []unmarshalTest{
{in: `"g-clef: \uD834\uDD1E"`, ptr: new(string), out: "g-clef: \U0001D11E"},
{in: `"invalid: \uD834x\uDD1E"`, ptr: new(string), out: "invalid: \uFFFDx\uFFFD"},
{in: "null", ptr: new(any), out: nil},
- {in: `{"X": [1,2,3], "Y": 4}`, ptr: new(T), out: T{Y: 4}, err: &UnmarshalTypeError{"array", reflect.TypeOf(""), 7, "T", "X"}},
- {in: `{"X": 23}`, ptr: new(T), out: T{}, err: &UnmarshalTypeError{"number", reflect.TypeOf(""), 8, "T", "X"}}, {in: `{"x": 1}`, ptr: new(tx), out: tx{}},
+ {in: `{"X": [1,2,3], "Y": 4}`, ptr: new(T), out: T{Y: 4}, err: &UnmarshalTypeError{Value: "array", Type: reflect.TypeOf(""), Offset: 7, Struct: "T", Field: "X"}}, // MODIFIED: don't use unkeyed fields (govet)
+ {in: `{"X": 23}`, ptr: new(T), out: T{}, err: &UnmarshalTypeError{Value: "number", Type: reflect.TypeOf(""), Offset: 8, Struct: "T", Field: "X"}}, {in: `{"x": 1}`, ptr: new(tx), out: tx{}}, // MODIFIED: don't use unkeyed fields (govet)
{in: `{"x": 1}`, ptr: new(tx), out: tx{}},
{in: `{"x": 1}`, ptr: new(tx), err: fmt.Errorf("json: unknown field \"x\""), disallowUnknownFields: true},
- {in: `{"S": 23}`, ptr: new(W), out: W{}, err: &UnmarshalTypeError{"number", reflect.TypeOf(SS("")), 0, "W", "S"}},
+ {in: `{"S": 23}`, ptr: new(W), out: W{}, err: &UnmarshalTypeError{Value: "number", Type: reflect.TypeOf(SS("")), Offset: 0, Struct: "W", Field: "S"}}, // MODIFIED: don't use unkeyed fields (govet)
{in: `{"F1":1,"F2":2,"F3":3}`, ptr: new(V), out: V{F1: float64(1), F2: int32(2), F3: Number("3")}},
{in: `{"F1":1,"F2":2,"F3":3}`, ptr: new(V), out: V{F1: Number("1"), F2: int32(2), F3: Number("3")}, useNumber: true},
{in: `{"k1":1,"k2":"s","k3":[1,2.0,3e-3],"k4":{"kk1":"s","kk2":2}}`, ptr: new(any), out: ifaceNumAsFloat64},
@@ -1342,7 +1342,7 @@ type All struct {
Float64 float64
Foo string `json:"bar"`
- Foo2 string `json:"bar2,dummyopt"`
+ Foo2 string `json:"bar2,dummyopt"` //nolint:staticcheck // testing handling of unknown options // MODIFIED: added nolint annotation
IntStr int64 `json:",string"`
UintptrStr uintptr `json:",string"`
@@ -1391,7 +1391,7 @@ type All struct {
Interface any
PInterface *any
- unexported int
+ unexported int //nolint:unused // it is used, but only via reflection // MODIFIED: added nolint annotation
}
type Small struct {
@@ -2047,10 +2047,10 @@ func TestUnmarshalSyntax(t *testing.T) {
// Issue 4660
type unexportedFields struct {
Name string
- m map[string]any `json:"-"`
- m2 map[string]any `json:"abcd"`
+ m map[string]any `json:"-"` //nolint:unused,govet // testing handling of unused fields // MODIFIED: added nolint annotation
+ m2 map[string]any `json:"abcd"` //nolint:unused // testing handling of unused fields // MODIFIED: added nolint annotation
- s []int `json:"-"`
+ s []int `json:"-"` //nolint:unused // testing handling of unused fields // MODIFIED: added nolint annotation
}
func TestUnmarshalUnexported(t *testing.T) {
@@ -2213,11 +2213,11 @@ func TestInvalidUnmarshalText(t *testing.T) {
func TestInvalidStringOption(t *testing.T) {
num := 0
item := struct {
- T time.Time `json:",string"`
- M map[string]string `json:",string"`
- S []string `json:",string"`
- A [1]string `json:",string"`
- I any `json:",string"`
+ T time.Time `json:",string"` //nolint:staticcheck // testing handling of bad options // MODIFIED: added nolint annotation
+ M map[string]string `json:",string"` //nolint:staticcheck // testing handling of bad options // MODIFIED: added nolint annotation
+ S []string `json:",string"` //nolint:staticcheck // testing handling of bad options // MODIFIED: added nolint annotation
+ A [1]string `json:",string"` //nolint:staticcheck // testing handling of bad options // MODIFIED: added nolint annotation
+ I any `json:",string"` //nolint:staticcheck // testing handling of bad options // MODIFIED: added nolint annotation
P *int `json:",string"`
}{M: make(map[string]string), S: make([]string, 0), I: num, P: &num}
@@ -2408,7 +2408,7 @@ func TestUnmarshalPanic(t *testing.T) {
t.Errorf("panic() = (%T)(%v), want 0xdead", got, got)
}
}()
- Unmarshal([]byte("{}"), &unmarshalPanic{})
+ _ = Unmarshal([]byte("{}"), &unmarshalPanic{}) // MODIFIED: added the _ dogsled for the linter
t.Fatalf("Unmarshal should have panicked")
}