debug: add function to easily log structures Signed-off-by: Chris Waldon <christopher.waldon.dev@gmail.com>
1 files changed, 11 insertions(+), 0 deletions(-) M debug/debug.go
M debug/debug.go => debug/debug.go +11 -0
@@ 4,7 4,11 @@ Package debug provides tools for debugging Gio layout code. package debug import ( "bytes" "encoding/json" "image/color" "io" "os" "gioui.org/layout" @@ "gioui.org/unit" 23,3 27,10 @@ func Outline(gtx C, w func(gtx C) D) D { Width: unit.Dp(1), }.Layout(gtx, w) } // Dump logs the input as formatting JSON on stderr. func Dump(v interface{}) { b, _ := json.MarshalIndent(v, "", " ") b = append(b, []byte("\n")...) io.Copy(os.Stderr, bytes.NewBuffer(b)) }