Great news for Go developers. New major version of Golang available now.
Go 1.9 has been released!https://t.co/GKiU0OsYIS
— Go (@golang) 24 августа 2017 г.
Let's see what's inside.
As we mentioned before, there were planned two major new features for Go 1.9. And they are finally available.
- Go now supports type aliases to support gradual code repair while moving a type between packages. The type alias design document and an article on refactoring cover the problem in detail. In short, a type alias declaration has the form:
type T1 = T2
This declaration introduces an alias name
T1—an alternate spelling—for the type denoted by
T2; that is, both
T2denote the same type.
- A smaller language change is that the language specification now states when implementations are allowed to fuse floating point operations together, such as by using an architecture’s “fused multiply and add” (FMA) instruction to compute
zwithout rounding the intermediate result
x*y. To force the intermediate rounding, write
Also, here are some interesting updates:
- The new math/bits package provides bit counting and manipulation functions for unsigned integers, implemented by special CPU instructions when possible. For example, on x86-64 systems,
bits.TrailingZeros(x)uses theBSF instruction.
syncpackage has added a new Map type, safe for concurrent access. It is not a general replacement for Go's map type.
testingpackage also has an addition. The new
Helpermethod, added to both testing.T and testing.B, marks the calling function as a test helper function. When the testing package prints file and line information, it shows the location of the call to a helper function instead of a line in the helper function itself.
Learn more at release notes.