Moved int gob write functions to the gob_encoding file

This commit is contained in:
Marius Orcsik 2022-01-02 16:24:24 +01:00
parent bafe58846f
commit 30317634f5
No known key found for this signature in database
GPG key ID: DBF5E47F5DBC4D21
2 changed files with 20 additions and 10 deletions

View file

@ -25,6 +25,26 @@ func (e *gobEncoder) encode(it Item) ([]byte, error) {
return e.w.Bytes(), nil
}
// TODO(marius): when migrating to go1.18, use a numeric constraint for this
func gobEncodeInt64(i int64) ([]byte, error) {
b := bytes.Buffer{}
gg := gob.NewEncoder(&b)
if err := gg.Encode(i); err != nil {
return nil, err
}
return b.Bytes(), nil
}
// TODO(marius): when migrating to go1.18, use a numeric constraint for this
func gobEncodeUint(i uint) ([]byte, error) {
b := bytes.Buffer{}
gg := gob.NewEncoder(&b)
if err := gg.Encode(i); err != nil {
return nil, err
}
return b.Bytes(), nil
}
//// GobEncode
//func GobEncode(it Item) ([]byte, error) {
// w := bytes.NewBuffer(make([]byte, 0))

10
link.go
View file

@ -124,16 +124,6 @@ func (l Link) MarshalBinary() ([]byte, error) {
return l.GobEncode()
}
// TODO(marius): when migrating to go1.18, use a numeric constraint for this
func gobEncodeUint(i uint) ([]byte, error) {
b := bytes.Buffer{}
gg := gob.NewEncoder(&b)
if err := gg.Encode(i); err != nil {
return nil, err
}
return b.Bytes(), nil
}
func (l Link) GobEncode() ([]byte, error) {
var (
mm = make(map[string][]byte)