diff --git a/.github/workflows/run_tests.yml b/.github/workflows/run_tests.yml index c554f77..85f4841 100644 --- a/.github/workflows/run_tests.yml +++ b/.github/workflows/run_tests.yml @@ -27,7 +27,7 @@ jobs: - name: Set up Go uses: actions/setup-go@v5 with: - go-version: 1.25 + go-version: 1.26 - name: Write coverage profile run: go test -v ./... -coverprofile=./coverage.txt -covermode=atomic @@ -44,17 +44,17 @@ jobs: runs-on: ${{ matrix.os }} strategy: matrix: - go_versions: [ '1.24', '1.25' ] + go_versions: [ '1.25', '1.26' ] os: [ubuntu-latest, windows-latest, macos-latest] exclude: # Only latest Go version for Windows and MacOS. - os: windows-latest - go_versions: '1.24' + go_versions: '1.25' - os: macos-latest - go_versions: '1.24' + go_versions: '1.25' # Exclude latest Go version for Ubuntu as Coverage uses it. - os: ubuntu-latest - go_versions: '1.25' + go_versions: '1.26' fail-fast: false steps: - uses: actions/checkout@v4 diff --git a/decode.go b/decode.go index 3b4b375..e88ad87 100644 --- a/decode.go +++ b/decode.go @@ -461,11 +461,11 @@ func (d *decodeState) indirect(v reflect.Value, decodingNull bool) (Unmarshaler, v.Set(reflect.New(v.Type().Elem())) } if v.Type().NumMethod() > 0 { - if u, ok := v.Interface().(Unmarshaler); ok { + if u, ok := reflect.TypeAssert[Unmarshaler](v); ok { return u, nil, reflect.Value{} } if !decodingNull { - if u, ok := v.Interface().(encoding.TextUnmarshaler); ok { + if u, ok := reflect.TypeAssert[encoding.TextUnmarshaler](v); ok { return nil, u, reflect.Value{} } } diff --git a/decode_test.go b/decode_test.go index 2e5ef37..f569225 100644 --- a/decode_test.go +++ b/decode_test.go @@ -1890,7 +1890,7 @@ func TestUnmarshalSyntax(t *testing.T) { type unexportedFields struct { Name string m map[string]any `json:"-"` //nolint:unused // Not really used, but important for test. - m2 map[string]any `json:"abcd"` //nolint:unused,govet // Not really used and wrong, but important for test. + m2 map[string]any `json:"abcd"` //nolint:unused,govet,staticcheck // Not really used and wrong, but important for test. } func TestUnmarshalUnexported(t *testing.T) { diff --git a/encode.go b/encode.go index a45ffd9..5d44066 100644 --- a/encode.go +++ b/encode.go @@ -445,7 +445,7 @@ func marshalerEncoder(e *encodeState, v reflect.Value, opts encOpts) { e.WriteString("null") return } - m, ok := v.Interface().(Marshaler) + m, ok := reflect.TypeAssert[Marshaler](v) if !ok { e.WriteString("null") return @@ -466,7 +466,7 @@ func addrMarshalerEncoder(e *encodeState, v reflect.Value, _ encOpts) { e.WriteString("null") return } - m := va.Interface().(Marshaler) + m, _ := reflect.TypeAssert[Marshaler](va) b, err := m.MarshalJSON() if err == nil { // copy JSON into buffer, checking validity. @@ -482,7 +482,7 @@ func textMarshalerEncoder(e *encodeState, v reflect.Value, opts encOpts) { e.WriteString("null") return } - m := v.Interface().(encoding.TextMarshaler) + m, _ := reflect.TypeAssert[encoding.TextMarshaler](v) b, err := m.MarshalText() if err != nil { e.error(&MarshalerError{v.Type(), err}) @@ -496,7 +496,7 @@ func addrTextMarshalerEncoder(e *encodeState, v reflect.Value, opts encOpts) { e.WriteString("null") return } - m := va.Interface().(encoding.TextMarshaler) + m, _ := reflect.TypeAssert[encoding.TextMarshaler](va) b, err := m.MarshalText() if err != nil { e.error(&MarshalerError{v.Type(), err}) @@ -714,7 +714,7 @@ func orderedObjectEncoder(e *encodeState, v reflect.Value, opts encOpts) { return } e.WriteByte('{') - var ov = v.Interface().(OrderedObject) + var ov, _ = reflect.TypeAssert[OrderedObject](v) for i, o := range ov { if i > 0 { e.WriteByte(',') @@ -885,7 +885,7 @@ func (w *reflectWithString) resolve() error { w.s = w.v.String() return nil } - if tm, ok := w.v.Interface().(encoding.TextMarshaler); ok { + if tm, ok := reflect.TypeAssert[encoding.TextMarshaler](w.v); ok { buf, err := tm.MarshalText() w.s = string(buf) return err diff --git a/go.mod b/go.mod index 627d352..4723659 100644 --- a/go.mod +++ b/go.mod @@ -1,3 +1,3 @@ module github.com/nspcc-dev/go-ordered-json -go 1.24 +go 1.25 diff --git a/tagkey_test.go b/tagkey_test.go index cfd7dc2..b388844 100644 --- a/tagkey_test.go +++ b/tagkey_test.go @@ -45,7 +45,7 @@ type punctuationTag struct { } type dashTag struct { - V string `json:"-,"` + V string `json:"-,"` // nolint:staticcheck // The test is written this way } type emptyTag struct {