This repository has been archived on 2022-07-30. You can view files and clone it, but cannot push or open issues/pull-requests.
|
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
|
|
}
|