MyGit

gopls/v0.14.0

golang/tools

版本发布时间: 2023-10-25 22:29:02

golang/tools最新发布版本:gopls/v0.16.2(2024-09-06 01:01:04)

These are release notes are identical to the v0.14.0-pre.4 prerelease notes. Thanks to all who tested the prerelease!

go install golang.org/x/tools/gopls@v0.14.0

This release includes initial support for the "inline call to function" refactoring, as well as a few other smaller features. It also includes several bug fixes, notably a fix for a performance regression in completion that may be significant in some environments.

The release also contains support for opt-in telemetry. If you want, you can enable the periodic uploading of telemetry data, including gopls stack traces and metrics, but never your source code, to telemetry.go.dev. See below for details.

New Features

Refactoring: inline call to function

This release includes a new code action to inline function calls:

inlinecall

While the outcome of this operation may be a simple replacement, there's a lot going on under the covers. For example, the new inliner checks whether changes to the order of argument evaluation could have unintended consequences. If so, it is careful to replicate the original behavior:

add preserves the order of effects ...but sub does not
inline_add inline_sub

The goal of the inliner is to rewrite your code idiomatically without introducing behavior changes. See the inlining documentation for more details.

When the call cannot be reduced to a simple expression, the inliner may fall back on an immediately invoked function literal (func() { statements }()) as this is often the only way to preserve the original behavior. As we continue to work on refactoring, we'll add additional rewriting strategies that avoid this fall-back in more cases.

Refactoring: removing unused parameters

The techniques described in the previous section serve as a foundation for other refactoring operations. As a proof of concept, this release also includes a code action to remove unused parameters. Since this operation uses inlining behind the scenes, it gets all of the related safety checks and rewriting strategies for free:

inline_unused

Improved support for go:embed directives

This release includes improved support for //go:embed directives, including hover and jump-to-definition. embed_def

New analyses

This release include three new static analyses, all of which are enabled by default.

"appends": reports calls to append that pass no values to be appended to the slice. image

"defers": checks for common mistakes in defer statements. image

"slog": checks for invalid structured logging calls. image

Opt-in telemetry

This is the first gopls release to include opt-in transparent telemetry. Telemetry uploading is off by default, and can be enabled with the following command:

go run golang.org/x/telemetry/cmd/gotelemetry@latest on

After telemetry is enabled, gopls will periodically upload metrics and stack traces to telemetry.go.dev. If we get enough adoption, this data can significantly advance the pace of gopls development and help us meet a higher standard of reliability. For example:

These are just a few ways that telemetry can improve gopls. The telemetry blog post series contains many more.

Go telemetry is designed to be transparent and privacy-preserving. If you have concerns about enabling telemetry, you can learn more at https://telemetry.go.dev/privacy.

Bugfixes

A full list of all issues fixed can be found in the gopls/v0.14.0 milestone. To report a new problem, please file a new issue at https://go.dev/issues/new.

Thank you to our contributors!

@adonovan @bcmills @cuishang @cuonglm @dmitshur @ericlohyg @findleyr @hyangah @jba @lfolger @nchengyeeshen @pjweinb @qiulaidongfeng @telemachus @timothy-king @tttoad @vikblom

相关地址:原始地址 下载(tar) 下载(zip)

查看:2023-10-25发行的版本