问题
当我兴致勃勃的开始 go 语言的 hello world 的时候, 蓦然回首
package main
import "fmt"
func main() {
var i = 1
fmt.Println("hello world ", i)
}
却发现, 竟然不能 debug....
could not launch process: EOF
Process exiting with code: 1
- 系统: mac OSX 10.13.3/4/5
- IDE :IntelliJ IDEA
仔细 google 了一番,貌似是CommandLineTools
更新后的问题.
解决方案
Solution 1(推荐)
感谢Nob东瓜提供,用新版的 dlv 替换 idea 提供的旧版的(旧版dlv bug导致的,编译最新的dlv替换idea自带的即可).
-
dlv
项目地址https://github.com/derekparker/delve
2.安装最新的 dlv.
go get -v -u github.com/derekparker/delve/cmd/dlv
cd $GOPATH/src/github.com/derekparker/delve
make install
完成后
➜ delve git:(master) make install
scripts/gencert.sh || (echo "An error occurred when generating and installing a new certificate"; exit 1)
go install -ldflags="-s -X main.Build=9a216211d3461ab031f822c012bc27cab9758da0" github.com/derekparker/delve/cmd/dlv
codesign -s "dlv-cert" /usr/local/Cellar/go/1.10.3/libexec/bin/dlv
- 替换文件
cd '/Users/{user}/Library/Application Support/IntelliJIdea2017.2/intellij-go/lib/dlv/mac'
mv dlv dlv_back
ln -s $GOROOT/bin/dlv dlv
$GOROOT/bin/dlv
指向的文件就是/usr/local/Cellar/go/1.10.3/libexec/bin/dlv
如果你用的 Goland 同样的道理
cd /Applications/GoLand.app/Contents/plugins/intellij-go-plugin/lib/dlv/mac
mv dlv dlv_back
ln -s $GOROOT/bin/dlv dlv
ps:貌似有些 goland 的路径在/Applications/GoLand.app/Contents/plugins/go/lib/dlv/mac
,自己试下就可以啦
哦了
Solution 2
- 删除系统现有的
CommandLineTools
sudo rm -rf /Library/Developer/CommandLineTools
- 访问 Apple 开发者工具 页面,用 apple ID 登录后,下载
Command Line Tools (Mac OS 10.13) for Xcode 9.1 (Dec 6,2017)
- 安装完成后. Everything OK!
API server listening at: 127.0.0.1:50661
hello world 1
Debugger finished with exit code 0
参考: