A few sprintf placeholders that I’ve found handy coding in golang.
%q placeholder #
%q placeholder formats strings
package main
import (
"fmt"
)
func main() {
fmt.Println(fmt.Sprintf("%q", "tralala"))
}"tralala"%t placeholder #
The %t formats booleans
package main
import (
"fmt"
)
func main() {
fmt.Println(fmt.Sprintf("%t", true))
}true%#v placeholder
#
%#v is a nice way to echo structs
package main
import (
"fmt"
)
type someStruct struct {
someValue int
}
func main() {
fmt.Println(fmt.Sprintf("%#v", someStruct{someValue: 3}))
}main.someStruct{someValue:3}