From f6896bf12bd59f2923301f62225541377a888036 Mon Sep 17 00:00:00 2001 From: Julian Kornberger Date: Fri, 20 Apr 2018 08:56:06 +0200 Subject: [PATCH] Make query output more readable --- cmd/query.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/query.go b/cmd/query.go index ea81708..8646262 100644 --- a/cmd/query.go +++ b/cmd/query.go @@ -1,6 +1,7 @@ package cmd import ( + "encoding/json" "log" "net" "time" @@ -33,7 +34,12 @@ var queryCmd = &cobra.Command{ time.Sleep(time.Second * time.Duration(wait)) for id, data := range nodes.List { - log.Printf("%s: %+v", id, data) + bytes, err := json.Marshal(data) + if err != nil { + log.Printf("%s: %+v", id, err) + } else { + log.Printf("%s: %+v", id, string(bytes)) + } } }, }