Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Unable to map $GOPATH when debugging remotely #3177

Closed
hgl opened this issue Apr 15, 2020 · 10 comments
Closed

Unable to map $GOPATH when debugging remotely #3177

hgl opened this issue Apr 15, 2020 · 10 comments
Labels

Comments

@hgl
Copy link

hgl commented Apr 15, 2020

Is your feature request related to a problem? Please describe.
When debugging a go program living inside a docker container, I'm able to map my own source code with remotePath and cwd, but I have no way to map $GOPATH. In docker it starts with /go, but on my host, not the case. So whenever I try to descend into a 3rd party package, I'm prompted with a file not found error.

Describe the solution you'd like
Maybe another option in launch.json to map $GOPATH? (Or is there already one that I missed?)

Since vscode should be able infer $GOPATH on the host, this option should only refer to remote $GOPATH imho.

@hyangah
Copy link
Contributor

hyangah commented Apr 15, 2020

@quoctruong @ramya-rao-a
I see only a special handling of GOROOT mapping for #1178 but no GOPATH mapping for remote debugging. Am I missing something?

@hyangah
Copy link
Contributor

hyangah commented Apr 15, 2020

Moreover, the GOROOT handling logic blindly replaces the part before /src/ with GOROOT, so it will interfere the correct mapping of source code under $GOPATH/src.
If the headless dlv does not provide info about its runtime environment, I think we need explicit mappings.

@hyangah
Copy link
Contributor

hyangah commented Apr 20, 2020

It seems the issue #3079 is trying to fix is also related.
@fnmunhoz

@quoctruong
Copy link
Contributor

This is now fixed in the nightly Go build (https://github.com/golang/vscode-go). @hgl please give it a try: https://github.com/golang/vscode-go/blob/master/docs/nightly.md

@hgl
Copy link
Author

hgl commented May 27, 2020

@quoctruong Thanks. Will do when time is available. How do I specify the remote $GOPATH? (Or does delve report the remote GOPATH value so there is nothing to be configured?)

@stamblerre
Copy link
Contributor

stamblerre commented May 27, 2020

@hgl: Based on golang/vscode-go#45, it sounds like you will not have to configure the remote GOPATH.

@hgl
Copy link
Author

hgl commented May 27, 2020

This looks pretty awesome. So even remotePath can be omitted now?

@stamblerre
Copy link
Contributor

Sounds like it, but I'll let @quoctruong confirm.

@quoctruong
Copy link
Contributor

@hgl yes that’s correct. The idea is that you won’t have to specify it.

@hgl
Copy link
Author

hgl commented May 28, 2020

@quoctruong I tried to test It just now, but remote debugging seems to be broken in nightly.

When I clicked the green triangle to start debugging in the debug panel, the debug session would automatically close after a couple of seconds, and there is no message in debug console or output, and the dlv output kept showing API server listening at: [::]:2000, without changing to my binary's normal output, which means it had never connected.

I could only connect after switching to the stable version of the extension.

My launch setting:

{
    "version": "0.2.0",
    "configurations": [
        {
        "name": "debug go",
        "type": "go",
        "request": "attach",
        "mode": "remote",
        "host": "127.0.0.1",
        "port": 2000
      }
    ]
}

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

4 participants