Remote debugging - Unverified breakpoint

北慕城南 提交于 2019-12-02 02:12:34

I managed to get delve and vscode with go working for me by using docker-compose.

I use my Dockerfile to build the app as you do and just override some container attributes in my docker-compose.yml.

Here's how my docker-compose.yml looks :

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"

And the launch.json file :

{
    "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": []
        }
    ]
}

Note that since I'm on OS X the IP is what my docker-machine ip default prints. You can change it to 127.0.0.1 if this is what your docker-machine ip outputs.

On docker-compose up, my_app prints :

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

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

my_app_1 | API server listening at: [::]:2345

And after setting up some breakpoints and attaching the debugger it works.

Hope this helps!

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!