Skip to content

gopls/v0.10.0

Compare
Choose a tag to compare
@findleyr findleyr released this 31 Oct 16:23
· 2145 commits to master since this release

This release contains initial support for standalone packages and package renaming. Please see below for more details.

We are also changing our release policy to better align with semver.

Support changes

This version of gopls contains changes to our release policy, deprecates support for some older Go versions, and deprecates support for several experimental features.

New release policy

As described in golang/go#55267, we are tightening our release policy to better follow semver, increase stability, and reduce release-related toil. Significant new features will only be introduced in *.*.0 patch versions, and subsequent patch releases will consist only of bugfixes. For example, this version (v0.10.0) introduces several new features, described below. Subsequent v0.10.* releases will contain only bugfixes.

Final support for Go 1.13-1.15

Consistent with the above release policy and our stated support window, the v0.10.* minor version will be the final set of releases to support being used with Go 1.13-1.15. See golang/go#52982 for details.

Gopls will pop up a warning if it resolves a version of the go command that is older than 1.16. Starting with [email protected], gopls will cease to function when used with a go command with a version older than 1.16.

Deprecated experimental features

The following experimental features are deprecated, and will be removed in [email protected]:

  • experimentalWorkspaceModule (golang/go#52897): this feature has been replaced by go.work files. See our documentation for information on how to use go.work files to work on multiple modules.
  • experimentalWatchedFileDelay (golang/go#55268): LSP clients should instead be responsible for buffering workspace/didChangeWatchedFiles notifications.
  • experimentalUseInvalidMetadata (golang/go#54180): we are going to focus instead on improving diagnostics for broken workspaces.

New Features

Support for "standalone packages"

Gopls now recognizes certain files as "standalone main packages", meaning they should be interpreted as main packages consisting of a single file. To do this, gopls looks for packages named main containing a single build constraint that matches one of the tags configured by the new standaloneTags setting.

This enables cross references and other features when working in a file such as the example below that contains a //go:build ignore build constraint.

image

(preview) Support for package renaming

This version of gopls contains initial support for renaming packages (golang/go#41567). This is a work in progress and has a surprising number of edge cases. Additionally, this feature depends heavily on LSP client behavior: renaming a package involves moving the underlying package directory, which may behave differently in different editors. Please try it out, and report your experience at golang/go#56184.

To rename a package, initiate a rename request on the package clause of a file in the package:
image

When this renaming is applied, gopls will adjust other package files accordingly, rename the package directory, and update import paths referencing the current package or any nested package in the renamed directory.
image

Method information in hover

Hovering over a type now shows a summary of its methods.

image

Support for Go 1.19 doc comment syntax

This version of gopls supports the new doc comment syntax added in Go 1.19. See https://go.dev/doc/comment for more details.

image

New diff algorithm

This version of gopls uses an entirely new diff algorithm behind the scenes, to compute the text edits that gopls sends to the LSP client. We hope that this fixes a number of bugs in the old diff implementation, but for the most part you should not notice any effect of this change. If you do experience problems related to text edits, please report an issue and set the "newDiff" setting to "old" to revert to the old diff algorithm.

Configuration changes

This release changes the default value of the "directoryFilters" setting from ["-node_modules"] to ["-**/node_modules"], following support for wildcard syntax.

Bug fixes

This version of gopls includes several bug fixes, notably:

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

Thank you to our contributors!

@adonovan, @brianpursley, @findleyr, @hyangah, @pjweinbgo, @suzmue, and @dle8!