clessy-ng/utils/kv.go

16 lines
317 B
Go
Raw Permalink Normal View History

2022-03-25 19:06:13 +00:00
package utils
import (
"github.com/cockroachdb/pebble"
jsoniter "github.com/json-iterator/go"
)
func ReadJSON(db *pebble.DB, key string, dst interface{}) error {
data, closer, err := db.Get([]byte(key))
if err != nil {
return err
}
defer closer.Close()
return jsoniter.ConfigFastest.Unmarshal(data, dst)
}