douxuqiao6394 2019-05-23 11:11
浏览 630

GoLand远程调试显示“找不到<file>”

I'm attempting to debug a single-file Go application running in a docker container, using delve in the container, and using GoLand on a Mac laptop.

When I run a local debugger, my breakpoints work. When I use a "Go Remote" configuration, all of my breakpoints become a circle-slash, and the note says "could not find FILENAME".

I verified that my source files are at the same relative path to the GOPATH on both the server (container) and client.

I'm using Go 1.12.5 in the container, with this delve command: dlv debug --headless --listen=:8044 --api-version=2 --accept-multiclient

It correctly builds my src/github.com/flinkt/reverseProxy/reverseProxy.go to bin/reverseProxy and begins outputting the expected messages when it gets the http requests it expects.

My GoLand build is 2019.1. The config hits localhost 8043, and has no other fields filled-in.

The docker container is mounting the source through, so I'm sure that they are looking at the exact same source files.

The project config has a content root right above the src/ and bin/ directories, and that is set as the project GOPATH too. There is no global GOPATH, and all dependencies are in the src/ tree. The checkbox to index everything is checked.

Suggestions on why my IDE can't see my source or stop at my breakpoints?

  • 写回答

1条回答 默认 最新

  • dongliang9682 2019-07-03 03:04
    关注

    I encounter a similar situation as you.

    Here is my scenario:

    • build go binary at a remote machine, but out of GOPATH dir (Use Go Module).
    • running in a docker container, using delve in the host machine directly attach to docker container pid.

    dlv --listen=:2345 --headless=true --api-version=2 --accept-multiclient attach $PID

    • local source code is under GOPATH, using GoLand on a Mac laptop connect to remote delve server.
    • I can see the Goroutine info, but breakpoints not work, says "could not find XXX".

    Solution:

    go modules

    Enable "Go Modules integration" at Goland settings, and it works!


    Perhaps I use Go Module while building, and Goland implements delve client by themselves, so I should enable Goland Go Module integration to let Goland treat source code path correctly.

    Goland: 2019.1.3, delve: 1.2.0, Go: 1.12.4

    Hope this will help you.

    评论

报告相同问题?

悬赏问题

  • ¥20 有关区间dp的问题求解
  • ¥15 多电路系统共用电源的串扰问题
  • ¥15 slam rangenet++配置
  • ¥15 有没有研究水声通信方面的帮我改俩matlab代码
  • ¥15 对于相关问题的求解与代码
  • ¥15 ubuntu子系统密码忘记
  • ¥15 信号傅里叶变换在matlab上遇到的小问题请求帮助
  • ¥15 保护模式-系统加载-段寄存器
  • ¥15 电脑桌面设定一个区域禁止鼠标操作
  • ¥15 求NPF226060磁芯的详细资料