简体   繁体   中英

GoLand remote debug shows “could not find <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?

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:

去模块

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM