I'm writing a lot of little scripts right now to learn go and for better or worse have gotten used to seeing output such as arrays, maps, slices in a nice highlighted, indented, pretty format.
I should maybe use http://golang.org/pkg/go/printer/#example_Fprint but I'm not exactly sure how to use it nor if it gives me the result I'm looking for...
ex: ruby's pry
If its a dumb idea for even asking for pretty printed output please explain in brief.
http://golang.org/pkg/fmt/
%v the value in a default format. when printing structs, the plus flag (%+v) adds field names
%#v a Go-syntax representation of the value
Like so:
fmt.Printf("%+v", mystruct)
Try github.com/davecgh/go-spew. It's like "%#v"
, but has much more prettier and detailed output.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With