在GoLang中打印“(双引号)

I am writing a Go code which reads from a file. To do so I use fmt.Println() to print into that intermediate file.

How can I print "?

This is very easy, Just like C.

fmt.Println("\"")

Old style string literals and their escapes can often be avoided. The typical Go solution is to use a raw string literal here:

 fmt.Println(`"`)

Don't say Go doesn't leave you options. The following all print a quotation mark ":

fmt.Println("\"")
fmt.Println("\x22")
fmt.Println("\u0022")
fmt.Println("\042")
fmt.Println(`"`)
fmt.Println(string('"'))
fmt.Println(string([]byte{'"'}))
fmt.Printf("%c
", '"')
fmt.Printf("%s
", []byte{'"'})

// Seriously, this one is just for demonstration not production :)
fmt.Println(xml.Header[14:15])
fmt.Println(strconv.Quote("")[:1])

Try them on the Go Playground.