RED TEXT IS FROM THE 1.1 DOC AND NEEDS TO BE UPDATED. (It is here for formatting and style reference.)
The release of Go version 1 (Go 1 or Go 1.0 for short) in March of 2012 introduced a new period of stability in the Go language and libraries. That stability has helped nourish a growing community of Go users and systems around the world. Several "point" releases since then—1.0.1, 1.0.2, and 1.0.3—have been issued. These point releases fixed known bugs but made no non-critical changes to the implementation.
This new release, Go 1.1, keeps the promise of compatibility but adds a couple of significant (backwards-compatible, of course) language changes, has a long list of (again, compatible) library changes, and includes major work on the implementation of the compilers, libraries, and run-time. The focus is on performance. Benchmarking is an inexact science at best, but we see significant, sometimes dramatic speedups for many of our test programs. We trust that many of our users' programs will also see improvements just by updating their Go installation and recompiling.
This document summarizes the changes between Go 1 and Go 1.2. Very little if any code will need modification to run with Go 1.1, although a couple of rare error cases surface with this release and need to be addressed if they arise. Details appear below; see the discussion of XXX.
The Go compatibility document promises that programs written to the Go 1 language specification will continue to operate, and those promises are maintained. In the interest of firming up the specification, though, there are details about some error cases that have been clarified. There are also some new language features.
cmd/gc: three-index slicing to set cap as well as length (CL 10743046).
The GCC release schedule does not coincide with the Go release schedule, so some skew is inevitable in
gccgo's releases.
The 4.8.0 version of GCC shipped in March, 2013 and includes a nearly-Go 1.1 version of gccgo.
Its library is a little behind the release, but the biggest difference is that method values are not implemented.
Sometime around July 2013, we expect 4.8.2 of GCC to ship with a gccgo
providing a complete Go 1.1 implementaiton.
TODO: write prose
The Go 1.1 tool chain adds experimental support for freebsd/arm,
netbsd/386, netbsd/amd64, netbsd/arm,
openbsd/386 and openbsd/amd64 platforms.
An ARMv6 or later processor is required for freebsd/arm or
netbsd/arm.
Go 1.1 adds experimental support for cgo on linux/arm.
The performance of code compiled with the Go 1.1 gc tool suite should be noticeably better for most Go programs. Typical improvements relative to Go 1.0 seem to be about 30%-40%, sometimes much more, but occasionally less or even non-existent. There are too many small performance-driven tweaks through the tools and libraries to list them all here, but the following major changes are worth noting:
TODO: choose which to call out
The various routines to scan textual input in the
bufio
package,
ReadBytes,
ReadString
and particularly
ReadLine,
are needlessly complex to use for simple purposes.
In Go 1.1, a new type,
Scanner,
has been added to make it easier to do simple tasks such as
read the input as a sequence of lines or space-delimited words.
It simplifies the problem by terminating the scan on problematic
input such as pathologically long lines, and having a simple
default: line-oriented input, with each line stripped of its terminator.
Here is code to reproduce the input a line at a time:
Updating:
To correct breakage caused by the new struct field,
go fix will rewrite code to add tags for these types.
More generally, go vet will identify composite literals that
should be revised to use field tags.
To make it easier for binary distributions to access them if desired, the exp
and old source subtrees, which are not included in binary distributions,
have been moved to the new go.exp subrepository at
code.google.com/p/go.exp. To access the ssa package,
for example, run
There are three new packages.
go/format package provides
a convenient way for a program to access the formatting capabilities of the
go fmt command.
It has two functions,
Node to format a Go parser
Node,
and
Source
to reformat arbitrary Go source code into the standard format as provided by the
go fmt command.
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.
archive/zip package
adds the
DataOffset accessor
to return the offset of a file's (possibly compressed) data within the archive.
bufio package
adds Reset
methods to Reader and
Writer.
These methods allow the Readers
and Writers
to be re-used on new input and output readers and writers, saving
allocation overhead.
compress/bzip2
can now decompress concatenated archives.
compress/flate
package adds a Reset
method on the Writer,
allowing compression of one file to start with another's dictionary.
container/heap package
adds a Fix
method to provide a more efficient way to update an item's position in the heap.
container/list package
adds the MoveBefore
and
MoveAfter
methods, which implement the obvious rearrangement.
crypto/cipher package
adds the a new GCM mode (Galois Counter Mode), which is almost always
used with AES encryption.
crypto/md5 package
adds a new Sum function
to simplify hashing without sacrificing performance.
crypto/sha1 package
adds a new Sum function.
crypto/sha256 package
adds Sum256
and Sum224 functions.
crypto/sha512 package
adds Sum512 and
Sum384 functions.
crypto/x509 package
adds support for reading and writing arbitrary extensions.
crypto/tls package adds
support for TLS 1.1, 1.2 and AES-GCM.
database/sql package adds a
SetMaxOpenConns
method on DB to limit the
number of open connections to the database.
encoding/csv package
now always allows trailing commas on fields.
encoding/gob package
now supports the generic encoding interfaces of the
encoding package
described above.
encoding/json package
now will alway escape ampersands as "\u0026" when printing strings.
It will now accept but correct invalid UTF-8 in
Marshal
(such input was previously rejected).
Finally, it now supports the generic encoding interfaces of the
encoding package
described above.
encoding/xml package
now allows attributes stored in pointers to be marshaled.
It also supports the generic encoding interfaces of the
encoding package
described above through the new
Marshaler,
UnMarshaler,
and related
MarshalerAttr and
UnmarshalerAttr
interfaces.
flag package now
has a Getter interface
to allow the value of a flag to be retrieved. Due to the
Go 1 compatibility guidelines, this method cannot be added to the existing
Value
interface, but all the existing standard flag types implement it.
The package also now exports the CommandLine
flag set, which holds the flags from the command line.
go/build package adds
the AllTags field
to the Package type,
to make it easier to process build tags.
image/draw package now
exports an interface, Drawer,
that wraps the standard Draw method.
The Porter-Duff operators now implement this interface, in effect binding an operation to
the draw operator rather than providing it explicitly.
Given a paletted image as its destination, the new
FloydSteinberg
implementation of the
Drawer
interface will use the Floyd-Steinberg error diffusion algorithm to draw the image.
To create palettes suitable for such processing, the new
Quantizer interface
represents implementations of quantization algorithms that choose a palette
given a full-color image.
There are no implementations of this interface in the library.
image/gif package
can now create GIF files using the new
Encode
and EncodeAll
functions.
Their options argument allows specification of an image
Quantizer to use;
if it is nil, the generated GIF will use the
Plan9
color map (palette) defined in the new
image/color/palette package.
The options also specify a
Drawer
to use to create the output image;
if it is nil, Floyd-Steinberg error diffusion is used.
Copy method of the
io package now prioritizes its
arguments differently.
If one argument implements WriterTo
and the other implements iReaderFrom,
Copy will now invoke
WriterTo to do the work,
so that less intermediate buffering is required in general.
runtime package relaxes
the constraints on finalizer functions in
SetFinalizer: the
actual argument can now be any type that is assignable to the formal type of
the function, as is the case for any normal function call in Go.
sort package has a new
Stable function that implements
stable sorting. It is less efficient than the normal sort algorithm, however.
strings package adds
an IndexByte
function for consistency with the bytes package.
testing package
now exports theTB interface.
It records the methods in common with the
T
and
B types,
to make it easier to share code between tests and benchmarks.
Also, the
AllocsPerRun
function now quantizes the return value to an integer (although it
still has type float64), to round off any error caused by
initialization and make the result more repeatable.
text/template package
now automatically dereferences pointer values when evaluating the arguments
to "escape" functions such as "html", to bring the behavior of such functions
in agreement with that of other printing functions such as "printf".
time package, the
Parse function
and
Format
method
now handle time zone offsets with seconds, such as in the historical
date "1871-01-01T05:33:02+00:34:08".
Also, pattern matching in the formats for those routines is stricter: a non-lowercase letter
must now follow the standard words such as "Jan" and "Mon".
unicode package
adds In,
a nicer-to-use but equivalent version of the original
IsOneOf,
to see whether a character is a member of a Unicode category.