mirror of
https://github.com/golang/go
synced 2024-11-11 19:21:37 -07:00
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:
parent
891547e2d4
commit
507cc341ec
@ -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:]) // &s1[0] == &s[1]
|
||||
s2 := (*[2]byte)(s) // &s2[0] == &s[0]
|
||||
s4 := (*[4]byte)(s) // panics: len([4]byte) > len(s)
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user