Literal

Interpreted string literals

Double-quoted literals interpret escapes such as newline, tab and Unicode escapes. They cannot contain an unescaped newline. The resulting string is an immutable sequence of bytes. Example output: '"a\\nb"'.

Formal Syntax & Structure

go syntaxgo
"line\nnext"

Working Example

Example Snippetgo
package main
import "fmt"
func main() {  fmt.Printf("%q\n", "a\nb")}
Go Reference