diff options
Diffstat (limited to 'vendor/github.com/fxamacker/cbor/v2/structfields.go')
| -rw-r--r-- | vendor/github.com/fxamacker/cbor/v2/structfields.go | 18 |
1 files changed, 5 insertions, 13 deletions
diff --git a/vendor/github.com/fxamacker/cbor/v2/structfields.go b/vendor/github.com/fxamacker/cbor/v2/structfields.go index 81228ac..23a12be 100644 --- a/vendor/github.com/fxamacker/cbor/v2/structfields.go +++ b/vendor/github.com/fxamacker/cbor/v2/structfields.go @@ -144,15 +144,7 @@ func getFields(t reflect.Type) (flds fields, structOptions string) { } // appendFields appends type t's exportable fields to flds and anonymous struct fields to nTypes . -func appendFields( - t reflect.Type, - idx []int, - flds fields, - nTypes map[reflect.Type][][]int, -) ( - _flds fields, - _nTypes map[reflect.Type][][]int, -) { +func appendFields(t reflect.Type, idx []int, flds fields, nTypes map[reflect.Type][][]int) (fields, map[reflect.Type][][]int) { for i := 0; i < t.NumField(); i++ { f := t.Field(i) @@ -173,12 +165,12 @@ func appendFields( continue } - tagged := tag != "" + tagged := len(tag) > 0 // Parse field tag options var tagFieldName string var omitempty, keyasint bool - for j := 0; tag != ""; j++ { + for j := 0; len(tag) > 0; j++ { var token string idx := strings.IndexByte(tag, ',') if idx == -1 { @@ -207,7 +199,7 @@ func appendFields( copy(fIdx, idx) fIdx[len(fIdx)-1] = i - if !f.Anonymous || ft.Kind() != reflect.Struct || tagFieldName != "" { + if !f.Anonymous || ft.Kind() != reflect.Struct || len(tagFieldName) > 0 { flds = append(flds, &field{ name: fieldName, idx: fIdx, @@ -229,7 +221,7 @@ func appendFields( // isFieldExportable returns true if f is an exportable (regular or anonymous) field or // a nonexportable anonymous field of struct type. // Nonexportable anonymous field of struct type can contain exportable fields. -func isFieldExportable(f reflect.StructField, fk reflect.Kind) bool { //nolint:gocritic // ignore hugeParam +func isFieldExportable(f reflect.StructField, fk reflect.Kind) bool { exportable := f.PkgPath == "" return exportable || (f.Anonymous && fk == reflect.Struct) } |
