Moved int gob write functions to the gob_encoding file
This commit is contained in:
parent
bafe58846f
commit
30317634f5
2 changed files with 20 additions and 10 deletions
|
@ -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
10
link.go
|
@ -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)
|
||||
|
|
Reference in a new issue