Go 1.26 Refines Language Syntax

Go 1.26 has been released with two significant refinements to the language syntax and type system. The changes modify the built-in new function, and simplify the use of generic types. 


Since its initial development by Google where it was designed as a systems programming language, Go has continued development as an open source project maintained by a team at Google with input from other contributors. Go has been used in a number of high profile commercial successes such as Docker.

Go 1.26 Refines Language Syntax

The changes to the new version start with a change to the built-in new function. This creates a new variable, and now allows its operand to be an expression, specifying the initial value of the variable. This simplifies setting up and assigning values to variables created using new as you can now have statements such as:

ptr := new(int64(300))

The second change to the language adds the ability for generic types to refer to themselves in their own type parameter list. This change simplifies the implementation of complex data structures and interfaces.

Elsewhere, the previously experimental Green Tea garbage collector is now enabled by default. It improves the performance of marking and scanning small objects. The developers say that while benchmark results vary, they expect a 10–40% reduction in garbage collection overhead in real-world programs that heavily use the garbage collector, and even better figures when running on newer amd64-based CPU platforms (Intel Ice Lake or AMD Zen 4 and newer). 

The baseline cgo overhead has also been reduced by approximately 30%. Cgo is a feature in the Go that lets Go packages call C code directly. 

The go fix command now includes a number of “modernizers”, analyzers that suggest safe fixes to help your code take advantage of newer features of the language and standard library. It also includes the inline analyzer, which attempts to inline calls to functions annotated with a //go:fixinline directive. 

There are also three new packages: crypto/hpke for Hybrid Public Key Encryption (HPKE), crypto/mlkem/mlkemtest which exposes functions that implement derandomized ML-KEM encapsulation, for use with known-answer tests; and testing/cryptotest which configures a global, deterministic cryptographic randomness source for the duration of the test. 

Go 1.26  is available for download now.

Go 1.26 Refines Language Syntax

More Information

Go Download Page

GoLang Org Webpage

Related Articles

Go 1.25 Adds Experimental Garbage Collector

Go 1.24 Adds Generic Type Alias Support

Go 1.23 Improves Tools

Go 1.21 Adds New Built-Ins 

Golang Back In TIOBE Top 10 

Why Is Go Good?

A Programmer’s Guide To Go

A Programmer’s Guide To Go Part 2 – Objects And Interfaces

A Programmer’s Guide To Go Part 3 – Goroutines And Concurrency

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Facebook or Linkedin.

Banner


uno q book


 

Comments

or email your comment to: [email protected]

link

Leave a Reply

Your email address will not be published. Required fields are marked *