The latest Go release, version 1.3, arrives six months after 1.2, and contains no language changes. It focuses primarily on implementation work, providing precise garbage collection, a major refactoring of the compiler tool chain that results in faster builds, especially for large projects, significant performance improvements across the board, and support for Solaris and Google's Native Client architecture (NaCl). It also has an important refinement to the memory model regarding synchronization. As always, Go 1.3 keeps the promise of compatibility, and almost everything will continue to compile and run without change when moved to 1.3.
Support for the Native Client virtual machine architecture has returned to Go with the 1.3 release.
It runs on the 32-bit Intel architectures (GOARCH=386
) and also on 64-bit Intel, but using
32-bit pointers (GOARCH=amd64p32
).
There is not yet support for Native Client on ARM.
Note that this is Native Client (NaCl), not Portable Native Client (PNaCl).
Details about Native Client are here;
how to set up the Go version is described here.
Go 1.3 now includes experimental support for Solaris on the amd64
(64-bit x86) architecture.
Microsoft stopped supporting Windows 2000 in 2010. Since it has implementation difficulties regarding exception handling (signals in Unix terminology), as of Go 1.3 it is not supported by Go either.
It was not announced at the time, but since the release of Go 1.2, support for Go on FreeBSD requires FreeBSD 8 or above.
As of Go 1.3, support for Go on FreeBSD requires that the kernel be compiled with the
COMPAT_FREEBSD32
flag configured.
The Go 1.3 memory model adds a new rule concerning sending and receiving on buffered channels, to make explicit that a buffered channel can be used as a simple semaphore, using a send into the channel to acquire and a receive from the channel to release. This is not a language change, just a clarification about an expected property of communication.
Go 1.3 has changed the implementation of goroutine stacks away from the old, "segmented" model to a contiguous model. When a goroutine needs more stack than is available, its stack is transferred to a larger single block of memory. The overhead of this transfer operation amortizes well and eliminates the old "hot spot" problem when a calculation repeatedly steps across a segment boundary. Details including performance numbers are in this design document.
Go 1.2 increased the minimum stack size to 8 kilobytes; with the new stack model, it has been put back to 4 kilobytes.
For a while now, the garbage collector has been precise when examining values in the heap; the Go 1.3 release adds equivalent precision to values on the stack. This means that a non-pointer Go value such as an integer will never be mistaken for a pointer and prevent unused memory from being reclaimed.
As part of the general overhaul to
the Go linker, the compilers and linkers have been refactored.
The linker is still a C program, but now the instruction selection phase that
was part of the linker has been moved to the compiler through the creation of a new
library called liblink
.
By doing instruction selection only once, when the package is first compiled,
this can speed up compilation of large projects significantly.
Updating: Although this is a major internal change, it should have no effect on programs.
GCC release 4.9 will contain the Go 1.2 (not 1.3) version of gccgo. The release schedules for the GCC and Go projects do not coincide, which means that 1.3 will be available in the development branch but that the next GCC release, 4.10, will likely have the Go 1.4 version of gccgo.
The cmd/go
command has several new
features.
The go run
and
go test
subcommands
support a new -exec
option to specify an alternate
way to run the resulting binary.
Its immediate purpose is to support NaCl.
The test coverage support of the go test
subcommand now automatically sets the coverage mode to -atomic
when the race detector is enabled, to eliminate false reports about unsafe
access to coverage counters.
Finally, the go command now supports packages that import Objective-C
files (suffixed .m
) through cgo.
In the gc tool chain, the assemblers now use the
same command-line flag parsing rules as the Go flag package, a departure
from the traditional Unix flag parsing. This may affect scripts that invoke
the tool directly.
For example,
go tool 6a -SDfoo
must now be written
go tool 6a -S -D foo
.
(The same change was made to the compilers and linkers in Go 1.1.)
The program misc/benchcmp
that compares
performance across benchmarking runs has been rewritten.
Once a shell and awk script in the main repository, it is now a Go program in the go.tools
repo.
Documentation is here.
For the few of us that build Go distributions, the tool misc/dist
has been
moved and renamed; it now lives in misc/makerelease
, still in the main repository.
The performance of Go binaries for this release has improved in many cases due to changes in the runtime and garbage collection, plus some changes to libraries. Significant instances include:
regexp
is now significantly faster for certain simple expressions due to the implementation of
a second, one-pass execution engine. The choice of which engine to use is automatic;
the details are hidden from the user.
Also, the runtime now includes in stack dumps how long a goroutine has been blocked, which can be useful information when debugging deadlocks or performance issues.
No new packages appear in the core libraries in Go 1.3.
A previous bug in crypto/tls
made it possible to skip verification in TLS inadvertently.
In Go 1.3, the bug is fixed: one must specify either ServerName or
InsecureSkipVerify, and if ServerName is specified it is enforced.
This may break existing code that incorrectly depended on insecure
behavior.
There is an important new type added to the standard library: sync.Pool
.
It provides an efficient mechanism for implementing certain types of caches whose memory
can be reclaimed automatically by the system.
The testing
package's benchmarking helper,
B
, now has a
RunParallel
method
to make it easier to run benchmarks that exercise multiple CPUs.
Updating: The crypto/tls fix may break existing code, but such code was erroneous and should be updated.
The following list summarizes a number of minor changes to the library, mostly additions. See the relevant package documentation for more information about each change.
Pow
,
now specifies the behavior when the first argument is zero. It was undefined before.
The details are in the documentation for the function.
crypto/tls
package,
a new DialWithDialer
function lets one establish a TLS connection using an existing dialer, making it easier
to control dial options such as timeouts.
The package also now reports the TLS version used by the connection in the
ConnectionState
struct.
CreateCertificate
function of the crypto/tls
package
now supports parsing (and elsewhere, serialization) of PKCS #10 certificate
signature requests.
fmt
package now define %F
as a synonym for %f
when printing floating-point values.
net/http
package now exposes the
properties of a TLS connection used to make a client request in the new
Response.TLS
field.
net/http
package now
allows setting an optional server error logger
with Server.ErrorLog
.
The default is still that all errors go to stderr.
net/http
package now
supports disabling HTTP keep-alive connections on the server
with Server.SetKeepAlivesEnabled
.
The default continues to be that the server does keep-alive (reuses
connections for multiple requests) by default. Only
resource-constrained servers or those in the process of graceful
shutdown will want to disable them.
net/http
package adds an optional
Transport.TLSHandshakeTimeout
setting to cap the amount of time HTTP client requests will wait for
TLS handshakes to complete. It's now also set by default
on DefaultTransport
.
net/http
package's
DefaultTransport
,
used by the HTTP client code, now
enables TCP
keep-alives by
default. Other Transport
values with a nil Dial
field continue to function the same
as before: no TCP keep-alives are used.
net/http
package
now enables TCP
keep-alives for incoming server requests when
ListenAndServe
or
ListenAndServeTLS
are used. When a server is started otherwise, TCP keep-alives are not enabled.
net/http
package now
provides an
optional Server.ConnState
callback to hook various phases of a server connection's lifecycle
(see ConnState
). This
can be used to implement rate limiting or graceful shutdown.
net/http
package's HTTP
client now has an
optional Client.Timeout
field to specify an end-to-end timeout on requests made using the
client.
net
package,
the Dialer
struct now
has a KeepAlive
option to specify a keep-alive period for the connection.
net/http
package's
Transport
now closes Request.Body
consistently, even on error.
os/exec
package now implements
what the documentation has always said with regard to relative paths for the binary.
In particular, it only calls LookPath
when the binary's file name contains no path separators.
runtime.Goexit
and all other goroutines finish execution, the program now always crashes,
reporting a detected deadlock.
Earlier versions of Go handled this situation inconsistently: most instances
were reported as deadlocks, but some trivial cases exited cleanly instead.
CanBackquote
function in the strconv
package
now considers the DEL
character, U+007F
, to be
non-printing.
syscall
package now
supports the cdecl calling convention through the addition of a new function
NewCallbackCDecl
alongside the existing function
NewCallback
.
testing
package now
diagnoses tests that call panic(nil)
, which are almost always erroneous.
unicode
package and associated
support throughout the system has been upgraded from
Unicode 6.2.0 to Unicode 6.3.0.