Open sharefantasy opened 4 years ago
Sorry, I'm not familiar with dlv. Maybe others could help you. 😄
We've been using the following:
full_bin = "dlv exec --continue --accept-multiclient --listen=:2345 --headless=true --api-version=2 --log ./tmp/app"
This is run within a docker container with port 2345 mapped to a host port. Host port is usually the same but depends on how many projects a dev runs simultaneously.
I wrote a plugin of goland. it will auto reconnect debugger. https://github.com/xiantang/air-plugin and finally I will make a pull request to air. then we can use air smoothly.
Hi @xiantang Im using Goland. Your plugin is ready for use ? I'm currently looking for use Air integrated to Goland
EDIT:
Wrote a small tutorial to use Delve with Air and VSCode that worked for me: https://dev.to/andreidascalu/setup-go-with-vscode-in-docker-for-debugging-24ch
嗯,看你标记的位置是广州,那,我就直接敲汉字吧。
netstat -antp | grep 6342
看下是哪个进程占用了这个端口我是在找dlv的最佳实践,然后找到了这里,确切的说是dlv debug
,写一下自己平时遇到的一些细节吧:
1. 传入参数
--
,后面接需要传给程序的参数;例如,服务启动时需要指定配置文件,形如:server -conf foo.yaml
,就可以这样弄:
dlv debug -- -conf ./foo.yaml
详见文档描述2. 设置断点(存疑)
b ./main.go:15
,在当前目录的main.go文件15行设置断点。我遇到的问题是:Command failed: could not find statement at
,因为,设置断点的语法貌似是要指定文件路径,“错误的”写法是这样的b main.go:15
;3. 重复上一个命令
n: Step over to next source line
),可以在输入完命令、按回车后,直接按回车,就是执行上一个命令了。4. 重启调试
restart (alias: r) ---------- Restart process
,重启,很实用。full_bin = "dlv exec --continue --accept-multiclient --listen=:2345 --headless=true --api-version=2 --log ./tmp/app"
Hot reload not working with this command right now with @latest verison of cosmtrek/air package. With previous version of both (.air.toml and delve for debugging) works perfect (It was versions from 4 months ago, since I have pause with this project). When I remove it, hot reload works perfect. Does anyone have same issue ?
I found solution.
Do not use @latest tag for delve package. It can cause an issue. Use specific release version and it is working.
Ex Docker. RUN go install github.com/cosmtrek/air@v1.40.4 && go install github.com/go-delve/delve/cmd/dlv@v1.9.1
Instead RUN go install github.com/cosmtrek/air@latest && go install github.com/go-delve/delve/cmd/dlv@latest
Can't figure out a way of running this!
Can any one give me a hand?
I have a docker compose which uses the air image. I am trying to enable debugging on goland intellij IDE. But I cant get the remote to connect to the container
@dusan91judo does your solution still work? Just started using a docker go setup and am getting the "port already in use" issues. Any particular versions you'd recommend?
Anyone else have a fix here?
first kill that port in os. Then, try with specific version setup. It should work for air@v1.40.4 and dlv@v1.9.1. My answer have more than a year, so for latest versions it might have some changes.
@dusan91judo thank you. Yeah those versions are a bit old at this point, so I don't think they'll work with the go version I'm using. I'll play around though and see if I can find working versions or configuration.
I wrote a plugin of goland. it will auto reconnect debugger. https://github.com/xiantang/air-plugin and finally I will make a pull request to air. then we can use air smoothly.
It doesn't appear like this plugin has any releases and it isn't available on the JetBrains Marketplace either. Is that expected?
@dusan91judo thank you. Yeah those versions are a bit old at this point, so I don't think they'll work with the go version I'm using. I'll play around though and see if I can find working versions or configuration.
@casey-speer did you manage to make it ran with the new version of air and dlv?
Hi, I'm looking for a better way to make air work with delve remote debugging. I setup up this param in full_bin
But during reloading delve reports an error of "address already in use".
Is there a best practice for delve debug config? Thanks! :)