This page summarizes the changes between official stable releases of Go. Between releases we issue less stable weekly snapshots. The weekly snapshot history contains more detail, and the Mercurial change log has full details.
To update to a specific release, use:
hg pull hg update release.rNN
The r57 release corresponds to
weekly.2011-04-27
with additional bug fixes.
This section highlights the most significant changes in this release.
For a more detailed summary, see the
The weekly release notes.
For complete information, see the
Mercurial change list.
The new gofix tool finds Go programs that use old APIs and rewrites them to use newer ones. After you update to a new Go release, gofix helps make the necessary changes to your programs. Gofix will handle the http, os, and syscall package changes described below, and we will update the program to keep up with future changes to the libraries. Gofix can’t handle all situations perfectly, so read and test the changes it makes before committing them. See the gofix blog post for more information.
Multiple assignment syntax replaces the closed
function.
The syntax for channel
receives allows an optional second assigned value, a boolean value
indicating whether the channel is closed. This code:
v := <-ch if closed(ch) { // channel is closed }
should now be written as:
v, ok := <-ch if !ok { // channel is closed }
Unused labels are now illegal, just as unused local variables are.
Package gob will now encode and decode values of types that implement the GobEncoder and GobDecoder interfaces. This allows types with unexported fields to transmit self-consistent descriptions; examples include big.Int and big.Rat.
Package http has been redesigned. For clients, there are new Client and Transport abstractions that give more control over HTTP details such as headers sent and redirections followed. These abstractions make it easy to implement custom clients that add functionality such as OAuth2. For servers, ResponseWriter has dropped its non-essential methods. The Hijack and Flush methods are no longer required; code can test for them by checking whether a specific value implements Hijacker or Flusher. The RemoteAddr and UsingTLS methods are replaced by Request's RemoteAddr and TLS fields. The SetHeader method is replaced by a Header method; its result, of type Header, implements Set and other methods.
Package net
drops the laddr
argument from Dial
and drops the cname
return value
from LookupHost.
The implementation now uses cgo to implement
network name lookups using the C library getaddrinfo(3)
function when possible. This ensures that Go and C programs
resolve names the same way and also avoids the OS X
application-level firewall.
Package os introduces simplified Open and Create functions. The original Open is now available as OpenFile. The final three arguments to StartProcess have been replaced by a pointer to a ProcAttr.
Package reflect has been redesigned.
Type is now an interface that implements
all the possible type methods.
Instead of a type switch on a Type t
, switch on t.Kind()
.
Value is now a struct value that
implements all the possible value methods.
Instead of a type switch on a Value v
, switch on v.Kind()
.
Typeof and NewValue are now called TypeOf and ValueOf
To create a writable Value, use New(t).Elem()
instead of Zero(t)
.
See the change description
for the full details.
The new API allows a more efficient implementation of Value
that avoids many of the allocations required by the previous API.
Remember that gofix will handle the bulk of the rewrites necessary for these changes to package APIs.
Gofix, a new command, is described above.
Gotest is now a Go program instead of a shell script.
The new -test.short
flag in combination with package testing's Short function
allows you to write tests that can be run in normal or “short” mode;
all.bash runs tests in short mode to reduce installation time.
The Makefiles know about the flag: use make testshort
.
The run-time support now implements CPU and memory profiling.
Gotest's new
-test.cpuprofile
and
-test.memprofile
flags make it easy to
profile tests.
To add profiling to your web server, see the http/pprof
documentation.
For other uses, see the runtime/pprof documentation.
The r56 release was the first stable release and corresponds to
weekly.2011-03-07.1
.
The numbering starts at 56 because before this release,
what we now consider weekly snapshots were called releases.