Go 1.17 moves to beta, with language and compiler enhancements

Go (golang) 1.17, the next release of the open source, Google-developed programming language, is now in a beta release stage, with changes intended to simplify coding for safety.The first beta was published on June 10, with the production release expected in August. Release notes cite three small enhancements to the language, intended to simplify writing code that conforms to unsafe.Pointer’s safety rules. These enhancements include: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

Nov 30, -0001 - 00:00
 0
Go 1.17 moves to beta, with language and compiler enhancements
Techatty All-in-1 Publishing
Techatty All-in-1 Publishing

Go (golang) 1.17, the next release of the open source, Google-developed programming language, is now in a beta release stage, with changes intended to simplify coding for safety.

The first beta was published on June 10, with the production release expected in August. Release notes cite three small enhancements to the language, intended to simplify writing code that conforms to unsafe.Pointer’s safety rules. These enhancements include:

  • 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.

For the compiler, Go 1.17 implements a new way of passing function arguments and results using registers rather than the stack. This is enabled for Linux, MacOS, and Windows on the 64-bit x86 architecture. Benchmarking has shown a resulting performance improvement of about 5% and a typical reduction in binary size of about 2%. This change does not affect the functionality of safe Go code but can affect code outside the compatibility guidelines with minimal impacts. Also with the compiler, functions containing closures can be inlined. One effect of this is that a function with a closure may produce a distinct closure function for each place that the function is inlined. This change could reveal bugs where Go functions are incorrectly compared by pointer value. Go functions by definition are not comparable.

To read this article in full, please click here

Techatty Connecting the world of tech differently! Read. Write. Learn. Thrive. Make an informed decision without distractions. We are building tech media and publication networks to connect YOU and everyone to reliable information, opportunities, and resources to achieve greater success.
Web and Cloud LLC - talk to us and let's discuss your needs.
Let's help transform your business