Hope I can explain this right.
Update: I can confirm that dlv debug -l 127.0.0.1:2345 does work. Therefore I must be in VsCode launch.json
Update: removed the panic. There was a different in go versions. Now the debugger in VsCode is just not working, it says "Unverified breakpoint". But it works fine if I use dlv from terminal, if I am in the folder with the code.
I am trying to remote debug with this sample code.
It works with this change.
Do you know what to do? I have tried to change the launch.json to "program": "${workspaceRoot}", to include the path like "program": "${workspaceRoot}/src/app",.
Launch.json
{ "version": "0.2.0", "configurations": [ { "name": "Launch", "type": "go", "request": "launch", "mode": "debug", "program": "${workspaceRoot}", "env": {}, "args": [] }, { // To remote debug in Docker, run the following before debugging: // # docker build -t webapp-go . // # docker run -d --name webapp-go --privileged -p 8080:8080 -p 2345:2345 webapp-go // # docker run -d --name webapp-go --privileged -p 8080:8080 -p 2345:2345 -v "${PWD%/*}/src/app/":/go/src/app webapp-go // And then each time you want to restart debugging: // # docker restart "name": "Remote debug in Docker", "type": "go", "request": "launch", "mode": "remote", "program": "${workspaceRoot}", "env": {}, "args": [], "remotePath": "/go/src/app", "port": 2345, // Port "host": "127.0.0.1" // Docker IP /* "preLaunchTask": "docker" */ } ] } Dockerfile:
FROM golang:1.6 RUN go get -u -v github.com/derekparker/delve/cmd/dlv EXPOSE 2345 # RUN mkdir -p /go/src/app # WORKDIR /go/src/app # VOLUME ["src/app2"] 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"]