MCPcopy Index your code
hub / github.com/livebud/bud / FieldAt

Method FieldAt

package/parser/struct.go:137–155  ·  view source on GitHub ↗

FieldAt gets the field at i

(nth int)

Source from the content-addressed store, hash-verified

135
136// FieldAt gets the field at i
137func (stct *Struct) FieldAt(nth int) (field *Field, err error) {
138 if stct.node.Fields == nil {
139 return nil, fmt.Errorf("struct %q in %q has no fields", stct.Name(), stct.file.Path())
140 }
141 i := 0
142 for _, field := range stct.node.Fields.List {
143 for _, name := range field.Names {
144 if nth == i {
145 return &Field{
146 stct: stct,
147 name: name.Name,
148 node: field,
149 }, nil
150 }
151 i++
152 }
153 }
154 return nil, fmt.Errorf("struct %q in %q has no field at %d", stct.Name(), stct.file.Path(), nth)
155}
156
157func (stct *Struct) Methods() (methods []*Function) {
158 for _, file := range stct.Package().Files() {

Callers

nothing calls this directly

Calls 2

NameMethod · 0.95
PathMethod · 0.45

Tested by

no test coverage detected