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: handle replace directives #36745

Closed
stamblerre opened this issue Jan 24, 2020 · 5 comments
Closed

x/tools/gopls: handle replace directives #36745

stamblerre opened this issue Jan 24, 2020 · 5 comments
Labels
FrozenDueToAge 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

@stamblerre
Copy link
Contributor

We watch all of the files in the module root for changes on-disk, and we also use changes to the current module as a heuristic for when it's necessary to rescan for imports. We should also track replace directives and watch file changes in replace targets.

@stamblerre stamblerre added this to the gopls/v1.0.0 milestone Jan 24, 2020
@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 Jan 24, 2020
@stamblerre stamblerre modified the milestones: gopls/v1.0.0, gopls/v0.5.0 Mar 12, 2020
@stamblerre stamblerre modified the milestones: gopls/v0.5.0, gopls/v0.6.0 Apr 2, 2020
@stamblerre stamblerre modified the milestones: gopls/v0.6.0, gopls/v0.5.0 Jun 24, 2020
@stamblerre
Copy link
Contributor Author

stamblerre commented Jul 14, 2020

Fixed as of CL 239198, though VS Code does not support watching directories outside of the workspace root.

@kevlar700
Copy link

kevlar700 commented Feb 3, 2021

Fixed as of CL 239198, though VS Code does not support watching directories outside of the workspace root.

Is this fixable, otherwise it seems to me that this means extending modules via the filesystem and package main is a better solution than replace and named modules? Not reliable on Windows unfortunately but workable on Unix systems.

I guess the other option is unworkable (putting all projects in one module) as in my experience, a library change might make build errors unhelpful and will be a pain with so many files in scope.

Edit: Actually replaced libs outside vscodes root, seems to work today, if you disable gopls.

Arrgh still has some issues with build tags then.

@stamblerre
Copy link
Contributor Author

The title of this issue is a bit misleading--specifically, the issue is that on-disk changes to replaced modules will not be reflected to the editor because of limitations to VS Code's file watching API. gopls should still generally work with replaced modules. @kevlar700: If you are having an issue with the VS Code Go extension, please take a look at the Troubleshooting guide and file a new issue.

@kevlar700
Copy link

If you are having an issue with the VS Code Go extension, please take a look at the Troubleshooting guide and file a new issue.

I think one issue might be that more people are using replace than perhaps should be?

"https://www.mail-archive.com/golang-nuts@googlegroups.com/msg41347.html"

Not sure whether to file an issue about documentation somewhere?

@stamblerre
Copy link
Contributor Author

Replace directives should work with gopls, and it's perfectly fine to use them if they fit your use case. In fact, gopls uses a nested module with a replace directive itself. As I mentioned above, if your set-up is causing issues with VS Code Go and gopls, we'll be happy to take a look and investigate the problem.

@golang golang locked and limited conversation to collaborators Feb 9, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge 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

3 participants