From cfbdcb6ce79d2122848b54df13892e37fc87dd73 Mon Sep 17 00:00:00 2001 From: Lunny Xiao Date: Thu, 21 Dec 2017 09:38:32 +0800 Subject: [PATCH] small refactor --- cache.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/cache.go b/cache.go index bf81bd52..8f9531da 100644 --- a/cache.go +++ b/cache.go @@ -1,11 +1,12 @@ package core import ( - "errors" - "fmt" - "time" "bytes" "encoding/gob" + "errors" + "fmt" + "strings" + "time" ) const ( @@ -55,11 +56,10 @@ func encodeIds(ids []PK) (string, error) { return buf.String(), err } - func decodeIds(s string) ([]PK, error) { pks := make([]PK, 0) - dec := gob.NewDecoder(bytes.NewBufferString(s)) + dec := gob.NewDecoder(strings.NewReader(s)) err := dec.Decode(&pks) return pks, err