How to print a map, struct or whatever in a readable way?
With PHP you can to this
echo \'\';
print_r($var);
echo \'
\';
Use the Go fmt package. For example,
package main
import "fmt"
func main() {
variable := "var"
fmt.Println(variable)
fmt.Printf("%#v\n", variable)
header := map[string]string{"content-type": "text/plain"}
fmt.Println(header)
fmt.Printf("%#v\n", header)
}
Output:
var
"var"
map[content-type:text/plain]
map[string]string{"content-type":"text/plain"}
Package fmt
import "fmt"
Overview
Package fmt implements formatted I/O with functions analogous to C's printf and scanf. The format 'verbs' are derived from C's but are simpler.