diff --git a/doc/go_spec.html b/doc/go_spec.html index 8c9003434c..13b8beb06c 100644 --- a/doc/go_spec.html +++ b/doc/go_spec.html @@ -1,6 +1,6 @@ @@ -4164,6 +4164,10 @@ in any of these cases:
  • x is a string and T is a slice of bytes or runes.
  • +
  • + x is a slice, T is a pointer to an array, + and the slice and array types have identical element types. +
  • @@ -4314,6 +4318,24 @@ MyRunes("白鵬翔") // []rune{0x767d, 0x9d6c, 0x7fd4} +

    Conversions from slice to array pointer

    + +

    +Converting a slice to an array pointer yields a pointer to the underlying array of the slice. +If the length of the slice is less than the length of the array, +a run-time panic occurs. +

    + +
    +s := make([]byte, 2, 4)
    +s0 := (*[0]byte)(s)      // s0 != nil
    +s2 := (*[2]byte)(s)      // &s2[0] == &s[0]
    +s4 := (*[4]byte)(s)      // panics: len([4]byte) > len(s)
    +
    +var t []string
    +t0 := (*[0]string)(t)    // t0 == nil
    +t1 := (*[1]string)(t)    // panics: len([1]string) > len(s)
    +

    Constant expressions