formatUnexportedValue formats unexported struct fields by kind without using Interface().
(val reflect.Value)
| 518 | |
| 519 | // formatUnexportedValue formats unexported struct fields by kind without using Interface(). |
| 520 | func formatUnexportedValue(val reflect.Value) string { |
| 521 | switch val.Kind() { |
| 522 | case reflect.Bool: |
| 523 | return strconv.FormatBool(val.Bool()) |
| 524 | case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: |
| 525 | return strconv.FormatInt(val.Int(), 10) |
| 526 | case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: |
| 527 | return strconv.FormatUint(val.Uint(), 10) |
| 528 | case reflect.Float32, reflect.Float64: |
| 529 | return fmt.Sprintf("%f", val.Float()) |
| 530 | case reflect.String: |
| 531 | return val.String() |
| 532 | default: |
| 533 | return val.Type().String() |
| 534 | } |
| 535 | } |
| 536 | |
| 537 | // formatNumericKind formats numeric kinds without Interface() as a fallback. |
| 538 | func formatNumericKind(val reflect.Value) string { |
no test coverage detected