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?
views:
77answers:
4
+1
A:
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..
marketer
2010-01-04 23:22:47
A:
Try
fmt.Printf("%+v", object)
That might give you something resembling what you want.
Evan Shaw
2010-01-05 00:29:20
+1
A:
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)
yuku
2010-01-06 05:40:34