Home

Awesome

goon

Go Reference

Package goon is a deep pretty printer with Go-like notation. It implements the goon specification.

Deprecated: This package is old, incomplete, low code quality, and now unmaintained. See github.com/hexops/valast for a newer package that is the closest known direct replacement. See the Alternatives section for other known entries in this problem space.

Installation

go get github.com/shurcooL/go-goon

Examples

x := Lang{
	Name: "Go",
	Year: 2009,
	URL:  "http",
	Inner: &Inner{
		Field1: "Secret!",
	},
}

goon.Dump(x)

// Output:
// (Lang)(Lang{
// 	Name: (string)("Go"),
// 	Year: (int)(2009),
// 	URL:  (string)("http"),
// 	Inner: (*Inner)(&Inner{
// 		Field1: (string)("Secret!"),
// 		Field2: (int)(0),
// 	}),
// })
items := []int{1, 2, 3}

goon.DumpExpr(len(items))

// Output:
// len(items) = (int)(3)
adderFunc := func(a int, b int) int {
	c := a + b
	return c
}

goon.DumpExpr(adderFunc)

// Output:
// adderFunc = (func(int, int) int)(func(a int, b int) int {
// 	c := a + b
// 	return c
// })

Directories

PathSynopsis
bypassPackage bypass allows bypassing reflect restrictions on accessing unexported struct fields.

Alternatives

Attribution

go-goon source was based on the existing source of go-spew by Dave Collins.

License