Today (a comment of the translator: 24-08-2017), our team is glad to present you the release of Go 1.9. You can download it
from here . There are a lot of changes in this release regarding the language itself, standard libraries, raintime, and ecosystem tools. In this post I will tell you about the most significant of them. The greatest effort in this release has been to improve runtime and ecosystem tools, which makes the announcement less interesting, but the release is more awesome.
The most important change in the language is aliases for types: a feature created for the gradual recovery of code. Type aliases are represented as follows:
type T1 = T2
This declaration creates a T1 alias for type T2, in the same way as
byte is an alias for
uint8 . The architecture of Alice for types is described in the
document , and the
article on refactorn covers this topic in more detail.
The new
math / bits package provides counting and manipulation functions for unsigned integers using special CPU instructions where possible. For example: on
x86-64 systems,
bits.TrailingZeros (x) uses
BSF instructions.
')
A new type of
Map , safe for competitive access (thread-safe), has been added to the
sync package. You can read more about this in the type documentation and learn more about how to create this type from the report on
GopherCon 2017 (
slides ).
Map is not a replacement for Go type of associative arrays; Please read the relevant documentation to get an understanding and idea for what purpose to use the Map.
Also, a portion of the additive package received
testing . A new
Helper method has been added to
testing.T and
testing.B , which
marks the called function as a test auxiliary function. When a test package displays information about a file and a line, it shows the location of the call to the auxiliary function instead of showing the line in the auxiliary test function itself.
For example, consider the following test:
package p import "testing" func failure(t *testing.T) { t.Helper()
Since
failure identifies itself as an auxiliary test function, the error messages displayed during the execution of
Test will point to line 11, where
failure is called, instead of line 7, where
failure causes
t.Fatal .
The
time package now transparently tracks “monotonous” time (note of the translator: reference to the
time types provided by the OS) in the
Time value, making the calculation of the execution time between two calls (values)
Time a safe operation, even in the presence of normal OS clocks (OS clock synchronization) . For example, the following piece of code calculates the exact execution time, even if the synchronization of regular hours occurs within one second:
start := time.Now() f() elapsed := time.Since(start)
See
the package documentation and design (architecture)
documents for more details.
And finally, as part of the effort to make the Go compiler even faster, in Go 1.9 the functions inside the package are compiled competitively (in parallel, simultaneously).
Go 1.9 includes many more new features, improvements and fixes. You can see the complete list of changes, as well as more detailed information about the improvements in
the Go 1.9 change list .
To celebrate a new release, the Go user community organizes
evening activities, timed to release around the world.