diff options
author | Ian Lance Taylor <iant@golang.org> | 2021-07-14 14:46:09 -0700 |
---|---|---|
committer | Ian Lance Taylor <iant@golang.org> | 2021-07-21 19:25:48 +0000 |
commit | 48c88f1b1bac1ef4fc81246a7f31933f8f922706 (patch) | |
tree | fbab30fe4bdc1734cfc86377510be3d50e04e01e /doc | |
parent | 9e26569293c13974d210fd588ebfd29b857d8525 (diff) | |
download | go-48c88f1b1bac1ef4fc81246a7f31933f8f922706.tar.gz go-48c88f1b1bac1ef4fc81246a7f31933f8f922706.zip |
reflect: add Value.CanConvert
For #395
For #46746
Change-Id: I4bfc094cf1cecd27ce48e31f92384cf470f371a6
Reviewed-on: https://go-review.googlesource.com/c/go/+/334669
Trust: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
Reviewed-by: Joe Tsai <thebrokentoaster@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r-- | doc/go1.17.html | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/doc/go1.17.html b/doc/go1.17.html index b31006fe65..7739d1c62e 100644 --- a/doc/go1.17.html +++ b/doc/go1.17.html @@ -989,6 +989,18 @@ func Foo() bool { <dl id="reflect"><dt><a href="/pkg/reflect/">reflect</a></dt> <dd> + <p><!-- CL 334669 --> + The new + <a href="/pkg/reflect/#Value.CanConvert"><code>Value.CanConvert</code></a> + method reports whether a value can be converted to a type. + This may be used to avoid a panic when converting a slice to an + array pointer type if the slice is too short. + Previously it was sufficient to use + <a href="/pkg/reflect/#Type.ConvertibleTo"><code>Type.ConvertibleTo</code></a> + for this, but the newly permitted conversion from slice to array + pointer type can panic even if the types are convertible. + </p> + <p><!-- CL 266197 --> The new <a href="/pkg/reflect/#StructField.IsExported"><code>StructField.IsExported</code></a> |