Go 1.17, the latest release of the open source, Google-developed programming language, is now available as a production release, with changes intended to simplify coding for safety.
Go 1.17 was published on August 16. Release notes cite three small enhancements to the language, including two intended to simplify writing code that conforms to unsafe.Pointer’s safety rules. The three enhancements include:
- An expression
sof type[]Tmay now be converted to array pointer type*[N]T. Ifais 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 panicsif len(s)is less thanN. unsafe.Add: unsafe.Add(ptr, len)addslentoptrand returns the updated pointerunsafe.Pointer(uintptr(ptr) + uintptr(len)).unsafe.Slice: For expression ptr of type*T, unsafe.Slice(ptr, len)returns a slice of type[]Twhose underlying array starts atptrand whose length and capacity arelen.











