Skip to content

Commit 507cc34

Browse files
cuonglmrandall77
authored andcommitted
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 <[email protected]> Run-TryBot: Cuong Manh Le <[email protected]> TryBot-Result: Go Bot <[email protected]> Reviewed-by: Keith Randall <[email protected]>
1 parent 891547e commit 507cc34

File tree

1 file changed

+1
-0
lines changed

1 file changed

+1
-0
lines changed

doc/go_spec.html

+1
Original file line numberDiff line numberDiff line change
@@ -4329,6 +4329,7 @@ <h4 id="Conversions_from_slice_to_array_pointer">Conversions from slice to array
43294329
<pre>
43304330
s := make([]byte, 2, 4)
43314331
s0 := (*[0]byte)(s) // s0 != nil
4332+
s1 := (*[1]byte)(s[1:]) // &amp;s1[0] == &amp;s[1]
43324333
s2 := (*[2]byte)(s) // &amp;s2[0] == &amp;s[0]
43334334
s4 := (*[4]byte)(s) // panics: len([4]byte) > len(s)
43344335

0 commit comments

Comments
 (0)