From de19f6a4e94137c5004fc76ad1df5b56457a0ac7 Mon Sep 17 00:00:00 2001 From: cws Date: Mon, 5 Jun 2017 21:03:23 -0400 Subject: [PATCH] stat: change encoding to JSON --- plugins/stats/stats.go | 13 ++++--------- 1 file changed, 4 insertions(+), 9 deletions(-) diff --git a/plugins/stats/stats.go b/plugins/stats/stats.go index 2123f9b..01cabcf 100644 --- a/plugins/stats/stats.go +++ b/plugins/stats/stats.go @@ -4,8 +4,7 @@ package stats import ( - "bytes" - "encoding/gob" + "encoding/json" "log" "strings" "time" @@ -42,17 +41,13 @@ type stat struct { type value int func (v value) Bytes() ([]byte, error) { - var b bytes.Buffer - enc := gob.NewEncoder(&b) - err := enc.Encode(v) - return b.Bytes(), err + b, err := json.Marshal(v) + return b, err } func valueFromBytes(b []byte) (value, error) { var v value - buf := bytes.NewReader(b) - dec := gob.NewDecoder(buf) - err := dec.Decode(&v) + err := json.Unmarshal(b, &v) return v, err }