Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

When I build a binary in a subdirectory, build error links are not valid/clickable #3068

Answered by firelizzard18
lzap asked this question in Help
Discussion options

Hello, I have the following launch config:

{
 "version": "0.2.0",
 "configurations": [
 {
 "name": "Service",
 "type": "go",
 "request": "launch",
 "mode": "auto",
 "program": "cmd/controller",
 "cwd": "${workspaceFolder}"
 }
 ]
}

Now, when I launch it Delve changes directory into cmd/controller and builds . and while this works the problem is then when I get compilation error, links are not valid. For example:

Starting: /home/lzap/go/bin/dlv dap --listen=127.0.0.1:41945 --log-dest=3 from /home/lzap/forester/cmd/controller
DAP server listening at: 127.0.0.1:41945
Build Error: go build -o /home/lzap/forester/cmd/controller/__debug_bin3829863487 -gcflags all=-N -l .
# forester/internal/config
../../internal/config/config.go:121:37: undefined: Hostname (exit status 1)

When I click on ../../internal/config/config.go:121:37 VSCode is unable to locate this file as it tries to find it two levels above the project directory.

I must be missing something, what is the correct launch configuration for this single Go application setup which is I believe pretty common use case. Thanks.

You must be logged in to vote

The go build invocation is controlled by delve, not vscode-go. If delve supports a flag or other configuration option to change this behavior, please open a vscode-go feature request to add support for that (if we don't already support it). If delve does not have any such option, then this is a delve issue/request, not a vscode-go one.

When I click on ../../internal/config/config.go:121:37 VSCode is unable to locate this file as it tries to find it two levels above the project directory.

This is a separate issue. Is it fair to say your actual issue is, "When I build a binary in a subdirectory, build error links are not valid/clickable"? If so, then that is potentially a bug that should ...

Replies: 2 comments 4 replies

Comment options

Have the same issue, unable to find solution for this.

As cwd param defined here

Workspace relative or absolute path to the working directory of the program being debugged if a non-empty value is specified. The program folder is used as the working directory if cwd is omitted or empty.(Default: "")

As far as I can tell, resulting binary is executed from cwd. Yet go build is not.

You must be logged in to vote
1 reply
Comment options

This seems like the expected behavior to me.

Comment options

The go build invocation is controlled by delve, not vscode-go. If delve supports a flag or other configuration option to change this behavior, please open a vscode-go feature request to add support for that (if we don't already support it). If delve does not have any such option, then this is a delve issue/request, not a vscode-go one.

When I click on ../../internal/config/config.go:121:37 VSCode is unable to locate this file as it tries to find it two levels above the project directory.

This is a separate issue. Is it fair to say your actual issue is, "When I build a binary in a subdirectory, build error links are not valid/clickable"? If so, then that is potentially a bug that should be fixed and IMO changing the working directory that delve uses for invoking go build is not the solution.

You must be logged in to vote
3 replies
Comment options

Thanks for the analysis, I have renamed the discussion to "When I build a binary in a subdirectory, build error links are not valid/clickable". Shall I create an issue? In which project tho, I am a bit confused here on how this works.

Comment options

Create an issue in vscode-go. Ideally we could handle this by making a change to vscode-go. It's possible that won't work, but we should investigate first. If you ping me in the issue I'll try to take a look, though I'm a volunteer contributor so I may not have time.

Comment options

Created an issue, thanks: #3771

Answer selected by lzap
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Help
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /