Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What features have been updated by Go1.15

2025-01-18 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/01 Report--

This article mainly introduces the Go1.15 updated which features of the relevant knowledge, the content is detailed and easy to understand, the operation is simple and fast, with a certain reference value, I believe you will gain after reading this Go1.15 update which features of the article, let's take a look at it.

1. New linker

This version of Go reduces the use of linker resources (time and memory) and improves code robustness / maintainability. For ELF-based operating systems running on amd64 architectures (Linux,FreeBSD,NetBSD,OpenBSD,Dragonfly and S olaris), typical large Go assemblies increase link speed by 20% and reduce memory requirements by an average of 30%. Improvements to other architecture / OS combinations. The key factors to improve the performance of the linker are the newly designed object file format and internal phase improvements to improve concurrency (for example, applying relocation parallelism to symbols). The target file in Go 1.15 is slightly larger than its 1.14 equivalent file. These changes are part of a multiversion project to modernize the Go linker, which means that other improvements to the linker are expected in future releases. Now, the linker defaults to the internal link mode of-buildmode=pie on linux/amd64 and linux/arm64, so these configurations no longer require a C linker.

2. Compiler improvements, including slightly smaller binaries

The security rules for the package unsafe allow you to convert unsafe.Pointer to uintptr when certain functions are called. In the past, in some cases, the compiler allowed multiple chained conversions (such as syscall.Syscall (... , uintptr (uintptr (ptr)), … ). The compiler now only needs to convert once. Code that uses multiple transformations should be updated to meet security rules.

Compared to Go 1.14, Go 1.15 reduces the typical binary size by about 5% compared to Go 1.14 by eliminating some types of GC metadata and more aggressively eliminating unused type metadata. The toolchain now alleviates Intel CPU Corrigendum SKX102 on GOARCH=amd64 by aligning functions with 32-byte boundaries and populating jump instructions. Although this padding increases the binary size, it goes far beyond what the above binary size improvement makes up for.

Go 1.15 added the-spectre flag to both the compiler and the assembler to allow Spectre mitigation to be enabled. These are almost absolutely unnecessary and are mainly provided as a "defense in depth" mechanism. For more information, see the Spectre Wiki page.

The compiler will now reject the / / go: compiler directive, which is meaningless to the declaration it uses, with a misplaced compiler instruction error. The instructions used by such errors have been broken before, but the compiler silently ignores them.

Now, the compiler's-json optimization logging report is a large (> = 128byte) copy and contains a description of the escape analysis decision.

3. Embedded tzdata (time zone data)

Added a new package: time/tzdata, when the system can not find the time zone data (such as Windows, etc.), by importing this package, embedded time zone data in the program, you can also pass-tags timetzdata at compile time to achieve the same effect.

4. Add testing.TB.TempDir

Test generation of temporary files is quite common, this is to better solve this problem.

5. Add testing.T.Deadline

Introduce context into the testing package.

6. Part about Ports

Darwin/386 and darwin/arm are no longer supported; riscv64 is getting better; and linux/arm64 is now supported as the first type of port.

7. Changes in API

Net/url.URL RawFragment and EscapedFragment

Net/url.URL.Redacted

3.time.Ticker.Reset, we know that Timer has Reset, and this time it is also added for Ticker.

Regexp.Regexp.SubexpIndex

Sync.Map.LoadAndDelete

There are other API changes in crypto/tls.Dialer.DialContext, which are not listed one by one.

8. Tool chain

Add go env GOMODCACHE: https://github.com/golang/go/issues/34527

Opt-in fallbacks in GOPROXY: https://github.com/golang/go/issues/37367

Vet:warn about string (int) and detect impossible interface assertions: https://github.com/golang/go/issues/32479 and https://github.com/golang/go/issues/4483

Println allows you to print two values. Println (twoValues ())

Panic: displays printable values instead of addresses. For example:

Type MyString stringpanic (MyString ("hello"))

Now print:

Panic: (main.MyString) (0x48aa00re0x4c0840)

Expect to print:

Panic: main.MyString ("hello")

The readability will be much better.

9. Performance

Better write masking on amd64

On Linux, forkAndExec uses dup3

Sha512 algorithm increases speed by 15%

95% reduction in ReadMemStats latency

99% faster channel reception in off state

Change a small int value to interface {} without additional memory allocation.

This is the end of the article on "what features have been updated by Go1.15". Thank you for reading! I believe you all have a certain understanding of the knowledge of "what functions have been updated by Go1.15". If you want to learn more, you are welcome to follow the industry information channel.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report