MCPcopy Index your code
hub / github.com/docker/docker-agent / scalarString

Function scalarString

pkg/modelerrors/modelerrors.go:764–778  ·  view source on GitHub ↗

scalarString renders a JSON scalar as text. JSON numbers decode to float64; whole numbers are rendered without a trailing ".0" so a code of 400 prints as "400". Returns "" for nil and empty strings.

(v any)

Source from the content-addressed store, hash-verified

762// whole numbers are rendered without a trailing ".0" so a code of 400 prints
763// as "400". Returns "" for nil and empty strings.
764func scalarString(v any) string {
765 switch x := v.(type) {
766 case nil:
767 return ""
768 case string:
769 return x
770 case float64:
771 if x == float64(int64(x)) {
772 return strconv.FormatInt(int64(x), 10)
773 }
774 return strconv.FormatFloat(x, 'g', -1, 64)
775 default:
776 return fmt.Sprint(v)
777 }
778}

Callers 3

classifyOverflowFunction · 0.85
formatProviderErrorFunction · 0.85

Calls

no outgoing calls

Tested by 1