Remote Debugging - Unchecked Breakpoint

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": []
        },
        {
            // 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"]
+2
1

delve vscode go, , docker-compose.

Dockerfile , , docker-compose.yml.

docker-compose.yml:

version: '2'
services:
  my_app:
    build: .
    security_opt:
      - seccomp:unconfined
    entrypoint: dlv debug github.com/my_user/my_app -l 0.0.0.0:2345 --headless=true --log=true -- server
    volumes:
      - .:/opt/go/src/github.com/my_user/my_app
    ports:
      - "2345:2345"
    expose:
      - "2345"

launch.json:

{
    "version": "0.2.0",
    "configurations": [
        {
            "name": "Remote Docker",
            "type": "go",
            "request": "launch",
            "mode": "remote",
            "remotePath": "/opt/go/src/github.com/my_user/my_app",
            "port": 2345,
            "host": "192.168.99.100",
            "program": "${workspaceRoot}",
            "env": {},
            "args": []
        }
    ]
}

, OS X, IP- , docker-machine ip default. 127.0.0.1, , docker-machine ip.

docker-compose up, my_app :

my_app_1 | 2016/12/14 12:41:32 server.go: 71: API v1

my_app_1 | 2016/12/14 12:41:32 debugger.go: 65: args: [/opt/go/src/github.com/my_user/my_app/debug server]

my_app_1 | API, : [::]: 2345

.

, !

+1

Source: https://habr.com/ru/post/1654392/


All Articles