1.16.15

Latest release in branch 1.16
Released 4 years ago (March 03, 2022)

Software Go
Branch 1.16
Status
End of life
End of life March 15, 2022
First official release version 1.16
First official release date 5 years ago (February 16, 2021)
Release notes https://go.dev/doc/go1.16
Source code https://github.com/golang/go/tree/go1.16.15
Documentation https://go.dev/doc/
Go 1.16 Releases View full list

What Is New in Go 1.16

Category Key Changes
Modules Module mode becomes default, lazy module loading, new go install behavior
Embedding New //go:embed directive for embedding files without external tools
Linker Improved performance with internal linker on macOS, reduced binary sizes
Standard Library New io/fs package, os package file system interfaces
Platform Support macOS ARM64 support (aka Apple Silicon), new net package on Linux
Deprecated ioutil package deprecated in favor of io or os equivalents

How does Go 1.16 change module behavior?

Go 1.16 makes module mode the default everywhere, even outside of GOPATH. The go command now operates in module-aware mode by default, with GO111MODULE=on behavior everywhere.

Lazy module loading significantly speeds up module operations by loading only essential module data. The go install command now installs executables in module-aware mode without affecting your main module's dependencies.

In practice, this means you no longer need to worry about setting GO111MODULE environment variables for most development workflows.

What's the new file embedding system in Go 1.16?

Go 1.16 introduces the //go:embed directive for embedding files and directories directly into your binaries without external build tools. This provides a first-party solution for including static assets.

You can embed single files, multiple files, or entire directory trees using pattern matching:

import "embed"

//go:embed static/*.css templates/*.html
var content embed.FS

The embedded files are accessible through the new embed.FS type, which implements the io/fs.FS interface. This matters because it eliminates the need for third-party embedding tools and works seamlessly with the standard library's file system interfaces.

How does Go 1.16 improve macOS development?

Go 1.16 adds full support for macOS ARM64 (Apple Silicon) architecture, allowing native compilation and execution on M1 Macs. This means your Go programs will run faster on Apple's new hardware without Rosetta translation.

The linker has been significantly improved for macOS - the internal linker now works on both AMD64 and ARM64 Darwin platforms, resulting in faster build times and smaller binaries. The external linker is no longer required for most macOS builds.

For developers using Apple's latest hardware, this translates to native performance and a smoother development experience without compatibility layers.

What file system changes should developers know about?

Go 1.16 introduces the new io/fs package, which defines fundamental file system interfaces used throughout the standard library. This package provides the FS, File, FileInfo, and other interfaces that form a consistent abstraction for file operations.

The os package now implements these interfaces, allowing your code to work with both real operating system files and virtual file systems like embed.FS. Many functions in os and other packages now accept fs.FS parameters.

This architectural change enables better testing with in-memory file systems and creates a unified interface for working with different file system implementations.

What's deprecated in Go 1.16 that affects existing code?

The ioutil package is now deprecated in favor of equivalent functionality in io and os packages. Common functions like ioutil.ReadFile should be replaced with os.ReadFile, and ioutil.WriteFile with os.WriteFile.

The go command will now report an error when building code that imports certain legacy secure/insecure packages that were removed in earlier versions. This helps identify compatibility issues early.

While existing code will still compile, you'll want to migrate from deprecated functions to avoid future breakage. The compiler warnings will guide you toward the modern equivalents.

FAQ

Does Go 1.16 break existing projects that aren't using modules?
Yes, module mode is now the default everywhere. If you have projects outside of GOPATH that weren't using modules, you'll need to either create a go.mod file or explicitly set GO111MODULE=off for those specific projects.

How do I migrate from ioutil functions to their replacements?
Most ioutil functions have direct equivalents: use os.ReadFile instead of ioutil.ReadFile, os.WriteFile instead of ioutil.WriteFile, and io.ReadAll instead of ioutil.ReadAll. The go fix tool can help automate some of these changes.

Can I use //go:embed with any file type?
Yes, the embed directive works with any file type - binaries, text files, images, etc. The main limitation is that the patterns must be relative to the source file containing the directive, and you cannot embed files above the module root.

Will my Go programs run faster on M1 Macs with 1.16?
Yes, programs compiled with Go 1.16 will run natively on Apple Silicon without Rosetta translation overhead, resulting in significantly better performance compared to running AMD64 binaries through emulation.

What's the benefit of the new io/fs package?
The io/fs package provides a standardized interface for file systems, making it easier to write code that works with different storage backends (real OS files, embedded files, memory filesystems) and improves testability by allowing mock file systems.

Releases In Branch 1.16

Version Release date
1.16.15 4 years ago
(March 03, 2022)
1.16.14 4 years ago
(February 09, 2022)
1.16.13 4 years ago
(January 06, 2022)
1.16.12 4 years ago
(December 09, 2021)
1.16.11 4 years ago
(December 02, 2021)
1.16.10 4 years ago
(November 04, 2021)
1.16.9 4 years ago
(October 07, 2021)
1.16.8 4 years ago
(September 09, 2021)
1.16.7 4 years ago
(August 04, 2021)
1.16.6 4 years ago
(July 12, 2021)
1.16.5 4 years ago
(June 03, 2021)
1.16.4 4 years ago
(May 06, 2021)
1.16.3 5 years ago
(April 01, 2021)
1.16.2 5 years ago
(March 11, 2021)
1.16.1 5 years ago
(March 10, 2021)
1.16 5 years ago
(February 16, 2021)
1.16rc1 5 years ago
(January 27, 2021)
1.16beta1 5 years ago
(December 17, 2020)