get returns the value of field f in cfg.
(f configField)
| 208 | |
| 209 | // get returns the value of field f in cfg. |
| 210 | func (cfg *config) get(f configField) string { |
| 211 | switch ptr := cfg.fieldPtr(f).(type) { |
| 212 | case *string: |
| 213 | return *ptr |
| 214 | case *int: |
| 215 | return fmt.Sprint(*ptr) |
| 216 | case *float64: |
| 217 | return fmt.Sprint(*ptr) |
| 218 | case *bool: |
| 219 | return fmt.Sprint(*ptr) |
| 220 | } |
| 221 | panic(fmt.Sprintf("unsupported config field type %v", f.field.Type)) |
| 222 | } |
| 223 | |
| 224 | // set sets the value of field f in cfg to value. |
| 225 | func (cfg *config) set(f configField, value string) error { |