【踩坑】IDEA通过DEBUG运行Go程序报错
source link: https://loli.fj.cn/2023/06/04/IDEA%E9%80%9A%E8%BF%87DEBUG%E8%BF%90%E8%A1%8CGo%E7%A8%8B%E5%BA%8F%E6%8A%A5%E9%94%99/
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
【踩坑】IDEA通过DEBUG运行Go程序报错
2023-06-04
IDEA通过DEBUG运行Go程序报错:Got a connection, launched process
- 下载并安装dlv
git clone https://github.com/go-delve/delve
cd delve
go install github.com/go-delve/delve/cmd/dlv
cd ..
rm -rf delve
完成
install
后会在GOPATH/bin
目录下生成dlv二进制文件创建一个
macarm
目录存放dlv二进制文件
这个步骤是必须的
当前案例中将macarm
目录放在了HOME目录下
~/go/
:如果没有修改过GOPATH,默认在HOME目录下的go目录即为GOPATH默认目录,如果修改过GOPATH,根据当前GOPATH环境修改命令
cd ~
mkdir macarm
cp ~/go/bin/dlv ./macarm
- 将
macarm
目录所在的父级目录配置在IDEA(或Goland)Custom Properties
中
Help
->Edit Custom Properties
当前案例中,macarm
目录所在的父级目录是HOME目录,所以将HOME目录的绝对路径配置为值
/Users/charon/Library/Application Support/JetBrains/IntelliJIdea/idea.properties
dlv.path=/Users/用户名
- 重启IDEA生效
Recommend
About Joyk
Aggregate valuable and interesting links.
Joyk means Joy of geeK