Robert Griesemer, on behalf of the Go teamRobert Griesemer,代表围棋队1 February 2023 2023年2月1日
Today the Go team is thrilled to release Go 1.20, which you can get by visiting the download page.今天,围棋团队非常高兴地发布了GO 1.20,你可以通过访问下载页面来获得它。
(资料图)
Go 1.20 benefited from an extended development phase, made possible by earlier broad testing and improved overall stability of the code base.Go 1.20得益于扩展的开发阶段,这得益于早期广泛的测试和提高了代码库的整体稳定性。
We’re particularly excited to launch a preview of profile-guided optimization (PGO), which enables the compiler to perform application- and workload-specific optimizations based on run-time profile information. Providing a profile to go build
enables the compiler to speed up typical applications by around 3–4%, and we expect future releases to benefit even more from PGO. Since this is a preview release of PGO support, we encourage folks to try it out, but there are still rough edges which may preclude production use.我们特别兴奋地推出了概要引导优化(PGO)的预览,它使编译器能够基于运行时概要信息执行特定于应用程序和工作负载的优化。向 go build
提供配置文件可以使编译器将典型应用程序的速度提高约3-4%,我们预计未来的版本将从PGO中获得更多好处。由于这是一个预览版的PGO支持,我们鼓励人们尝试它,但仍然有一些粗糙的边缘,可能会排除生产使用。
Go 1.20 also includes a handful of language changes, many improvements to tooling and the library, and better overall performance.Go 1.20还包括一些语言更改,对工具和库的许多改进,以及更好的整体性能。
The predeclared comparable
constraint is now also satisfied by ordinary comparable types, such as interfaces, which will simplify generic code.预声明的 comparable
约束现在也可以由普通的可比较类型(如接口)来满足,这将简化泛型代码。
The functions SliceData
, String
, and StringData
have been added to package unsafe
. They complete the set of functions for implementation-independent slice and string manipulation.函数 SliceData
、 String
和 StringData
已添加到包 unsafe
。它们完善了独立于实现的切片和字符串操作的函数集。
Go’s type conversion rules have been extended to permit direct conversion from a slice to an array.GO的类型转换规则已经扩展,允许从片到数组的直接转换。
The language specification now defines the exact order in which array elements and struct fields are compared. This clarifies what happens in case of panics during comparisons.语言规范现在定义了比较数组元素和结构字段的确切顺序。这阐明了在比较过程中出现恐慌时会发生什么。
The cover
tool now can collect coverage profiles of whole programs, not just of unit tests.cover
覆盖工具现在可以收集整个程序的覆盖配置文件,而不仅仅是单元测试的覆盖配置文件。
The go
tool no longer relies on pre-compiled standard library package archives in the $GOROOT/pkg
directory, and they are no longer shipped with the distribution, resulting in smaller downloads. Instead, packages in the standard library are built as needed and cached in the build cache, like other packages.go
Go工具不再依赖于 $GOROOT/pkg
目录中预编译的标准库程序包存档,并且它们不再随发行版一起提供,从而导致下载量较小。相反,标准库中的包是根据需要构建的,并像其他包一样缓存在构建缓存中。
The implementation of go test -json
has been improved to make it more robust in the presence of stray writes to stdout
.已改进 go test -json
的实现,使其在存在对 stdout
的零散写入时更加可靠。
The go build
, go install
, and other build-related commands now accept a -pgo
flag enabling profile-guided optimizations as well as a -cover
flag for whole-program coverage analysis.现在, go build
、 go install
和其他与生成相关的命令接受启用配置文件制导优化的 -pgo
标志以及用于全程序覆盖率分析的 -cover
标志。
The go
command now disables cgo
by default on systems without a C toolchain. Consequently, when Go is installed on a system without a C compiler, it will now use pure Go builds for packages in the standard library that optionally use cgo, instead of using pre-distributed package archives (which have been removed, as noted above).现在,在没有C工具链的系统上,默认情况下, go
命令会禁用 cgo
。因此,当Go安装在没有C编译器的系统上时,它现在将对标准库中的包使用纯Go版本,这些包可以选择使用CGO,而不是使用预先分发的包存档(如上所述,这些包已经被删除)。
The vet
tool reports more loop variable reference mistakes that may occur in tests running in parallel.vet
VET工具报告在并行运行的测试中可能发生的更多循环变量引用错误。
The new crypto/ecdh
package provides explicit support for Elliptic Curve Diffie-Hellman key exchanges over NIST curves and Curve25519.新的 crypto/ecdh
包为NIST曲线和Curve25519上的椭圆曲线Diffie-Hellman密钥交换提供了明确的支持。
The new function errors.Join
returns an error wrapping a list of errors which may be obtained again if the error type implements the Unwrap() []error
method.新函数 errors.Join
返回包装错误列表的错误,如果错误类型实现了 Unwrap() []error
方法,则可能会再次获取该错误列表。
The new http.ResponseController
type provides access to extended per-request functionality not handled by the http.ResponseWriter
interface.新的 http.ResponseController
类型提供对未由 http.ResponseWriter
接口处理的扩展的每请求功能的访问。
The httputil.ReverseProxy
forwarding proxy includes a new Rewrite
hook function, superseding the previous Director
hook.httputil.ReverseProxy
转发代理包括新的 Rewrite
挂钩函数,取代了以前的 Director
挂钩。
The new context.WithCancelCause
function provides a way to cancel a context with a given error. That error can be retrieved by calling the new context.Cause
function.新的 context.WithCancelCause
函数提供了一种取消具有给定错误的上下文的方法。可以通过调用新的 context.Cause
函数来检索该错误。
The new os/exec.Cmd
fields Cancel
and WaitDelay
specify the behavior of the Cmd
when its associated Context
is canceled or its process exits.新的 os/exec.Cmd
字段 Cancel
和 WaitDelay
指定当其关联的 Cmd
被取消或其进程退出时 Context
的行为。
Compiler and garbage collector improvements have reduced memory overhead and improved overall CPU performance by up to 2%.编译器和垃圾回收器的改进减少了内存开销,并将整体CPU性能提高了2%。
Work specifically targeting compilation times led to build improvements by up to 10%. This brings build speeds back in line with Go 1.17.专门针对编译时间的工作使构建改进了高达10%。这使构建速度回到了Go 1.17的水平。
When building a Go release from source, Go 1.20 requires a Go 1.17.13 or newer release. In the future, we plan to move the bootstrap toolchain forward approximately once a year. Also, starting with Go 1.21, some older operating systems will no longer be supported: this includes Windows 7, 8, Server 2008 and Server 2012, macOS 10.13 High Sierra, and 10.14 Mojave. On the other hand, Go 1.20 adds experimental support for FreeBSD on RISC-V.从源代码构建GO版本时,GO 1.20需要GO 1.17.13或更高版本。在未来,我们计划将引导工具链向前推进大约一年一次。此外,从Go 1.21开始,一些较旧的操作系统将不再受支持:包括Windows 7、8、服务器2008和服务器2012、MacOS 10.13 High Sierra和10.14 Mojave。另一方面,GO 1.20在RISC-V上添加了对FreeBSD的实验性支持。
For a complete and more detailed list of all changes see the full release notes.有关所有更改的完整和更详细的列表,请参阅完整的发行说明。
Thanks to everyone who contributed to this release by writing code, filing bugs, sharing feedback, and testing the release candidates. Your efforts helped to ensure that Go 1.20 is as stable as possible. As always, if you notice any problems, please file an issue.感谢通过编写代码、归档错误、共享反馈和测试发布候选版本为此次发布做出贡献的每一个人。您的努力有助于确保GO 1.20尽可能稳定。一如既往,如果您注意到任何问题,请提交问题。
Enjoy Go 1.20! 享受围棋1.20!
Copyright © 2015-2022 南方健康网版权所有 备案号:粤ICP备18023326号-21 联系邮箱:855 729 8@qq.com