Major updates for Golang 1.9

Source: Internet
Author: User
This is a creation in Article, where the information may have evolved or changed.

Because this information on the Internet is difficult to check, so reprint a copy, the original text please click

Major updates for Go1.9

Golang is updated every six months, the latest version is Go1.8, and Go1.9 will be released this August.
There is only one change in syntax in Go1.9, and that is the addition 类型别名 , most of the changes are tool chains, runtime, library changes,

Changes in syntax

With the addition of the type alias syntax in Go1.9, type aliases can be more elegantly implemented when the movement of a struct between two packets. The syntax for type aliases is as follows:

type T1 = T2

This means declaring an alias T1 of a T2 type.

Tools

Parallel compilation

Compile in parallel in Go1.9 the package is the default setting, and if you need to turn off parallel compilation, you need to set the environment variable GO19CONCURRENTCOMPILATION=0 .

./... can match vendor.

In response to the requirements of the pro-people, ./... not previously supported matching files under the vendor directory, now Go1.9 support.

Performance

In general, it is difficult to describe the performance impact of these changes on various scenarios. Most programs should run faster because of the GC's ascension, the better code generation, and the optimization of the core library.

Garbage collection

Before Go1.9, many library functions would trigger Stop-the-world, and now only trigger concurrent garbage collection. For example runtime.GC,debug.SetGCPerent : debug.FreeOSMemory and, it now only triggers a concurrent garbage collection, blocking only the current call goroutine until the GC is complete.
debug.SetGCPrercentFunction... The allocation performance of large objects is significantly improved when the application uses a super-large heap (>50g), which contains many large objects.

runtime.ReadMemStatsThe function now reads a large heap less than 100usin time.

Core Library

The Concurrent map

Well, finally officially supported, the new type in the Sync package Map , this Map is a thread-safe map.

Time package supports display of monotonic

The time packet of the Go1.9 supports a monotonic duration for each of the times, so that when the system time changes, it is safe to calculate two times difference. See Package docs and Design doc specifically

New bit Action Pack

Go1.9 adds a new package called Math/bits, which provides optimizations for some bit operations.

Reference

go1.9 Release Notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.