diff --git a/storage/dir.go b/storage/dir.go index 0f0e6b9..199bb4a 100644 --- a/storage/dir.go +++ b/storage/dir.go @@ -1,7 +1,7 @@ package storage import ( - "encoding/json" + "encoding/gob" "log" "os" "path" @@ -21,8 +21,8 @@ type dir struct { } type dirEntry struct { - Password []byte `json:"password"` - ExpiresAt time.Time `json:"expires-at"` + Password []byte + ExpiresAt time.Time } func (store *dir) Create(password []byte, expiresAt time.Time) (string, error) { @@ -49,7 +49,7 @@ func (store *dir) Create(password []byte, expiresAt time.Time) (string, error) { ExpiresAt: expiresAt, } - err = json.NewEncoder(file).Encode(&entry) + err = gob.NewEncoder(file).Encode(&entry) if err != nil { log.Printf("%s", err) return "", err @@ -78,7 +78,7 @@ func (store *dir) Get(id string) ([]byte, error) { defer file.Close() var entry dirEntry - err = json.NewDecoder(file).Decode(&entry) + err = gob.NewDecoder(file).Decode(&entry) if err != nil { return nil, err } @@ -119,7 +119,7 @@ func (store *dir) ClearExpired() error { defer file.Close() var entry dirEntry - err = json.NewDecoder(file).Decode(&entry) + err = gob.NewDecoder(file).Decode(&entry) if err != nil { return err }