New release

Go 1.6 is now available

Gabriela Motroc
Writing new release on blackboard image via Shutterstock

Go 1.6, the seventh major stable release of Go is now available. The announcement comes just a few months after Go marked its sixth anniversary and even though Go 1.5 incorporated massive implementation changes, the release of Go 1.6 is “more incremental,” the blog post reads.

Go 1.6 has been released and, as a Reddit AMA with the Go contributors shows, the community is pleased with the fixes, improvements, and additions.

Focal points of Go 1.6

The biggest change is support for HTTP/2 in the net/http package. In Go 1.6, support for this new protocol -a follow-on to HTTP which has been widely adopted by browser vendors and leading websites-  is enabled by default not only for servers, but also for clients when using HTTPS. This change “brings the benefits of the new protocol to a wide range of Go projects, such as the popular Caddy web server,” the blog post explains.

In the seventh major stable release of Go, the template packages have upped their game, with support for trimming spaces around template actions to generate cleaner template output, as well as the introduction of the {{block}} action which can be used to produce templates that build on other templates. These new features are further explained in a new template example program.

The previous version introduced experimental support for a “vendor” directory which was enabled by an environment variable. The feature is now enabled by default -source trees which include a directory named “vendor” that is not used in conformity with the new feature will necessitate alterations to avoid broken builds. According to the blog post announcing the Go 1.6 version, the simplest fix is to rename the directory.

The runtime has added light-weight, best-effort detection of concurrent misuse of maps. If one goroutine is writing to a map, it should not be read or written by other goroutines concurrently -if the runtime detects this condition, it prints a diagnosis and crashes the program. The best way to find out more about the issue is to run it under the race detector, which will pinpoint the race and offer further details.

Another change refers to the way the runtime prints program-ending panics; it does not print all existing goroutines anymore -just the stack of the panicking goroutine. One can configure this behavior in two ways: either by using the GOTRACEBACK environment variable or by calling the debug.SetTraceback function.

“Users of cgo should be aware of major changes to the rules for sharing pointers between Go and C code,” the blog post warns. The purpose of the rules is to make sure such C code can coexist with Go’s garbage collector -they are checked during program execution, which means that code may require changes in order to make sure crashes do not occur. For more information, see the release notes.

The compiler, linker, and go command have a new -msan flag analogous to -race and available only on linux/amd64, which allows interoperation with the Clang MemorySanitizer. This comes in handy when testing a program that contains suspect C or C++ code.

Performance of Go programs built with the new version does not differ from those built with Go 1.5. Garbage-collection pauses are lower than with Go 1.5, but this is evident for programs that use large amounts of memory. As far as the performance of the compiler tool chain is concerned, build times should be similar to those of Go 1.5.

The algorithm inside sort.Sort has been revised and now runs approximately 10 percent faster. However, the change could break programs which expect a particular ordering of elements that are equal, but distinguishable. Programs of this kind should either refine their Less methods to illustrate the desired ordering or use sort.Stable to maintain the input order for equal values.

The entire list of fixes, improvements, and additions can be found in the release notes.

Go contributors celebrate the 1.6 release with AMA

When asked during a Reddit AMA about some features that contributors would like to see in Go, but which cannot be included until Go 2, Rob Pike answered that he would like “the opportunity to rewrite the lower-level, earliest-written libraries to be more Go-like […] and the File type itself to be more abstract so it can be implemented by other packages transparently.”

Austin Clements explained that for the next few releases, they are planning to focus on GC throughput to reduce the total CPU time spent in the garbage collector. ” We’re attacking this on both the ‘micro-optimization’ level, by improving how quickly the garbage collector  can scan memory, and the ‘macro-optimization’ level, by reducing the amount of memory the garbage collector has to scan by focusing on areas of the heap that are more likely to be fruitful,” he said. Clements concluded that although they are not planning to “rework” the garbage collector in the next few releases, they are planning to keep improving it.

Gabriela Motroc
Gabriela Motroc is editor of and JAX Magazine. Before working at S&S Media she studied International Communication Management at The Hague University of Applied Sciences.

Leave a Reply

Be the First to Comment!

Notify of