Standard library / strconv
strconv.Quote()
Returns a double-quoted Go string literal representing s, escaping quotes, backslashes and nonprintable bytes/runes as needed. Not a general JSON encoder. Expected stdout: '"a\\nb"\n'.
Formal Syntax & Structure
go syntaxgo
func Quote(s string) stringParameters & Attributes
| Name | Type | Description |
|---|---|---|
| s | string | Input text to parse, inspect or quote. |
Return Value
string
Encoded representation.
Working Example
Example Snippetgo
package main
import ( "fmt" "strconv")
func main() { fmt.Println(strconv.Quote("a\nb"))}