Google releases Go 1.18 Beta with generic code

Google has released a preview of the new version of programming language Go. Version 1.18 adds functionality for ‘generic’ programming with so-called ‘parameterized’ types.

In their own words, it is the most important and biggest change to the programming language since the release of Go version 1. The idea behind generics is that it now allows functionality for representing functions and data structures by modifying the types. This excludes the ‘generality’ allowed by defining an interface type as a way of abstracting the actual data being brought to a function.

Google indicates that Go developers should realize that the functionality will undoubtedly lead to new bugs. They should therefore approach these ‘generics’ with caution.

Other functionality in Go 1.18 Beta

In addition to the above functionality, the new preview also has built-in support for writing fuzzing-based tests. These tests can automatically find inputs that cause programs to crash or return invalid answers. Go 1.18 Beta also offers a new ‘Go workspace mode’. This allows programmers to work with multiple Go modules simultaneously. This is especially useful for large projects, according to Google.

Furthermore, version 1.18 Beta adds functionality with an extended go version -m command. This command now stores details as compiler flags. A program can now query its own build details with the command debug.ReadBuildInfo.

Also, more register-based calling convention, available since Go 1.17, has been added in the preview. Where in the previous version this functionality was only suitable for speeding up Go code on x86 and x64 systems, it is now also suitable for ARM64 and PPC64 based systems. This should provide up to 20 percent more speed.