MCPcopy Create free account
hub / github.com/docker/cli / formatJSON

Function formatJSON

templates/templates.go:91–102  ·  view source on GitHub ↗
(v any)

Source from the content-addressed store, hash-verified

89}
90
91func formatJSON(v any) string {
92 buf := &bytes.Buffer{}
93 enc := json.NewEncoder(buf)
94 enc.SetEscapeHTML(false)
95 err := enc.Encode(v)
96 if err != nil {
97 panic(err)
98 }
99
100 // Remove the trailing new line added by the encoder
101 return strings.TrimSpace(buf.String())
102}
103
104// joinElements joins a slice of items with the given separator. It uses
105// [strings.Join] if it's a slice of strings, otherwise uses [fmt.Sprint]

Callers

nothing calls this directly

Calls 1

StringMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…