Go 1.19, an update of the Google-developed programming language due in August, introduces a revised memory model and new types that make it easier to use atomic values.Now in a preview stage, Go 1.19 can be downloaded from go.dev. The release is still considered unstable at this point.With Go 1.19, the language’s memory model has been revised to align Go with the memory model used by C, C++, Java, JavaScript, and Swift, according to release notes. Go 1.19 also features new types in the sync/atomic package that make it easier to use atomic values such as atomic.int64 and atomic.Pointer(T).The Go memory model specifies conditions under which reads of a variable in one goroutine can be guaranteed to observe values produced by writes to the same variable in a different goroutine. Go only provides sequentially consistent atomics, not any of more relaxed forms offered in other languages.Go 1.19 also introduces a “small” change to the language, consisting of a correction to the scope of type parameters in method declarations. Existing programs are unaffected. Go 1.19 follows the momentous release in March of Go 1.18, which featured long-sought generics capabilities. Other new features and improvements in Go 1.19:
The runtime now includes support for a soft memory limit. The limit includes the Go heap and other memory managed by the runtime and excludes external memory sources such as mappings of the binary, memory managed in other languages, and memory held by the OS on behalf of the Go program. Also, the runtime now schedules fewer GC worker routines on idle OS threads when the application is idle enough to force a periodic GC cycle.
The compiler now uses a jump table to implement large integer and string switch statements. Performance improvements for the switch statement vary but can be on the order of 20% faster.
The release supports links, lists, and clearer headings in doc comments.
The build constraint, unix, is now recognized in //go:build lines.
Support is added for the Loongson 64-bit architecture LoongArch on Linux.
Copyright © 2022 IDG Communications, Inc.
Source link