MCPcopy
hub / github.com/XiaoMi/Gaea / WriteString

Method WriteString

parser/format/format.go:312–326  ·  view source on GitHub ↗

WriteString writes the string into writer `str` may be wrapped in quotes and escaped according to RestoreFlags.

(str string)

Source from the content-addressed store, hash-verified

310// WriteString writes the string into writer
311// `str` may be wrapped in quotes and escaped according to RestoreFlags.
312func (ctx *RestoreCtx) WriteString(str string) {
313 if ctx.Flags.HasStringEscapeBackslashFlag() {
314 str = strings.Replace(str, `\`, `\\`, -1)
315 }
316 quotes := ""
317 switch {
318 case ctx.Flags.HasStringSingleQuotesFlag():
319 str = strings.Replace(str, `'`, `''`, -1)
320 quotes = `'`
321 case ctx.Flags.HasStringDoubleQuotesFlag():
322 str = strings.Replace(str, `"`, `""`, -1)
323 quotes = `"`
324 }
325 fmt.Fprint(ctx.In, quotes, str, quotes)
326}
327
328// WriteName writes the name into writer
329// `name` maybe wrapped in quotes and escaped according to RestoreFlags.

Callers 15

TestRestoreCtxFunction · 0.95
appendSetCharsetFunction · 0.80
appendSetVariableFunction · 0.80
setUseBufMethod · 0.80
RestoreMethod · 0.80
StringMethod · 0.80
convertDateFormatMethod · 0.80
RestoreMethod · 0.80
RestoreMethod · 0.80
RestoreMethod · 0.80
RestoreMethod · 0.80

Tested by 6

TestRestoreCtxFunction · 0.76
TestConsoleWarnFunction · 0.64
TestConsoleFatalFunction · 0.64
TestConsoleNoticeFunction · 0.64
TestConsoleTraceFunction · 0.64
TestConsoleDebugFunction · 0.64