I hope I can explain this right.
Update: I can confirm that it dlv debug -l 127.0.0.1:2345works. So I have to be in VsCodelaunch.json
Update: panic removed. There were different versions of go. Now the debugger in VsCode just does not work, it says "Unchecked breakpoint". But it works fine if I use dlvfrom the terminal, if I'm in the code folder.
I am trying to remotely debug this sample code.
It works with this change.
You know what to do? I tried changing launch.jsonto "program": "${workspaceRoot}",to include the path, for example "program": "${workspaceRoot}/src/app",.
Launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Launch",
"type": "go",
"request": "launch",
"mode": "debug",
"program": "${workspaceRoot}",
"env": {},
"args": []
},
{
"name": "Remote debug in Docker",
"type": "go",
"request": "launch",
"mode": "remote",
"program": "${workspaceRoot}",
"env": {},
"args": [],
"remotePath": "/go/src/app",
"port": 2345,
"host": "127.0.0.1"
}
]
}
Dockerfile:
FROM golang:1.6
RUN go get -u -v github.com/derekparker/delve/cmd/dlv
EXPOSE 2345
VOLUME ["/go/src/app"]
RUN mkdir -p /go/src/app
WORKDIR /go/src/app
COPY src/app /go/src/app
RUN go-wrapper download
RUN go-wrapper install
EXPOSE 8080
CMD ["dlv", "debug", "--headless", "--listen=:2345", "--log"]