What Is New in Go 1.20
Go 1.20 introduces targeted enhancements across the language, standard library, and toolchain. These updates focus on improving performance, security, and developer experience without major breaking changes.
| Category | Key Changes |
|---|---|
| Language | Method conversions, struct comparison changes, slice to array conversions |
| Ports | New support for FreeBSD on RISC-V, dropped support for Windows 7/8/Server 2008/2012 |
| Tools | Go command changes, vet improvements, profile-guided optimization |
| Runtime & Compiler | Memory management optimizations, faster builds |
| Library | New wrapping multiple errors, crypto/rsa improvements, HTTP ResponseController |
What language changes should Go developers know about?
Go 1.20 adds several subtle but useful language features. The most significant change allows converting a slice to an array pointer, giving developers more control over memory layout.
You can now write s := make([]byte, 2, 4) followed by s2 := (*[2]byte)(s). This conversion panics if the slice is shorter than the array length, so use it carefully. Struct comparison rules were also updated to handle blank fields and non-comparable types more consistently.
How does profile-guided optimization improve Go performance?
Profile-guided optimization (PGO) is now production-ready in Go 1.20. It lets the compiler optimize based on real workload profiles collected from your application.
After building your binary with -cpuprofile, the compiler uses that data to make better inlining decisions and optimize hot code paths. Early adopters see 2-4% performance gains in production systems. This matters because it allows the compiler to make data-driven optimizations specific to your application's behavior.
What security improvements were made to the crypto libraries?
The crypto packages received important security hardening in Go 1.20. crypto/rsa now uses constant-time implementations for RSA operations, preventing timing attacks.
Additionally, the crypto/tls and crypto/x509 packages dropped support for SHA-1 certificates and improved verification logic. These changes make Go's cryptographic primitives more resistant to side-channel attacks by default.
How does the new errors package improve error handling?
Go 1.20 enhances error handling with support for wrapping multiple errors. The new errors.Join function returns an error that wraps multiple other errors.
This is particularly useful when you need to aggregate errors from concurrent operations. The returned error implements Unwrap() []error allowing you to extract all wrapped errors. In practice, this simplifies error handling patterns in concurrent code where multiple operations might fail independently.
What platform support changes affect deployment targets?
Go 1.20 adds and removes several platform targets. The most notable addition is FreeBSD on RISC-V (freebsd/riscv64), expanding Go's support for emerging hardware architectures.
Conversely, Go dropped support for Windows 7, 8, Server 2008, and Server 2012. If you're deploying to older Windows systems, you'll need to stick with Go 1.19 or upgrade your operating systems. The runtime also improved memory management on ARM64 and PowerPC architectures.
FAQ
Does Go 1.20 break existing code?
Most existing code should work unchanged. The language changes are backward-compatible additions, though the Windows platform drop might affect some deployments.
How significant are the performance improvements?
Most users will see 1-3% performance gains from compiler optimizations. Applications using PGO can achieve 2-4% additional improvements based on their specific profiles.
What's the most impactful change for web servers?
The new HTTP ResponseController provides finer-grained control over response behaviors, allowing per-request overrides of standard library defaults.
Should I upgrade to Go 1.20 for better security?
Yes, the constant-time cryptographic operations in crypto/rsa alone justify upgrading security-sensitive applications.
How does the new coverage tool work?
Go 1.20 supports whole-program coverage analysis, collecting coverage data across multiple packages and tests for better code coverage insights.