air-verse / air

☁️ Live reload for Go apps
GNU General Public License v3.0
17.42k stars 799 forks source link

Best Practice to work with delve #76

Open sharefantasy opened 4 years ago

sharefantasy commented 4 years ago

Hi, I'm looking for a better way to make air work with delve remote debugging. I setup up this param in full_bin

dlv exec --head --accept-multiclient --listen=127.0.0.1:6342 --continue

But during reloading delve reports an error of "address already in use".

Is there a best practice for delve debug config? Thanks! :)

cosmtrek commented 4 years ago

Sorry, I'm not familiar with dlv. Maybe others could help you. 😄

sokratisg commented 4 years ago

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.

xiantang commented 4 years ago

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.

Metrakit commented 4 years ago

Hi @xiantang Im using Goland. Your plugin is ready for use ? I'm currently looking for use Air integrated to Goland

andrei-dascalu commented 3 years ago

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

maliyan commented 2 years ago

嗯,看你标记的位置是广州,那,我就直接敲汉字吧。

提示的是端口被占用了

实践

我是在找dlv的最佳实践,然后找到了这里,确切的说是dlv debug,写一下自己平时遇到的一些细节吧:

1. 传入参数

2. 设置断点(存疑)

3. 重复上一个命令

4. 重启调试

dusan91judo commented 2 years ago

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 ?

dusan91judo commented 2 years ago

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

ShuttleSantalex commented 1 year ago

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

casey-speer commented 9 months ago

@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?

dusan91judo commented 9 months ago

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.

casey-speer commented 9 months ago

@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.

nadeemc commented 1 day ago

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?