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
2 changes: 1 addition & 1 deletion .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,4 +23,4 @@ jobs:
- name: Lint
uses: golangci/golangci-lint-action@v9
with:
version: v2.11.4
version: latest
4 changes: 4 additions & 0 deletions .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@ linters:
- unparam
- unused
settings:
goconst:
# A literal repeated across table-driven test cases reads better than a
# constant the reader has to look up.
ignore-tests: true
govet:
enable:
- shadow
Expand Down
10 changes: 5 additions & 5 deletions fields.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@ func indirect(v reflect.Value, decodingNull bool) (json.Unmarshaler, encoding.Te
// If v is a named type and is addressable,
// start with its address, so that if the type has pointer methods,
// we find them.
if v.Kind() != reflect.Ptr && v.Type().Name() != "" && v.CanAddr() {
if v.Kind() != reflect.Pointer && v.Type().Name() != "" && v.CanAddr() {
v = v.Addr()
}
for {
// Load value from interface, but only if the result will be
// usefully addressable.
if v.Kind() == reflect.Interface && !v.IsNil() {
e := v.Elem()
if e.Kind() == reflect.Ptr && !e.IsNil() && (!decodingNull || e.Elem().Kind() == reflect.Ptr) {
if e.Kind() == reflect.Pointer && !e.IsNil() && (!decodingNull || e.Elem().Kind() == reflect.Pointer) {
v = e
continue
}
}

if v.Kind() != reflect.Ptr {
if v.Kind() != reflect.Pointer {
break
}

if v.Elem().Kind() != reflect.Ptr && decodingNull && v.CanSet() {
if v.Elem().Kind() != reflect.Pointer && decodingNull && v.CanSet() {
break
}
if v.IsNil() {
Expand Down Expand Up @@ -171,7 +171,7 @@ func typeFields(t reflect.Type) []field {
index[len(f.index)] = i

ft := sf.Type
if ft.Name() == "" && ft.Kind() == reflect.Ptr {
if ft.Name() == "" && ft.Kind() == reflect.Pointer {
// Follow pointer.
ft = ft.Elem()
}
Expand Down
Loading