Skip to content

Commit

Permalink
Encode now returns an error
Browse files Browse the repository at this point in the history
  • Loading branch information
JAicewizard committed May 4, 2020
1 parent 723bf73 commit 3ac35ce
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions v3.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,23 @@ func NewV3Encoder(out v3.Writer, isStream bool) *V3Encoder {
}

//Encodev3 encodes an `interface{}`` into a bytebuffer using ttv3
func Encodev3(d interface{}, out v3.Writer) {
func Encodev3(d interface{}, out v3.Writer) error {
out.Write(v3NoStreamHeader)

enc := &V3Encoder{
out: out,
varintbuf: &[binary.MaxVarintLen64]byte{},
}
//We dont have to lock/unlock since we know we are the only one witha acces
enc.encodeValuev3(d, v3.Key{})
return enc.encodeValuev3(d, v3.Key{})
}

//Encode encodes an `interface{}`` into a bytebuffer using ttv3
func (enc *V3Encoder) Encode(d interface{}) {
func (enc *V3Encoder) Encode(d interface{}) error {
enc.Lock()
enc.encodeValuev3(d, v3.Key{})
ret := enc.encodeValuev3(d, v3.Key{})
enc.Unlock()
return ret
}

func encodeKeyv3(k interface{}) v3.Key {
Expand Down

0 comments on commit 3ac35ce

Please sign in to comment.