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
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)
}