made • It was released on Mar 15th, 2022 , seven months after Go 1.17 📆 • It’s one of the major changes in the language ever done 🚛 • It packs a TON of new features, plus library and tooling improvements • Generics 㿂 • Fuzzing 🎛 • Workspace mode 🗃 • Sane packages for sorting stuff! 🥇 • It keeps the Compatibility Promise, as usual 😎
• Write functions or types that work with any of a set of types provided by the calling code • Generic code is loosely coupled to the speci f ic types being used • Generics add three new, important features to the language: • Type parameters • Type inference • Interface types as sets of types • Create zero values out of generic types
func Min[T constraints.Ordered](x, y T) T { if x < y { return x } return y } func main() { fmt.Println(Min[int](2, 3)) fmt.Println(Min[float32](2.5, 2.6)) }
which continuously manipulates inputs to a program to f ind bugs. Good for f inding edge cases: it’s an extremely valuable feat whenever security is concerned, and still very valuable to hunt down hard-to- f ind bugs.
• A new, optional go.work f ile has been introduced: if present, it will set Go in Workspace Mode. • When in Workspace Mode, go will use the go.work f ile to determine all the modules to use as roots for module resolution, as opposed to having a single one as imposed by go.mod • Such Mode allows for work on multiple, independent modules at the same time more conveniently than it was in the past
package, featuring Addr and AddrPort types • Compared to net.IP, netip.Addr is more memory ef f icient, immutable, comparable and can be used as a map key • Besides an IP and a port, AddrPort can also represent a CIDR pre f ix • Tons of new functions to work on the newly de f ined types • Loads of helpers for bridging with the old net.IP package
icient way to pass function argument on arm64 and some amd64, getting up to 10% performance improvements • Due to generics, compile speed can get about 15% slower than go 1.17 • Nice strings functions improvements, hello Cut()! • Ditto for bytes • Introduces the new any identi f ier as an alias for interface{} • Loads of other little minor changes
1.18 Release Notes • Article: An Introduction to Generics • Article: Are Go Generics ready for Prime Time? • Documentation: Fuzzing • Reference: Go Workspaces • Learning Go's free chapters on Generics
• re f inements and improvements to generics • new unix build constraint • faster regex functions (~ -30% exec time) • faster large switch statements(int and string only) • more ef f icient race detector (1.5-2.0x faster, ~50% memory usage, unlimited goroutines) • lots of minor library changes, as usual