What’s new in Google’s Go Version 1.12

Version 1.12 changes the implementation of the toolchain, runtime, and libraries

What’s new in Google’s Go language
Bill Selak (CC BY-ND 2.0)

Version 1.12 of Google’s Go language (Golang) is now available in its production release, with changes in the implementation of the toolchain, runtime, and libraries.

Where to download Go

You can download the production release of Go from the Go project site.

Current version: The new features in Go 1.12

In the compiler toolchain, the live variable analysis capability has been improved. This may mean that finalizers will be executed sooner than in previous releases. If this is a problem, developers should consider the addition of a runtime.KeepAlive call.

Other new and changed features in Go 1.12 include:

  • When GO111Module is set to on, the go command supports module-aware operations outside of a module directory, provided that these operations do not need to resolve import paths relative to the current directory or explicitly edit the mod file. The intent is to have the Go module mode on by default in Go Version 1.13, due in August 2019.
  • go commands that download and extract modules can be safely invoked concurrently. The module cache (GOPATH/pkg/mod) must reside in a file system that supports file locking.
  • The runtime offers better performance in sweeping when a large fraction of the heap remains alive. This reduces allocation latency following a garbage collection.
  • The runtime releases memory back to the OS more aggressively, particularly in response to large allocations that cannot reuse existing heap space. For Linux, the runtime now releases memory to the OS only when the OS is under memory pressure.
  • The Go race detector, for finding race conditions in code, is now supported on the Linux ARM64 architecture.
  • The build cache is now required as a step to eliminating $GOPATH/pkg. Setting the environment variable, GOCACHE=Off causes go commands that write to the cache to fail.
  • The windows/arm platform is supported.
  • The trace tool supports plotting of mutator utilization curves, including cross-references to the execution trace. This helps in analyzing the impact of the garbage collector on application latency and throughput.
  • The core library adds optional support for the crypto/tls package for TLS (Transport Layer Security) 1.3.
  • In the bufio package, which implements buffered I/O, the reader’s UnreadRunE and UnreadByte methods return an error if called after Peek.
  • libsystem is now used when making calls on Darwin, to ensure compatibility with future versions of Apple’s MacOS and iOS operating systems. This switch to libsystem has triggered additional App Store checks for private API usage; since it is considered private, syscall.Getdirentries fails with Enosys on iOS. Also, Go 1.12 is the last release that will run on MacOS 10.10 Yosemite. Go 1.13 will require MacOS 10.11 El Capitan or later.

Previous version: What’s new in Go 1.11

Released in August 2018, Go 1.11 features an experimental port to the WebAssembly binary format. The port is called JS/Wasm. In addition to potential application performance benefits, WebAssembly provides a binary format that serves as a compilation target for other languages, enabling deployment on the web for both client and server applications.

Go 1.11 has added preliminary support for modules, which are collections of related Go packages. Modules replace the Gopath approach to specifying which source files are in a build. With modules, version dependency information is explicit but lightweight. Builds are more reliable and reproducible, documentation states.

As part of module support, the module-aware go get command has been added. To take advantage of modules, developers should check out their repository into a directory outside GOPATH/src, create a go.mod file, and run go commands via that file tree.

Also new to Go 1.11:

  • The package org/x/tools/go/packages provides an API for locating and loading packages of source code. While not yet included in the standard library, the package effectively replaces the go/build package, which has an API not able to fully support modules. The new package enables development of analysis tools that work equally well with build tools such as Buck and Bazel.
  • The runtime/trace package’s user annotation API enables recording of application-level information in execution traces and creation of groups of related goroutines. The go tool trace command visualizes this information in the trace view and the new user task/region analysis page.
  • Version 1.11 is the last release to support the setting environment variable GOCACHE=off to disable the build cache. With Go 1.12, the build cache will be required as a step toward eliminating $GOPATH/pkg.
  • The compiler tool chain supports column information in line directives.
  • More compiler tool chain functions are eligible for inlining by default.
  • For debugging, the compiler now produces more accurate debug information for optimized binaries, including variable location information and breakpoint locations.
  • The go vet command now reports a fatal error when a package being analyzed does not type-check.
  • The runtime uses a sparse heap layout so there is no longer a limit to the size of the Go heap.
  • Minor changes to the standard libraryincludee removing older platform support.

The Go 1.11 release requires MacOS 10.10 Yosemite or later, Windows 7 or later, or OpenBSD 6.2 or later. Support has been removed for previous releases of these operating systems.

Previous version: The new features in Google Go 1.10

The upgrade offers compiler tool chain and performance improvements but no substantive language changes. Released in February 2018, Go 1.10 provides these key features:

  • Improved performance of code generated by the compiler, spread across supported architectures.
  • Programs should run a bit faster due to speedups in garbage collection, better code generation, and core library optimizations.
  • Dwarf debug information in binaries has been improved, with constant values now recorded. Also, line-number information is more accurate.
  • The linux/ppc64le port now needs external linking with any programs using the cgo command.
  • The go build command detects out-of-date packages based on the content of source files, specified build flags, and metadata in stored packages. Modification times are no longer relevant.
  • The go install command now only installs packages and commands listed on the command line. To force installation of dependencies, developers should use the go install –i flag
  • An update to the grammar for method expressions relaxes the syntax so any type expression is allowed as a receiver, thus matching how compilers already operated.
  • Test results are now cached via go test.
  • The Unicode package has been upgraded from Unicode 9.0 to version 10.0, adding 8,518 characters, including a bitcoin currency symbol and 56 emojis.

Previous version: The new features in Google Go 1.9

Google released Go 1.9 in August 2017. Here’s what is new and improved:

  • Speedups in the garbage collector, better-generated code, and core library optimizations should make programs run a bit faster.
  • The math/bits package offers optimized implementations to manipulate bits. Functions in this package are treated by the compiler as intrinsics to boost performance.
  • The Go 1.9 compiler supports parallel compilation of functions in a package, leveraging multiple processor cores. Go 1.9 retains the previous versions’ go command’s support for parallel compilation of separate packages. Parallel compilation is on by default but can be disabled. 
  • For scalability, Go 1.9 adds support for type-alias declaration for code repair. A change to the Go language, type aliases support gradual code repair while moving a type between packages. It should aid code repair during large-scale refactoring, moving a type from a package in a way that code referring to an old name interoperates with code referring to the new name. Essentially, the introduction of type aliases  provides a transition period in which the API is available from both new and old packages, making references to old and new versions interoperable.
  • Go 1.9 adds transparent monotonic time support, which makes computing durations between two Time values a safe operation in the presence of wall-clock adjustments.
  • Go 1.9 improves test helper capabilities, with new methods to mark the calling function as a test helper function.
  • A new type in the sync package serves as a concurrent map with amortized-constant-time loads, stores, and deletes. Thus, multiple go routines can call a map’s methods concurrently.

Copyright © 2019 IDG Communications, Inc.

How to choose a low-code development platform