Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

x/tools/gopls: deprecate the "experimentalUseInvalidMetadata" setting #54180

Closed
findleyr opened this issue Aug 1, 2022 · 4 comments
Closed
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Milestone

Comments

@findleyr
Copy link
Contributor

findleyr commented Aug 1, 2022

Discovered while investigating #54147: with "experimentalUseInvalidMetadata" set, we may diagnose a package with invalid metadata, and not re-diagnose when new metadata arrives. This can lead to diagnostics which are stale until you begin typing again.

We could fix this by re-diagnosing after each metadata load, but more generally we should reconsider whether it is worth landing this feature:

Pros:

  • when the workspace is totally broken, gopls will continue to work

Cons:

  • though gopls will continue to work, it may have inconsistent or confusing state
  • users should generally fix broken workspaces before doing anything else
  • we really don't want users to have to restart gopls, so in all other respects we are trying to avoid places where gopls "remembers history"
@findleyr findleyr added this to the gopls/later milestone Aug 1, 2022
@gopherbot gopherbot added Tools This label describes issues relating to any tools in the x/tools repository. gopls Issues related to the Go language server, gopls. labels Aug 1, 2022
@gopherbot
Copy link

Change https://go.dev/cl/420956 mentions this issue: internal/lsp/cache: invalid packages should not be workspace packages

gopherbot pushed a commit to golang/tools that referenced this issue Aug 4, 2022
To support the experimentalUseInvalidMetadata mode, we keep around
invalid metadata. This can help gopls features work when, for example,
the go.mod file is broken. It is debatable whether this feature is worth
supporting (see golang/go#54180), but in the meantime there is a very
negative side-effect when module paths are changed in the go.mod file:
we keep around a bunch of workspace packages with a stale module path.
As a result we can be left with a lots of extra type-checked packages
in memory, and many inaccurate diagnostics.

Fix this by skipping packages with invalid metadata when computing
workspace packages. While we may want to use invalid metadata when
finding the best package for a file, it does not make sense to re-
type-check and diagnose all those stale packages.

Fixes golang/go#43186

Change-Id: Id73b47ea138ec80a9de63b03dae41d4e509b8d5a
Reviewed-on: https://go-review.googlesource.com/c/tools/+/420956
Run-TryBot: Robert Findley <rfindley@google.com>
Reviewed-by: Suzy Mueller <suzmue@golang.org>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
@findleyr findleyr modified the milestones: gopls/later, gopls/v0.10.0 Sep 22, 2022
@findleyr
Copy link
Contributor Author

CC @adonovan

Unless anyone objects, I propose that we remove this setting. We should avoid any cases where gopls' state is path-dependent.

@findleyr findleyr changed the title x/tools/gopls: reconsider the experimental feature to use invalid metadata x/tools/gopls: deprecate the "experimentalUseInvalidMetadata" setting Sep 22, 2022
@gopherbot
Copy link

Change https://go.dev/cl/434640 mentions this issue: gopls: deprecate three experimental features

@gopherbot
Copy link

Change https://go.dev/cl/452057 mentions this issue: gopls/internal/lsp/cache: eliminate obsolete invalidation step

gopherbot pushed a commit to golang/tools that referenced this issue Nov 29, 2022
This change removes the call to invalidatePackagesLocked after
buildMetadata in the load method; now that we no longer permit
invalid metadata, it is unnecessary.
(The sole remaining call to invalidatePackagesLocked was
inlined into Clone.)

Also:
- check the invalidation invariant in load before Clone.
- merge MetadataForFile and getOrLoadIDsForURI since all
  callers want the Metadata (not just PackageID) and the
  defensive check is no longer needed.
- simplify awaitLoadedAllErrors by calling getInitializationError.
- reduce allocation and critical sections in various
  snapshot methods that retrieve the metadataGraph.
- flag various places where we can avoid type-checking.
- various other doc comments.

Updates golang/go#54180

Change-Id: I82dca203b2520259630b2fd9d08e120030d44a96
Reviewed-on: https://go-review.googlesource.com/c/tools/+/452057
Run-TryBot: Alan Donovan <adonovan@google.com>
Reviewed-by: Robert Findley <rfindley@google.com>
gopls-CI: kokoro <noreply+kokoro@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Jan 7, 2023
gopls/v0.11.0

This is a small release containing new integrations of vulnerability analysis.

Vulnerability analysis for go.mod files can be enabled by configuring the
"vulncheck" setting to "Imports". For more information on vulnerability
management, see the Vulnerability Management for Go blog post.

Support changes

This release removes support for the "experimentalUseInvalidMetadata" setting,
as described in the v0.10.0 release. Other settings slated for deprecation in
that release remain temporarily supported, but will be removed in v0.12.0.

New Features

- Analyzing dependencies for vulnerabilities
- Additional checks for the loopclosure analyzer

gopls/v0.10.0

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 gopls@v0.11.0, 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
gopls@v0.11.0:

  * 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.
netbsd-srcmastr pushed a commit to NetBSD/pkgsrc that referenced this issue Jan 18, 2023
gopls/v0.11.0

This is a small release containing new integrations of vulnerability analysis.

Vulnerability analysis for go.mod files can be enabled by configuring the
"vulncheck" setting to "Imports". For more information on vulnerability
management, see the Vulnerability Management for Go blog post.

Support changes

This release removes support for the "experimentalUseInvalidMetadata" setting,
as described in the v0.10.0 release. Other settings slated for deprecation in
that release remain temporarily supported, but will be removed in v0.12.0.

New Features

- Analyzing dependencies for vulnerabilities
- Additional checks for the loopclosure analyzer

gopls/v0.10.0

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 gopls@v0.11.0, 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
gopls@v0.11.0:

  * 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
gopls Issues related to the Go language server, gopls. Tools This label describes issues relating to any tools in the x/tools repository.
Projects
None yet
Development

No branches or pull requests

2 participants