stream to stdout

This commit is contained in:
Celogeek 2022-01-02 17:07:12 +01:00
parent 234a63f208
commit 8697fa0956
Signed by: celogeek
GPG Key ID: E6B7BDCFC446233A

View File

@ -1,14 +1,20 @@
/*
Debug tools
debug.Dump(myStruct)
*/
package debug package debug
import ( import (
"encoding/json" "encoding/json"
"fmt" "os"
) )
func Dump(v interface{}) (err error) { /*
b, err := json.MarshalIndent(v, "", " ") Dump an interface to the stdout
if err == nil { */
fmt.Println(string(b)) func Dump(v interface{}) error {
} d := json.NewEncoder(os.Stdout)
return d.SetIndent("", " ")
return d.Encode(v)
} }