stat: change encoding to JSON

This commit is contained in:
cws 2017-06-05 21:03:23 -04:00
parent e1e58591ec
commit de19f6a4e9
1 changed files with 4 additions and 9 deletions

View File

@ -4,8 +4,7 @@
package stats package stats
import ( import (
"bytes" "encoding/json"
"encoding/gob"
"log" "log"
"strings" "strings"
"time" "time"
@ -42,17 +41,13 @@ type stat struct {
type value int type value int
func (v value) Bytes() ([]byte, error) { func (v value) Bytes() ([]byte, error) {
var b bytes.Buffer b, err := json.Marshal(v)
enc := gob.NewEncoder(&b) return b, err
err := enc.Encode(v)
return b.Bytes(), err
} }
func valueFromBytes(b []byte) (value, error) { func valueFromBytes(b []byte) (value, error) {
var v value var v value
buf := bytes.NewReader(b) err := json.Unmarshal(b, &v)
dec := gob.NewDecoder(buf)
err := dec.Decode(&v)
return v, err return v, err
} }