Go's fmt
package defines %q
(for strings) as:
%q a double-quoted string safely escaped with Go syntax
What does safely escaped with Go syntax mean?
Some experimentation shows it preserves escape sequences used in the original string:
s := "This has \"quotes\" in it"
fmt.Printf("%q
", s) // output: "This has \"quotes\" in it"
Is there anything else it does? In what situations might you want to use this? I'm guessing perhaps in templates that generate Go code?