the following are taken from sloghuman:
(v interface{})
| 724 | // the following are taken from sloghuman: |
| 725 | |
| 726 | func formatValue(v interface{}) string { |
| 727 | if vr, ok := v.(driver.Valuer); ok { |
| 728 | var err error |
| 729 | v, err = vr.Value() |
| 730 | if err != nil { |
| 731 | return fmt.Sprintf("error calling Value: %v", err) |
| 732 | } |
| 733 | } |
| 734 | if v == nil { |
| 735 | return "<nil>" |
| 736 | } |
| 737 | typ := reflect.TypeOf(v) |
| 738 | switch typ.Kind() { |
| 739 | case reflect.Struct, reflect.Map: |
| 740 | byt, err := json.Marshal(v) |
| 741 | if err != nil { |
| 742 | panic(err) |
| 743 | } |
| 744 | return string(byt) |
| 745 | case reflect.Slice: |
| 746 | // Byte slices are optimistically readable. |
| 747 | if typ.Elem().Kind() == reflect.Uint8 { |
| 748 | return fmt.Sprintf("%q", v) |
| 749 | } |
| 750 | fallthrough |
| 751 | default: |
| 752 | return quote(fmt.Sprintf("%+v", v)) |
| 753 | } |
| 754 | } |
| 755 | |
| 756 | // quotes quotes a string so that it is suitable |
| 757 | // as a key for a map or in general some output that |
no test coverage detected