6

【踩坑】IDEA通过DEBUG运行Go程序报错

 1 year ago
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.
neoserver,ios ssh client

【踩坑】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生效

知乎——宇哥
CSDN——刘贤松handler


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK