unpackValue returns values inside of non-nil interfaces when possible and ensures that types for values which have been unpacked from an interface are displayed when the show types flag is also set. This is useful for data types like structs, arrays, slices, and maps which can contain varying types
(v reflect.Value)
| 92 | // This is useful for data types like structs, arrays, slices, and maps which |
| 93 | // can contain varying types packed inside an interface. |
| 94 | func (f *formatState) unpackValue(v reflect.Value) reflect.Value { |
| 95 | if v.Kind() == reflect.Interface { |
| 96 | f.ignoreNextType = false |
| 97 | if !v.IsNil() { |
| 98 | v = v.Elem() |
| 99 | } |
| 100 | } |
| 101 | return v |
| 102 | } |
| 103 | |
| 104 | // formatPtr handles formatting of pointers by indirecting them as necessary. |
| 105 | func (f *formatState) formatPtr(v reflect.Value) { |