FirstEmbed returns the first field if it is embedded, supporting convention of placing embedded "parent" types first
()
| 126 | // FirstEmbed returns the first field if it is embedded, |
| 127 | // supporting convention of placing embedded "parent" types first |
| 128 | func (s *Struct) FirstEmbed() *symbol { |
| 129 | st := s.Struct() |
| 130 | numFields := st.NumFields() |
| 131 | if numFields == 0 { |
| 132 | return nil |
| 133 | } |
| 134 | f := s.Struct().Field(0) |
| 135 | if !f.Embedded() { |
| 136 | return nil |
| 137 | } |
| 138 | ftyp := current.symtype(f.Type()) |
| 139 | if ftyp == nil { |
| 140 | return nil |
| 141 | } |
| 142 | return ftyp |
| 143 | } |
| 144 | |
| 145 | /////////////////////////////////////////////////////////////////////////////////// |
| 146 | // Interface |
no test coverage detected