通过Go官网的The Go Blog可以检索出每个版本的发布信息,以及详细的版本说明。本文参考以下文章:
为了防止内容因为作者在翻译时理解错误,因此大部分会从官网原文摘取出来,其中也只会摘取一些重点的更新。
25 February 2019
Users should use go doc for command-line help output instead. Go 1.12 is the last release that will include the godoc webserver; go doc now supports the -all flag, which will cause it to print all exported APIs and their documentation, as the godoc command line used to do. go doc also now includes the -src flag, which will show the target's source code.
The trace tool now supports plotting mutator utilization curves, including cross-references to the execution trace. These are useful for analyzing the impact of the garbage collector on application latency and throughput.
Go 1.12 adds opt-in support for TLS 1.3 in the crypto/tls package as specified by RFC 8446. It can be enabled by adding the value tls13=1 to the GODEBUG environment variable. It will be enabled by default in Go 1.13.
3 September 2019
supports a more uniform and modernized set of number literal prefixes.
When extracting a module from a version control system, the go command now performs additional validation on the requested version string.
1. The version prefix must be of the form vX.0.0, or derived from a tag on an ancestor of the named revision, or derived from a tag that includes build metadata on the named revision itself.
2. The date string must match the UTC timestamp of the revision.
3. The short name of the revision must use the same number of characters as what the go command would generate. (For SHA-1 hashes as used by git, a 12-digit prefix.)
If one of the transitive dependencies of the main module requires an invalid version or pseudo-version, the invalid version can be replaced with a valid one using a replace directive in the go.mod file of the main module. If the replacement is a commit hash, it will be resolved to the appropriate pseudo-version as above. For example,
replace github.com/docker/docker v1.14.0-0.20190319215453-e7b5f7dbe98c => github.com/docker/docker e7b5f7dbe98c
25 February 2020
Go 1.14 now permits embedding of interfaces with overlapping method sets
methods from an embedded interface may have the same names and identical signatures as methods already present in the (embedding) interface. This solves problems that typically (but not exclusively) occur with diamond-shaped embedding graphs. Explicitly declared methods in an interface must remainunique, as before.
vendoring
When the main module contains a top-level vendor directory and its go.mod file specifies go 1.14 or higher, the go command now defaults to -mod=vendor for operations that accept that flag. A new value for that flag, -mod=mod, causes the go command to instead load modules from the module cache (as when no vendor directory is present).
When -mod=vendor is set (explicitly or by default), the go command now verifies that the main module's vendor/modules.txt file is consistent with its go.mod file.
GOINSECURE is a new environment variable that instructs the go command to not require an HTTPS connection, and to skip certificate validation, when fetching certain modules directly from their origins. Like the existing GOPRIVATE variable, the value of GOINSECURE is a comma-separated list of glob patterns.
+incompatible versions
If the latest version of a module contains a go.mod file, go get will no longer upgrade to an incompatible major version of that module unless such a version is requested explicitly or is already required. go list also omits incompatible major versions for such a module when fetching directly from version control, but may include them if reported by a proxy.
go.mod file maintenance
go commands other than go mod tidy no longer edit the go.mod file if the changes are only cosmetic.
Module downloading
The go command now supports Subversion repositories in module mode.
11 August 2020
Go command
The GOPROXY environment variable now supports skipping proxies that return errors. Proxy URLs may now be separated with either commas (,) or pipe characters (|). If a proxy URL is followed by a comma, thegocommand will only try the next proxy in the list after a 404 or 410 HTTP response. If a proxy URL is followed by a pipe character, thegocommand will try the next proxy in the list after any error. Note that the default value ofGOPROXYremainshttps://proxy.golang.org,direct, which does not fall back todirectin case of errors.
The location of the module cache may now be set with the GOMODCACHE environment variable. The default value of GOMODCACHE is GOPATH[0]/pkg/mod, the location of the module cache before this change.
Vet
The vet tool now warns about conversions of the form string(x) where x has an integer type other than rune or byte. Experience with Go has shown that many conversions of this form erroneously assume that string(x) evaluates to the string representation of the integer x. It actually evaluates to a string containing the UTF-8 encoding of the value of x. For example, string(9786) does not evaluate to the string "9786"; it evaluates to the string "\xe2\x98\xba", or "☺".
The vet tool now warns about type assertions from one interface type to another interface type when the type assertion will always fail. This will happen if both interface types implement a method with the same name but with a different type signature.
Runtime
Linker
This release includes substantial improvements to the Go linker, which reduce linker resource usage (both time and memory) and improve code robustness/maintainability.
For a representative set of large Go programs, linking is 20% faster and requires 30% less memory on average, for ELF-based OSes (Linux, FreeBSD, NetBSD, OpenBSD, Dragonfly, and Solaris) running on amd64 architectures, with more modest improvements for other architecture/OS combinations.
Core library
Go 1.15 includes a new package, time/tzdata, that permits embedding the timezone database into a program. Importing this package (as import _ "time/tzdata") permits the program to find timezone information even if the timezone database is not available on the local system. You can also embed the timezone database by building with -tags timetzdata. Either approach increases the size of the program by about 800 KB.
The deprecated, legacy behavior of treating the CommonName field on X.509 certificates as a host name when no Subject Alternative Names are present is now disabled by default. It can be temporarily re-enabled by adding the value x509ignoreCN=0 to the GODEBUG environment variable.
Note that if the CommonName is an invalid host name, it's always ignored, regardless of GODEBUG settings. Invalid names include those with any characters other than letters, digits, hyphens and underscores, and those with empty labels or trailing dots.
下一篇文章会继续整理Go16-20版本的变更。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有