From: Robert Griesemer Date: Tue, 3 Jul 2012 23:06:24 +0000 (-0700) Subject: reflect: reflect.Zero results are neither addressable nor settable X-Git-Tag: go1.1rc2~2834 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=6044dbdf1b627fc1f30422add87216137b709bae;p=gostls13.git reflect: reflect.Zero results are neither addressable nor settable This could be deduced from "The Laws of Reflection" but it seems worthwhile highlighting it. R=r CC=golang-dev https://golang.org/cl/6350073 --- diff --git a/src/pkg/reflect/value.go b/src/pkg/reflect/value.go index 79476ad229..c44d408c6b 100644 --- a/src/pkg/reflect/value.go +++ b/src/pkg/reflect/value.go @@ -1713,10 +1713,11 @@ func ValueOf(i interface{}) Value { return Value{typ, unsafe.Pointer(eface.word), fl} } -// Zero returns a Value representing a zero value for the specified type. +// Zero returns a Value representing the zero value for the specified type. // The result is different from the zero value of the Value struct, // which represents no value at all. // For example, Zero(TypeOf(42)) returns a Value with Kind Int and value 0. +// The returned value is neither addressable nor settable. func Zero(typ Type) Value { if typ == nil { panic("reflect: Zero(nil)")