Go 1.23 programming language extends iterators and introduces telemetry

Version 1.23 adds three new packages to the Go standard library. Toolchain can now pass on telemetry data. Generic type aliases have also been added.

listen Print view
A laptop with code, behind it a "gopher" (pocket rat) for the mascot of the language

(Image: Erstellt mit Dall-E durch iX)

3 min. read
Contents

Go 1.23 has been released every six months. The release mainly includes extensions to the standard library and the toolchain.

Among the linguistic innovations, the extended iterators are worth mentioning. In Go 1.22, the team had already started the range-over-func experiment as an approach to using user-defined iterators for function values.

Videos by heise

In the current release, Go's standard library introduces the iter package, which provides basic definitions for user-defined iterators. At the same time, the Go team has extended the slices and maps packages so that they work together with the iterators.

Among other things, Keys returns an iterator for all keys of a map. For slices, Backward returns an iterator that runs through the slice backwards. Further additions can be found in the section on iterators in the release notes.

In addition to the iter, the standard library in Go 1.23 has two other new packages on board: structs makes it possible to change the properties of struct types for the memory layout, among other things. The [code]unique[/code] package is used to canonicalize comparable values in order to bring them into a normal form. This allows programs to deduplicate values efficiently.

Go Telemetry is a new system that collects telemetry data from the toolchain. It is designed as an opt-in system: By default, the tools in the Go toolchain only collect statistics that can be analyzed locally. Anyone using go telemetry on transmits a subset of the information to telemetry.go.dev about once a week. Charts on some user data can be found on the site.

Shortly after the official start of telemetry, the public data, such as here for the Go-Language-Server gopls ("Go Please"), is manageable.

(Image: Screenshot (Rainald Menge-Sonnentag))

Telemetry can also be completely deactivated with the off parameter so that Go does not store any usage data locally. Details on telemetry and information on data protection can be found in the Go documentation.

The go command also receives a few extensions in the current version. Among other things, the vet subcommand for checking packages with the stdversion analyzer can test whether individual symbols are newer than the Go version specified in the configuration file go.mod.

There is also an addition for go mod tidy, which ensures that the go.mod file meets the requirements for the packages and dependencies: With the additional flag -diff, the command does not change the configuration file, but only shows the required changes.

Also worth mentioning in the current release are the generic typaliases marked as preview as an extension of the generics introduced in version 1.18.

Further new features in Go 1.23, such as adjustments to the time package , can be found on the Go blog. The complete list of new features can be found in the release notes. The binaries for Linux, Windows and macOS as well as the source code are available on the download page.

(rme)

Don't miss any news – follow us on Facebook, LinkedIn or Mastodon.

This article was originally published in German. It was translated with technical assistance and editorially reviewed before publication.