Go 1.16, a planned upgrade to the , has been published as a beta release, with core library and runtime improvements anchoring a host of new capabilities. There are no changes to the language itself.
Changes to the core library in Go 1.16 include the new
embed package, which offers access to files embedded in the program during compilation, via the
//go:embed directive. Minor changes and updates have been made to the library as well. Changes range from the deprecation of
crypto/dsa to upgrading the
unicode package to Unicode 13.0.0.
The core library also gains file systems enhancements. A new
io/fs package defines an abstraction for read-only trees of files, the
fs.FS interface, and standard library packages have been adapted to make use of the interface when appropriate. On the producer side of the interface, the new
embed.FS type implements
fs.FS as does
zip.Reader. A new
os.DirFS function provides an implementation of
fs.FS backed by a tree of operating system files. On the consumer side, a new
http.FS function converts an
fs.FS to an
http.Handler. And the
ParseFS functions and methods read templates from
fs.FS. To test code implementing
fs.FS, a new
testing/fstest package provides a
TestFS function to report common mistakes. It also provides a simple in-memory file system implementation,
MapFS, for testing code that accepts
Go 1.16 also brings improvements to the runtime. A new
runtime/metrics package introduces a stable interface for reading implementation-defined metrics. On Linux, the Go runtime now defaults to releasing memory to the operating system promptly, rather than lazily when the OS is under memory pressure. Go 1.16 also fixes a discrepancy between the race detector and the Go memory model. The detector now more precisely follows the channel synchronization rules of the memory model. Thus the detector now may report races that previously had been missed.
The release of the first beta was announced on December 17. Go 1.16 is due as a production release in February 2021. The current line arrived in August. Binary and source distribution files for Go 1.16 can be downloaded from .
Other changes cited in the include:
, is supported, with
ios/amd64 port has been added, targeting the iOS simulator running on AMD64-based MacOS.
forloops, method values, and type switches. The inliner also can detect more inlining calls when inlining is a possibility.
gocommand now supports inclusion of static files and file trees as part of the final executable, via the new
GOVCSenvironment variable limits which version control tools the
gocommand may use to download source code. This mitigates security issues with tools typically used in trusted, authenticated environments.
Copyright © 2020 IDG Communications, Inc.