(fields []structField, t reflect.Type, offset uintptr, seen map[reflect.Type]*structType, canAddr bool)
| 548 | } |
| 549 | |
| 550 | func appendStructFields(fields []structField, t reflect.Type, offset uintptr, seen map[reflect.Type]*structType, canAddr bool) []structField { |
| 551 | type embeddedField struct { |
| 552 | index int |
| 553 | offset uintptr |
| 554 | pointer bool |
| 555 | unexported bool |
| 556 | subtype *structType |
| 557 | subfield *structField |
| 558 | } |
| 559 | |
| 560 | names := make(map[string]struct{}) |
| 561 | embedded := make([]embeddedField, 0, 10) |
| 562 | |
| 563 | for i := range t.NumField() { |
| 564 | f := t.Field(i) |
| 565 | |
| 566 | var ( |
| 567 | name = f.Name |
| 568 | anonymous = f.Anonymous |
| 569 | tag = false |
| 570 | omitempty = false |
| 571 | stringify = false |
| 572 | unexported = len(f.PkgPath) != 0 |
| 573 | ) |
| 574 | |
| 575 | if unexported && !anonymous { // unexported |
| 576 | continue |
| 577 | } |
| 578 | |
| 579 | if parts := strings.Split(f.Tag.Get("json"), ","); len(parts) != 0 { |
| 580 | if len(parts[0]) != 0 { |
| 581 | name, tag = parts[0], true |
| 582 | } |
| 583 | |
| 584 | if name == "-" && len(parts) == 1 { // ignored |
| 585 | continue |
| 586 | } |
| 587 | |
| 588 | if !isValidTag(name) { |
| 589 | name = f.Name |
| 590 | } |
| 591 | |
| 592 | for _, tag := range parts[1:] { |
| 593 | switch tag { |
| 594 | case "omitempty": |
| 595 | omitempty = true |
| 596 | case "string": |
| 597 | stringify = true |
| 598 | } |
| 599 | } |
| 600 | } |
| 601 | |
| 602 | if anonymous && !tag { // embedded |
| 603 | typ := f.Type |
| 604 | ptr := f.Type.Kind() == reflect.Ptr |
| 605 | |
| 606 | if ptr { |
| 607 | typ = f.Type.Elem() |
no test coverage detected
searching dependent graphs…