From 1603d6f3850d2d223a80916ae5bdfc854f64a40b Mon Sep 17 00:00:00 2001 From: Jae Kwon Date: Tue, 15 Jul 2014 21:53:39 -0700 Subject: [PATCH] pretty print addrbook json --- p2p/addrbook.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/p2p/addrbook.go b/p2p/addrbook.go index 5a3a60c2b..8bc7d795d 100644 --- a/p2p/addrbook.go +++ b/p2p/addrbook.go @@ -305,11 +305,11 @@ func (a *AddrBook) saveToFile(filePath string) { log.Error("Error opening file: ", filePath, err) return } - enc := json.NewEncoder(w) defer w.Close() - err = enc.Encode(&aJSON) + jsonBytes, err := json.MarshalIndent(aJSON, "", "\t") + _, err = w.Write(jsonBytes) if err != nil { - panic(err) + log.Error("Failed to save AddrBook to file %v: %v", filePath, err) } }