Out of the blocks: Go version 1.15 speeds up linker, tests waters to end conversion confusion

Out of the blocks: Go version 1.15 speeds up linker, tests waters to end conversion confusion

Go 1.15 is out, fitting the Google-bred programming language with a revamped linker, and improvements in areas such as binary size, allocation for small objects, and timezone handling.

According to the Go team, the linker has become 20 per cent faster, requiring 30 per cent less memory on average for operating systems such as Linux and FreeBSD that are based on the executable and linkable format, when running on AMD64 architectures. This is mainly due to a redesigned object file format and some adjustments to increase concurrency. 

Upcoming Go versions are expected to see more linker improvements, following an initiative to modernise the component. It was started in autumn 2019 as a reaction to linker performance and resource consumption issues interfering with API enhancements, amongst other things.

Go’s compiler has become more rigorous when it comes to eliminating unused type and garbage collection metadata leading to a slight reduction in binary size. For safety reasons, it no longer allows multiple chained conversions, which is why developers should check their code and make modifications if needed.

The biggest change in the core library is the new package time/tzdata: Once embedded, it lets a program find timezone information should a timezone database not be locally available. Other core updates include Cgo now translating C’s EGLConfig to Go’s uintptr type for a more uniform type treatment and the disabling of the already deprecated behaviour in which the CommonName field on X.509 certificates is used as a host name.

In terms of tooling, vet now comes with a warning for string(x) conversions where x is of an integer type other than rune or byte. Conversions like this are often wrongly used, as they evaluate the UTF-8 encoding of x instead of its string representation. 

To prevent this from happening, the Go team said it is thinking of disallowing such an operation altogether. This would however entail a backwards incompatible language change. The same is true for impossible interface conversions, which has been highlighted as well.  

The go command has also seen some changes in v1.15, allowing developers to give a comma or pipe character separated list of proxy URLs to the GOPROXY environment variable. If a proxy returns an error, the tool is then able to skip to the next URL on the list if it is followed by a pipe character. Comma-separated lists meanwhile only allow the environment to try the next option when faced with a 404 or 410 HTTP response. 

Devs are now also free to set the location of the module cache through the GOMODCACHE environment variable, and can use GODEBUG=modcacheunzipinplace=1 to work around “Access is denied” errors in go commands that access the module cache on Windows. As the latter isn’t safe for Go versions lower than 1.14.2 and 1.13.10, systems should be updated accordingly first. A complete list of changes can be found in the language’s documentation.