]> Cypherpunks repositories - gostls13.git/commitdiff
encoding/gob: document that Decode returns EOF at EOF
authorRob Pike <r@golang.org>
Fri, 7 Mar 2014 02:24:14 +0000 (13:24 +1100)
committerRob Pike <r@golang.org>
Fri, 7 Mar 2014 02:24:14 +0000 (13:24 +1100)
Just commentary describing existing behavior, no code changes.

Fixes #7033.

LGTM=bradfitz
R=golang-codereviews, bradfitz
CC=golang-codereviews
https://golang.org/cl/71860043

src/pkg/encoding/gob/decoder.go

index 04f706ca540327602488de59dad780b4e22a8846..3a769ec1254ad15d080f6a61c8741eb343835352 100644 (file)
@@ -183,11 +183,13 @@ func (dec *Decoder) decodeTypeSequence(isInterface bool) typeId {
        return -1
 }
 
-// Decode reads the next value from the connection and stores
+// Decode reads the next value from the input stream and stores
 // it in the data represented by the empty interface value.
 // If e is nil, the value will be discarded. Otherwise,
 // the value underlying e must be a pointer to the
 // correct type for the next data item received.
+// If the input is at EOF, Decode returns io.EOF and
+// does not modify e.
 func (dec *Decoder) Decode(e interface{}) error {
        if e == nil {
                return dec.DecodeValue(reflect.Value{})
@@ -202,10 +204,12 @@ func (dec *Decoder) Decode(e interface{}) error {
        return dec.DecodeValue(value)
 }
 
-// DecodeValue reads the next value from the connection.
+// DecodeValue reads the next value from the input stream.
 // If v 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.
 func (dec *Decoder) DecodeValue(v reflect.Value) error {
        if v.IsValid() {
                if v.Kind() == reflect.Ptr && !v.IsNil() {