A Pretty-printer for Go data structures.
- Support to print maps ordered by key using fmtsort
- Support to print byte with hexadecimal
- Expose a handler to handle Unsupported Type
- Support to print compact array or slice
go get github.com/sikasjc/pretty
package main
import "github.com/sikasjc/pretty"
func main() {
m := map[string]interface{}{
"a": 123,
"b": "string",
"z": 1.2,
"c": "xyz",
"foo": "bar",
"empty": map[string]interface{}{},
"map": map[int]interface{}{
1: "one",
2: 2,
3: 3.0,
},
}
pretty.Print(m)
}
/* output
{
"a": 123,
"b": "string",
"c": "xyz",
"empty": {},
"foo": "bar",
"map":
{
1: "one",
2: 2,
3: 3
},
"z": 1.2
}
*/