fieldPtr returns a pointer to the field identified by f in *cfg.
(f configField)
| 198 | |
| 199 | // fieldPtr returns a pointer to the field identified by f in *cfg. |
| 200 | func (cfg *config) fieldPtr(f configField) interface{} { |
| 201 | // reflect.ValueOf: converts to reflect.Value |
| 202 | // Elem: dereferences cfg to make *cfg |
| 203 | // FieldByIndex: fetches the field |
| 204 | // Addr: takes address of field |
| 205 | // Interface: converts back from reflect.Value to a regular value |
| 206 | return reflect.ValueOf(cfg).Elem().FieldByIndex(f.field.Index).Addr().Interface() |
| 207 | } |
| 208 | |
| 209 | // get returns the value of field f in cfg. |
| 210 | func (cfg *config) get(f configField) string { |
no outgoing calls
no test coverage detected