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.

    评论

报告相同问题?

悬赏问题

  • ¥15 求帮我调试一下freefem代码
  • ¥15 matlab代码解决,怎么运行
  • ¥15 R语言Rstudio突然无法启动
  • ¥15 关于#matlab#的问题:提取2个图像的变量作为另外一个图像像元的移动量,计算新的位置创建新的图像并提取第二个图像的变量到新的图像
  • ¥15 改算法,照着压缩包里边,参考其他代码封装的格式 写到main函数里
  • ¥15 用windows做服务的同志有吗
  • ¥60 求一个简单的网页(标签-安全|关键词-上传)
  • ¥35 lstm时间序列共享单车预测,loss值优化,参数优化算法
  • ¥15 Python中的request,如何使用ssr节点,通过代理requests网页。本人在泰国,需要用大陆ip才能玩网页游戏,合法合规。
  • ¥100 为什么这个恒流源电路不能恒流?