Go 1.18 promises to be the most significant update to the language ever

Programming code abstract on a reflective background
(Image credit: Shutterstock)

The development team behind the Google-created Go programming language has released what it’s calling the “biggest change ever to the language”.

Go version 1.18 is available to download now and brings with it support for generic code using parameterised types – often simply referred to as ‘generics’ – a most-requested feature from the Go community, the development team said.

Generics is an approach that can be found in other popular programming languages like Java, Python, Rust, and Swift, and allows developers to write data structures and functions in a way that they can be applied to many different cases.

For example, a developer may want to code a ‘reverse’ function for integers, but also want it to apply to strings – two different types of data. Generics makes this less difficult to achieve by opening up the function to accept different, unspecified data types.

“Supporting generics has been Go’s most often requested feature, and we’re proud to deliver the generic support that the majority of users need today,” said Go. “Subsequent releases will provide additional support for some of the more complicated generic use cases.”

Go said the generics support is a “major” addition but is fully backwards-compatible in the language. While it believes the feature has been implemented well, it said it does not have much testing data from real-world applications, and so advises developers to exercise caution when deploying generic code.

It's the first implementation of generics in Go and there is a possibility that generic code written in Go 1.18 may break in later releases if the method of implementation has to be changed, the development team said.

“We will minimise any such breakage as much as possible, but we can't guarantee that the breakage will be zero,” it said.

Full details of what Go supports with generics and what its current limitations are can be found in the official release notes.

Fuzzing

Go has also implemented fuzzing – another of the most requested features from its community and the first major programming language to fully integrate fuzzing into its toolchain, the development team said.

Fuzzing is an automated testing tool that feeds invalid or random data into an application’s code as a way to test it for bugs or problems that could lead to crashes.

Go said its fuzzing can be particularly useful for developers looking to test for security exploits and vulnerabilities in the edge cases humans often miss.

The developers warned that using fuzzing in an application can consume a lot of system memory and that developers may experience significant performance dips on their machines while it runs. There is also no limit to the number of files or total bytes that can be written to the fuzz cache, which may lead to multiple gigabytes of storage being used.

Workspaces and performance improvements

Go has introduced multi-module workspaces that allow developers to tell the Go command that code is being written on multiple modules at the same time.

RELATED RESOURCE

Four strategies for building a hybrid workplace that works

All indications are that the future of work is hybrid, if it's not here already

FREE DOWNLOAD

It addresses one of the chief challenges identified in the development team’s annual survey of Go programmers that showed it was difficult to work using Go across multiple modules. The new workspace mode makes this a more streamlined process.

Go also said the latest version delivers performance increases of up to 20% when using Apple M1, ARM64, and PowerPC64 thanks to an expansion of Go 1.17’s register ABI calling convention to the architectures.

The improvement is significant, and Go emphasised that while it’s proud of the speed increase, it’s still only the fourth most important part of the release, underlining how significant the other changes are.

Connor Jones
News and Analysis Editor

Connor Jones has been at the forefront of global cyber security news coverage for the past few years, breaking developments on major stories such as LockBit’s ransomware attack on Royal Mail International, and many others. He has also made sporadic appearances on the ITPro Podcast discussing topics from home desk setups all the way to hacking systems using prosthetic limbs. He has a master’s degree in Magazine Journalism from the University of Sheffield, and has previously written for the likes of Red Bull Esports and UNILAD tech during his career that started in 2015.