DRAFT RELEASE NOTES - Introduction to Go 1.13

Go 1.13 is not yet released. These are work-in-progress release notes. Go 1.13 is expected to be released in August 2019.

As of Go 1.13, the go command by default downloads and authenticates modules using the Go module mirror and Go checksum database run by Google. See https://proxy.golang.org/privacy for privacy information about these services and the go command documentation for configuration details including how to disable the use of these servers or use different ones.

TODO

Changes to the language

Per the number literal proposal, Go 1.13 supports a more uniform and modernized set of number literal prefixes.

Per the signed shift counts proposal Go 1.13 removes the restriction that a shift count must be unsigned. This change eliminates the need for many artificial uint conversions, solely introduced to satisfy this (now removed) restriction of the << and >> operators.

These language changes were implemented by changes to the compiler, and corresponding internal changes to the library packages go/scanner and text/scanner (number literals), and go/types (signed shift counts).

If your code uses modules and your go.mod files specifies a language version, be sure it is set to at least 1.13 to get access to these language changes. You can do this by editing the go.mod file directly, or you can run go mod edit -go=1.13.

Ports

AIX

AIX on PPC64 (aix/ppc64) now supports cgo, external linking, and the c-archive and pie build modes.

Android

Go programs are now compatible with Android Q.

Darwin

As announced in the Go 1.12 release notes, Go 1.13 now requires macOS 10.11 El Capitan or later; support for previous versions has been discontinued.

FreeBSD

As announced in the Go 1.12 release notes, Go 1.13 now requires FreeBSD 11.2 or later; support for previous versions has been discontinued. FreeBSD 12.0 or later requires a kernel with the COMPAT_FREEBSD11 option set (this is the default).

Illumos

Go now supports Illumos with GOOS=illumos. The illumos build tag implies the solaris build tag.

NetBSD

Go now supports NetBSD on arm64.

OpenBSD

Go now supports OpenBSD on arm64.

Windows

The Windows version specified by internally-linked Windows binaries is now Windows 7 rather than NT 4.0. This was already the minimum required version for Go, but can affect the behavior of system calls that have a backwards-compatibility mode. These will now behave as documented. Externally-linked binaries (any program using cgo) have always specified a more recent Windows version.

Tools

Modules

go get in module mode now supports the version suffix @patch to request the latest patch release. TODO(bcmills): expand.

Version validation

When extracting a module from a version control system, the go command now performs additional validation on the requested version string.

The +incompatible version annotation bypasses the requirement of semantic import versioning for repositories that predate the introduction of modules. The go command now verifies that such a version does not include an explicit go.mod file.

The go command now verifies the mapping between pseudo-versions and version-control metadata. Specifically:

If the main module directly requires a version that fails the above validation, a corrected version can be obtained by redacting the version to just the commit hash and re-running a go command such as go list -m all or go mod tidy. For example,

require github.com/docker/docker v1.14.0-0.20190319215453-e7b5f7dbe98c
can be redacted to
require github.com/docker/docker e7b5f7dbe98c
which resolves to
require github.com/docker/docker v0.7.3-0.20190319215453-e7b5f7dbe98c

If the main module has a transitive requirement on a version that fails validation, the invalid version can still be replaced with a valid one through the use of a replace directive in the go.mod file of the main module. If the replacement is a commit hash, it will be resolved to the appropriate pseudo-version. For example,

replace github.com/docker/docker v1.14.0-0.20190319215453-e7b5f7dbe98c => github.com/docker/docker e7b5f7dbe98c
resolves to
replace github.com/docker/docker v1.14.0-0.20190319215453-e7b5f7dbe98c => github.com/docker/docker v0.7.3-0.20190319215453-e7b5f7dbe98c

Go command

The new go build flag -trimpath removes all file system paths from the compiled executable, to improve build reproducibility.

The go build flag -tags now takes a comma-separated list of build tags, to allow for multiple tags in GOFLAGS. The space-separated form is deprecated but still recognized and will be maintained.

go generate now sets the generate build tag so that files may be searched for directives but ignored during build.

Compiler toolchain

The compiler has a new implementation of escape analysis that is more precise. For most Go code should be an improvement (in other words, more Go variables and expressions allocated on the stack instead of heap). However, this increased precision may also break invalid code that happened to work before (for example, code that violates the unsafe.Pointer safety rules). If you notice any regressions that appear related, the old escape analysis pass can be re-enabled with go build -gcflags=all=-newescape=false. The option to use the old escape analysis will be removed in a future release.

The compiler no longer emits floating point or complex constants to go_asm.h files. These have always been emitted in a form that could not be used as numeric constant in assembly code.

Assembler

The assembler now supports many of the atomic instructions introduced in ARM v8.1.

gofmt

gofmt (and with that go fmt) now canonicalizes number literal prefixes and exponents to use lower-case letters, but leaves hexadecimal digits alone. This improves readability when using the new octal prefix (0O becomes 0o), and the rewrite is applied consistently. gofmt now also removes unnecessary leading zeroes from a decimal integer imaginary literal. (For backwards-compatibility, an integer imaginary literal starting with 0 is considered a decimal, not an octal number. Removing superfluous leading zeroes avoids potential confusion.) For instance, 0B1010, 0XabcDEF, 0O660, 1.2E3, and 01i become 0b1010, 0xabcDEF, 0o660, 1.2e3, and 1i after applying gofmt.

godoc and go doc

The godoc webserver is no longer included in the main binary distribution. To run the godoc webserver locally, manually install it first:

go get golang.org/x/tools/cmd/godoc
godoc

The go doc command now always includes the package clause in its output, except for commands. This replaces the previous behavior where a heuristic was used, causing the package clause to be omitted under certain conditions.

Runtime

Out of range panic messages now include the index that was out of bounds and the length (or capacity) of the slice. For example, s[3] on a slice of length 1 will panic with "runtime error: index out of range [3] with length 1".

This release improves performance of most uses of defer by 30%.

The runtime is now more aggressive at returning memory to the operating system to make it available to co-tenant applications. Previously, the runtime could retain memory for five or more minutes following a spike in the heap size. It will now begin returning it promptly after the heap shrinks. However, on many OSes, including Linux, the OS itself reclaims memory lazily, so process RSS will not decrease until the system is under memory pressure.

Core library

TODO generally

TLS 1.3

As announced in Go 1.12, Go 1.13 enables support for TLS 1.3 in the crypto/tls package by default. It can be disabled by adding the value tls13=0 to the GODEBUG environment variable. The opt-out will be removed in Go 1.14.

See the Go 1.12 release notes for important compatibility information.

crypto/ed25519

The new crypto/ed25519 package implements the Ed25519 signature scheme. This functionality was previously provided by the golang.org/x/crypto/ed25519 package, which becomes a wrapper for crypto/ed25519 when used with Go 1.13+.

Minor changes to the library

As always, there are various minor changes and updates to the library, made with the Go 1 promise of compatibility in mind.

TODO

bytes

The new ToValidUTF8 function returns a copy of a given byte slice with each run of invalid UTF-8 byte sequences replaced by a given slice.

context

The formatting of contexts returned by WithValue no longer depends on fmt and will not stringify in the same way. Code that depends on the exact previous stringification might be affected.

crypto/tls

Ed25519 certificates are now supported in TLS versions 1.2 and 1.3.

crypto/x509

Ed25519 keys are now supported in certificates and certificate requests according to RFC 8410, as well as by the ParsePKCS8PrivateKey, MarshalPKCS8PrivateKey, and ParsePKIXPublicKey functions.

The paths searched for system roots now include /etc/ssl/cert.pem to support the default location in Alpine Linux 3.7+.

database/sql

The new NullTime type represents a time.Time that may be null.

The new NullInt32 type represents an int32 that may be null.

debug/dwarf

The Data.Type method no longer panics if it encounters an unknown DWARF tag in the type graph. Instead, it represents that component of the type with an UnsupportedType object.

html/template

When using a <script> tag with "module" set as the type attribute, code will now be interperted as JavaScript module script.

go/scanner

The scanner has been updated to recognize the new Go number literals, specifically binary literals with 0b/0B prefix, octal literals with 0o/0O prefix, and floating-point numbers with hexadecimal mantissa. The imaginary suffix i may now be used with any number literal, and underscores may used as digit separators for grouping. See the Changes to the language for details.

go/types

The type-checker has been updated to follow the new rules for integer shifts. See the Changes to the language for details.

log

The new Writer function returns the output destination for the standard logger.

math/big

The new Rat.SetUint64 method sets the Rat to a uint64 value.

Rat.SetString now accepts non-decimal floating point representations.

math/bits

The execution time of Add, Sub, Mul, RotateLeft, and ReverseBytes is now guaranteed to be independent of the inputs.

net

On Unix systems where use-vc is set in resolve.conf, TCP is used for DNS resolution.

The new field ListenConfig.KeepAlive specifies the keep-alive period for network connections accepted by the listener.

net/http

The new field Transport.ForceAttemptHTTP2 controls whether HTTP/2 is enabled when a non-zero Dial, DialTLS, or DialContext func or TLSClientConfig is provided.

When reusing HTTP/2, the Transport no longer performs unnecessary TLS handshakes.

TimeoutHandler's ResponseWriter now implements the Pusher and Flusher interfaces.

The new Server fields BaseContext and ConnContext allow finer control over the Context values provided to requests and connections.

The new Header method Clone returns a copy of the receiver.

os

The new UserConfigDir function returns the default directory to use for user-specific configuration data.

If a File is opened using the O_APPEND flag, its WriteAt method will always return an error.

os/exec

On Windows, the environment for a Cmd always inherits the %SYSTEMROOT% value of the parent process unless the Cmd.Env field includes an explicit value for it.

reflect

The new Value.IsZero method reports whether a Value is the zero value for its type.

The MakeFunc function now allows assignment conversions on returned values, instead of requiring exact type match. This is particularly useful when the type being returned is an interface type, but the value actually returned is a concrete value implementing that type.

runtime

Tracebacks, runtime.Caller, and runtime.Callers now refer to the function that initializes the global variables of PKG as PKG.init instead of PKG.init.ializers

strings

The new ToValidUTF8 function returns a copy of a given string with each run of invalid UTF-8 byte sequences replaced by a given string.

sync

Large Pool no longer increase stop-the-world pause times.

Pool no longer needs to be completely repopulated after every GC. It now retains some objects across GCs, as opposed to releasing all objects, reducing load spikes for heavy users of Pool.

syscall

Uses of _getdirentries64 have been removed from Darwin builds, to allow binaries built with 1.12 to be uploaded to the macOS App Store.

The new ProcessAttributes and ThreadAttributes fields in SysProcAttr have been introduced for Windows, exposing security settings when creating new processes.

EINVAL is no longer returned in zero Chmod mode on Windows.

syscall/js

TypedArrayOf has been replaced by CopyBytesToGo and CopyBytesToJS for copying bytes between a byte slice and a Uint8Array.

testing

When running benchmarks, B.N is no longer rounded.

The new method B.ReportMetric lets users report custom benchmark metrics and override built-in metrics.

Testing flags are now registered in the new Init function. As a result, testing flags are now only registered when running a test binary.

text/scanner

The scanner has been updated to recognize the new Go number literals, specifically binary literals with 0b/0B prefix, octal literals with 0o/0O prefix, and floating-point numbers with hexadecimal mantissa. Also, the new AllowDigitSeparators mode allows number literals to contain underscores as digit separators (off by default for backwards-compatibility). See the Changes to the language for details.

text/template

The new slice function returns the result of slicing its first argument by the following arguments.

time

Day-of-year is now supported by Format and Parse.

The new Duration methods Microseconds and Milliseconds return the duration as an integer count of their respectively named units.