Update Aug 13, 2019 tracked by Updatify
go1.12.8 (released 2019-08-13)
go1.12.8 (released 2019-08-13) includes security fixes to the net/http and net/url packages. See the Go 1.12.8 milestone on our issue tracker for details.
Go is a high-level, general-purpose programming language that is statically typed and compiled. It is known for the simplicity of its syntax and the efficiency of development that it enables through the inclusion of a large standard library supplying many needs for common projects.
Update Aug 13, 2019 tracked by Updatify
go1.12.8 (released 2019-08-13) includes security fixes to the net/http and net/url packages. See the Go 1.12.8 milestone on our issue tracker for details.
Update Aug 13, 2019 tracked by Updatify
go1.11.13 (released 2019-08-13) includes security fixes to the net/http and net/url packages. See the Go 1.11.13 milestone on our issue tracker for details.
Update Jul 8, 2019 tracked by Updatify
go1.12.7 (released 2019-07-08) includes fixes to cgo, the compiler, and the linker. See the Go 1.12.7 milestone on our issue tracker for details.
Update Jul 8, 2019 tracked by Updatify
go1.11.12 (released 2019-07-08) includes fixes to the compiler and the linker. See the Go 1.11.12 milestone on our issue tracker for details.
Update Jun 11, 2019 tracked by Updatify
go1.12.6 (released 2019-06-11) includes fixes to the compiler, the linker, the go command, and the crypto/x509, net/http, and os packages. See the Go 1.12.6 milestone on our issue tracker for details.
Update Jun 11, 2019 tracked by Updatify
go1.11.11 (released 2019-06-11) includes a fix to the crypto/x509 package. See the Go 1.11.11 milestone on our issue tracker for details.
Update May 6, 2019 tracked by Updatify
go1.12.5 (released 2019-05-06) includes fixes to the compiler, the linker, the go command, the runtime, and the os package. See the Go 1.12.5 milestone on our issue tracker for details.
Update May 6, 2019 tracked by Updatify
go1.11.10 (released 2019-05-06) includes security fixes to the runtime, as well as bug fixes to the linker. See the Go 1.11.10 milestone on our issue tracker for details.
Update Apr 11, 2019 tracked by Updatify
go1.12.4 (released 2019-04-11) fixes an issue where using the prebuilt binary releases on older versions of GNU/Linux led to failures when linking programs that used cgo. Only Linux users who hit this issue need to update.
Update Apr 11, 2019 tracked by Updatify
go1.11.9 (released 2019-04-11) fixes an issue where using the prebuilt binary releases on older versions of GNU/Linux led to failures when linking programs that used cgo. Only Linux users who hit this issue need to update.
Update Apr 8, 2019 tracked by Updatify
go1.12.3 (released 2019-04-08) was accidentally released without its intended fix. It is identical to go1.12.2, except for its version number. The intended fix is in go1.12.4.
Update Apr 8, 2019 tracked by Updatify
go1.11.8 (released 2019-04-08) was accidentally released without its intended fix. It is identical to go1.11.7, except for its version number. The intended fix is in go1.11.9.
Update Apr 5, 2019 tracked by Updatify
go1.12.2 (released 2019-04-05) includes security fixes to the runtime, as well as bug fixes to the compiler, the go command, and the doc, net, net/http/httputil, and os packages. See the Go 1.12.2 milestone on our issue tracker for details.
Update Apr 5, 2019 tracked by Updatify
go1.11.7 (released 2019-04-05) includes fixes to the runtime and the net package. See the Go 1.11.7 milestone on our issue tracker for details.
Update Mar 14, 2019 tracked by Updatify
go1.12.1 (released 2019-03-14) includes fixes to cgo, the compiler, the go command, and the fmt, net/smtp, os, path/filepath, sync, and text/template packages. See the Go 1.12.1 milestone on our issue tracker for details.
Update Mar 14, 2019 tracked by Updatify
go1.11.6 (released 2019-03-14) includes fixes to cgo, the compiler, linker, runtime, go command, and the crypto/x509, encoding/json, net, and net/url packages. See the Go 1.11.6 milestone on our issue tracker for details.
Update Feb 25, 2019 tracked by Updatify
The latest Go release, version 1.12, arrives six months after Go 1.11. Most of its 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.
There are no changes to the language specification.
The race detector is now supported on linux/arm64.
Go 1.12 is the last release that is supported on FreeBSD 10.x, which has already reached end-of-life. Go 1.13 will require FreeBSD 11.2+ or FreeBSD 12.0+. FreeBSD 12.0+ requires a kernel with the COMPAT_FREEBSD11 option set (this is the default).
cgo is now supported on linux/ppc64.
hurd is now a recognized value for GOOS, reserved
for the GNU/Hurd system for use with gccgo.
Go’s new windows/arm port supports running Go on Windows 10
IoT Core on 32-bit ARM chips such as the Raspberry Pi 3.
Go now supports AIX 7.2 and later on POWER8 architectures ( aix/ppc64). External linking, cgo, pprof and the race detector aren’t yet supported.
Go 1.12 is the last release that will run on macOS 10.10 Yosemite. Go 1.13 will require macOS 10.11 El Capitan or later.
libSystem is now used when making syscalls on Darwin,
ensuring forward-compatibility with future versions of macOS and iOS. The switch to libSystem triggered additional App Store
checks for private API usage. Since it is considered private, syscall.Getdirentries now always fails with ENOSYS on iOS.
Additionally, syscall.Setrlimit reports invalid argument in places where it historically
succeeded. These consequences are not specific to Go and users should expect
behavioral parity with libSystem ’s implementation going forward.
go tool vet no longer supported
The go vet command has been rewritten to serve as the
base for a range of different source code analysis tools. See
the golang.org/x/tools/go/analysis package for details. A side-effect is that go tool vet is no longer supported. External tools that use go tool vet must be changed to use go vet. Using go vet instead of go tool vet should work with all supported versions of Go.
As part of this change, the experimental -shadow option
is no longer available with go vet. Checking for
variable shadowing may now be done using
go get -u golang.org/x/tools/go/analysis/passes/shadow/cmd/shadow
go vet -vettool=$(which shadow)
The Go tour is no longer included in the main binary distribution. To
run the tour locally, instead of running go tool tour,
manually install it:
go get -u golang.org/x/tour
tour
The build cache is now
required as a step toward eliminating $GOPATH/pkg. Setting the environment variable GOCACHE=off will cause go commands that write to the
cache to fail.
Go 1.12 is the last release that will support binary-only packages.
Go 1.12 will translate the C type EGLDisplay to the Go type uintptr.
This change is similar to how Go 1.10 and newer treats Darwin’s CoreFoundation
and Java’s JNI types. See the cgo documentation for more information.
Mangled C names are no longer accepted in packages that use Cgo. Use the Cgo
names instead. For example, use the documented cgo name C.char rather than the mangled name _Ctype_char that cgo generates.
When GO111MODULE is set to on, the go command now supports module-aware operations outside of a module directory,
provided that those operations do not need to resolve import paths relative to
the current directory or explicitly edit the go.mod file.
Commands such as go get, go list, and go mod download behave as if in a
module with initially-empty requirements.
In this mode, go env GOMOD reports
the system’s null device ( /dev/null or NUL).
go commands that download and extract modules are now safe to
invoke concurrently.
The module cache ( GOPATH/pkg/mod) must reside in a filesystem that
supports file locking.
The go directive in a go.mod file now indicates the
version of the language used by the files within that module.
It will be set to the current release
( go 1.12) if no existing version is
present.
If the go directive for a module specifies a
version newer than the toolchain in use, the go command
will attempt to build the packages regardless, and will note the mismatch only if
that build fails.
This changed use of the go directive means that if you
use Go 1.12 to build a module, thus recording go 1.12 in the go.mod file, you will get an error when
attempting to build the same module with Go 1.11 through Go 1.11.3.
Go 1.11.4 or later will work fine, as will releases older than Go 1.11.
If you must use Go 1.11 through 1.11.3, you can avoid the problem by
setting the language version to 1.11, using the Go 1.12 go tool,
via go mod edit -go=1.11.
When an import cannot be resolved using the active modules,
the go command will now try to use the modules mentioned in the
main module’s replace directives before consulting the module
cache and the usual network sources.
If a matching replacement is found but the replace directive does
not specify a version, the go command uses a pseudo-version
derived from the zero time.Time (such
as v0.0.0-00010101000000-000000000000).
The compiler’s live variable analysis has improved. This may mean that
finalizers will be executed sooner in this release than in previous
releases. If that is a problem, consider the appropriate addition of a runtime.KeepAlive call.
More functions are now eligible for inlining by default, including
functions that do nothing but call another function.
This extra inlining makes it additionally important to use runtime.CallersFrames instead of iterating over the result of runtime.Callers directly.
// Old code which no longer works correctly (it will miss inlined call frames).
var pcs [10]uintptr
n := runtime.Callers(1, pcs[:])
for _, pc := range pcs[:n] {
f := runtime.FuncForPC(pc)
if f != nil {
fmt.Println(f.Name())
}
}
// New code which will work correctly.
var pcs [10]uintptr
n := runtime.Callers(1, pcs[:])
frames := runtime.CallersFrames(pcs[:n])
for {
frame, more := frames.Next()
fmt.Println(frame.Function)
if !more {
break
}
}
Wrappers generated by the compiler to implement method expressions
are no longer reported
by runtime.CallersFrames and runtime.Stack. They
are also not printed in panic stack traces.
This change aligns the gc toolchain to match
the gccgo toolchain, which already elided such wrappers
from stack traces.
Clients of these APIs might need to adjust for the missing
frames. For code that must interoperate between 1.11 and 1.12
releases, you can replace the method expression x.M with the function literal func (...) { x.M(...) }.
The compiler now accepts a -lang flag to set the Go language
version to use. For example, -lang=go1.8 causes the compiler to
emit an error if the program uses type aliases, which were added in Go 1.9.
Language changes made before Go 1.12 are not consistently enforced.
The compiler toolchain now uses different conventions to call Go functions and assembly functions. This should be invisible to users, except for calls that simultaneously cross between Go and assembly and cross a package boundary. If linking results in an error like “relocation target not defined for ABIInternal (but is defined for ABI0)”, please refer to the compatibility section of the ABI design document.
There have been many improvements to the DWARF debug information produced by the compiler, including improvements to argument printing and variable location information.
Go programs now also maintain stack frame pointers on linux/arm64 for the benefit of profiling tools like perf. The frame pointer
maintenance has a small run-time overhead that varies but averages around 3%.
To build a toolchain that does not use frame pointers, set GOEXPERIMENT=noframepointer when running make.bash.
The obsolete “safe” compiler mode (enabled by the -u gcflag) has been removed.
godoc and go doc
In Go 1.12, godoc no longer has a command-line interface and
is only a web server. Users should use go doc for command-line help output instead. Go 1.12 is the last release that will
include the godoc webserver; in Go 1.13 it will be available
via go get.
go doc now supports the -all flag,
which will cause it to print all exported APIs and their documentation,
as the godoc command line used to do.
go doc also now includes the -src flag,
which will show the target’s source code.
The trace tool now supports plotting mutator utilization curves, including cross-references to the execution trace. These are useful for analyzing the impact of the garbage collector on application latency and throughput.
On arm64, the platform register was renamed from R18 to R18_PLATFORM to prevent accidental
use, as the OS could choose to reserve this register.
Go 1.12 significantly improves the performance of sweeping when a large fraction of the heap remains live. This reduces allocation latency immediately following a garbage collection.
The Go runtime now releases memory back to the operating system more aggressively, particularly in response to large allocations that can’t reuse existing heap space.
The Go runtime’s timer and deadline code is faster and scales better with higher numbers of CPUs. In particular, this improves the performance of manipulating network connection deadlines.
On Linux, the runtime now uses MADV_FREE to release unused
memory. This is more efficient but may result in higher reported
RSS. The kernel will reclaim the unused data when it is needed.
To revert to the Go 1.11 behavior ( MADV_DONTNEED), set the
environment variable GODEBUG=madvdontneed=1.
Adding cpu. extension =off to the GODEBUG environment variable now disables the use of optional CPU instruction set extensions in the standard library and runtime. This is not yet supported on Windows.
Go 1.12 improves the accuracy of memory profiles by fixing overcounting of large heap allocations.
Tracebacks, runtime.Caller,
and runtime.Callers no longer include
compiler-generated initialization functions. Doing a traceback
during the initialization of a global variable will now show a
function named PKG.init.ializers.
Go 1.12 adds opt-in support for TLS 1.3 in the crypto/tls package as
specified by RFC 8446. It can
be enabled by adding the value tls13=1 to the GODEBUG environment variable. It will be enabled by default in Go 1.13.
To negotiate TLS 1.3, make sure you do not set an explicit MaxVersion in Config and run your program with
the environment variable GODEBUG=tls13=1 set.
All TLS 1.2 features except TLSUnique in ConnectionState and renegotiation are available in TLS 1.3 and provide equivalent or
better security and performance. Note that even though TLS 1.3 is backwards
compatible with previous versions, certain legacy systems might not work
correctly when attempting to negotiate it. RSA certificate keys too small
to be secure (including 512-bit keys) will not work with TLS 1.3.
TLS 1.3 cipher suites are not configurable. All supported cipher suites are
safe, and if PreferServerCipherSuites is set in Config the preference order
is based on the available hardware.
Early data (also called “0-RTT mode”) is not currently supported as a client or server. Additionally, a Go 1.12 server does not support skipping unexpected early data if a client sends it. Since TLS 1.3 0-RTT mode involves clients keeping state regarding which servers support 0-RTT, a Go 1.12 server cannot be part of a load-balancing pool where some other servers do support 0-RTT. If switching a domain from a server that supported 0-RTT to a Go 1.12 server, 0-RTT would have to be disabled for at least the lifetime of the issued session tickets before the switch to ensure uninterrupted operation.
In TLS 1.3 the client is the last one to speak in the handshake, so if it causes
an error to occur on the server, it will be returned on the client by the first Read, not by Handshake. For
example, that will be the case if the server rejects the client certificate.
Similarly, session tickets are now post-handshake messages, so are only
received by the client upon its first Read.
As always, there are various minor changes and updates to the library, made with the Go 1 promise of compatibility in mind.
Reader ’s UnreadRune and UnreadByte methods will now return an error
if they are called after Peek.
The new function ReplaceAll returns a copy of
a byte slice with all non-overlapping instances of a value replaced by another.
A pointer to a zero-value Reader is now
functionally equivalent to NewReader (nil).
Prior to Go 1.12, the former could not be used as a substitute for the latter in all cases.
A warning will now be printed to standard error the first time Reader.Read is blocked for more than 60 seconds waiting
to read entropy from the kernel.
On FreeBSD, Reader now uses the getrandom system call if available, /dev/urandom otherwise.
This release removes the assembly implementations, leaving only the pure Go version. The Go compiler generates code that is either slightly better or slightly worse, depending on the exact CPU. RC4 is insecure and should only be used for compatibility with legacy systems.
If a client sends an initial message that does not look like TLS, the server
will no longer reply with an alert, and it will expose the underlying net.Conn in the new field Conn of RecordHeaderError.
A query cursor can now be obtained by passing a *Rows value to the Row.Scan method.
The new Delete method allows
for deletion of key/value pairs from a Map.
Maps are now printed in key-sorted order to ease testing. The ordering rules are:
reflect.Type describing the concrete type
and then by concrete value as described in the previous rules.
When printing maps, non-reflexive key values like NaN were previously
displayed as <nil>. As of this release, the correct values are printed.
To address some outstanding issues in cmd/doc,
this package has a new Mode bit, PreserveAST, which controls whether AST data is cleared.
The File type has a new LineStart field,
which returns the position of the start of a given line. This is especially useful
in programs that occasionally handle non-Go files, such as assembly, but wish to use
the token.Pos mechanism to identify file positions.
The RegisterFormat function is now safe for concurrent use.
Paletted images with fewer than 16 colors now encode to smaller outputs.
The new StringWriter interface wraps the WriteString function.
The functions Sin, Cos, Tan,
and Sincos now
apply Payne-Hanek range reduction to huge arguments. This
produces more accurate answers, but they will not be bit-for-bit
identical with the results in earlier releases.
New extended precision operations Add, Sub, Mul, and Div are available in uint, uint32, and uint64 versions.
The Dialer.DualStack setting is now ignored and deprecated;
RFC 6555 Fast Fallback (“Happy Eyeballs”) is now enabled by default. To disable, set Dialer.FallbackDelay to a negative value.
Similarly, TCP keep-alives are now enabled by default if Dialer.KeepAlive is zero.
To disable, set it to a negative value.
On Linux, the splice system call is now used when copying from a UnixConn to a TCPConn.
The HTTP server now rejects misdirected HTTP requests to HTTPS servers with a plaintext “400 Bad Request” response.
The new Client.CloseIdleConnections method calls the Client ’s underlying Transport ’s CloseIdleConnections if it has one.
The Transport no longer rejects HTTP responses which declare
HTTP Trailers but don’t use chunked encoding. Instead, the declared trailers are now just ignored.
The Transport no longer handles MAX_CONCURRENT_STREAMS values
advertised from HTTP/2 servers as strictly as it did during Go 1.10 and Go 1.11. The default behavior is now back
to how it was in Go 1.9: each connection to a server can have up to MAX_CONCURRENT_STREAMS requests
active and then new TCP connections are created as needed. In Go 1.10 and Go 1.11 the http2 package
would block and wait for requests to finish instead of creating new connections.
To get the stricter behavior back, import the golang.org/x/net/http2 package
directly and set Transport.StrictMaxConcurrentStreams to true.
Parse, ParseRequestURI,
and URL.Parse now return an
error for URLs containing ASCII control characters, which includes NULL,
tab, and newlines.
The ReverseProxy now automatically
proxies WebSocket requests.
The new ProcessState.ExitCode method
returns the process’s exit code.
ModeCharDevice has been added to the ModeType bitmask, allowing for ModeDevice | ModeCharDevice to be recovered when masking a FileMode with ModeType.
The new function UserHomeDir returns the
current user’s home directory.
RemoveAll now supports paths longer than 4096 characters
on most Unix systems.
File.Sync now uses F_FULLFSYNC on macOS
to correctly flush the file contents to permanent storage.
This may cause the method to run more slowly than in previous releases.
File now supports
a SyscallConn method returning
a syscall.RawConn interface value. This may be used to invoke system-specific
operations on the underlying file descriptor.
The IsAbs function now returns true when passed
a reserved filename on Windows such as NUL. List of reserved names.
A new MapIter type is
an iterator for ranging over a map. This type is exposed through the Value type’s new MapRange method.
This follows the same iteration semantics as a range statement, with Next to advance the iterator, and Key / Value to access each entry.
Copy is no longer necessary
to avoid lock contention, so it has been given a partial deprecation comment. Copy may still be appropriate if the reason for its use is to make two copies with
different Longest settings.
A new BuildInfo type
exposes the build information read from the running binary, available only in
binaries built with module support. This includes the main package path, main
module information, and the module dependencies. This type is given through the ReadBuildInfo function
on BuildInfo.
The new function ReplaceAll returns a copy of
a string with all non-overlapping instances of a value replaced by another.
A pointer to a zero-value Reader is now
functionally equivalent to NewReader (nil).
Prior to Go 1.12, the former could not be used as a substitute for the latter in all cases.
The new Builder.Cap method returns the capacity of the builder’s underlying byte slice.
The character mapping functions Map, Title, ToLower, ToLowerSpecial, ToTitle, ToTitleSpecial, ToUpper, and ToUpperSpecial now always guarantee to return valid UTF-8. In earlier releases, if the input was invalid UTF-8 but no character replacements
needed to be applied, these routines incorrectly returned the invalid UTF-8 unmodified.
64-bit inodes are now supported on FreeBSD 12. Some types have been adjusted accordingly.
The Unix socket
( AF_UNIX)
address family is now supported for compatible versions of Windows.
The new function Syscall18 has been introduced for Windows, allowing for calls with up to 18 arguments.
The Callback type and NewCallback function have been renamed;
they are now called Func and FuncOf, respectively.
This is a breaking change, but WebAssembly support is still experimental
and not yet subject to the Go 1 compatibility promise. Any code using the
old names will need to be updated.
If a type implements the new Wrapper interface, ValueOf will use it to return the JavaScript value for that type.
The meaning of the zero Value has changed. It now represents the JavaScript undefined value
instead of the number zero.
This is a breaking change, but WebAssembly support is still experimental
and not yet subject to the Go 1 compatibility promise. Any code relying on
the zero Value to mean the number zero will need to be updated.
The new Value.Truthy method reports the JavaScript “truthiness” of a given value.
The -benchtime flag now supports setting an explicit iteration count instead of a time when the value ends with an “ x ”. For example, -benchtime=100x runs the benchmark 100 times.
When executing a template, long context values are no longer truncated in errors.
executing "tmpl" at <.very.deep.context.v...>: map has no entry for key "notpresent"
is now
executing "tmpl" at <.very.deep.context.value.notpresent>: map has no entry for key "notpresent"
If a user-defined function called by a template panics, the
panic is now caught and returned as an error by
the Execute or ExecuteTemplate method.
The time zone database in $GOROOT/lib/time/zoneinfo.zip has been updated to version 2018i. Note that this ZIP file is
only used if a time zone database is not provided by the operating
system.
It is invalid to convert a nil unsafe.Pointer to uintptr and back with arithmetic.
(This was already invalid, but will now cause the compiler to misbehave.)
Update Jan 23, 2019 tracked by Updatify
go1.11.5 (released 2019-01-23) includes a security fix to the crypto/elliptic package. See the Go 1.11.5 milestone on our issue tracker for details.
Update Jan 23, 2019 tracked by Updatify
go1.10.8 (released 2019-01-23) includes a security fix to the crypto/elliptic package. See the Go 1.10.8 milestone on our issue tracker for details.
Update Dec 14, 2018 tracked by Updatify
go1.11.4 (released 2018-12-14) includes fixes to cgo, the compiler, linker, runtime, documentation, go command, and the go/types and net/http packages. It includes a fix to a bug introduced in Go 1.11.3 that broke go get for import path patterns containing “ ... “. See the Go 1.11.4 milestone on our issue tracker for details.
Update Dec 14, 2018 tracked by Updatify
go1.10.7 (released 2018-12-14) includes a fix to a bug introduced in Go 1.10.6 that broke go get for import path patterns containing “ ... “. See the Go 1.10.7 milestone on our issue tracker for details.
Update Dec 12, 2018 tracked by Updatify
go1.11.3 (released 2018-12-12) includes three security fixes to “go get” and the crypto/x509 package. See the Go 1.11.3 milestone on our issue tracker for details.
Update Dec 12, 2018 tracked by Updatify
go1.10.6 (released 2018-12-12) includes three security fixes to “go get” and the crypto/x509 package. It contains the same fixes as Go 1.11.3 and was released at the same time. See the Go 1.10.6 milestone on our issue tracker for details.
Update Nov 2, 2018 tracked by Updatify
go1.11.2 (released 2018-11-02) includes fixes to the compiler, linker, documentation, go command, and the database/sql and go/types packages. See the Go 1.11.2 milestone on our issue tracker for details.
Update Nov 2, 2018 tracked by Updatify
go1.10.5 (released 2018-11-02) includes fixes to the go command, linker, runtime, and the database/sql package. See the Go 1.10.5 milestone on our issue tracker for details.
Update Oct 1, 2018 tracked by Updatify
go1.11.1 (released 2018-10-01) includes fixes to the compiler, documentation, go command, runtime, and the crypto/x509, encoding/json, go/types, net, net/http, and reflect packages. See the Go 1.11.1 milestone on our issue tracker for details.
Update Aug 24, 2018 tracked by Updatify
The latest Go release, version 1.11, arrives six months after Go 1.10. Most of its 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.
There are no changes to the language specification.
As announced in the Go 1.10 release notes, Go 1.11 now requires OpenBSD 6.2 or later, macOS 10.10 Yosemite or later, or Windows 7 or later; support for previous versions of these operating systems has been removed.
Go 1.11 supports the upcoming OpenBSD 6.4 release. Due to changes in the OpenBSD kernel, older versions of Go will not work on OpenBSD 6.4.
There are known issues with NetBSD on i386 hardware.
The race detector is now supported on linux/ppc64le and, to a lesser extent, on netbsd/amd64. The NetBSD race detector support
has known issues.
The memory sanitizer ( -msan) is now supported on linux/arm64.
The build modes c-shared and c-archive are now supported on freebsd/amd64.
On 64-bit MIPS systems, the new environment variable settings GOMIPS64=hardfloat (the default) and GOMIPS64=softfloat select whether to use
hardware instructions or software emulation for floating-point computations.
For 32-bit systems, the environment variable is still GOMIPS,
as added in Go 1.10.
On soft-float ARM systems ( GOARM=5), Go now uses a more
efficient software floating point interface. This is transparent to
Go code, but ARM assembly that uses floating-point instructions not
guarded on GOARM will break and must be ported to
the new interface.
Go 1.11 on ARMv7 no longer requires a Linux kernel configured
with KUSER_HELPERS. This setting is enabled in default
kernel configurations, but is sometimes disabled in stripped-down
configurations.
Go 1.11 adds an experimental port to WebAssembly ( js/wasm).
Go programs currently compile to one WebAssembly module that
includes the Go runtime for goroutine scheduling, garbage
collection, maps, etc.
As a result, the resulting size is at minimum around
2 MB, or 500 KB compressed. Go programs can call into JavaScript
using the new experimental syscall/js package.
Binary size and interop with other languages has not yet been a
priority but may be addressed in future releases.
As a result of the addition of the new GOOS value
“ js ” and GOARCH value “ wasm ”,
Go files named *_js.go or *_wasm.go will
now be ignored by Go
tools except when those GOOS/GOARCH values are being used.
If you have existing filenames matching those patterns, you will need to rename them.
More information can be found on the WebAssembly wiki page.
The main Go compiler does not yet support the RISC-V architecture but we’ve reserved the GOARCH values
“ riscv ” and “ riscv64 ”, as used by Gccgo,
which does support RISC-V. This means that Go files
named *_riscv.go will now also
be ignored by Go
tools except when those GOOS/GOARCH values are being used.
Go 1.11 adds preliminary support for a new concept called “modules,” an alternative to GOPATH with integrated support for versioning and package distribution. Using modules, developers are no longer confined to working inside GOPATH, version dependency information is explicit yet lightweight, and builds are more reliable and reproducible.
Module support is considered experimental.
Details are likely to change in response to feedback from Go 1.11 users,
and we have more tools planned.
Although the details of module support may change, projects that convert
to modules using Go 1.11 will continue to work with Go 1.12 and later.
If you encounter bugs using modules,
please file issues so we can fix them. For more information, see the go command documentation.
Because Go module support assigns special meaning to the @ symbol in command line operations,
the go command now disallows the use of
import paths containing @ symbols.
Such import paths were never allowed by go get,
so this restriction can only affect users building
custom GOPATH trees by other means.
The new package golang.org/x/tools/go/packages provides a simple API for locating and loading packages of Go source code.
Although not yet part of the standard library, for many tasks it
effectively replaces the go/build package, whose API is unable to fully support modules.
Because it runs an external query command such as go list to obtain information about Go packages, it enables the construction of
analysis tools that work equally well with alternative build systems
such as Bazel and Buck.
Go 1.11 will be the last release to support setting the environment
variable GOCACHE=off to disable the build cache,
introduced in Go 1.10.
Starting in Go 1.12, the build cache will be required,
as a step toward eliminating $GOPATH/pkg.
The module and package loading support described above
already require that the build cache be enabled.
If you have disabled the build cache to avoid problems you encountered,
please file an issue to let us know about them.
More functions are now eligible for inlining by default, including
functions that call panic.
The compiler toolchain now supports column information in line directives.
A new package export data format has been introduced.
This should be transparent to end users, except for speeding up
build times for large Go projects.
If it does cause problems, it can be turned off again by
passing -gcflags=all=-iexport=false to
the go tool when building a binary.
The compiler now rejects unused variables declared in a type switch
guard, such as x in the following example:
func f(v interface{}) {
switch x := v.(type) {
}
}
This was already rejected by both gccgo and go/types.
The assembler for amd64 now accepts AVX512 instructions.
The compiler now produces significantly more accurate debug
information for optimized binaries, including variable location
information, line numbers, and breakpoint locations.
This should make it possible to debug binaries
compiled without -N -l.
There are still limitations to the quality of the debug information,
some of which are fundamental, and some of which will continue to
improve with future releases.
DWARF sections are now compressed by default because of the expanded
and more accurate debug information produced by the compiler.
This is transparent to most ELF tools (such as debuggers on Linux
and *BSD) and is supported by the Delve debugger on all platforms,
but has limited support in the native tools on macOS and Windows.
To disable DWARF compression,
pass -ldflags=-compressdwarf=false to
the go tool when building a binary.
Go 1.11 adds experimental support for calling Go functions from
within a debugger.
This is useful, for example, to call String methods
when paused at a breakpoint.
This is currently only supported by Delve (version 1.1.0 and up).
Since Go 1.10, the go test command runs go vet on the package being tested,
to identify problems before running the test. Since vet typechecks the code with go/types before running, tests that do not typecheck will now fail.
In particular, tests that contain an unused variable inside a
closure compiled with Go 1.10, because the Go compiler incorrectly
accepted them ( Issue #3059),
but will now fail, since go/types correctly reports an
“unused variable” error in this case.
The -memprofile flag
to go test now defaults to the
“allocs” profile, which records the total bytes allocated since the
test began (including garbage-collected bytes).
The go vet command now reports a fatal error when the package under analysis
does not typecheck. Previously, a type checking error simply caused
a warning to be printed, and vet to exit with status 1.
Additionally, go vet has become more robust when format-checking printf wrappers.
Vet now detects the mistake in this example:
func wrapper(s string, args ...interface{}) {
fmt.Printf(s, args...)
}
func main() {
wrapper("%s", 42)
}
With the new runtime/trace package’s user
annotation API, users can record application-level information
in execution traces and create groups of related goroutines.
The go tool trace command visualizes this information in the trace view and the new
user task/region analysis page.
Since Go 1.10, cgo has translated some C pointer types to the Go
type uintptr. These types include
the CFTypeRef hierarchy in Darwin’s CoreFoundation
framework and the jobject hierarchy in Java’s JNI
interface. In Go 1.11, several improvements have been made to the code
that detects these types. Code that uses these types may need some
updating. See the Go 1.10 release notes for
details.
The environment variable GOFLAGS may now be used
to set default flags for the go command.
This is useful in certain situations.
Linking can be noticeably slower on underpowered systems due to DWARF,
and users may want to set -ldflags=-w by default.
For modules, some users and CI systems will want vendoring always,
so they should set -mod=vendor by default.
For more information, see the go command documentation.
Go 1.11 will be the last release to support godoc ’s command-line interface.
In future releases, godoc will only be a web server. Users should use go doc for command-line help output instead.
The godoc web server now shows which version of Go introduced
new API features. The initial Go version of types, funcs, and methods are shown
right-aligned. For example, see UserCacheDir, with “1.11”
on the right side. For struct fields, inline comments are added when the struct field was
added in a Go version other than when the type itself was introduced.
For a struct field example, see ClientTrace.Got1xxResponse.
One minor detail of the default formatting of Go source code has changed. When formatting expression lists with inline comments, the comments were aligned according to a heuristic. However, in some cases the alignment would be split up too easily, or introduce too much whitespace. The heuristic has been changed to behave better for human-written code.
Note that these kinds of minor updates to gofmt are expected from time to
time.
In general, systems that need consistent formatting of Go source code should
use a specific version of the gofmt binary.
See the go/format package documentation for more
information.
The go run command now allows a single import path, a directory name or a
pattern matching a single package.
This allows go run pkg or go run dir, most importantly go run .
The runtime now uses a sparse heap layout so there is no longer a
limit to the size of the Go heap (previously, the limit was 512GiB).
This also fixes rare “address space conflict” failures in mixed Go/C
binaries or binaries compiled with -race.
On macOS and iOS, the runtime now uses libSystem.dylib instead of
calling the kernel directly. This should make Go binaries more
compatible with future versions of macOS and iOS.
The syscall package still makes direct
system calls; fixing this is planned for a future release.
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 better generated code and optimizations in the core library.
There were multiple performance changes to the math/big package as well as many changes across the tree specific to GOARCH=arm64.
The compiler now optimizes map clearing operations of the form:
for k := range m {
delete(m, k)
}
The compiler now optimizes slice extension of the form append(s, make([]T, n)...).
The compiler now performs significantly more aggressive bounds-check
and branch elimination. Notably, it now recognizes transitive
relations, so if i<j and j<len(s),
it can use these facts to eliminate the bounds check
for s[i]. It also understands simple arithmetic such
as s[i-10] and can recognize more inductive cases in
loops. Furthermore, the compiler now uses bounds information to more
aggressively optimize shift operations.
All of the changes to the standard library are minor.
As always, there are various minor changes and updates to the library, made with the Go 1 promise of compatibility in mind.
Certain crypto operations, including ecdsa.Sign, rsa.EncryptPKCS1v15 and rsa.GenerateKey,
now randomly read an extra byte of randomness to ensure tests don’t rely on internal behavior.
The new function NewGCMWithTagSize implements Galois Counter Mode with non-standard tag lengths for compatibility with existing cryptosystems.
PublicKey now implements a Size method that
returns the modulus size in bytes.
ConnectionState ’s new ExportKeyingMaterial method allows exporting keying material bound to the
connection according to RFC 5705.
The deprecated, legacy behavior of treating the CommonName field as
a hostname when no Subject Alternative Names are present is now disabled when the CN is not a
valid hostname.
The CommonName can be completely ignored by adding the experimental value x509ignoreCN=1 to the GODEBUG environment variable.
When the CN is ignored, certificates without SANs validate under chains with name constraints
instead of returning NameConstraintsWithoutSANs.
Extended key usage restrictions are again checked only if they appear in the KeyUsages field of VerifyOptions, instead of always being checked.
This matches the behavior of Go 1.9 and earlier.
The value returned by SystemCertPool is now cached and might not reflect system changes between invocations.
More ELFOSABI and EM constants have been added.
Marshal and Unmarshal now support “private” class annotations for fields.
The decoder now consistently
returns io.ErrUnexpectedEOF for an incomplete
chunk. Previously it would return io.EOF in some
cases.
The Reader now rejects attempts to set
the Comma field to a double-quote character, as double-quote characters
already have a special meaning in CSV.
The package has changed its behavior when a typed interface
value is passed to an implicit escaper function. Previously such
a value was written out as (an escaped form)
of <nil>. Now such values are ignored, just
as an untyped nil value is (and always has been)
ignored.
Non-looping animated GIFs are now supported. They are denoted by having a LoopCount of -1.
The TempFile function now supports specifying where the random characters in
the filename are placed. If the prefix argument
includes a “ * ”, the random string replaces the
“ * ”. For example, a prefix argument of “ myname.*.bat ” will
result in a random filename such as
“ myname.123456.bat ”. If no “ * ” is
included the old behavior is retained, and the random digits are
appended to the end.
ModInverse now returns nil when g and n are not relatively prime. The result was previously undefined.
The handling of form-data with missing/empty file names has been
restored to the behavior in Go 1.9: in the Form for
the form-data part the value is available in
the Value field rather than the File field. In Go releases 1.10 through 1.10.3 a form-data part with
a missing/empty file name and a non-empty “Content-Type” field
was stored in the File field. This change was a
mistake in 1.10 and has been reverted to the 1.9 behavior.
To support invalid input found in the wild, the package now permits non-ASCII bytes but does not validate their encoding.
The new ListenConfig type and the new Dialer.Control field permit
setting socket options before accepting and creating connections, respectively.
The syscall.RawConn Read and Write methods now work correctly on Windows.
The net package now automatically uses the splice system call on Linux when copying data between TCP connections in TCPConn.ReadFrom, as called by io.Copy. The result is faster, more efficient TCP proxying.
The TCPConn.File, UDPConn.File, UnixConn.File,
and IPConn.File methods no longer put the returned *os.File into
blocking mode.
The Transport type has a
new MaxConnsPerHost option that permits limiting the maximum number of connections
per host.
The Cookie type has a new SameSite field
(of new type also named SameSite) to represent the new cookie attribute recently supported by most browsers.
The net/http ’s Transport does not use the SameSite attribute itself, but the package supports parsing and serializing the
attribute for browsers to use.
It is no longer allowed to reuse a Server after a call to Shutdown or Close. It was never officially supported
in the past and had often surprising behavior. Now, all future calls to the server’s Serve methods will return errors after a shutdown or close.
The constant StatusMisdirectedRequest is now defined for HTTP status code 421.
The HTTP server will no longer cancel contexts or send on CloseNotifier channels upon receiving pipelined HTTP/1.1 requests. Browsers do
not use HTTP pipelining, but some clients (such as
Debian’s apt) may be configured to do so.
ProxyFromEnvironment, which is used by the DefaultTransport, now
supports CIDR notation and ports in the NO_PROXY environment variable.
The ReverseProxy has a new ErrorHandler option to permit changing how errors are handled.
The ReverseProxy now also passes
“ TE: trailers ” request headers
through to the backend, as required by the gRPC protocol.
The new UserCacheDir function
returns the default root directory to use for user-specific cached data.
The new ModeIrregular is a FileMode bit to represent
that a file is not a regular file, but nothing else is known about it, or that
it’s not a socket, device, named pipe, symlink, or other file type for which
Go has a defined mode bit.
Symlink now works
for unprivileged users on Windows 10 on machines with Developer
Mode enabled.
When a non-blocking descriptor is passed
to NewFile, the
resulting *File will be kept in non-blocking
mode. This means that I/O for that *File will use
the runtime poller rather than a separate thread, and that
the SetDeadline methods will work.
The new Ignored function reports
whether a signal is currently ignored.
The os/user package can now be built in pure Go
mode using the build tag “ osusergo ”,
independent of the use of the environment
variable CGO_ENABLED=0. Previously the only way to use
the package’s pure Go implementation was to disable cgo support across the entire program.
Setting the GODEBUG=tracebackancestors=*N* environment variable now extends tracebacks with the stacks at
which goroutines were created, where N limits the
number of ancestor goroutines to report.
This release adds a new “allocs” profile type that profiles
total number of bytes allocated since the program began
(including garbage-collected bytes). This is identical to the
existing “heap” profile viewed in -alloc_space mode.
Now go test -memprofile=... reports an “allocs” profile
instead of “heap” profile.
The mutex profile now includes reader/writer contention
for RWMutex.
Writer/writer contention was already included in the mutex
profile.
On Windows, several fields were changed from uintptr to a new Pointer type to avoid problems with Go’s garbage collector. The same change was made
to the golang.org/x/sys/windows package. For any code affected, users should first migrate away from the syscall package to the golang.org/x/sys/windows package, and then change
to using the Pointer, while obeying the unsafe.Pointer conversion rules.
On Linux, the flags parameter to Faccessat is now implemented just as in glibc. In earlier Go releases the
flags parameter was ignored.
On Linux, the flags parameter to Fchmodat is now validated. Linux’s fchmodat doesn’t support the flags parameter
so we now mimic glibc’s behavior and return an error if it’s non-zero.
The Scanner.Scan method now returns
the RawString token
instead of String for raw string literals.
Modifying template variables via assignments is now permitted via the = token:
{{ $v := "init" }}
{{ if true }}
{{ $v = "changed" }}
{{ end }}
v: {{ $v }} {{/* "changed" */}}
In previous versions untyped nil values passed to
template functions were ignored. They are now passed as normal
arguments.
Parsing of timezones denoted by sign and offset is now
supported. In previous versions, numeric timezone names
(such as +03) were not considered valid, and only
three-letter abbreviations (such as MST) were accepted
when expecting a timezone name.
Update Aug 24, 2018 tracked by Updatify
go1.10.4 (released 2018-08-24) includes fixes to the go command, linker, and the bytes, mime/multipart, net/http, and strings packages. See the Go 1.10.4 milestone on our issue tracker for details.
Update Jun 5, 2018 tracked by Updatify
go1.10.3 (released 2018-06-05) includes fixes to the go command, and the crypto/tls, crypto/x509, and strings packages. In particular, it adds minimal support to the go command for the vgo transition. See the Go 1.10.3 milestone on our issue tracker for details.
Update Jun 5, 2018 tracked by Updatify
go1.9.7 (released 2018-06-05) includes fixes to the go command, and the crypto/x509 and strings packages. In particular, it adds minimal support to the go command for the vgo transition. See the Go 1.9.7 milestone on our issue tracker for details.
Update May 1, 2018 tracked by Updatify
go1.10.2 (released 2018-05-01) includes fixes to the compiler, linker, and go command. See the Go 1.10.2 milestone on our issue tracker for details.
Update May 1, 2018 tracked by Updatify
go1.9.6 (released 2018-05-01) includes fixes to the compiler and go command. See the Go 1.9.6 milestone on our issue tracker for details.
Update Mar 28, 2018 tracked by Updatify
go1.10.1 (released 2018-03-28) includes security fixes to the go command, as well as bug fixes to the compiler, runtime, and the archive/zip, crypto/tls, crypto/x509, encoding/json, net, net/http, and net/http/pprof packages. See the Go 1.10.1 milestone on our issue tracker for details.
Update Mar 28, 2018 tracked by Updatify
go1.9.5 (released 2018-03-28) includes security fixes to the go command, as well as bug fixes to the compiler, go command, and the net/http/pprof package. See the Go 1.9.5 milestone on our issue tracker for details.
Update Feb 16, 2018 tracked by Updatify
The latest Go release, version 1.10, arrives six months after Go 1.9. Most of its 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.
This release improves caching of built packages,
adds caching of successful test results,
runs vet automatically during tests,
and
permits passing string values directly between Go and C using cgo.
A new hard-coded set of safe compiler options may cause
unexpected invalid flag errors in code that built successfully with older
releases.
There are no significant changes to the language specification.
A corner case involving shifts of untyped constants has been clarified,
and as a result the compilers have been updated to allow the index expression x[1.0 << s] where s is an unsigned integer;
the go/types package already did.
The grammar for method expressions has been updated to relax the
syntax to allow any type expression as a receiver;
this matches what the compilers were already implementing.
For example, struct{io.Reader}.Read is a valid, if unusual,
method expression that the compilers already accepted and is
now permitted by the language grammar.
There are no new supported operating systems or processor architectures in this release. Most of the work has focused on strengthening the support for existing ports, in particular new instructions in the assembler and improvements to the code generated by the compilers.
As announced in the Go 1.9 release notes, Go 1.10 now requires FreeBSD 10.3 or later; support for FreeBSD 9.3 has been removed.
Go now runs on NetBSD again but requires the unreleased NetBSD 8.
Only GOARCH amd64 and 386 have
been fixed. The arm port is still broken.
On 32-bit MIPS systems, the new environment variable settings GOMIPS=hardfloat (the default) and GOMIPS=softfloat select whether to use
hardware instructions or software emulation for floating-point computations.
Go 1.10 is the last release that will run on OpenBSD 6.0. Go 1.11 will require OpenBSD 6.2.
Go 1.10 is the last release that will run on OS X 10.8 Mountain Lion or OS X 10.9 Mavericks. Go 1.11 will require OS X 10.10 Yosemite or later.
Go 1.10 is the last release that will run on Windows XP or Windows Vista. Go 1.11 will require Windows 7 or later.
If the environment variable $GOROOT is unset,
the go tool previously used the default GOROOT set during toolchain compilation.
Now, before falling back to that default, the go tool attempts to
deduce GOROOT from its own executable path.
This allows binary distributions to be unpacked anywhere in the
file system and then be used without setting GOROOT explicitly.
By default, the go tool creates its temporary files and directories
in the system temporary directory (for example, $TMPDIR on Unix).
If the new environment variable $GOTMPDIR is set,
the go tool will create its temporary files and directories in that directory instead.
The go build command now detects out-of-date packages
purely based on the content of source files, specified build flags, and metadata stored in the compiled packages.
Modification times are no longer consulted or relevant.
The old advice to add -a to force a rebuild in cases where
the modification times were misleading for one reason or another
(for example, changes in build flags) is no longer necessary:
builds now always detect when packages must be rebuilt.
(If you observe otherwise, please file a bug.)
The go build -asmflags, -gcflags, -gccgoflags, and -ldflags options
now apply by default only to the packages listed directly on the command line.
For example, go build -gcflags=-m mypkg passes the compiler the -m flag when building mypkg but not its dependencies.
The new, more general form -asmflags=pattern=flags (and similarly for the others)
applies the flags only to the packages matching the pattern.
For example: go install -ldflags=cmd/gofmt=-X=main.version=1.2.3 cmd/... installs all the commands matching cmd/... but only applies the -X option
to the linker flags for cmd/gofmt.
For more details, see go help build.
The go build command now maintains a cache of
recently built packages, separate from the installed packages in $GOROOT/pkg or $GOPATH/pkg.
The effect of the cache should be to speed builds that do not explicitly install packages
or when switching between different copies of source code (for example, when changing
back and forth between different branches in a version control system).
The old advice to add the -i flag for speed, as in go build -i or go test -i,
is no longer necessary: builds run just as fast without -i.
For more details, see go help cache.
The go install command now installs only the
packages and commands listed directly on the command line.
For example, go install cmd/gofmt installs the gofmt program but not any of the packages on which it depends.
The new build cache makes future commands still run as quickly as if the
dependencies had been installed.
To force the installation of dependencies, use the new go install -i flag.
Installing dependency packages should not be necessary in general,
and the very concept of installed packages may disappear in a future release.
Many details of the go build implementation have changed to support these improvements.
One new requirement implied by these changes is that
binary-only packages must now declare accurate import blocks in their
stub source code, so that those imports can be made available when
linking a program using the binary-only package.
For more details, see go help filetype.
The go test command now caches test results:
if the test executable and command line match a previous run
and the files and environment variables consulted by that run
have not changed either, go test will print
the previous test output, replacing the elapsed time with the string “(cached).”
Test caching applies only to successful test results;
only to go test commands with an explicit list of packages; and
only to command lines using a subset of the -cpu, -list, -parallel, -run, -short, and -v test flags.
The idiomatic way to bypass test caching is to use -count=1.
The go test command now automatically runs go vet on the package being tested,
to identify significant problems before running the test.
Any such problems are treated like build errors and prevent execution of the test.
Only a high-confidence subset of the available go vet checks are enabled for this automatic check.
To disable the running of go vet, use go test -vet=off.
The go test -coverpkg flag now
interprets its argument as a comma-separated list of patterns to match against
the dependencies of each test, not as a list of packages to load anew.
For example, go test -coverpkg=all is now a meaningful way to run a test with coverage enabled for the test package
and all its dependencies.
Also, the go test -coverprofile option is now
supported when running multiple tests.
In case of failure due to timeout, tests are now more likely to write their profiles before exiting.
The go test command now always
merges the standard output and standard error from a given test binary execution
and writes both to go test ’s standard output.
In past releases, go test only applied this
merging most of the time.
The go test -v output
now includes PAUSE and CONT status update
lines to mark when parallel tests pause and continue.
The new go test -failfast flag
disables running additional tests after any test fails.
Note that tests running in parallel with the failing test are allowed to complete.
Finally, the new go test -json flag
filters test output through the new command go tool test2json to produce a machine-readable JSON-formatted description of test execution.
This allows the creation of rich presentations of test execution
in IDEs and other tools.
For more details about all these changes,
see go help test and the test2json documentation.
Options specified by cgo using #cgo CFLAGS and the like
are now checked against a list of permitted options.
This closes a security hole in which a downloaded package uses
compiler options like -fplugin to run arbitrary code on the machine where it is being built.
This can cause a build error such as invalid flag in #cgo CFLAGS.
For more background, and how to handle this error, see https://golang.org/s/invalidflag.
Cgo now implements a C typedef like “ typedef X Y ” using a Go type alias,
so that Go code may use the types C.X and C.Y interchangeably.
It also now supports the use of niladic function-like macros.
Also, the documentation has been updated to clarify that
Go structs and Go arrays are not supported in the type signatures of cgo-exported functions.
Cgo now supports direct access to Go string values from C.
Functions in the C preamble may use the type _GoString_ to accept a Go string as an argument.
C code may call _GoStringLen and _GoStringPtr for direct access to the contents of the string.
A value of type _GoString_ may be passed in a call to an exported Go function that takes an argument of Go type string.
During toolchain bootstrap, the environment variables CC and CC_FOR_TARGET specify
the default C compiler that the resulting toolchain will use for host and target builds, respectively.
However, if the toolchain will be used with multiple targets, it may be necessary to specify a different C compiler for each
(for example, a different compiler for darwin/arm64 versus linux/ppc64le).
The new set of environment variables CC_FOR_*goos*_*goarch* allows specifying a different default C compiler for each target.
Note that these variables only apply during toolchain bootstrap,
to set the defaults used by the resulting toolchain.
Later go build commands use the CC environment
variable or else the built-in default.
Cgo now translates some C types that would normally map to a pointer
type in Go, to a uintptr instead. These types include
the CFTypeRef hierarchy in Darwin’s CoreFoundation
framework and the jobject hierarchy in Java’s JNI
interface.
These types must be uintptr on the Go side because they
would otherwise confuse the Go garbage collector; they are sometimes
not really pointers but data structures encoded in a pointer-sized integer.
Pointers to Go memory must not be stored in these uintptr values.
Because of this change, values of the affected types need to be
zero-initialized with the constant 0 instead of the
constant nil. Go 1.10 provides gofix modules to help with that rewrite:
go tool fix -r cftype <pkg>
go tool fix -r jni <pkg>
For more details, see the cgo documentation.
The go doc tool now adds functions returning slices of T or *T to the display of type T, similar to the existing behavior for functions returning single T or *T results.
For example:
$ go doc mail.Address
package mail // import "net/mail"
type Address struct {
Name string
Address string
}
Address represents a single mail address.
func ParseAddress(address string) (*Address, error)
func ParseAddressList(list string) ([]*Address, error)
func (a *Address) String() string
$
Previously, ParseAddressList was only shown in the package overview ( go doc mail).
The go fix tool now replaces imports of "golang.org/x/net/context" with "context".
(Forwarding aliases in the former make it completely equivalent to the latter when using Go 1.9 or later.)
The go get command now supports Fossil source code repositories.
The blocking and mutex profiles produced by the runtime/pprof package
now include symbol information, so they can be viewed
in go tool pprof without the binary that produced the profile.
(All other profile types were changed to include symbol information in Go 1.9.)
The go tool pprof profile visualizer has been updated to git version 9e20b5b (2017-11-08)
from github.com/google/pprof,
which includes an updated web interface.
The go vet command now always has access to
complete, up-to-date type information when checking packages, even for packages using cgo or vendored imports.
The reports should be more accurate as a result.
Note that only go vet has access to this information;
the more low-level go tool vet does not
and should be avoided except when working on vet itself.
(As of Go 1.9, go vet provides access to all the same flags as go tool vet.)
This release includes a new overview of available Go program diagnostic tools.
Two minor details of the default formatting of Go source code have changed.
First, certain complex three-index slice expressions previously formatted like x[i+1 : j:k] and now
format with more consistent spacing: x[i+1 : j : k].
Second, single-method interface literals written on a single line,
which are sometimes used in type assertions,
are no longer split onto multiple lines.
Note that these kinds of minor updates to gofmt are expected from time to time. In general, we recommend against building systems that check that source code matches the output of a specific version of gofmt. For example, a continuous integration test that fails if any code already checked into a repository is not “properly formatted” is inherently fragile and not recommended.
If multiple programs must agree about which version of gofmt is used to format a source file,
we recommend that they do this by arranging to invoke the same gofmt binary.
For example, in the Go open source repository, our Git pre-commit hook is written in Go
and could import go/format directly, but instead it invokes the gofmt binary found in the current path, so that the pre-commit hook need not be recompiled
each time gofmt changes.
The compiler includes many improvements to the performance of generated code, spread fairly evenly across the supported architectures.
The DWARF debug information recorded in binaries has been improved in a few ways: constant values are now recorded; line number information is more accurate, making source-level stepping through a program work better; and each package is now presented as its own DWARF compilation unit.
The various build modes have been ported to more systems.
Specifically, c-shared now works on linux/ppc64le, windows/386, and windows/amd64; pie now works on darwin/amd64 and also forces the use of external linking on all systems;
and plugin now works on linux/ppc64le and darwin/amd64.
The linux/ppc64le port now requires the use of external linking
with any programs that use cgo, even uses by the standard library.
For the ARM 32-bit port, the assembler now supports the instructions BFC, BFI, BFX, BFXU, FMULAD, FMULAF, FMULSD, FMULSF, FNMULAD, FNMULAF, FNMULSD, FNMULSF, MULAD, MULAF, MULSD, MULSF, NMULAD, NMULAF, NMULD, NMULF, NMULSD, NMULSF, XTAB, XTABU, XTAH,
and XTAHU.
For the ARM 64-bit port, the assembler now supports the VADD, VADDP, VADDV, VAND, VCMEQ, VDUP, VEOR, VLD1, VMOV, VMOVI, VMOVS, VORR, VREV32,
and VST1 instructions.
For the PowerPC 64-bit port, the assembler now supports the POWER9 instructions ADDEX, CMPEQB, COPY, DARN, LDMX, MADDHD, MADDHDU, MADDLD, MFVSRLD, MTVSRDD, MTVSRWS, PASTECC, VCMPNEZB, VCMPNEZBCC,
and VMSUMUDM.
For the S390X port, the assembler now supports the TMHH, TMHL, TMLH,
and TMLL instructions.
For the X86 64-bit port, the assembler now supports 359 new instructions,
including the full AVX, AVX2, BMI, BMI2, F16C, FMA3, SSE2, SSE3, SSSE3, SSE4.1, and SSE4.2 extension sets.
The assembler also no longer implements MOVL $0, AX as an XORL instruction,
to avoid clearing the condition flags unexpectedly.
Due to the alignment of Go’s semiannual release schedule with GCC’s annual release schedule, GCC release 7 contains the Go 1.8.3 version of gccgo. We expect that the next release, GCC 8, will contain the Go 1.10 version of gccgo.
The behavior of nested calls to LockOSThread and UnlockOSThread has changed.
These functions control whether a goroutine is locked to a specific operating system thread,
so that the goroutine only runs on that thread, and the thread only runs that goroutine.
Previously, calling LockOSThread more than once in a row
was equivalent to calling it once, and a single UnlockOSThread always unlocked the thread.
Now, the calls nest: if LockOSThread is called multiple times, UnlockOSThread must be called the same number of times
in order to unlock the thread.
Existing code that was careful not to nest these calls will remain correct.
Existing code that incorrectly assumed the calls nested will become correct.
Most uses of these functions in public Go source code falls into the second category.
Because one common use of LockOSThread and UnlockOSThread is to allow Go code to reliably modify thread-local state (for example, Linux or Plan 9 name spaces),
the runtime now treats locked threads as unsuitable for reuse or for creating new threads.
Stack traces no longer include implicit wrapper functions (previously marked <autogenerated>),
unless a fault or panic happens in the wrapper itself.
As a result, skip counts passed to functions like Caller should now always match the structure of the code as written, rather than depending on
optimization decisions and implementation details.
The garbage collector has been modified to reduce its impact on allocation latency. It now uses a smaller fraction of the overall CPU when running, but it may run more of the time. The total CPU consumed by the garbage collector has not changed significantly.
The GOROOT function
now defaults (when the $GOROOT environment variable is not set)
to the GOROOT or GOROOT_FINAL in effect
at the time the calling program was compiled.
Previously it used the GOROOT or GOROOT_FINAL in effect
at the time the toolchain that compiled the calling program was compiled.
There is no longer a limit on the GOMAXPROCS setting.
(In Go 1.9 the limit was 1024.)
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.
Many applications should experience significantly lower allocation latency and overall performance overhead when the garbage collector is active.
All of the changes to the standard library are minor. The changes in bytes and net/url are the most likely to require updating of existing programs.
As always, there are various minor changes and updates to the library, made with the Go 1 promise of compatibility in mind.
In general, the handling of special header formats is significantly improved and expanded.
FileInfoHeader has always
recorded the Unix UID and GID numbers from its os.FileInfo argument
(specifically, from the system-dependent information returned by the FileInfo ’s Sys method)
in the returned Header.
Now it also records the user and group names corresponding to those IDs,
as well as the major and minor device numbers for device files.
The new Header.Format field
of type Format controls which tar header format the Writer uses.
The default, as before, is to select the most widely-supported header type
that can encode the fields needed by the header (USTAR if possible, or else PAX if possible, or else GNU).
The Reader sets Header.Format for each header it reads.
Reader and the Writer now support arbitrary PAX records,
using the new Header.PAXRecords field,
a generalization of the existing Xattrs field.
The Reader no longer insists that the file name or link name in GNU headers
be valid UTF-8.
When writing PAX- or GNU-format headers, the Writer now includes
the Header.AccessTime and Header.ChangeTime fields (if set).
When writing PAX-format headers, the times include sub-second precision.
Go 1.10 adds more complete support for times and character set encodings in ZIP archives.
The original ZIP format used the standard MS-DOS encoding of year, month, day, hour, minute, and second into fields in two 16-bit values.
That encoding cannot represent time zones or odd seconds, so multiple extensions have been
introduced to allow richer encodings.
In Go 1.10, the Reader and Writer now support the widely-understood Info-Zip extension that encodes the time separately in the 32-bit Unix “seconds since epoch” form.
The FileHeader ’s new Modified field of type time.Time obsoletes the ModifiedTime and ModifiedDate fields, which continue to hold the MS-DOS encoding.
The Reader and Writer now adopt the common
convention that a ZIP archive storing a time zone-independent Unix time
also stores the local time in the MS-DOS field,
so that the time zone offset can be inferred.
For compatibility, the ModTime and SetModTime methods
behave the same as in earlier releases; new code should use Modified directly.
The header for each file in a ZIP archive has a flag bit indicating whether
the name and comment fields are encoded as UTF-8, as opposed to a system-specific default encoding.
In Go 1.8 and earlier, the Writer never set the UTF-8 bit.
In Go 1.9, the Writer changed to set the UTF-8 bit almost always.
This broke the creation of ZIP archives containing Shift-JIS file names.
In Go 1.10, the Writer now sets the UTF-8 bit only when
both the name and the comment field are valid UTF-8 and at least one is non-ASCII.
Because non-ASCII encodings very rarely look like valid UTF-8, the new
heuristic should be correct nearly all the time.
Setting a FileHeader ’s new NonUTF8 field to true
disables the heuristic entirely for that file.
The Writer also now supports setting the end-of-central-directory record’s comment field,
by calling the Writer ’s new SetComment method.
The new Reader.Size and Writer.Size methods report the Reader or Writer ’s underlying buffer size.
The Fields, FieldsFunc, Split,
and SplitAfter functions have always returned subslices of their inputs.
Go 1.10 changes each returned subslice to have capacity equal to its length,
so that appending to one cannot overwrite adjacent data in the original input.
NewOFB now panics if given
an initialization vector of incorrect length, like the other constructors in the
package always have.
(Previously it returned a nil Stream implementation.)
The TLS server now advertises support for SHA-512 signatures when using TLS 1.2. The server already supported the signatures, but some clients would not select them unless explicitly advertised.
Certificate.Verify now enforces the name constraints for all
names contained in the certificate, not just the one name that a client has asked about.
Extended key usage restrictions are similarly now checked all at once.
As a result, after a certificate has been validated, now it can be trusted in its entirety.
It is no longer necessary to revalidate the certificate for each additional name
or key usage.
Parsed certificates also now report URI names and IP, email, and URI constraints, using the new Certificate fields URIs, PermittedIPRanges, ExcludedIPRanges, PermittedEmailAddresses, ExcludedEmailAddresses, PermittedURIDomains, and ExcludedURIDomains. Certificates with
invalid values for those fields are now rejected.
The new MarshalPKCS1PublicKey and ParsePKCS1PublicKey functions convert an RSA public key to and from PKCS#1-encoded form.
The new MarshalPKCS8PrivateKey function converts a private key to PKCS#8-encoded form.
( ParsePKCS8PrivateKey has existed since Go 1.)
Name now implements a String method that
formats the X.509 distinguished name in the standard RFC 2253 format.
Drivers that currently hold on to the destination buffer provided by driver.Rows.Next should ensure they no longer
write to a buffer assigned to the destination array outside of that call.
Drivers must be careful that underlying buffers are not modified when closing driver.Rows.
Drivers that want to construct a sql.DB for
their clients can now implement the Connector interface
and call the new sql.OpenDB function,
instead of needing to encode all configuration into a string
passed to sql.Open.
Drivers that want to parse the configuration string only once per sql.DB instead of once per sql.Conn,
or that want access to each sql.Conn ’s underlying context,
can make their Driver implementations also implement DriverContext ’s
new OpenConnector method.
Drivers that implement ExecerContext no longer need to implement Execer;
similarly, drivers that implement QueryerContext no longer need to implement Queryer.
Previously, even if the context-based interfaces were implemented they were ignored
unless the non-context-based interfaces were also implemented.
To allow drivers to better isolate different clients using a cached driver connection in succession,
if a Conn implements the new SessionResetter interface, database/sql will now call ResetSession before
reusing the Conn for a new client.
This release adds 348 new relocation constants divided between the relocation types R_386, R_AARCH64, R_ARM, R_PPC64,
and R_X86_64.
Go 1.10 adds support for reading relocations from Mach-O sections,
using the Section struct’s new Relocs field
and the new Reloc, RelocTypeARM, RelocTypeARM64, RelocTypeGeneric,
and RelocTypeX86_64 types and associated constants.
Go 1.10 also adds support for the LC_RPATH load command,
represented by the types RpathCmd and Rpath,
and new named constants for the various flag bits found in headers.
Marshal now correctly encodes
strings containing asterisks as type UTF8String instead of PrintableString,
unless the string is in a struct field with a tag forcing the use of PrintableString. Marshal also now respects struct tags containing application directives.
The new MarshalWithParams function marshals its argument as if the additional params were its associated
struct field tag.
Unmarshal now respects
struct field tags using the explicit and tag directives.
Both Marshal and Unmarshal now support a new struct field tag numeric, indicating an ASN.1 NumericString.
Reader now disallows the use of
nonsensical Comma and Comment settings,
such as NUL, carriage return, newline, invalid runes, and the Unicode replacement character,
or setting Comma and Comment equal to each other.
In the case of a syntax error in a CSV record that spans multiple input lines, Reader now reports the line on which the record started in the ParseError ’s new StartLine field.
The new functions NewEncoder and NewDecoder provide streaming conversions to and from hexadecimal,
analogous to equivalent functions already in encoding/base32 and encoding/base64.
When the functions Decode and DecodeString encounter malformed input,
they now return the number of bytes already converted
along with the error.
Previously they always returned a count of 0 with any error.
The Decoder adds a new method DisallowUnknownFields that causes it to report inputs with unknown JSON fields as a decoding error.
(The default behavior has always been to discard unknown fields.)
As a result of fixing a reflect bug, Unmarshal can no longer decode into fields inside
embedded pointers to unexported struct types,
because it cannot initialize the unexported embedded pointer
to point at fresh storage. Unmarshal now returns an error in this case.
Encode and EncodeToMemory no longer generate partial output when presented with a
block that is impossible to encode as PEM data.
The new function NewTokenDecoder is like NewDecoder but creates a decoder reading from a TokenReader instead of an XML-formatted byte stream.
This is meant to enable the construction of XML stream transformers in client libraries.
The default Usage function now prints
its first line of output to CommandLine.Output() instead of assuming os.Stderr,
so that the usage message is properly redirected for
clients using CommandLine.SetOutput.
PrintDefaults now
adds appropriate indentation after newlines in flag usage strings,
so that multi-line usage strings display nicely.
FlagSet adds new methods ErrorHandling, Name,
and Output,
to retrieve the settings passed to NewFlagSet and FlagSet.SetOutput.
To support the doc change described above,
functions returning slices of T, *T, **T, and so on
are now reported in T ’s Type ’s Funcs list,
instead of in the Package ’s Funcs list.
The For function now accepts a non-nil lookup argument.
The changes to the default formatting of Go source code discussed in the gofmt section above are implemented in the go/printer package and also affect the output of the higher-level go/format package.
Implementations of the Hash interface are now
encouraged to implement encoding.BinaryMarshaler and encoding.BinaryUnmarshaler to allow saving and recreating their internal state,
and all implementations in the standard library
( hash/crc32, crypto/sha256, and so on)
now implement those interfaces.
The new Srcset content
type allows for proper handling of values within the srcset attribute of img tags.
Int now supports conversions to and from bases 2 through 62
in its SetString and Text methods.
(Previously it only allowed bases 2 through 36.)
The value of the constant MaxBase has been updated.
Int adds a new CmpAbs method
that is like Cmp but
compares only the absolute values (not the signs) of its arguments.
Float adds a new Sqrt method to
compute square roots.
Branch cuts and other boundary cases in Asin, Asinh, Atan,
and Sqrt have been corrected to match the definitions used in the C99 standard.
The new Shuffle function and corresponding Rand.Shuffle method
shuffle an input sequence.
The new functions Round and RoundToEven round their arguments to the nearest floating-point integer; Round rounds a half-integer to its larger integer neighbor (away from zero)
while RoundToEven rounds a half-integer to its even integer neighbor.
The new functions Erfinv and Erfcinv compute the inverse error function and the
inverse complementary error function.
Reader now accepts parts with empty filename attributes.
ParseMediaType now discards
invalid attribute values; previously it returned those values as empty strings.
The Conn and Listener implementations
in this package now guarantee that when Close returns,
the underlying file descriptor has been closed.
(In earlier releases, if the Close stopped pending I/O
in other goroutines, the closing of the file descriptor could happen in one of those
goroutines shortly after Close returned.)
TCPListener and UnixListener now implement syscall.Conn,
to allow setting options on the underlying file descriptor
using syscall.RawConn.Control.
The Conn implementations returned by Pipe now support setting read and write deadlines.
The IPConn.ReadMsgIP, IPConn.WriteMsgIP, UDPConn.ReadMsgUDP,
and UDPConn.WriteMsgUDP,
methods are now implemented on Windows.
On the client side, an HTTP proxy (most commonly configured by ProxyFromEnvironment)
can now be specified as an https:// URL,
meaning that the client connects to the proxy over HTTPS before issuing a standard, proxied HTTP request.
(Previously, HTTP proxy URLs were required to begin with http:// or socks5://.)
On the server side, FileServer and its single-file equivalent ServeFile now apply If-Range checks to HEAD requests. FileServer also now reports directory read failures to the Server ’s ErrorLog.
The content-serving handlers also now omit the Content-Type header when serving zero-length content.
ResponseWriter ’s WriteHeader method now panics
if passed an invalid (non-3-digit) status code.
The Server will no longer add an implicit Content-Type when a Handler does not write any output.
Redirect now sets the Content-Type header before writing its HTTP response.
ParseAddress and ParseAddressList now support a variety of obsolete address formats.
The Client adds a new Noop method,
to test whether the server is still responding.
It also now defends against possible SMTP injection in the inputs
to the Hello and Verify methods.
ReadMIMEHeader now rejects any header that begins with a continuation (indented) header line.
Previously a header with an indented first line was treated as if the first line
were not indented.
ResolveReference now preserves multiple leading slashes in the target URL.
Previously it rewrote multiple leading slashes to a single slash,
which resulted in the http.Client following certain redirects incorrectly.
For example, this code’s output has changed:
base, _ := url.Parse("http://host//path//to/page1")
target, _ := url.Parse("page2")
fmt.Println(base.ResolveReference(target))
Note the doubled slashes around path.
In Go 1.9 and earlier, the resolved URL was http://host/path//to/page2:
the doubled slash before path was incorrectly rewritten
to a single slash, while the doubled slash after path was
correctly preserved.
Go 1.10 preserves both doubled slashes, resolving to http://host//path//to/page2 as required by RFC 3986.
This change may break existing buggy programs that unintentionally
construct a base URL with a leading doubled slash in the path and inadvertently
depend on ResolveReference to correct that mistake.
For example, this can happen if code adds a host prefix
like http://host/ to a path like /my/api,
resulting in a URL with a doubled slash: http://host//my/api.
UserInfo ’s methods
now treat a nil receiver as equivalent to a pointer to a zero UserInfo.
Previously, they panicked.
File adds new methods SetDeadline, SetReadDeadline,
and SetWriteDeadline that allow setting I/O deadlines when the
underlying file descriptor supports non-blocking I/O operations.
The definition of these methods matches those in net.Conn.
If an I/O method fails due to missing a deadline, it will return a
timeout error; the
new IsTimeout function
reports whether an error represents a timeout.
Also matching net.Conn, File ’s Close method
now guarantee that when Close returns,
the underlying file descriptor has been closed.
(In earlier releases,
if the Close stopped pending I/O
in other goroutines, the closing of the file descriptor could happen in one of those
goroutines shortly after Close returned.)
On BSD, macOS, and Solaris systems, Chtimes now supports setting file times with nanosecond precision
(assuming the underlying file system can represent them).
The Copy function now allows copying
from a string into a byte array or byte slice, to match the built-in copy function.
In structs, embedded pointers to unexported struct types were
previously incorrectly reported with an empty PkgPath in the corresponding StructField,
with the result that for those fields,
and Value.CanSet incorrectly returned true and Value.Set incorrectly succeeded.
The underlying metadata has been corrected;
for those fields, CanSet now correctly returns false
and Set now correctly panics.
This may affect reflection-based unmarshalers
that could previously unmarshal into such fields
but no longer can.
For example, see the encoding/json notes.
As noted above, the blocking and mutex profiles now include symbol information so that they can be viewed without needing the binary that generated them.
ParseUint now returns
the maximum magnitude integer of the appropriate size
with any ErrRange error, as it was already documented to do.
Previously it returned 0 with ErrRange errors.
A new type Builder is a replacement for bytes.Buffer for the use case of
accumulating text into a string result.
The Builder ’s API is a restricted subset of bytes.Buffer ’s
that allows it to safely avoid making a duplicate copy of the data
during the String method.
On Windows,
the new SysProcAttr field Token,
of type Token allows the creation of a process that
runs as another user during StartProcess (and therefore also during os.StartProcess and exec.Cmd.Start).
The new function CreateProcessAsUser gives access to the underlying system call.
On BSD, macOS, and Solaris systems, UtimesNano is now implemented.
LoadLocation now uses the directory
or uncompressed zip file named by the $ZONEINFO environment variable before looking in the default system-specific list of
known installation locations or in $GOROOT/lib/time/zoneinfo.zip.
The new function LoadLocationFromTZData allows conversion of IANA time zone file data to a Location.
The unicode package and associated
support throughout the system has been upgraded from Unicode 9.0 to Unicode 10.0,
which adds 8,518 new characters, including four new scripts, one new property,
a Bitcoin currency symbol, and 56 new emoji.
Update Feb 7, 2018 tracked by Updatify
go1.9.4 (released 2018-02-07) includes a security fix to “go get”. See the Go 1.9.4 milestone on our issue tracker for details.
Update Feb 7, 2018 tracked by Updatify
go1.8.7 (released 2018-02-07) includes a security fix to “go get”. It contains the same fix as Go 1.9.4 and was released at the same time. See the Go 1.8.7 milestone on our issue tracker for details.
Update Jan 22, 2018 tracked by Updatify
go1.9.3 (released 2018-01-22) includes security fixes to the net/url package, as well as bug fixes to the compiler, runtime, and the database/sql, math/big, and net/http packages. See the Go 1.9.3 milestone on our issue tracker for details.
Update Jan 22, 2018 tracked by Updatify
go1.8.6 (released 2018-01-22) includes the same fix in math/big as Go 1.9.3 and was released at the same time. See the Go 1.8.6 milestone on our issue tracker for details.
Update Oct 25, 2017 tracked by Updatify
go1.9.2 (released 2017-10-25) includes fixes to the compiler, linker, runtime, documentation, go command, and the crypto/x509, database/sql, log, and net/smtp packages. It includes a fix to a bug introduced in Go 1.9.1 that broke go get of non-Git repositories under certain conditions. See the Go 1.9.2 milestone on our issue tracker for details.
Update Oct 25, 2017 tracked by Updatify
go1.8.5 (released 2017-10-25) includes fixes to the compiler, linker, runtime, documentation, go command, and the crypto/x509 and net/smtp packages. It includes a fix to a bug introduced in Go 1.8.4 that broke go get of non-Git repositories under certain conditions. See the Go 1.8.5 milestone on our issue tracker for details.
Update Oct 4, 2017 tracked by Updatify
go1.9.1 (released 2017-10-04) includes two security fixes. See the Go 1.9.1 milestone on our issue tracker for details.
Update Oct 4, 2017 tracked by Updatify
go1.8.4 (released 2017-10-04) includes two security fixes. It contains the same fixes as Go 1.9.1 and was released at the same time. See the Go 1.8.4 milestone on our issue tracker for details.
Update Aug 24, 2017 tracked by Updatify
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 are two changes to the language: adding support for type aliases and defining when implementations may fuse floating point operations. 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, includes a new bit manipulation package, and has a new concurrent map type.
There are two changes 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.
A smaller language change is that the language specification
now states when implementations are allowed to fuse floating
point operations together, such as by using an architecture’s “fused
multiply and add” (FMA) instruction to compute x*y + z without rounding the intermediate result x*y.
To force the intermediate rounding, write float64(x*y) + z.
There are no new supported operating systems or processor architectures in this release.
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.
Go 1.9 is the last release that will run on FreeBSD 9.3, which is already unsupported by FreeBSD. Go 1.10 will require FreeBSD 10.3+.
Go 1.9 now enables PT_TLS generation for cgo binaries and thus requires OpenBSD 6.0 or newer. Go 1.9 no longer supports OpenBSD 5.9.
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.
Go stopped running NetBSD builders during the Go 1.9 development cycle due to NetBSD kernel crashes, up to and including NetBSD 7.1. As Go 1.9 is being released, NetBSD 7.1.1 is being released with a fix. However, at this time we have no NetBSD builders passing our test suite. Any help investigating the various NetBSD issues would be appreciated.
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 it can be disabled by setting the
environment variable GO19CONCURRENTCOMPILATION to 0.
By popular request, ./... no longer matches packages
in vendor directories in tools accepting package names,
such as go test. To match vendor
directories, write ./vendor/....
The go tool will now use the path from which it
was invoked to attempt to locate the root of the Go install tree.
This means that if the entire Go installation is moved to a new
location, the go tool should continue to work as usual.
This may be overridden by setting GOROOT in the environment,
which should only be done in unusual circumstances.
Note that this does not affect the result of
the runtime.GOROOT function, which
will continue to report the original installation location;
this may be fixed in later releases.
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.
The compiler now includes lexical scopes in the generated DWARF if the -N -l flags are provided, allowing
debuggers to hide variables that are not in scope. The .debug_info section is now DWARF version 4.
The values of GOARM and GO386 now affect a
compiled package’s build ID, as used by the go tool’s
dependency caching.
The four-operand ARM MULA instruction is now assembled correctly,
with the addend register as the third argument and the result
register as the fourth and final argument.
In previous releases, the two meanings were reversed.
The three-operand form, in which the fourth argument is implicitly
the same as the third, is unaffected.
Code using four-operand MULA instructions
will need to be updated, but we believe this form is very rarely used. MULAWT and MULAWB were already
using the correct order in all forms and are unchanged.
The assembler now supports ADDSUBPS/PD, completing the
two missing x86 SSE3 instructions.
Long lists of arguments are now truncated. This improves the readability
of go doc on some generated code.
Viewing documentation on struct fields is now supported.
For example, go doc http.Client.Jar.
The new go env -json flag
enables JSON output, instead of the default OS-specific output
format.
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.
Profiles produced by the runtime/pprof package now
include symbol information, so they can be viewed
in go tool pprof without the binary that produced the profile.
The go tool pprof command now
uses the HTTP proxy information defined in the environment, using http.ProxyFromEnvironment.
The vet command has been better integrated into the go tool,
so go vet now supports all standard build
flags while vet ’s own flags are now available
from go vet as well as
from go tool vet.
Due to the alignment of Go’s semiannual release schedule with GCC’s annual release schedule, GCC release 7 contains the Go 1.8.3 version of gccgo. We expect that the next release, GCC 8, will contain the Go 1.10 version of gccgo.
Users of runtime.Callers should avoid directly inspecting the resulting PC slice and instead use runtime.CallersFrames to get a complete view of the call stack, or runtime.Caller to get information about a single caller.
This is because an individual element of the PC slice cannot account
for inlined frames or other nuances of the call stack.
Specifically, code that directly iterates over the PC slice and uses
functions such as runtime.FuncForPC to resolve each PC individually will miss inlined frames.
To get a complete view of the stack, such code should instead use CallersFrames.
Likewise, code should not assume that the length returned by Callers is any indication of the call depth.
It should instead count the number of frames returned by CallersFrames.
Code that queries a single caller at a specific depth should use Caller rather than passing a slice of length 1 to Callers.
runtime.CallersFrames has been available since Go 1.7, so code can be updated prior to
upgrading to Go 1.9.
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.
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.
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.
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.
The
new (*T).Helper and (*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.
The new Map type
in the sync package
is a concurrent map with amortized-constant-time loads, stores, and
deletes. It is safe for multiple goroutines to call a Map ’s methods
concurrently.
The runtime/pprof package now supports adding labels to pprof profiler records.
Labels form a key-value map that is used to distinguish calls of the
same function in different contexts when looking at profiles
with the pprof command.
The pprof package’s
new Do function runs code associated with some provided labels. Other new functions
in the package help work with labels.
As always, there are various minor changes and updates to the library, made with the Go 1 promise of compatibility in mind.
The
ZIP Writer now sets the UTF-8 bit in
the FileHeader.Flags when appropriate.
On Linux, Go now calls the getrandom system call
without the GRND_NONBLOCK flag; it will now block
until the kernel has sufficient randomness. On kernels predating
the getrandom system call, Go continues to read
from /dev/urandom.
On Unix systems the environment
variables SSL_CERT_FILE and SSL_CERT_DIR can now be used to override the
system default locations for the SSL certificate file and SSL
certificate files directory, respectively.
The FreeBSD file /usr/local/etc/ssl/cert.pem is
now included in the certificate search path.
The package now supports excluded domains in name constraints.
In addition to enforcing such constraints, CreateCertificate will create certificates with excluded name constraints
if the provided template certificate has the new
field ExcludedDNSDomains populated.
If any SAN extension, including with no DNS names, is present
in the certificate, then the Common Name from Subject is ignored.
In previous releases, the code tested only whether DNS-name SANs were
present in a certificate.
The package will now use a cached Stmt if
available in Tx.Stmt.
This prevents statements from being re-prepared each time Tx.Stmt is called.
The package now allows drivers to implement their own argument checkers by implementing driver.NamedValueChecker.
This also allows drivers to support OUTPUT and INOUT parameter types. Out should be used to return output parameters
when supported by the driver.
Rows.Scan can now scan user-defined string types.
Previously the package supported scanning into numeric types like type Int int64. It now also supports
scanning into string types like type String string.
The new DB.Conn method returns the new Conn type representing an
exclusive connection to the database from the connection pool. All queries run on
a Conn will use the same underlying
connection until Conn.Close is called
to return the connection to the connection pool.
The new NullBytes and NullRawValue represent the ASN.1 NULL type.
The new Encoding.WithPadding method adds support for custom padding characters and disabling padding.
The new field Reader.ReuseRecord controls whether calls to Read may return a slice sharing the backing array of the previous
call’s returned slice for improved performance.
The sharp flag (’ # ’) is now supported when printing
floating point and complex numbers. It will always print a
decimal point
for %e, %E, %f, %F, %g and %G; it will not remove trailing zeros
for %g and %G.
The package now includes 128-bit FNV-1 and FNV-1a hash support with New128 and New128a, respectively.
The package now reports an error if a predefined escaper (one of “html”, “urlquery” and “js”) is found in a pipeline and does not match what the auto-escaper would have decided on its own. This avoids certain security or correctness issues. Now use of one of these escapers is always either a no-op or an error. (The no-op case eases migration from text/template.)
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.
The YCbCr to RGBA conversion formula has been tweaked to ensure that rounding adjustments span the complete [0, 0xffff] RGBA range.
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.
The new IsInt64 and IsUint64 methods report whether an Int may be represented as an int64 or uint64 value.
The new FileHeader.Size field describes the size of a file in a multipart message.
The new Resolver.StrictErrors provides control over how Go’s built-in DNS resolver handles
temporary errors during queries composed of multiple sub-queries,
such as an A+AAAA address lookup.
The new Resolver.Dial allows a Resolver to use a custom dial function.
JoinHostPort now only places an address in square brackets if the host contains a colon.
In previous releases it would also wrap addresses in square brackets if they contained a percent (’ % ’) sign.
The new methods TCPConn.SyscallConn, IPConn.SyscallConn, UDPConn.SyscallConn,
and UnixConn.SyscallConn provide access to the connections’ underlying file descriptors.
It is now safe to call Dial with the address obtained from (*TCPListener).String() after creating the listener with [Listen](https://go.dev/pkg/net/#Listen)(“tcp”, “:0”).
Previously it failed on some machines with half-configured IPv6 stacks.
The Cookie.String method, used for Cookie and Set-Cookie headers, now encloses values in double quotes
if the value contains either a space or a comma.
Server changes:
ServeMux now ignores ports in the host
header when matching handlers. The host is matched unmodified for CONNECT requests. Server.ServeTLS method wraps Server.Serve with added TLS support. Server.WriteTimeout now applies to HTTP/2 connections and is enforced per-stream. StripPrefix now calls its provided handler with a modified clone of the original *http.Request.
Any code storing per-request state in maps keyed by *http.Request should
use Request.Context, Request.WithContext,
and context.WithValue instead. LocalAddrContextKey now contains
the connection’s actual network address instead of the interface address used by the listener. Client & Transport changes:
Transport now supports making requests via SOCKS5 proxy when the URL returned by Transport.Proxy has the scheme socks5.
The new ProcessEnv function returns FastCGI environment variables associated with an HTTP request
for which there are no appropriate http.Request fields, such as REMOTE_USER.
The new Server.Client method returns an HTTP client configured for making requests to the test server.
The new Server.Certificate method returns the test server’s TLS certificate, if any.
The ReverseProxy now proxies all HTTP/2 response trailers, even those not declared in the initial response
header. Such undeclared trailers are used by the gRPC protocol.
The os package now uses the internal runtime poller
for file I/O.
This reduces the number of threads required for read/write
operations on pipes, and it eliminates races when one goroutine
closes a file while another is using the file for I/O.
On Windows, Args is now populated without shell32.dll, improving process start-up time by 1-7 ms.
The os/exec package now prevents child processes from being created with
any duplicate environment variables.
If Cmd.Env contains duplicate environment keys, only the last
value in the slice for each duplicate key is used.
Lookup and LookupId now
work on Unix systems when CGO_ENABLED=0 by reading
the /etc/passwd file.
LookupGroup and LookupGroupId now
work on Unix systems when CGO_ENABLED=0 by reading
the /etc/group file.
The new MakeMapWithSize function creates a map with a capacity hint.
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.
Calling SetGCPercent with a negative value no longer runs an immediate garbage collection.
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.
Mutex is now more fair.
The new field Credential.NoSetGroups controls whether Unix systems make a setgroups system call
to set supplementary groups when starting a new process.
The new field SysProcAttr.AmbientCaps allows setting ambient capabilities on Linux 4.3+ when creating
a new process.
On 64-bit x86 Linux, process creation latency has been optimized with
use of CLONE_VFORK and CLONE_VM.
The new Conn interface describes some types in the net package that can provide access to their underlying file descriptor
using the new RawConn interface.
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 [-2 <sup>62</sup>, 2 <sup>62</sup>) range.
In previous releases, using a nil Config.Rand value caused a fixed deterministic random number generator to be used.
It now uses a random number generator seeded with the current time.
For the old behavior, set Config.Rand to rand.New(rand.NewSource(0)).
The handling of empty blocks, which was broken by a Go 1.8 change that made the result dependent on the order of templates, has been fixed, restoring the old Go 1.7 behavior.
The new methods Duration.Round and Duration.Truncate handle rounding and truncating durations to multiples of a given duration.
Retrieving the time and sleeping now work correctly under Wine.
If a Time value has a monotonic clock reading, its
string representation (as returned by String) now includes a
final field "m=±value", where value is the
monotonic clock reading formatted as a decimal number of seconds.
The included tzdata timezone database has been
updated to version 2017b. As always, it is only used if the
system does not already have the database available.
Update May 24, 2017 tracked by Updatify
go1.8.3 (released 2017-05-24) includes fixes to the compiler, runtime, documentation, and the database/sql package. See the Go 1.8.3 milestone on our issue tracker for details.
Update May 23, 2017 tracked by Updatify
go1.8.2 (released 2017-05-23) includes a security fix to the crypto/elliptic package. See the Go 1.8.2 milestone on our issue tracker for details.
Update May 23, 2017 tracked by Updatify
go1.7.6 (released 2017-05-23) includes the same security fix as Go 1.8.2 and was released at the same time. See the Go 1.8.2 milestone on our issue tracker for details.
Update Apr 7, 2017 tracked by Updatify
go1.8.1 (released 2017-04-07) includes fixes to the compiler, linker, runtime, documentation, go command and the crypto/tls, encoding/xml, image/png, net, net/http, reflect, text/template, and time packages. See the Go 1.8.1 milestone on our issue tracker for details.
Update Feb 16, 2017 tracked by Updatify
The latest Go release, version 1.8, arrives six months after Go 1.7. Most of its changes are in the implementation of the toolchain, runtime, and libraries. There are two minor changes 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 release adds support for 32-bit MIPS, updates the compiler back end to generate more efficient code, reduces GC pauses by eliminating stop-the-world stack rescanning, adds HTTP/2 Push support, adds HTTP graceful shutdown, adds more context support, enables profiling mutexes, and simplifies sorting slices.
When explicitly converting a value from one struct type to another, as of Go 1.8 the tags are ignored. Thus two structs that differ only in their tags may be converted from one to the other:
func example() {
type T1 struct {
X int `json:"foo"`
}
type T2 struct {
X int `json:"bar"`
}
var v1 T1
var v2 T2
v1 = T1(v2) // now legal
}
The language specification now only requires that implementations
support up to 16-bit exponents in floating-point constants. This does not affect
either the “ gc ” or gccgo compilers, both of
which still support 32-bit exponents.
Go now supports 32-bit MIPS on Linux for both big-endian
( linux/mips) and little-endian machines
( linux/mipsle) that implement the MIPS32r1 instruction set with FPU
or kernel FPU emulation. Note that many common MIPS-based routers lack an FPU and
have firmware that doesn’t enable kernel FPU emulation; Go won’t run on such machines.
On DragonFly BSD, Go now requires DragonFly 4.4.4 or later.
On OpenBSD, Go now requires OpenBSD 5.9 or later.
The Plan 9 port’s networking support is now much more complete and matches the behavior of Unix and Windows with respect to deadlines and cancellation. For Plan 9 kernel requirements, see the Plan 9 wiki page.
Go 1.8 now only supports OS X 10.8 or later. This is likely the last Go release to support 10.8. Compiling Go or running binaries on older OS X versions is untested.
Go 1.8 will be the last release to support Linux on ARMv5E and ARMv6 processors:
Go 1.9 will likely require the ARMv6K (as found in the Raspberry Pi 1) or later.
To identify whether a Linux system is ARMv6K or later, run
“ go tool dist -check-armv6k ”
(to facilitate testing, it is also possible to just copy the dist command to the
system without installing a full copy of Go 1.8)
and if the program terminates with output “ARMv6K supported.” then the system
implements ARMv6K or later.
Go on non-Linux ARM systems already requires ARMv6K or later.
zos is now a recognized value for GOOS,
reserved for the z/OS operating system.
There are some instabilities on FreeBSD and NetBSD that are known but not understood. These can lead to program crashes in rare cases. See issue 15658 and issue 16511. Any help in solving these issues would be appreciated.
For 64-bit x86 systems, the following instructions have been added: VBROADCASTSD, BROADCASTSS, MOVDDUP, MOVSHDUP, MOVSLDUP, VMOVDDUP, VMOVSHDUP, and VMOVSLDUP.
For 64-bit PPC systems, the common vector scalar instructions have been
added: LXS, LXSDX, LXSI, LXSIWAX, LXSIWZX, LXV, LXVD2X, LXVDSX, LXVW4X, MFVSR, MFVSRD, MFVSRWZ, MTVSR, MTVSRD, MTVSRWA, MTVSRWZ, STXS, STXSDX, STXSI, STXSIWX, STXV, STXVD2X, STXVW4X, XSCV, XSCVDPSP, XSCVDPSPN, XSCVDPSXDS, XSCVDPSXWS, XSCVDPUXDS, XSCVDPUXWS, XSCVSPDP, XSCVSPDPN, XSCVSXDDP, XSCVSXDSP, XSCVUXDDP, XSCVUXDSP, XSCVX, XSCVXP, XVCV, XVCVDPSP, XVCVDPSXDS, XVCVDPSXWS, XVCVDPUXDS, XVCVDPUXWS, XVCVSPDP, XVCVSPSXDS, XVCVSPSXWS, XVCVSPUXDS, XVCVSPUXWS, XVCVSXDDP, XVCVSXDSP, XVCVSXWDP, XVCVSXWSP, XVCVUXDDP, XVCVUXDSP, XVCVUXWDP, XVCVUXWSP, XVCVX, XVCVXP, XXLAND, XXLANDC, XXLANDQ, XXLEQV, XXLNAND, XXLNOR, XXLOR, XXLORC, XXLORQ, XXLXOR, XXMRG, XXMRGHW, XXMRGLW, XXPERM, XXPERMDI, XXSEL, XXSI, XXSLDWI, XXSPLT, and XXSPLTW.
The yacc tool (previously available by running
“ go tool yacc ”) has been removed.
As of Go 1.7 it was no longer used by the Go compiler.
It has moved to the “tools” repository and is now available at golang.org/x/tools/cmd/goyacc.
The fix tool has a new “ context ”
fix to change imports from “ golang.org/x/net/context ”
to “ context ”.
The pprof tool can now profile TLS servers
and skip certificate validation by using the “ https+insecure ”
URL scheme.
The callgrind output now has instruction-level granularity.
The trace tool has a new -pprof flag for
producing pprof-compatible blocking and latency profiles from an
execution trace.
Garbage collection events are now shown more clearly in the execution trace viewer. Garbage collection activity is shown on its own row and GC helper goroutines are annotated with their roles.
Vet is stricter in some ways and looser where it previously caused false positives.
Vet now checks for copying an array of locks,
duplicate JSON and XML struct field tags,
non-space-separated struct tags,
deferred calls to HTTP Response.Body.Close before checking errors, and
indexed arguments in Printf.
It also improves existing checks.
Go 1.7 introduced a new compiler back end for 64-bit x86 systems. In Go 1.8, that back end has been developed further and is now used for all architectures.
The new back end, based on static single assignment form (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 20-30% on 32-bit ARM systems. For 64-bit x86 systems, which already used the SSA back end in Go 1.7, the gains are a more modest 0-10%. Other architectures will likely see improvements closer to the 32-bit ARM numbers.
The temporary -ssa=0 compiler flag introduced in Go 1.7
to disable the new back end has been removed in Go 1.8.
In addition to enabling the new compiler back end for all systems, Go 1.8 also introduces a new compiler front end. The new compiler front end should not be noticeable to users but is the foundation for future performance work.
The compiler and linker have been optimized and run faster in this release than in Go 1.7, although they are still slower than we would like and will continue to be optimized in future releases. Compared to the previous release, Go 1.8 is about 15% faster.
The Go tool now remembers the value of the CGO_ENABLED environment
variable set during make.bash and applies it to all future compilations
by default to fix issue #12808.
When doing native compilation, it is rarely necessary to explicitly set
the CGO_ENABLED environment variable as make.bash will detect the correct setting automatically. The main reason to explicitly
set the CGO_ENABLED environment variable is when your environment
supports cgo, but you explicitly do not want cgo support, in which case, set CGO_ENABLED=0 during make.bash or all.bash.
The environment variable PKG_CONFIG may now be used to
set the program to run to handle #cgo pkg-config directives. The default is pkg-config, the program
always used by earlier releases. This is intended to make it easier
to cross-compile cgo code.
The cgo tool now supports a -srcdir option, which is used by the go command.
If cgo code calls C.malloc, and malloc returns NULL, the program will now
crash with an out of memory error. C.malloc will never return nil.
Unlike most C functions, C.malloc may not be used in a
two-result form returning an errno value.
If cgo is used to call a C function passing a pointer to a C union, and if the C union can contain any pointer values, and if cgo pointer checking is enabled (as it is by default), the union value is now checked for Go pointers.
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. We expect that the next release, GCC 7, will contain the Go 1.8 version of gccgo.
The GOPATH environment variable now has a default value if it
is unset. It defaults to $HOME/go on Unix and %USERPROFILE%/go on Windows.
The “ go get ” command now always respects
HTTP proxy environment variables, regardless of whether
the -insecure flag is used. In previous releases, the -insecure flag had the side effect of not using proxies.
The new
“ go bug ”
command starts a bug report on GitHub, prefilled
with information about the current system.
The
“ go doc ”
command now groups constants and variables with their type,
following the behavior of godoc.
In order to improve the readability of doc ’s
output, each summary of the first-level items is guaranteed to
occupy a single line.
Documentation for a specific method in an interface definition can
now be requested, as in
“ go doc net.Conn.SetDeadline ”.
Go now provides early support for plugins with a “ plugin ”
build mode for generating plugins written in Go, and a
new plugin package for
loading such plugins at run time. Plugin support is currently only
available on Linux. Please report any issues.
The garbage collector no longer considers
arguments live throughout the entirety of a function. For more
information, and for how to force a variable to remain live, see
the runtime.KeepAlive function added in Go 1.7.
Updating: Code that sets a finalizer on an allocated object may need to add
calls to runtime.KeepAlive in functions or methods
using that object.
Read the KeepAlive documentation and its example for more details.
In Go 1.6, the runtime added lightweight, best-effort detection of concurrent misuse of maps. This release improves that detector with support for detecting programs that concurrently write to and iterate over a map.
As always, if one goroutine is writing to a map, no other goroutine should be reading (which includes iterating) or writing the map concurrently. If the runtime detects this condition, it prints a diagnosis and crashes the program. The best way to find out more about the problem is to run the program under the race detector, which will more reliably identify the race and give more detail.
The runtime.MemStats type has been more thoroughly documented.
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 standard library.
There have been optimizations to implementations in the bytes, crypto/aes, crypto/cipher, crypto/elliptic, crypto/sha256, crypto/sha512, encoding/asn1, encoding/csv, encoding/hex, encoding/json, hash/crc32, image/color, image/draw, math, math/big, reflect, regexp, runtime, strconv, strings, syscall, text/template, and unicode/utf8 packages.
Garbage collection pauses should be significantly shorter than they were in Go 1.7, usually under 100 microseconds and often as low as 10 microseconds. See the document on eliminating stop-the-world stack re-scanning for details. More work remains for Go 1.9.
The overhead of deferred function calls has been reduced by about half.
The overhead of calls from Go into C has been reduced by about half.
Examples have been added to the documentation across many packages.
The sort package
now includes a convenience function Slice to sort a
slice given a less function.
In many cases this means that writing a new sorter type is not
necessary.
Also new are SliceStable and SliceIsSorted.
The net/http package now includes a
mechanism to
send HTTP/2 server pushes from a Handler.
Similar to the existing Flusher and Hijacker interfaces, an HTTP/2 ResponseWriter now implements the new Pusher interface.
The HTTP Server now has support for graceful shutdown using the new Server.Shutdown method and abrupt shutdown using the new Server.Close method.
Continuing Go 1.7’s adoption of context.Context into the standard library, Go 1.8 adds more context support
to existing packages:
Server.Shutdown takes a context argument. Lookup methods on the new net.Resolver now
take a context. The runtime and tools now support profiling contended mutexes.
Most users will want to use the new -mutexprofile flag with “ go test ”,
and then use pprof on the resultant file.
Lower-level support is also available via the new MutexProfile and SetMutexProfileFraction.
A known limitation for Go 1.8 is that the profile only reports contention for sync.Mutex,
not sync.RWMutex.
As always, there are various minor changes and updates to the library, made with the Go 1 promise of compatibility in mind. The following sections list the user visible changes and additions. Optimizations and minor bug fixes are not listed.
The tar implementation corrects many bugs in corner cases of the file format.
The Reader is now able to process tar files in the PAX format with entries larger than 8GB.
The Writer no longer produces invalid tar files in some situations involving long pathnames.
There have been some minor fixes to the encoder to improve the
compression ratio in certain situations. As a result, the exact
encoded output of DEFLATE may be different from Go 1.7. Since DEFLATE is the underlying compression of gzip, png, zlib, and zip,
those formats may have changed outputs.
The encoder, when operating in NoCompression mode, now produces a consistent output that is not dependent on
the size of the slices passed to the Write method.
The decoder, upon encountering an error, now returns any buffered data it had uncompressed along with the error.
The Writer now encodes a zero MTIME field when
the Header.ModTime field is the zero value.
In previous releases of Go, the Writer would encode
a nonsensical value.
Similarly,
the Reader now reports a zero encoded MTIME field as a zero Header.ModTime.
The DeadlineExceeded error now implements net.Error and reports true for both the Timeout and Temporary methods.
The new method Conn.CloseWrite allows TLS connections to be half closed.
The new method Config.Clone clones a TLS configuration.
The new Config.GetConfigForClient callback allows selecting a configuration for a client dynamically, based
on the client’s ClientHelloInfo. The ClientHelloInfo struct now has new
fields Conn, SignatureSchemes (using
the new
type SignatureScheme), SupportedProtos, and SupportedVersions.
The new Config.GetClientCertificate callback allows selecting a client certificate based on the server’s
TLS CertificateRequest message, represented by the new CertificateRequestInfo.
The new Config.KeyLogWriter allows debugging TLS connections
in WireShark and
similar tools.
The new Config.VerifyPeerCertificate callback allows additional validation of a peer’s presented certificate.
The crypto/tls package now implements basic
countermeasures against CBC padding oracles. There should be
no explicit secret-dependent timings, but it does not attempt to
normalize memory accesses to prevent cache timing leaks.
The crypto/tls package now supports
X25519 and ChaCha20-Poly1305. ChaCha20-Poly1305 is now prioritized unless hardware support for AES-GCM is present.
AES-128-CBC cipher suites with SHA-256 are also now supported, but disabled by default.
PSS signatures are now supported.
UnknownAuthorityError now has a Cert field, reporting the untrusted
certificate.
Certificate validation is more permissive in a few cases and stricter in a few other cases.
Root certificates will now also be looked for
at /etc/pki/ca-trust/extracted/pem/tls-ca-bundle.pem on Linux, to support RHEL and CentOS.
The package now supports context.Context. There are new methods
ending in Context such as DB.QueryContext and DB.PrepareContext that take context arguments. Using the new Context methods ensures that
connections are closed and returned to the connection pool when the
request is done; enables canceling in-progress queries
should the driver support that; and allows the database
pool to cancel waiting for the next available connection.
The IsolationLevel can now be set when starting a transaction by setting the isolation level
on TxOptions.Isolation and passing
it to DB.BeginTx.
An error will be returned if an isolation level is selected that the driver
does not support. A read-only attribute may also be set on the transaction
by setting TxOptions.ReadOnly to true.
Queries now expose the SQL column type information for drivers that support it.
Rows can return ColumnTypes which can include SQL type information, column type lengths, and the Go type.
A Rows can now represent multiple result sets. After Rows.Next returns false, Rows.NextResultSet may be called to advance to the next result set. The existing Rows should continue to be used after it advances to the next result set.
NamedArg may be used
as query arguments. The new function Named helps create a NamedArg more succinctly.
If a driver supports the new Pinger interface, the DB.Ping and DB.PingContext methods will use that interface to check whether a
database connection is still valid.
The new Context query methods work for all drivers, but Context cancellation is not responsive unless the driver has been
updated to use them. The other features require driver support in database/sql/driver.
Driver authors should review the new interfaces. Users of existing
driver should review the driver documentation to see what
it supports and any system specific documentation on each feature.
The package has been extended and is now used by the Go linker to read gcc -generated object files.
The new File.StringTable and Section.Relocs fields provide access to the COFF string table and COFF relocations.
The new File.COFFSymbols allows low-level access to the COFF symbol table.
The new Encoding.Strict method returns an Encoding that causes the decoder
to return an error when the trailing padding bits are not zero.
Read and Write now support booleans.
UnmarshalTypeError now includes the struct and field name.
A nil Marshaler now marshals as a JSON null value.
A RawMessage value now
marshals the same as its pointer type.
Marshal encodes floating-point numbers using the same format as in ES6,
preferring decimal (not exponential) notation for a wider range of values.
In particular, all floating-point integers up to 2 <sup>64</sup> format the
same as the equivalent int64 representation.
In previous versions of Go, unmarshaling a JSON null into an Unmarshaler was considered a no-op; now the Unmarshaler ’s UnmarshalJSON method is called with the JSON literal null and can define the semantics of that case.
Decode is now strict about the format of the ending line.
Unmarshal now has wildcard support for collecting all attributes using
the new ",any,attr" struct tag.
The new methods Int.Value, String.Value, Float.Value, and Func.Value report the current value of an exported variable.
The new
function Handler returns the package’s HTTP handler, to enable installing it in
non-standard locations.
Scanf, Fscanf, and Sscanf now
handle spaces differently and more consistently than
previous releases. See the scanning documentation for details.
The new IsPredeclared function reports whether a string is a predeclared identifier.
The new function Default returns the default “typed” type for an “untyped” type.
The alignment of complex64 now matches
the Go compiler.
The package now validates
the "type" attribute on
a <script> tag.
Decode (and DecodeConfig)
now supports True Color and grayscale transparency.
Encoder is now faster and creates smaller output
when encoding paletted images.
The new method Int.Sqrt calculates ⌊√x⌋.
The new method Float.Scan is a support routine for fmt.Scanner.
Int.ModInverse now supports negative numbers.
The new Rand.Uint64 method returns uint64 values. The
new Source64 interface describes sources capable of generating such values
directly; otherwise the Rand.Uint64 method
constructs a uint64 from two calls
to Source ’s Int63 method.
ParseMediaType now preserves unnecessary backslash escapes as literals,
in order to support MSIE.
When MSIE sends a full file path (in “intranet mode”), it does not
escape backslashes: “ C:\dev\go\foo.txt ”, not
“ C:\\dev\\go\\foo.txt ”.
If we see an unnecessary backslash escape, we now assume it is from MSIE
and intended as a literal backslash.
No known MIME generators emit unnecessary backslash escapes
for simple token characters like numbers and letters.
The Reader ’s
parsing has been relaxed in two ways to accept
more input seen in the wild. First, it accepts an equals sign ( =) not followed
by two hex digits as a literal equal sign. Second, it silently ignores a trailing equals sign at the end of
an encoded input.
The Conn documentation
has been updated to clarify expectations of an interface
implementation. Updates in the net/http packages
depend on implementations obeying the documentation.
Updating: implementations of the Conn interface should verify
they implement the documented semantics. The golang.org/x/net/nettest package will exercise a Conn and validate it behaves properly.
The new method UnixListener.SetUnlinkOnClose sets whether the underlying socket file should be removed from the file system when
the listener is closed.
The new Buffers type permits
writing to the network more efficiently from multiple discontiguous buffers
in memory. On certain machines, for certain types of connections,
this is optimized into an OS-specific batch write operation (such as writev).
The new Resolver looks up names and numbers
and supports context.Context.
The Dialer now has an optional Resolver field.
Interfaces is now supported on Solaris.
The Go DNS resolver now supports resolv.conf ’s “ rotate ”
and “ option ndots:0 ” options. The “ ndots ” option is
now respected in the same way as libresolve.
Server changes:
Server adds configuration options ReadHeaderTimeout and IdleTimeout and documents WriteTimeout. FileServer and ServeContent now support HTTP If-Match conditional requests,
in addition to the previous If-None-Match support for ETags properly formatted according to RFC 7232, section 2.3.
There are several additions to what a server’s Handler can do:
Context returned
by Request.Context is canceled if the underlying net.Conn closes. For instance, if the user closes their browser in the
middle of a slow request, the Handler can now
detect that the user is gone. This complements the
existing CloseNotifier support. This functionality requires that the underlying net.Conn implements recently clarified interface documentation. TrailerPrefix mechanism. Handler can now abort a response by panicking
with the error ErrAbortHandler. Write of zero bytes to a ResponseWriter is now defined as a
way to test whether a ResponseWriter has been hijacked:
if so, the Write returns ErrHijacked without printing an error
to the server’s error log. Client & Transport changes:
Client now copies most request headers on redirect. See the documentation on the Client type for details. Transport now supports international domain names. Consequently, so do Get and other helpers. Client now supports 301, 307, and 308 redirects.
For example, Client.Post now follows 301
redirects, converting them to GET requests
without bodies, like it did for 302 and 303 redirect responses
previously.
The Client now also follows 307 and 308
redirects, preserving the original request method and body, if
any. If the redirect requires resending the request body, the
request must have the new Request.GetBody field defined. NewRequest sets Request.GetBody automatically for common
body types. Transport now rejects requests for URLs with
ports containing non-digit characters. Transport will now retry non-idempotent
requests if no bytes were written before a network failure
and the request has no body. Transport.ProxyConnectHeader allows configuration of header values to send to a proxy
during a CONNECT request. DefaultTransport.Dialer now enables DualStack (“ Happy Eyeballs “) support,
allowing the use of IPv4 as a backup if it looks like IPv6 might be
failing. Transport no longer reads a byte of a non-nil Request.Body when the Request.ContentLength is zero to determine whether the ContentLength is actually zero or just undefined.
To explicitly signal that a body has zero length,
either set it to nil, or set it to the new value NoBody.
The new NoBody value is intended for use by Request constructor functions; it is used by NewRequest.
There is now support for tracing a client request’s TLS handshakes with
the new ClientTrace.TLSHandshakeStart and ClientTrace.TLSHandshakeDone.
The ReverseProxy has a new optional hook, ModifyResponse,
for modifying the response from the back end before proxying it to the client.
Empty quoted strings are once again allowed in the name part of
an address. That is, Go 1.4 and earlier accepted "" <gopher@example.com>,
but Go 1.5 introduced a bug that rejected this address.
The address is recognized again.
The Header.Date method has always provided a way to parse
the Date: header.
A new function ParseDate allows parsing dates found in other
header lines, such as the Resent-Date: header.
If an implementation of the Auth.Start method returns an empty toServer value,
the package no longer sends
trailing whitespace in the SMTP AUTH command,
which some servers rejected.
The new functions PathEscape and PathUnescape are similar to the query escaping and unescaping functions but
for path elements.
The new methods URL.Hostname and URL.Port return the hostname and port fields of a URL,
correctly handling the case where the port may not be present.
The existing method URL.ResolveReference now properly handles paths with escaped bytes without losing
the escaping.
The URL type now implements encoding.BinaryMarshaler and encoding.BinaryUnmarshaler,
making it possible to process URLs in gob data.
Following RFC 3986, Parse now rejects URLs like this_that:other/thing instead of
interpreting them as relative paths ( this_that is not a valid scheme).
To force interpretation as a relative path,
such URLs should be prefixed with “ ./ ”.
The URL.String method now inserts this prefix as needed.
The new function Executable returns
the path name of the running executable.
An attempt to call a method on
an os.File that has
already been closed will now return the new error
value os.ErrClosed.
Previously it returned a system-specific error such
as syscall.EBADF.
On Unix systems, os.Rename will now return an error when used to rename a directory to an
existing empty directory.
Previously it would fail when renaming to a non-empty directory
but succeed when renaming to an empty directory.
This makes the behavior on Unix correspond to that of other systems.
On Windows, long absolute paths are now transparently converted to
extended-length paths (paths that start with “ \\?\ ”).
This permits the package to work with files whose path names are
longer than 260 characters.
On Windows, os.IsExist will now return true for the system
error ERROR_DIR_NOT_EMPTY.
This roughly corresponds to the existing handling of the Unix
error ENOTEMPTY.
On Plan 9, files that are not served by #M will now
have ModeDevice set in
the value returned
by FileInfo.Mode.
A number of bugs and corner cases on Windows were fixed: Abs now calls Clean as documented, Glob now matches
“ \\?\c:\* ”, EvalSymlinks now
correctly handles “ C:. ”, and Clean now properly
handles a leading “ .. ” in the path.
The new function Swapper was
added to support sort.Slice.
The Unquote function now strips carriage returns ( \r) in
backquoted raw strings, following the Go language semantics.
The Getpagesize now returns the system’s size, rather than a constant value.
Previously it always returned 4KB.
The signature
of Utimes has
changed on Solaris to match all the other Unix systems’
signature. Portable code should continue to use os.Chtimes instead.
The X__cmsg_data field has been removed from Cmsghdr.
Template.Execute can now take a reflect.Value as its data
argument, and FuncMap functions can also accept and return reflect.Value.
The new function Until complements
the analogous Since function.
ParseDuration now accepts long fractional parts.
Parse now rejects dates before the start of a month, such as June 0;
it already rejected dates beyond the end of the month, such as
June 31 and July 32.
The tzdata database has been updated to version
2016j for systems that don’t already have a local time zone
database.
The new method T.Name (and B.Name) returns the name of the current
test or benchmark.
The new function CoverMode reports the test coverage mode.
Tests and benchmarks are now marked as failed if the race detector is enabled and a data race occurs during execution. Previously, individual test cases would appear to pass, and only the overall execution of the test binary would fail.
The signature of the MainStart function has changed, as allowed by the documentation. It is an
internal detail and not part of the Go 1 compatibility promise.
If you’re not calling MainStart directly but see
errors, that likely means you set the
normally-empty GOROOT environment variable and it
doesn’t match the version of your go command’s binary.
SimpleFold now returns its argument unchanged if the provided input was an invalid rune.
Previously, the implementation failed with an index bounds check panic.
Update Jan 26, 2017 tracked by Updatify
go1.7.5 (released 2017-01-26) includes fixes to the compiler, runtime, and the crypto/x509 and time packages. See the Go 1.7.5 milestone on our issue tracker for details.