Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
type fataler interface {
Fatal(...interface{})
}
func logJSON(t fataler, w io.Writer, label string, callback func() (interface{}, error)) {
data, err := callback()
if err != nil {
t.Fatal(err, label)
}
enc := json.NewEncoder(w)
enc.SetIndent("", " ")
enc.Encode(label)
enc.Encode(data)
}
// logJSON(t, os.Stderr, "users", func() { return users, nil })
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment