Go 1.18 is now available as a beta release featuring highly anticipated generics capabilities, called the most significant change to the programming language since the release of Go 1.0 in 2012.
Published December 14, Go 1.18 Beta 1 is the first preview release of the Google-developed open source language containing support for generic code using parameterised types.
Generic programming is an enhancement enabling representation of functions and data structures in a generic form, with types being factored out. Generics can provide building blocks to share code and make it easier to build programs.
In a blog post, the Go team cautioned that with any significant new feature, it was common for users to discover new bugs; generics is not expected to be an exception to this rule. Developers are advised to approach new generics with appropriate caution. Additionally, support for certain subtle cases such as specific kinds of recursive generic types has been postponed to future releases.
Nevertheless, some early adopters have been “quite happy,” the team said. A brief tutorial has been published on getting started with generics.
While Go has had interface types, a form of generic programming, it has lacked what Go developers have wanted from generics, according a July 2019 blog post. For example, advocates for Go generics have sought abilities such as being able write functions such as
Reverse without caring about the element type of a slice.
- Built-in support is offered for writing fuzzing-based tests, to find inputs that cause a program to crash or return invalid answers.
- A Go workspace mode lets developers work with multiple Go modules simultaneously, which is important for larger projects.
- An expanded
go version -mcommand now records build details such as compiler flags.
- A GOAMD64 environment variable allows users to select any of four versions of the AMD64 architecture.
- The Windows/Arm and Windows/Arm64 ports now support non-cooperative pre-emption, bringing this capability to all four Windows ports and hopefully addressing subtle bugs encountered when calling into Win32 functions that block for extended time periods.
- The garbage collector now includes non-heap sources of GC work when determining how frequently to run. This makes GC overhead more predictable when these sources are significant.
Go 1.17 was released in August. Probably best known for being used in development of the Docker container system, Go was designed to be a simple, easy-to-learn programming language with strong support for concurrency.