MCPcopy Index your code
hub / github.com/coder/coder / formatValue

Function formatValue

vpn/tunnel.go:726–754  ·  view source on GitHub ↗

the following are taken from sloghuman:

(v interface{})

Source from the content-addressed store, hash-verified

724// the following are taken from sloghuman:
725
726func 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

Callers 1

sinkEntryToPbFunction · 0.70

Calls 3

quoteFunction · 0.85
ValueMethod · 0.45
MarshalMethod · 0.45

Tested by

no test coverage detected