I'm looking for something like PHP's print_r or python's dict. Anybody know if this function exists, or its something that needs to be implemented?
For printing native go objects, like maps, slices, and arrays, you can try:
fmt.Printf("%v", object)
However there isn't a general method to do it with user-defined struct types..
Try
fmt.Printf("%+v", object)
That might give you something resembling what you want.
You can try using the package dump
, which acts similar to PHP's print_r
or var_dump
.
The sources are here and the main project page is here.
Then just call dump.Dump(yourObject)
or dump.Fdump(file, yourObject)