Fields returns all the field names. The names can be used to query the Record.
()
| 34 | // Fields returns all the field names. |
| 35 | // The names can be used to query the Record. |
| 36 | func (r Record) Fields() (fields []string) { |
| 37 | t := reflect.TypeOf(record{}) |
| 38 | |
| 39 | for i := 0; i < t.NumField(); i++ { |
| 40 | f := t.Field(i) |
| 41 | s := fmt.Sprintf("(%s: %s)", f.Name, f.Type.Name()) |
| 42 | |
| 43 | fields = append(fields, s) |
| 44 | } |
| 45 | |
| 46 | return |
| 47 | } |
| 48 | |
| 49 | // mustGet the field with the same kind or panics. |
| 50 | func (r Record) mustGet(field string, kind reflect.Kind) reflect.Value { |