Go 1.21 Released! New min, max, clear Functions & PGO GA

Go language 1.21 is out! Let’s see what’s new in the release of the popular Google’s programming language.

First, Go changed the version number system starting in this release. Now, it has minor version number, so it will be Go 1.21.0, 1.21.1, 1.21.2 …

Go 1.21 introduced a few new built-in functions. They include min and max to compute the smallest and max value of a fixed number of given arguments. And, new function clear to delete/zero all elements from a map or a slice.

The Profile Guided Optimization (PGO) feature introduced in 1.20 is now generally available, results performance improvements from 2% to 7%. As well, Go compiler itself has been rebuilt with PGO enabled.

The release also tunes the garbage collector to reduce tail latency, and collects traces with runtime/trace now results smaller CPU usage on amd64/arm64.

Other changes in Go 1.21 include:

  • Experimental port for WebAssembly System Interface (WASI).
  • Support -buildmode=c-archive, -buildmode=c-shared and -buildmode=pie in Linux/loong64 port.
  • On Linux ppc64/ppc64le, GOPPC64=power10 now generates PC-relative instructions, prefixed instructions, and other new Power10 instructions.
  • Improve backwards compatibility and forwards compatibility in the Go toolchain.
  • New standard library additions:
    • log/slog package for structured logging
    • slices package for common operations on slices of any element type
    • maps package for common operations on maps of any key or element type
    • cmp package with new utilities for comparing ordered values.

Get Go 1.21

For source code, as well as binary packages for Windows, macOS, and Linux, go to Go website via link below:

For Debian, Ubuntu and Linux Mint users, I have a step by step guide shows how to install Go language and add it to your PATH.

Hi, I'm Merilyn Ne, a computer geek working on Ubuntu Linux for many years and would like to write useful tips for beginners. Forgive me for language mistakes. I'm not a native speaker of English.