From 40b5d5481a6dc3e877487923dcf9d81515ebb072 Mon Sep 17 00:00:00 2001 From: Robert Griesemer Date: Sat, 22 Sep 2012 05:53:59 +1000 Subject: [PATCH] [release-branch.go1] reflect: reflect.Zero results are neither addressable nor settable MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ««« backport 21130d62eeb0 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 »»» --- src/pkg/reflect/value.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) 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)") -- 2.50.0