From 5b29bb72850e9aa658b6f3567c1a7d08cf471c21 Mon Sep 17 00:00:00 2001 From: 1e99 <1e99@1e99.eu> Date: Wed, 30 Oct 2024 12:18:27 +0100 Subject: [PATCH] use gob instead of JSON --- storage/dir.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) 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 }