From 8697fa0956060f8423f8c802fead732a796020c7 Mon Sep 17 00:00:00 2001 From: celogeek <65178+celogeek@users.noreply.github.com> Date: Sun, 2 Jan 2022 17:07:12 +0100 Subject: [PATCH] stream to stdout --- internal/debug/dump.go | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/internal/debug/dump.go b/internal/debug/dump.go index 8994f77..3975ab2 100644 --- a/internal/debug/dump.go +++ b/internal/debug/dump.go @@ -1,14 +1,20 @@ +/* + Debug tools + + debug.Dump(myStruct) +*/ package debug import ( "encoding/json" - "fmt" + "os" ) -func Dump(v interface{}) (err error) { - b, err := json.MarshalIndent(v, "", " ") - if err == nil { - fmt.Println(string(b)) - } - return +/* + Dump an interface to the stdout +*/ +func Dump(v interface{}) error { + d := json.NewEncoder(os.Stdout) + d.SetIndent("", " ") + return d.Encode(v) }