DRAFT RELEASE NOTES - Introduction to Go 1.9

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

The latest Go release, version 1.9, arrives six months after Go 1.8 and is the tenth release in the Go 1.x series. There is one change to the language, adding support for type aliases. Most of the changes are in the implementation of the toolchain, runtime, and libraries. As always, the release maintains the Go 1 promise of compatibility. We expect almost all Go programs to continue to compile and run as before.

The release adds transparent monotonic time support, parallelizes compilation of functions within a package, better supports test helper functions, and includes a new bit manipulation package.

Changes to the language

There is one change to the language. Go now supports type aliases to support gradual code repair while moving a type between packages. The type alias design document and an article on refactoring cover the problem in detail. In short, a type alias declaration has the form:

type T1 = T2

This declaration introduces an alias name T1—an alternate spelling—for the type denoted by T2; that is, both T1 and T2 denote the same type.

Ports

There are no new supported operating systems or processor architectures in this release.

ppc64x requires Power8

Both GOARCH=ppc64 and GOARCH=ppc64le now require at least Power8 support. In previous releases, only GOARCH=ppc64le required Power8 and the big endian ppc64 architecture supported older hardware.

Known Issues

There are some instabilities on FreeBSD that are known but not understood. These can lead to program crashes in rare cases. See issue 15658. Any help in solving this FreeBSD-specific issue would be appreciated.

Tools

Parallel Compilation

The Go compiler now supports compiling a package's functions in parallel, taking advantage of multiple cores. This is in addition to the go command's existing support for parallel compilation of separate packages. Parallel compilation is on by default, but can be disabled by setting the environment variable GO19CONCURRENTCOMPILATION to 0.

Compiler Toolchain

Complex division is now C99-compatible. This has always been the case in gccgo and is now fixed in the gc toolchain.

The linker will now generate DWARF information for cgo executables on Windows.

Go test

The go test command accepts a new -list flag, which takes a regular expression as an argument and prints to stdout the name of any tests, benchmarks, or examples that match it, without running them.

Performance

As always, the changes are so general and varied that precise statements about performance are difficult to make. Most programs should run a bit faster, due to speedups in the garbage collector, better generated code, and optimizations in the core library.

TODO: There have been significant optimizations bringing more than 10% improvements to implementations in the foo, bar, and quux packages.

Garbage Collector

Library functions that used to trigger stop-the-world garbage collection now trigger concurrent garbage collection. Specifically, runtime.GC, debug.SetGCPercent, and debug.FreeOSMemory, now trigger concurrent garbage collection, blocking only the calling goroutine until the garbage collection is done.

The debug.SetGCPercent function only triggers a garbage collection if one is immediately necessary because of the new GOGC value. This makes it possible to adjust GOGC on-the-fly.

Large object allocation performance is significantly improved in applications using large (>50GB) heaps containing many large objects.

The runtime.ReadMemStats function now takes less than 100µs even for very large heaps.

Core library

Transparent Monotonic Time support

The time package now transparently tracks monotonic time in each Time value, making computing durations between two Time values a safe operation in the presence of wall clock adjustments. See the package docs and design document for details.

New bit manipulation package

Go 1.9 includes a new package, math/bits, with optimized implementations for manipulating bits. On most architectures functions in this package are additionally recognized by the compiler and treated as intrinsics for additional performance.

Test Helper Functions

The new (*T).Helper an (*B).Helper methods mark the calling function as a test helper function. When printing file and line information, that function will be skipped. This permits writing test helper functions while still having useful line numbers for users.

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

TODO: https://golang.org/cl/39570: set utf-8 flag

crypto

TODO: https://golang.org/cl/36876: add BLAKE2b and BLAKE2s hash constants

crypto/aes

TODO: https://golang.org/cl/38366: ARM assembly versions of encrypt, decrypt and expandKey

crypto/rand

TODO: https://golang.org/cl/43852: use blocking getrandom call on Linux when supported

crypto/x509

TODO: https://golang.org/cl/36093: load certs from env vars + extra locations

TODO: https://golang.org/cl/36900: support excluded domains in name constraints.

database/sql

TODO: https://golang.org/cl/35476: proper prepared statement support in transactions

TODO: https://golang.org/cl/39031: support scanning into user defined string types

TODO: https://golang.org/cl/40694: allow using a single connection from the database

debug/dwarf

TODO: https://golang.org/cl/44017: heuristically handle both UNIX and Windows paths

encoding/asn1

TODO: https://golang.org/cl/38660: add NullBytes and NullRawValue for working with ASN.1 NULL

encoding/base32

TODO: https://golang.org/cl/38634: add Encoding.WithPadding, StdPadding, NoPadding

encoding/gob

TODO: https://golang.org/cl/39203: speedup decoding of maps by zeroing values

fmt

TODO: https://golang.org/cl/37051: support sharp flag for float and complex value printing

go/build

TODO: https://golang.org/cl/44291: make -I/-L options in cgo flags absolute

hash/fnv

TODO: https://golang.org/cl/38356: add 128-bit FNV hash support

html/template

TODO: https://golang.org/cl/37880: panic if predefined escapers are found in pipelines during rewriting

TODO: https://golang.org/cl/40936: allow safe usage of predefined escapers in pipelines

image

The Rectangle.Intersect method now returns a zero Rectangle when called on adjacent but non-overlapping rectangles, as documented. In earlier releases it would incorrectly return an empty but non-zero Rectangle.

image/color

The YCbCr to RGBA conversion formula has been tweaked to ensure that rounding adjustments span the complete [0, 0xffff] RGBA range.

image/png

The new Encoder.BufferPool field allows specifying an EncoderBufferPool, that will be used by the encoder to get temporary EncoderBuffer buffers when encoding a PNG image. The use of a BufferPool reduces the number of memory allocations performed while encoding multiple images.

The package now supports the decoding of transparent 8-bit grayscale ("Gray8") images.

math/big

TODO: https://golang.org/cl/36487: add IsInt64/IsUint64 predicates

mime/multipart

TODO: https://golang.org/cl/39223: add Size to FileHeader

net

TODO: https://golang.org/cl/32572: add Resolver.StrictErrors

TODO: https://golang.org/cl/37260: allow Resolver to use a custom dialer

TODO: https://golang.org/cl/37402: implement deadline functionality on Pipe

TODO: https://golang.org/cl/40510: don't enclose non-literal IPv6 addresses in square brackets

TODO: https://golang.org/cl/40512: validate network in Dial{,IP} and Listen{Packet,IP} for IP networks

net/http

TODO: https://golang.org/cl/35488: add support for socks5 proxy

TODO: https://golang.org/cl/38194: strip port from host in mux Handler

TODO: https://golang.org/cl/43231: for http2, use the priority write scheduler by default

net/http/fcgi

TODO: https://golang.org/cl/40012: expose cgi env vars in request context

net/http/httptest

TODO: https://golang.org/cl/34639: add Client and Certificate to Server

net/rpc

TODO: https://golang.org/cl/38474: Create empty maps and slices as return type

os

TODO: https://golang.org/cl/37915: parse command line without shell32.dll

TODO: https://golang.org/cl/41830: do not report ModeDir for symlinks on windows

os/exec

TODO: https://golang.org/cl/37586: remove duplicate environment variables in Cmd.Start

os/user

TODO: https://golang.org/cl/33713: add Go implementation of LookupGroup, LookupGroupId

TODO: https://golang.org/cl/37664: add non-cgo versions of Lookup, LookupId

reflect

TODO: https://golang.org/cl/38335: Add MakeMapWithSize for creating maps with size hint

runtime

Tracebacks generated by the runtime and recorded in profiles are now accurate in the presence of inlining. To retrieve tracebacks programmatically, applications should use runtime.CallersFrames rather than directly iterating over the results of runtime.Callers.

On Windows, Go no longer forces the system timer to run at high resolution when the program is idle. This should reduce the impact of Go programs on battery life.

On FreeBSD, GOMAXPROCS and runtime.NumCPU are now based on the process' CPU mask, rather than the total number of CPUs.

The runtime has preliminary support for Android O.

runtime/pprof

TODO: https://golang.org/cl/34198: add definitions of profile label types

runtime/trace

The execution trace now displays mark assist events, which indicate when an application goroutine is forced to assist garbage collection because it is allocating too quickly.

"Sweep" events now encompass the entire process of finding free space for an allocation, rather than recording each individual span that is swept. This reduces allocation latency when tracing allocation-heavy programs. The sweep event shows how many bytes were swept and how many were reclaimed.

sync

TODO: https://golang.org/cl/34310: make Mutex more fair

TODO: https://golang.org/cl/36617: import Map from x/sync/syncmap

syscall

TODO: https://golang.org/cl/36697: only call setgroups if we need to

TODO: https://golang.org/cl/37439: use CLONE_VFORK and CLONE_VM

TODO: https://golang.org/cl/37913: add Conn and RawConn interfaces

testing/quick

The package now chooses values in the full range when generating int64 and uint64 random numbers; in earlier releases generated values were always limited to the [-262, 262) range.

text/template

TODO: https://golang.org/cl/38420: fix handling of empty blocks

time

TODO: https://golang.org/cl/36615: add Duration.Truncate and Duration.Round

Retrieving the time and sleeping now work correctly under Wine.