As of yesterday, the team behind Go has released a new version 1.18 with some significant changes to the language. Those of you who want to start using these new features are in luck: you can do it right away on Platform.sh.
If you’re already using Go on Platform.sh, you can upgrade by changing the number in the
type key of your app configuration. In your
If you’re not yet using Go for your project, now’s a great time to give Go a try.
The major change in this release is the possibility to use generic features. This means your functions and types can now take type parameters.
This change has been in the works for many years. The first proposal for generics came within a day of the first Go release.
The new changes mean you can now write a function that can apply to parameters with different types. Previously, if you wanted to, say, add a map of integer values and a map of float values, you’d have to write two separate functions for that, one for each type.
Now, you can write a single generic function that can handle each type. For the details, see a tutorial on generics in Go.
For the details of all the changes in this release, see the Go 1.18 release notes.