golang / vscode-go

Go extension for Visual Studio Code
https://marketplace.visualstudio.com/items?itemName=golang.Go
Other
3.79k stars 729 forks source link

Go Syntax Check does not work with go.mod replace #3148

Closed haraldrudell closed 4 months ago

haraldrudell commented 5 months ago

What version of Go, VS Code & VS Code Go extension are you using?

Version Information
* Run `go version` to get version of Go from _the VS Code integrated terminal_. - go version go1.21.6 darwin/arm64 * Run `gopls -v version` to get version of Gopls from _the VS Code integrated terminal_. - golang.org/x/tools/gopls v0.14.2 * Run `code -v` or `code-insiders -v` to get version of VS Code or VS Code Insiders. - Version: 1.85.2 * Check your installed extensions to get the version of the VS Code Go extension - Go v0.40.3 * Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > `Go: Locate Configured Go Tools` command. - go: /opt/homebrew/Cellar/go/1.21.6/libexec/bin/go: go version go1.21.6 darwin/arm64 gopls: /Users/foxyboy/go/bin/gopls (version: v0.14.2 built with go: go1.21.3) gotests: /Users/foxyboy/go/bin/gotests (version: v1.6.0 built with go: go1.21.0) gomodifytags: /Users/foxyboy/go/bin/gomodifytags (version: v1.16.0 built with go: go1.21.0) impl: /Users/foxyboy/go/bin/impl (version: v1.1.0 built with go: go1.21.0) goplay: /Users/foxyboy/go/bin/goplay (version: v1.0.0 built with go: go1.21.0) dlv: /Users/foxyboy/go/bin/dlv (version: v1.21.0 built with go: go1.21.0) staticcheck: /Users/foxyboy/go/bin/staticcheck (version: v0.4.5 built with go: go1.21.0)

Describe the bug

When editing multiple Go modules, with each edited module in a separate Code window, syntax errors occur in other Code windows when changing public identifiers in one Code window

Steps to reproduce the behavior:

  1. Change the name of a public identifier used in both modules in one Code window
  2. GOOD: the identifier name is changed across all modules and Code windows
  3. BUG: syntax check now fails. In other Code windows than where the change was made, a red squiggly line appears under the new identifier name that was changed
  4. GETAROUND: exit and restart Visual Studio Code: syntax check now reports no errors

Can the syntax-check propagation somehow be made automatic, which is what is expected? Is there some easier GETAROUND than relaunching Visual Studio Code?

suzmue commented 5 months ago

Thanks for filing this issue @haraldrudell, yes that does sound like a bug. Does this occur both when renaming identifiers from module2 from the code window with module1 and from module2?

Also if you could provide a case to reproduce that would be great, I have not yet been able to reproduce. Thanks!

suzmue commented 5 months ago

Could you send a screenshot of the inaccurate diagnostics? In particular I am wondering what appears in the section after the error message (compiler(UndeclaredName) in the example screenshot):

Screenshot 2024-01-25 at 4 31 17 PM
gopherbot commented 4 months ago

Timed out in state WaitingForInfo. Closing.

(I am just a bot, though. Please speak up if this is a mistake or you have the requested information.)