Go 1.21 Adds New Built-Ins
Written by Kay Ewbank   
Tuesday, 15 August 2023

Go 1.21 has been released with improvements including support for built-ins and production-ready support for Profile Guided Optimizations (PGO).

Since its initial development by Google, Go has matured as an open source project maintained by a team at Google alongside many contributors from the open source community. Go was designed as a systems programming language, and has also been used in high profile commercial successes such as Docker.

goicon2

The full support for PGO follows on from the preview support introduced in the previous release. PGO is also known as feedback-directed optimization (FDO), and it improves performance by feeding information back from representative runs of the compiler. The compiler uses the feedback to make more informed optimization decisions for the next run of the compiler.

The Go team says that most programs from a representative set of Go programs are seeing between 2% and 7% improvement from enabling PGO. 

In language terms, Go 1.21 adds three new built-ins to the language. There are new min and max functions that do what you'd expect, and a new clear function that deletes all elements from a map or zeroes all elements of a slice.

There are also a number of improvements that increase the power and precision of type inference. You can now call a function with arguments that are themselves (possibly partially instantiated) generic functions, and as in earlier versions, the compiler will attempt to infer the missing type arguments. What's new is that it for each argument that is a generic function that is not fully instantiated, the compiler will also attempt to infer its missing type arguments.

Type inference now also considers methods when a value is assigned to an interface, and it is now precise when matching corresponding types in assignments.

Go 1.21 also includes a preview of a language change the developers are considering for a future version of Go, making for loop variables per-iteration instead of per-loop, to avoid accidental sharing bugs.

Go 1.21  is available for download now.

goicon2

More Information

Go Download Page

GoLang Org Webpage

Related Articles

Why Is Go Good?

Go Survey 2021

Go 1.18 Released With Generics And Fuzzing

Insights Into Where Go Is Going

A Programmer's Guide To Go

A Programmer's Guide To Go Part 2 - Objects And Interfaces

A Programmer's Guide To Go Part 3 - Goroutines And Concurrency

To be informed about new articles on I Programmer, sign up for our weekly newsletter, subscribe to the RSS feed and follow us on Twitter, Facebook or Linkedin.

Banner


Apache Shiro 2.0 Released
21/03/2024

Apache Shiro 2.0 has been released. The Java security framework now requires at least Java 11, and has added support for Jakarta EE 10.



Grafana 11 Improves Metrics
11/04/2024

Grafana Labs, creators of the Grafana open-source metrics analytics and visualization suite, has announced the preview release of Grafana 11 with improvements to make it easier to view metrics, and ch [ ... ]


More News

raspberry pi books

 

Comments




or email your comment to: comments@i-programmer.info

Last Updated ( Tuesday, 15 August 2023 )