← All releases

go1.2.0

Major

November 28, 2013

Go 1.2 is a compatible, moderate release: it adds three-index slicing, tightens the spec around nil pointer dereferences (may expose already-broken code), improves the scheduler's preemption, and ships go test coverage tooling plus several library and performance improvements.

highlights
  • New language feature: three-index slicing (e.g. array[2:4:7]) lets you set a slice's capacity explicitly, not just its length.

  • Spec clarified so that dereferencing a nil pointer, interface, slice, etc. is now guaranteed to panic (or return a safe value) rather than silently corrupting memory; already-buggy code relying on old behavior may now fail.

  • Scheduler now preempts goroutines at function-call boundaries, so tight loops with function calls no longer starve other goroutines on the same OS thread.

  • Minimum goroutine stack size raised from 4KB to 8KB to reduce costly stack-segment switching; may increase memory use for programs with many goroutines.

  • New runtime/debug.SetMaxThreads and SetMaxStack let you tune the default 10,000-thread limit and default max stack size (1GB on 64-bit, 250MB on 32-bit).

  • go test gains -cover flag and a separate 'go tool cover' for computing and reporting test coverage.

  • godoc and vet source moved to the go.tools subrepository (still shipped as binaries); the 'go doc' subcommand is removed in favor of running godoc directly.

  • cgo can now build and link against C++ portions of a library.

  • New encoding package defines BinaryMarshaler/Unmarshaler and TextMarshaler/Unmarshaler interfaces, now used by encoding/json, encoding/xml, and encoding/gob.

  • fmt formatting verbs support explicit argument indices, e.g. %[2]s, to reorder or reuse arguments.

  • text/template and html/template add built-in comparison functions (eq, ne, lt, le, gt, ge) and support 'else if' chains without extra 'end' blocks.

  • Notable performance gains: bzip2 decompression ~30% faster, crypto/des ~5x faster, encoding/json encoding ~30% faster, and Windows/BSD networking ~30% faster via an integrated poller.