Golang encoding/gob.Decoder.DecodeValue() function example

package encoding/gob

DecodeValue reads the next value from the input stream. If v(1st parameter) is the zero reflect.Value (v.Kind() == Invalid), DecodeValue discards the value. Otherwise, it stores the value into v. In that case, v must represent a non-nil pointer to data or be an assignable reflect.Value (v.CanSet()) If the input is at EOF, DecodeValue returns io.EOF and does not modify e.

Golang encoding/gob.Decoder.DecodeValue() function usage example

 func (ed *encDec) decode(value reflect.Value) error {
 ed.decLock.Lock()
 err := ed.dec.DecodeValue(value)  // <--- here
 if err != nil {
 return err
 }
 ed.decLock.Unlock()
 return err
 }

Reference :

http://golang.org/pkg/encoding/gob/#Decoder.DecodeValue

https://gowalker.org/code.google.com/p/go.exp/old/netchan?f=common.go

Advertisement