initial commit

This commit is contained in:
ston1th 2019-04-19 15:45:28 +02:00
commit 18995db757
871 changed files with 492725 additions and 0 deletions

30
pkg/store/marshal.go Normal file
View file

@ -0,0 +1,30 @@
// Copyright (C) 2019 Marius Schellenberger
package store
import (
"bytes"
"encoding/gob"
)
type Marshaler interface {
Marshal(v interface{}) ([]byte, error)
Unmarshal(data []byte, v interface{}) error
}
type gobMarshaler struct{}
func NewGOB() Marshaler {
return gobMarshaler{}
}
func (gobMarshaler) Marshal(v interface{}) (b []byte, err error) {
buf := new(bytes.Buffer)
err = gob.NewEncoder(buf).Encode(v)
b = buf.Bytes()
return
}
func (gobMarshaler) Unmarshal(data []byte, v interface{}) error {
return gob.NewDecoder(bytes.NewBuffer(data)).Decode(v)
}