(v reflect.Value)
| 57 | } |
| 58 | |
| 59 | func fieldToString(v reflect.Value) string { |
| 60 | // Check time.Time before kind switch since it's a struct. |
| 61 | if v.Type() == timeType { |
| 62 | t, _ := v.Interface().(time.Time) |
| 63 | return formatTime(t) |
| 64 | } |
| 65 | switch v.Kind() { |
| 66 | case reflect.String: |
| 67 | return v.String() |
| 68 | case reflect.Bool: |
| 69 | return formatBool(v.Bool()) |
| 70 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: |
| 71 | return strconv.FormatInt(v.Int(), 10) |
| 72 | default: |
| 73 | return fmt.Sprintf("%v", v.Interface()) |
| 74 | } |
| 75 | } |
| 76 | |
| 77 | func formatTime(t time.Time) string { |
| 78 | if t.IsZero() { |
no test coverage detected