use gob instead of JSON
This commit is contained in:
parent
7536e5d9af
commit
5b29bb7285
1 changed files with 6 additions and 6 deletions
|
@ -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
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue