vscode-go icon indicating copy to clipboard operation
vscode-go copied to clipboard

Filenames in launch output build errors are not clickable

Open ThinkChaos opened this issue 2 years ago • 5 comments

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.19.2 linux/amd64
  • Run gopls -v version to get version of Gopls from the VS Code integrated terminal.
    • golang.org/x/tools/gopls v0.11.0
  • Run code -v or code-insiders -v to get version of VS Code or VS Code Insiders.
    • 1.74.3 97dec172d3256f8ca4bfb2143f3f76b503ca0534
  • Check your installed extensions to get the version of the VS Code Go extension
    • v0.37.1
  • Run Ctrl+Shift+P (Cmd+Shift+P on Mac OS) > Go: Locate Configured Go Tools command.
gotests:	not installed
gomodifytags:	not installed
impl:	not installed
goplay:	not installed
dlv:	/go/bin/dlv	(version: v1.20.1 built with go: go1.19.2)
golangci-lint:	/go/bin/golangci-lint	(version: v1.50.1 built with go: go1.19.2)
gopls:	/go/bin/gopls	(version: v0.11.0 built with go: go1.19.2)

Describe the bug

When starting a debug session fails due to go build errors, VS Code can't open the file paths printed.
This is because the paths are relative to the built package, and not the workspace root as VS Code expects.

Steps to reproduce the behavior:

  1. Add a Go launch configuration
  2. Break compilation
  3. Launch a debug session
  4. Ctrl-Click a path in the go build output

ThinkChaos avatar Jan 20 '23 21:01 ThinkChaos

@hyangah is there precedent for this type of path sanitization? What about making the errors clickable by recognizing relative paths: is that within our control?

findleyr avatar Jan 26 '23 16:01 findleyr

Yes, unfortunately, that's a well known issue.

I think we can either utilize this coming feature (-fullpath) https://github.com/golang/go/issues/37708 and its extension (to apply the same to compile in addition to test).

Or, an alternative is to utilize the VS Code tasks to build the binary. I just did a quick testing and it seems to recognize relative paths well. (related: https://github.com/golang/vscode-go/issues/194)

cc @golang/tools-team

hyangah avatar Feb 02 '23 18:02 hyangah

(I think your cc didn't work)

ThinkChaos avatar Feb 03 '23 17:02 ThinkChaos

I confirm the issue. Bug is not fixed on latest version of go extension

alex-aparin avatar Apr 30 '25 18:04 alex-aparin

The most viable solution is for https://github.com/golang/go/issues/60451 to be completed, which would add -fullpath to go build. That is an accepted proposal so it just needs someone to implement it.

firelizzard18 avatar Apr 30 '25 20:04 firelizzard18