doc: add example for conversion from slice expressions to array ptr

Fixes #47599

Change-Id: I8f4ccd3b0c2bcdb057ee853163b4421229141333
Reviewed-on: https://go-review.googlesource.com/c/go/+/340351
Trust: Cuong Manh Le <cuong.manhle.vn@gmail.com>
Run-TryBot: Cuong Manh Le <cuong.manhle.vn@gmail.com>
TryBot-Result: Go Bot <gobot@golang.org>
Reviewed-by: Keith Randall <khr@golang.org>
This commit is contained in:
Cuong Manh Le 2021-08-09 00:52:21 +07:00 committed by Keith Randall
parent 891547e2d4
commit 507cc341ec

View file

@ -4329,6 +4329,7 @@ a <a href="#Run_time_panics">run-time panic</a> occurs.
<pre>
s := make([]byte, 2, 4)
s0 := (*[0]byte)(s) // s0 != nil
s1 := (*[1]byte)(s[1:]) // &amp;s1[0] == &amp;s[1]
s2 := (*[2]byte)(s) // &amp;s2[0] == &amp;s[0]
s4 := (*[4]byte)(s) // panics: len([4]byte) > len(s)