This repository has been archived on 2022-07-30. You can view files and clone it, but cannot push or open issues/pull-requests.
mdb/codec.go

18 lines
233 B
Go

package mdb
import (
"encoding/json"
)
func decode[T any](data []byte) *T {
item := new(T)
must(json.Unmarshal(data, item))
return item
}
func encode(item any) []byte {
buf, err := json.Marshal(item)
must(err)
return buf
}