diff --git a/.github/workflows/lint.yml b/.github/workflows/lint.yml index eb441f7..684cbc7 100644 --- a/.github/workflows/lint.yml +++ b/.github/workflows/lint.yml @@ -12,5 +12,5 @@ jobs: - uses: actions/checkout@v2 - uses: golangci/golangci-lint-action@v2 with: - version: v1.36.0 + version: v1.45.2 args: --timeout=5m diff --git a/.golangci.yml b/.golangci.yml index 44ae40f..57ae5a5 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -48,6 +48,14 @@ linters: - nlreturn - testpackage - wsl + - varnamelen + - nilnil + - ireturn + - govet + - forcetypeassert + - cyclop + - containedctx + - revive issues: exclude-rules: diff --git a/decode_test.go b/decode_test.go index 57d9c6a..577d1d5 100644 --- a/decode_test.go +++ b/decode_test.go @@ -3907,3 +3907,14 @@ func TestIssue342(t *testing.T) { t.Errorf("unexpected result: got(%v) != expected(%v)", got, expected) } } + +func TestIssue360(t *testing.T) { + var uints []uint8 + err := json.Unmarshal([]byte(`[0, 1, 2]`), &uints) + if err != nil { + t.Errorf("unexpected error: %v", err) + } + if len(uints) != 3 || !(uints[0] == 0 && uints[1] == 1 && uints[2] == 2) { + t.Errorf("unexpected result: %v", uints) + } +} diff --git a/internal/decoder/bytes.go b/internal/decoder/bytes.go index 01a37fe..92c7dcf 100644 --- a/internal/decoder/bytes.go +++ b/internal/decoder/bytes.go @@ -23,9 +23,8 @@ func byteUnmarshalerSliceDecoder(typ *runtime.Type, structName string, fieldName unmarshalDecoder = newUnmarshalJSONDecoder(runtime.PtrTo(typ), structName, fieldName) case runtime.PtrTo(typ).Implements(unmarshalTextType): unmarshalDecoder = newUnmarshalTextDecoder(runtime.PtrTo(typ), structName, fieldName) - } - if unmarshalDecoder == nil { - return nil + default: + unmarshalDecoder, _ = compileUint8(typ, structName, fieldName) } return newSliceDecoder(unmarshalDecoder, typ, 1, structName, fieldName) } diff --git a/internal/decoder/compile_norace.go b/internal/decoder/compile_norace.go index 592f637..eb7e2b1 100644 --- a/internal/decoder/compile_norace.go +++ b/internal/decoder/compile_norace.go @@ -1,3 +1,4 @@ +//go:build !race // +build !race package decoder diff --git a/internal/decoder/compile_race.go b/internal/decoder/compile_race.go index b691bc9..49cdda4 100644 --- a/internal/decoder/compile_race.go +++ b/internal/decoder/compile_race.go @@ -1,3 +1,4 @@ +//go:build race // +build race package decoder