MCPcopy Index your code
hub / github.com/oapi-codegen/oapi-codegen / StringToGoString

Function StringToGoString

pkg/codegen/utils.go:912–914  ·  view source on GitHub ↗

StringToGoString takes an arbitrary string and converts it to a valid Go string literal, including the quotes. For instance, `foo "bar"` would be converted to `"foo \"bar\""`. strconv.Quote escapes backslashes, newlines and other control characters too, so untrusted spec text cannot break out of th

(in string)

Source from the content-addressed store, hash-verified

910// strconv.Quote escapes backslashes, newlines and other control characters too,
911// so untrusted spec text cannot break out of the generated string literal.
912func StringToGoString(in string) string {
913 return strconv.Quote(in)
914}
915
916// StringToGoComment renders a possible multi-line string as a valid Go-Comment.
917// Each line is prefixed as a comment.

Callers 3

buildUnmarshalCaseFunction · 0.85
buildUnmarshalCaseStrictFunction · 0.85

Calls

no outgoing calls

Tested by 1