NOTE: This is a DRAFT of the Go 1.7 release notes, prepared for the Go 1.7 beta. Go 1.7 has NOT yet been released. By our regular schedule, it is expected some time in August 2016.
The latest Go release, version 1.7, arrives six months after 1.6. Most of its changes are in the implementation of the toolchain, runtime, and libraries. There is one minor change to the language specification. 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 releaseadds a port to IBM LinuxOne;updates the x86-64 compiler back endto generate more efficient code; includes the, promoted from thex/net subrepository and now used in the standard library; andadds support in the testing packagefor creating hierarchies of tests and benchmarks. The release alsofinalizes the vendoring supportstarted in Go 1.5, making it a standard feature.
There is one tiny language change in this release. The section on terminating statements
clarifies that to determine whether a statement list ends in a terminating statement, the “final non-empty statement” is considered the end, matching the existing behavior of the gc and gccgo compiler toolchains. In earlier releases the definition referred only to the “final statement,” leaving the effect of trailing empty statements at the least unclear. The
package has been updated to match the gc and gccgo compiler toolchains in this respect. This change has no effect on the correctness of existing programs.
Go 1.7 adds an experimental port to Linux on z Systems
) and the beginning of a port to Plan 9 on ARM (
The experimental ports to Linux on 64-bit MIPS (
) added in Go 1.6 now have full support for cgo and external linking.
The experimental port to Linux on big-endian 64-bit PowerPC (
) now requires the POWER8 architecture or later.
The OpenBSD port now requires OpenBSD 5.6 or later, for access to the getentropy (2) system call.
For 64-bit ARM systems, the vector register names have been corrected to
; previous releases incorrectly referred to them as
For 64-bit x86 systems, the following instructions have been added:
This release includes a new code generation back end for 64-bit x86 systems, following aproposal from 2015 that has been under development since then. The new back end, based on SSA , generates more compact, more efficient code and provides a better platform for optimizations such as bounds check elimination. The new back end reduces the CPU time required by our benchmark programs by 5-35%.
For this release, the new back end can be disabled by passing
to the compiler. If you find that your program compiles or runs successfully only with the new back end disabled, pleasefile a bug report.
The format of exported metadata written by the compiler in package archives has changed: the old textual format has been replaced by a more compact binary format. This results in somewhat smaller package archives and fixes a few long-standing corner case bugs.
For this release, the new export format can be disabled by passing
to the compiler. If you find that your program compiles or runs successfully only with the new export format disabled, pleasefile a bug report.
option no longer supports the unusual two-argument form
, asannounced in the Go 1.6 release and in warnings printed by the linker. Use
The compiler and linker have been optimized and run significantly faster in this release than in Go 1.6, although they are still slower than we would like and will continue to be optimized in future releases.
Due to changes across the compiler toolchain and standard library, binaries built with this release should typically be smaller than binaries built with Go 1.6, sometimes by as much as 20-30%.
On x86-64 systems, Go programs now maintain stack frame pointers as expected by profiling tools like Linux's perf and Intel's VTune, making it easier to analyze and optimize Go programs using these tools. The frame pointer maintenance has a small run-time overhead that varies but averages around 2%. We hope to reduce this cost in future releases. To build a toolchain that does not use frame pointers, set
Packages usingcgo may now include Fortran source files (in addition to C, C++, Objective C, and SWIG), although the Go bindings must still use C language APIs.
Go bindings may now use a new helper function
. In contrast to
, which takes a Go
and returns a
takes a Go
and returns an
Packages and binaries built using
have in past releases produced different output on each build, due to the embedding of temporary directory names. When using this release with new enough versions of GCC or Clang (those that support the
option), those builds should finally be deterministic.
Due to the alignment of Go's semiannual release schedule with GCC's annual release schedule, GCC release 6 contains the Go 1.6.1 version of gccgo. The next release, GCC 7, will likely have the Go 1.8 version of gccgo.
command's basic operation is unchanged, but there are a number of changes worth noting.
This release removes support for the
environment variable, asannounced in the Go 1.6 release.Vendoring support is now a standard feature of the
command and toolchain.
data structure made available to “
” now includes a
field explaining why a particular package is or is not considered stale (in need of rebuilding). This field is available to the
options and is useful for understanding why a target is being rebuilt.
” command now supports import paths referring to
This release adds experimental, minimal support for building programs usingbinary-only packages, packages distributed in binary form without the corresponding source code. This feature is needed in some commercial settings but is not intended to be fully integrated into the rest of the toolchain. For example, tools that assume access to complete source code will not work with such packages, and there are no plans to support such packages in the “
” command now groups constructors with the type they construct, following
” command has more accurate analysis in its
checks, and a new
check that checks the name and signature of likely test functions. To avoid confusion with the new
check, the old, unadvertised
option has been removed; it was equivalent to
The new subcommand “
” prints all supported operating system/architecture pairs.
” command,introduced in Go 1.5, has been refined in various ways.
First, collecting traces is significantly more efficient than in past releases. In this release, the typical execution-time overhead of collecting a trace is about 25%; in past releases it was at least 400%. Second, trace files now include file and line number information, making them more self-contained and making the original executable optional when running the trace tool. Third, the trace tool now breaks up large traces to avoid limits in the browser-based viewer.
Although the trace file format has changed in this release, the Go 1.7 tools can still read traces from earlier releases.
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 and optimizations in the core library. On x86-64 systems, many programs will run significantly faster, due to improvements in generated code brought by the new compiler back end. As noted above, in our own benchmarks, the code generation changes alone typically reduce program CPU time by 5-35%.
There have been significant optimizations bringing more than 10% improvements to implementations in the
Go 1.7 moves the
package into the standard library as
. This allows the use of contexts for cancellation, timeouts, and passing request-scoped data in other standard library packages, including,, and, as noted below.
package now supports the definition of tests with subtests and benchmarks with sub-benchmarks. This support makes it easy to write table-driven benchmarks and to create hierarchical tests. It also provides a way to share common setup and tear-down code. See the package documentation
During panics, if a signal's name is known, it will be printed in the stack trace. Otherwise, the signal's number will be used, as it was before Go1.7.
The new function
provides an explicit mechanism for declaring that an allocated object must be considered reachable at a particular point in a program, typically to delay the execution of an associated finalizer.
The new function
translates a PC slice obtained from
into a sequence of frames corresponding to the call stack. This new API should be preferred instead of direct use of
, because the frame sequence can more accurately describe call stacks with inlined function calls.
The new function
facilitates tighter integration between Go and C code executing in the same process called using cgo.
On 32-bit systems, the runtime can now use memory allocated by the operating system anywhere in the address space, eliminating the “memory allocated by OS not in usable range” failure common in some environments.
On Windows, Go programs in Go 1.5 and earlier forced the global Windows timer resolution to 1ms at startup by calling
. Changing the global timer resolution caused problems on some systems, and testing suggested that the call was not needed for good scheduler performance, so Go 1.6 removed the call. Go 1.7 brings the call back: under some workloads the call is still needed for good scheduler performance.
As always, there are various minor changes and updates to the library, made with the Go 1 promise of compatibility in mind.
In previous releases of Go, if
method were asked for more bytes than fit in the underlying buffer, it would return an empty slice and the error
. Now it returns the entire underlying buffer, still accompanied by the error
As noted above, there are significant performance optimizations throughout the package. Decompression speed is improved by about 10%, while compression speed for
is roughly doubled.
In addition to those general improvements, the
compressor has been replaced entirely and uses an algorithm similar to Snappy
, resulting in about a 2.5X speed increase, although the output can be 5-10% larger than with the previous algorithm.
There is also a new compression level
that applies Huffman but not Lempel-Ziv encoding. Forgoing Lempel-Ziv encoding
runs about 3X faster than the new
but at the cost of producing compressed outputs that are 20-40% larger than those generated by the new
It is important to note that both
produce a compressed output that is RFC 1951
compliant. In other words, any valid DEFLATE decompressor will continue to be able to decompress these outputs.
Lastly, there is a minor change to the decompressor's implementation of
. In previous versions, the decompressor deferred reporting
until exactly no more bytes could be read. Now, it reports
more eagerly when reading the last set of bytes.
The TLS implementation sends the first few data packets on each connection using small record sizes, gradually increasing to the TLS maximum record size. This heuristic reduces the amount of data that must be received before the first packet can be decrypted, improving communication latency over low-bandwidth networks. Setting
field to true forces the behavior of Go 1.6 and earlier, where packets are as large as possible from the start of the connection.
The TLS client now has optional, limited support for server-initiated renegotiation, enabled by setting the
field. This is needed for connecting to many Microsoft Azure servers.
The errors returned by the package now consistently begin with a
prefix. In past releases, some errors used a
prefix, some used a
prefix, and some had no prefix at all.
When generating self-signed certificates, the package no longer sets the “Authority Key Identifier” field by default.
relocation type and its many predefined constants support the S390 port.
The ASN.1 decoder now rejects non-minimal integer encodings. This may cause the package to reject some invalid but formerly accepted ASN.1 data.
method controls whether the
characters in quoted strings should be escaped as
, respectively. As in previous releases, the encoder defaults to applying this escaping, to avoid certain problems that can arise when embedding JSON in HTML.
In earlier versions of Go, this package only supported encoding and decoding maps using keys with string types. Go 1.7 adds support for maps using keys with integer types: the encoding uses a quoted decimal representation as the JSON key. Go 1.7 also adds support for encoding maps using non-string keys that implement the
) method, as well as support for decoding maps using non-string keys that implement the
) method. These methods are ignored for keys with string types in order to preserve the encoding and decoding used in earlier versions of Go.
When encoding a slice of typed bytes,
now generates an array of elements encoded using that byte type's
method if present, only falling back to the default base64-encoded string data if neither method is available. Earlier versions of Go accept both the original base64-encoded string encoding and the array encoding (assuming the byte type also implements
as appropriate), so this change should be semantically backwards compatible with earlier versions of Go, even though it does change the chosen encoding.
To implement the go command's new support for binary-only packages and for Fortran code in cgo-based packages, the
type adds new fields
To support the corresponding change in
struct adds a Unordered field indicating whether the example may generate its output lines in any order.
The package adds new constants
, for use with
implementations. These constants are preferred over
, but the latter will be preserved for compatibility.
implementation now emits each multipart section's header sorted by key. Previously, iteration over a map caused the section header to use a non-deterministic order.
As part of the introduction of, the
type has a new method
but adding the
for the dial operation. The context is intended to obsolete the
fields, but the implementation continues to respect them, for backwards compatibility.
method has changed its result for invalid
addresses. In past releases, if an
byte slice had length other than 0, 4, or 16,
. Go 1.7 adds the hexadecimal encoding of the bytes, as in
The pure Goname resolution implementation now respects
's stated preference for the priority of DNS lookups compared to local file (that is,
's documentation now makes clear that beginning to write the response may prevent future reads on the request body. For maximal compatibility, implementations are encouraged to read the request body completely before writing any part of the response.
records in the request context both the underlying
using the key
and the local address on which the request was received (a
) using the key
. For example, the address on which a request received is
The server implementation now pads response codes less than 100 to three digits as required by the protocol, so that
uses the HTTP response status
, not just
In the client, the
implementation passes the request context to any dial operation connecting to the remote server. If a custom dialer is needed, the new
is preferred over the existing
field, to allow the transport to supply a context.
also adds fields
to help control client resources consumed by idle or chatty servers.
function can now return
to indicate that the most recent redirect response should be returned as the result of the HTTP request. That response is now available to the
Since Go 1, the default behavior of the HTTP client is to request server-side compression using the
request header and then to decompress the response body transparently, and this behavior is adjustable using the
field. In Go 1.7, to aid the implementation of HTTP proxies, the
field reports whether this transparent decompression took place.
adds support for a few new audio and video content types.
adds a new field
that allows redirection of the child process's standard error away from the host process's standard error.
method returns the recorded
. Tests that need to check the response's headers or trailers should call
and inspect the response fields instead of accessing
implementation now responds with “502 Bad Gateway” when it cannot reach a back end; in earlier releases it responded with “500 Internal Server Error.”
have been documented as deprecated. They are low-level, old, and unused by Go's current HTTP stack and will no longer be updated. Programs should use
The runtime trace HTTP handler, installed to handle the path
, now accepts a fractional number in its
query parameter, allowing collection of traces for intervals smaller than one second. This is especially useful on busy servers.
The address parser now allows unescaped UTF-8 text in addresses following RFC 6532
, but it does not apply any normalization to the result. For compatibility with older mail parsers, the address encoder, namely
method, continues to escape all UTF-8 text following RFC 5322
field records whether the URL must have a query string, in order to distinguish URLs without query strings (like
) from URLs with empty query strings (like
now returns true for
, on systems where that error exists.
now removes read-only files when possible, making the implementation behave as on non-Windows systems.
function is now implemented even when cgo is not available.
method has always been documented to panic if the given field number
is out of range, it has instead silently returned a zero
. Go 1.7 changes the method to behave as documented.
The method call
on all systems; in earlier releases, it returned an empty string on Windows.
The time zone database in
has been updated to IANA release 2016d. This fallback database is only used when the system time zone database cannot be found, for example on Windows. The Windows time zone abbreviation list has also been updated.