← All releases

go1.4.0

Major

December 11, 2014

Go 1.4 is mostly an internals release: the runtime was rewritten from C to Go, stacks became contiguous, and write barriers were added ahead of Go 1.5's concurrent GC, shrinking heaps 10-30%. It also has two small breaking changes (disallowed **T method calls, stricter file-name build tags) plus go generate, internal packages, and canonical import paths.

highlights
  • New for-range loop form: 'for range x { }' with no loop variables is now legal syntax (backwards compatible).

  • Breaking change: calling a method through a pointer-to-pointer (**T) is no longer allowed by the compiler; requires an explicit dereference to fix.

  • Breaking change: source files with a bare OS/arch suffix (e.g. arm.go) are no longer auto-tagged for that platform; the suffix must now be preceded by an underscore (e.g. os_arm.go) or use explicit build tags.

  • Runtime (GC, scheduler, maps, strings, etc.) largely rewritten from C to Go, enabling a fully precise garbage collector and reducing heap size 10-30% versus 1.3.

  • Goroutine stacks are now contiguous and reallocated on growth instead of segmented, eliminating the 'hot stack split' problem; default starting stack size dropped from 8192 to 2048 bytes.

  • Write barriers added for heap pointer writes in preparation for the fully concurrent garbage collector planned for Go 1.5; no semantic effect but can affect performance.

  • Interface values now always store a pointer internally, which can increase allocations for code that stores small scalar values (e.g. ints) in interfaces.

  • Added support for Android/ARM, NaCl on ARM, and Plan 9 on AMD64.

  • go command adds an 'internal' package convention restricting imports to code within the enclosing directory tree, and enforces canonical import path comments in package clauses.

  • New 'go generate' subcommand added to automate running code-generation tools before compilation.

  • Source tree reorganized: the src/pkg directory is gone, so package sources moved up one level (e.g. fmt now lives in src/fmt).

  • syscall package is now frozen except for core-repo needs; new golang.org/x/sys subrepo hosts future syscall additions, and Go 1.4 now requires SWIG 3.0.3 due to runtime changes.