From: Matthew Dempsky Date: Mon, 7 Jun 2021 21:28:14 +0000 (-0700) Subject: doc: document Go 1.17 language changes X-Git-Tag: go1.17beta1~26 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=39c39ae52f;p=gostls13.git doc: document Go 1.17 language changes Fixes #46020. Change-Id: Iadf9a0ac4a8863e17155d6ba1af2cc497634a634 Reviewed-on: https://go-review.googlesource.com/c/go/+/325870 Trust: Matthew Dempsky Reviewed-by: Ian Lance Taylor Reviewed-by: Dmitri Shuralyov --- diff --git a/doc/go1.17.html b/doc/go1.17.html index 7438d894fe..c1978ff1c1 100644 --- a/doc/go1.17.html +++ b/doc/go1.17.html @@ -25,12 +25,46 @@ Do not send CLs removing the interior tags from such phrases.

Changes to the language

-

- TODO: https://golang.org/cl/216424: allow conversion from slice to array ptr -

+

+ Go 1.17 includes three small enhancements to the language. +

+ +
    +
  • + Conversions + from slice to array pointer: An expression s of + type []T may now be converted to array pointer type + *[N]T. If a is the result of such a + conversion, then corresponding indices that are in range refer to + the same underlying elements: &a[i] == &s[i] + for 0 <= i < N. The conversion panics if + len(s) is less than N. +
  • + +
  • + unsafe.Add: + unsafe.Add(ptr, len) adds len + to ptr and returns the updated pointer + unsafe.Pointer(uintptr(ptr) + uintptr(len)). +
  • + +
  • + unsafe.Slice: + For expression ptr of type *T, + unsafe.Slice(ptr, len) returns a slice of + type []T whose underlying array starts + at ptr and whose length and capacity + are len. +
  • +
-

- TODO: https://golang.org/cl/312212: add unsafe.Add and unsafe.Slice +

+ These enhancements were added to simplify writing code that conforms + to unsafe.Pointer's safety + rules, but the rules remain unchanged. In particular, existing + programs that correctly use unsafe.Pointer remain + valid, and new programs must still follow the rules when + using unsafe.Add or unsafe.Slice.

Ports