Remove GOB serialization code

This commit is contained in:
Tobie Morgan Hitchcock 2016-10-14 07:14:58 +01:00
parent 40a52dfbf1
commit cae06f2b4b

View file

@ -16,51 +16,27 @@ package pack
import ( import (
"bytes" "bytes"
"encoding/gob"
"github.com/abcum/cork" "github.com/abcum/cork"
"github.com/abcum/surreal/sql"
) )
var opt cork.Handle
func init() { func init() {
opt.Precision = false
gob.Register(sql.Null{}) opt.ArrType = []interface{}{}
gob.Register(sql.Void{}) opt.MapType = map[string]interface{}{}
gob.Register(sql.Empty{})
gob.Register(sql.Field{})
gob.Register(sql.Group{})
gob.Register(sql.Order{})
gob.Register(sql.Ident{})
gob.Register(sql.Table{})
gob.Register(sql.Thing{})
gob.Register(sql.DiffExpression{})
gob.Register(sql.MergeExpression{})
gob.Register(sql.ContentExpression{})
gob.Register(sql.SelectStatement{})
gob.Register(sql.CreateStatement{})
gob.Register(sql.UpdateStatement{})
gob.Register(sql.ModifyStatement{})
gob.Register(sql.DeleteStatement{})
gob.Register(sql.RelateStatement{})
gob.Register(sql.DefineViewStatement{})
gob.Register(sql.DefineTableStatement{})
gob.Register(sql.DefineRulesStatement{})
gob.Register(sql.DefineFieldStatement{})
gob.Register(sql.DefineIndexStatement{})
} }
// Encode encodes a data object into a GOB. // Encode encodes a data object into a CORK.
func Encode(src interface{}) (dst []byte) { func Encode(src interface{}) (dst []byte) {
buf := bytes.NewBuffer(nil) buf := bytes.NewBuffer(nil)
// gob.NewEncoder(buf).Encode(src) cork.NewEncoder(buf).Options(&opt).Encode(src)
cork.NewEncoder(buf).Encode(src)
return buf.Bytes() return buf.Bytes()
} }
// Decode decodes a GOB into a data object. // Decode decodes a CORK into a data object.
func Decode(src []byte, dst interface{}) { func Decode(src []byte, dst interface{}) {
buf := bytes.NewBuffer(src) buf := bytes.NewBuffer(src)
// gob.NewDecoder(buf).Decode(&dst) cork.NewDecoder(buf).Options(&opt).Decode(dst)
cork.NewDecoder(buf).Decode(dst)
return return
} }