DRAFT RELEASE NOTES — Introduction to Go 1.17

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

Changes to the language

TODO: https://golang.org/cl/216424: allow conversion from slice to array ptr

TODO: https://golang.org/cl/312212: add unsafe.Add and unsafe.Slice

Ports

Darwin

As announced in the Go 1.16 release notes, Go 1.17 requires macOS 10.13 High Sierra or later; support for previous versions has been discontinued.

Windows

Go 1.17 adds support of 64-bit ARM architecture on Windows (the windows/arm64 port). This port supports cgo.

OpenBSD

The 64-bit MIPS architecture on OpenBSD (the openbsd/mips64 port) now supports cgo.

In Go 1.16, on the 64-bit x86 and 64-bit ARM architectures on OpenBSD (the openbsd/amd64 and openbsd/arm64 ports) system calls are made through libc, instead of directly using the machine instructions. In Go 1.17, this is also done on the 32-bit x86 and 32-bit ARM architectures on OpenBSD (the openbsd/386 and openbsd/arm ports). This ensures forward-compatibility with future versions of OpenBSD.

TODO: complete the Ports section

Tools

TODO: complete the Tools section

Go command

Lazy module loading

If a module specifies go 1.17 or higher in its go.mod file, its transitive requirements are now loaded lazily, avoiding the need to download or read go.mod files for otherwise-irrelevant dependencies. To support lazy loading, in Go 1.17 modules the go command maintains explicit requirements in the go.mod file for every dependency that provides any package transitively imported by any package or test within the module. See the design document for more detail.

To facilitate the upgrade to lazy loading, the go mod tidy subcommand now supports a -go flag to set or change the go version in the go.mod file. To enable lazy loading for an existing module without changing the selected versions of its dependencies, run:

  go mod tidy -go=1.17

TODO: Describe the -compat flag for go mod tidy.

Module deprecation comments

Module authors may deprecate a module by adding a // Deprecated: comment to go.mod, then tagging a new version. go get now prints a warning if a module needed to build packages named on the command line is deprecated. go list -m -u prints deprecations for all dependencies (use -f or -json to show the full message). The go command considers different major versions to be distinct modules, so this mechanism may be used, for example, to provide users with migration instructions for a new major version.

go get

The go get -insecure flag is deprecated and has been removed. To permit the use of insecure schemes when fetching dependencies, please use the GOINSECURE environment variable. The -insecure flag also bypassed module sum validation, use GOPRIVATE or GONOSUMDB if you need that functionality. See go help environment for details.

go.mod files missing go directives

If the main module's go.mod file does not contain a go directive and the go command cannot update the go.mod file, the go command now assumes go 1.11 instead of the current release. (go mod init has added go directives automatically since Go 1.12.)

If a module dependency lacks an explicit go.mod file, or its go.mod file does not contain a go directive, the go command now assumes go 1.16 for that dependency instead of the current release. (Dependencies developed in GOPATH mode may lack a go.mod file, and the vendor/modules.txt has to date never recorded the go versions indicated by dependencies' go.mod files.)

vendor contents

If the main module specifies go 1.17 or higher, go mod vendor now annotates vendor/modules.txt with the go version indicated by each vendored module in its own go.mod file. The annotated version is used when building the module's packages from vendored source code.

If the main module specifies go 1.17 or higher, go mod vendor now omits go.mod and go.sum files for vendored dependencies, which can otherwise interfere with the ability of the go command to identify the correct module root when invoked within the vendor tree.

Password prompts

The go command by default now suppresses SSH password prompts and Git Credential Manager prompts when fetching Git repositories using SSH, as it already did previously for other Git password prompts. Users authenticating to private Git repos with password-protected SSH may configure an ssh-agent to enable the go command to use password-protected SSH keys.

go mod download

When go mod download is invoked without arguments, it will no longer save sums for downloaded module content to go.sum. It may still make changes to go.mod and go.sum needed to load the build list. This is the same as the behavior in Go 1.15. To save sums for all modules, use go mod download all.

TODO: https://golang.org/cl/249759: cmd/cover: replace code using optimized golang.org/x/tools/cover

Vet

TODO: https://golang.org/cl/299532: cmd/vet: bring in sigchanyzer to report unbuffered channels to signal.Notify

TODO: complete the Vet section

Runtime

TODO: https://golang.org/cl/304470: cmd/compile, runtime: add metadata for argument printing in traceback

TODO: complete the Runtime section

Compiler

Functions containing closures can now be inlined. One effect of this change is that a function with a closure may actually produce a distinct closure function for each place that the function is inlined. Hence, this change could reveal bugs where Go functions are compared (incorrectly) by pointer value. Go functions are by definition not comparable. TODO: complete the Compiler section, or delete if not needed

Linker

TODO: complete the Linker section, or delete if not needed

Core library

TODO: complete the Core library section

crypto/tls

(*Conn).HandshakeContext was added to allow the user to control cancellation of an in-progress TLS Handshake. The context provided is propagated into the ClientHelloInfo and CertificateRequestInfo structs and accessible through the new (*ClientHelloInfo).Context and (*CertificateRequestInfo).Context methods respectively. Canceling the context after the handshake has finished has no effect.

When Config.NextProtos is set, servers now enforce that there is an overlap between the configured protocols and the protocols advertised by the client, if any. If there is no overlap the connection is closed with the no_application_protocol alert, as required by RFC 7301.

Cgo

The runtime/cgo package now provides a new facility that allows to turn any Go values to a safe representation that can be used to pass values between C and Go safely. See runtime/cgo.Handle for more information.

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.

archive/zip

The new methods File.OpenRaw, Writer.CreateRaw, Writer.Copy provide support for cases where performance is a primary concern.

bufio

The Writer.WriteRune method now writes the replacement character U+FFFD for negative rune values, as it does for other invalid runes.

bytes

The Buffer.WriteRune method now writes the replacement character U+FFFD for negative rune values, as it does for other invalid runes.

compress/lzw

The new Reader.Reset and Writer.Reset methods allow reuse of a Reader or Writer.

crypto/rsa

TODO: https://golang.org/cl/302230: fix salt length calculation with PSSSaltLengthAuto

database/sql

The DB.Close method now closes the connector field if the type in this field implements the io.Closer interface.

The new NullInt16 and NullByte structs represent the int16 and byte values that may be null. These can be used as destinations of the Scan method, similar to NullString.

encoding/binary

binary.Uvarint will stop reading after 10 bytes to avoid wasted computations. If more than 10 bytes are needed, the byte count returned is -11.
Previous Go versions could return larger negative counts when reading incorrectly encoded varints.

flag

TODO: https://golang.org/cl/271788: panic if flag name begins with - or contains =

io/fs

The new FileInfoToDirEntry function converts a FileInfo to a DirEntry.

math

The math package now defines three more constants: MaxUint, MaxInt and MinInt. For 32-bit systems their values are 2^32 - 1, 2^31 - 1 and -2^31, respectively. For 64-bit systems their values are 2^64 - 1, 2^63 - 1 and -2^63, respectively.

mime

TODO: https://golang.org/cl/305230: support reading shared mime-info database on unix systems

net

TODO: https://golang.org/cl/272668: add IP.IsPrivate

TODO: https://golang.org/cl/301709: make go resolver aware of network parameter

TODO: https://golang.org/cl/307030: make ErrClosed and ParseError implement net.Error

net/http

The net/http package now uses the new (*tls.Conn).HandshakeContext with the Request context when performing TLS handshakes in the client or server.

TODO: https://golang.org/cl/235437: add to deadlines only when positive

The ReadRequest function now returns an error when the request has multiple Host headers.

net/http/httptest

TODO: https://golang.org/cl/308950: panic on non-3 digit (XXX) status code in Recorder.WriteHeader

net/url

TODO: https://golang.org/cl/314850: add Values.Has

os

The File.WriteString method has been optimized to no longer make a copy of the input string.

reflect

The new StructField.IsExported and Method.IsExported methods report whether a struct field or type method is exported. They provide a more readable alternative to checking whether PkgPath is empty.

TODO: https://golang.org/cl/281233: add VisibleFields function

TODO: https://golang.org/cl/284136: panic if ArrayOf is called with negative length

strconv

TODO: https://golang.org/cl/170079: implement Ryū-like algorithm for fixed precision ftoa

TODO: https://golang.org/cl/170080: Implement Ryū algorithm for ftoa shortest mode

The new QuotedPrefix function returns the quoted string (as understood by Unquote) at the start of input.

strings

The Builder.WriteRune method now writes the replacement character U+FFFD for negative rune values, as it does for other invalid runes.

sync/atomic

atomic.Value now has Swap and CompareAndSwap methods that provide additional atomic operations.

syscall

TODO: https://golang.org/cl/295371: do not overflow key memory in GetQueuedCompletionStatus

TODO: https://golang.org/cl/313653: restore signal mask after setting foreground process group

testing

TODO: https://golang.org/cl/310033: add -shuffle=off|on|N to alter the execution order of tests and benchmarks

text/template/parse

TODO: https://golang.org/cl/301493: add a mode to skip func-check on parsing

time

The Time type now has a GoString method that will return a more useful value for times when printed with the %#v format specifier in the fmt package.

TODO: https://golang.org/cl/264077: add Time.IsDST() to check if its Location is in Daylight Savings Time

TODO: https://golang.org/cl/293349: add Time.Unix{Milli,Micro} and to-Time helpers UnixMicro, UnixMilli

TODO: https://golang.org/cl/300996: support "," as separator for fractional seconds

unicode

The Is, IsGraphic, IsLetter, IsLower, IsMark, IsNumber, IsPrint, IsPunct, IsSpace, IsSymbol, and IsUpper functions now return false on negative rune values, as they do for other invalid runes.