Golang encoding/gob.Encoder.EncodeValue() function example

package encoding/gob

EncodeValue transmits the data item represented by the reflection value, guaranteeing that all necessary type information has been transmitted first.

Golang encoding/gob.Encoder.EncodeValue() function usage example

 func (gobCodec) Write(w io.Writer, v reflect.Value, b WriteBasic) (err error) {
  if err = binary.Write(w, binary.BigEndian, Gob); err != nil {
 return
  }
  return gob.NewEncoder(w).EncodeValue(v) // <---- here
 }

References :

http://golang.org/pkg/encoding/gob/#Encoder.EncodeValue

https://github.com/markchadwick/typedbytes/blob/master/gob.go

Advertisement