Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions .github/workflows/run_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
4 changes: 2 additions & 2 deletions decode.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}
}
}
Expand Down
2 changes: 1 addition & 1 deletion decode_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
12 changes: 6 additions & 6 deletions encode.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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.
Expand All @@ -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})
Expand All @@ -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})
Expand Down Expand Up @@ -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(',')
Expand Down Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
module github.com/nspcc-dev/go-ordered-json

go 1.24
go 1.25
2 changes: 1 addition & 1 deletion tagkey_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
Loading