I am currently facing an issue related to setting the root token ID to a previous value in the HashiCorp Vault Go code. I have tried debugging the application using dlv debug within a Docker container. However, when attempting to run the application on my Windows machine, it hangs. Although the application eventually runs on the Docker machine, I encountered an issue with the debugger not functioning properly when setting breakpoints.
The question is how can I get delve debugger to properly stop at breakpoints as the application is running in the docker container
To provide a better understanding of the problem, I have attached a minimal reproduction of the issue on GitHub.
What I've tried
- tried to run the application on windows local but it hangs
- tried to make sure the go versions match still no luck
If you look carefully in the log, you will see something like this:
It could not set the breakpoint on the file
/usr/src/app/minimal_repro/main.go
. The correct file location is/usr/src/app/main.go
.This is your
.vscode/launch.json
file:And this is the directory structure:
Replace
"cwd": "${workspaceFolder}"
with"cwd": "${workspaceFolder}/minimal_repro"
will address the issue.According to vscode-go debugging,
remotePath
is deprecated. UsesubstitutePath
instead. WithsubstitutePath
,.vscode/launch.json
looks like this:Regarding that this code:
Generates this output:
This is most likely due to the write cache. This issue should have been discussed somewhere else. I don't have the link to the discussion by hand, and since it's not important to the main issue in this question, I will ignore it for now.
This is your
Dockerfile
:Please note that
dlv debug
compiles and begins debugging main package in current directory. It does not exec the one generated byRUN go build -gcflags="all=-N -l" -v -o /usr/local/bin/app ./...
. Usedlv exec
instead if you want to debug a pre-compiled executable.