The Go programming language released version 1.20 a few days ago. See what’s the new features!
Go 1.20 allows conversions from a slice to an array. Given a slice x, user can write [4]byte(x)
instead of *(*[4]byte)(x)
.
The unsafe package now has three new functions SliceData
, String
, and StringData
with complete ability to construct and deconstruct slice and string values, without depending on their exact representation.
The specification now defines that struct values are compared one field at a time. Similarly, the specification now defines that array values are compared one element at a time.
And, comparable types (such as ordinary interfaces) may now satisfy comparable constraints, even if the type arguments are not strictly comparable.
Go 1.20 also adds experimental support for FreeBSD on RISC-V. Also, this is the last release that supports for Windows 7, Windows 8, Server 2008 and Server 2012, macOS 10.13 High Sierra and 10.14 Mojave.
Other changes in Go 1.20 include:
- The directory
$GOROOT/pkg
no longer stores pre-compiled package archives for the standard library. Instead, they are built as needed and cached in the build cache. - Allow
-C <dir>
to navigate directory before performing go sub-command. - Remove
-i
flag support ingo build
andgo test
commands go version -m
command supports reading more types of Go binaries- Add
-skip <pattern>
ingo generate
andgo test
command. - Support
-pgo
flag andcover
flag ingo build
,go install
, and other build-related commands. - Disable cgo by default on systems without a C toolchain
- Support collecting code coverage profiles for programs by building with go build’s
-cover
flag - The vet tool reports ISO 8601 date (yyyy-dd-mm) time format with
Time.Format
andtime.Parse
- Reorganize garbage collector’s internal data structures to improve overall CPU performance by up to 2%.
- New runtime/coverage package containing APIs
- Preview support for profile-guided optimization (PGO)
- Select the dynamic interpreter for glibc or musl at link time on Linux.
- Go linker supports modern LLVM-based C toolchains in Windows.
- New
crypto/ecdh
package to provide explicit support - New function
errors.Join
returns an error wrapping a list of errors. - New
"net/http".ResponseController
ResponseController type - The httputil.ReverseProxy forwarding proxy includes a new Rewrite hook function.
- Many other minor library changes.
For more about the Go 1.20 release, see the official release note.
Get Go 1.20
Go website offers the binary packages for macOS, Linux, and Windows. Along with the source tarball, they are available to download at the link below:
For Ubuntu and Debian based systems, I’ve a step by step tutorial shows how to install Go language and setup the environment, see HERE for details.