4308

mac配置VSCode开发Golang过程中的坑

乐果   发表于   2017 年 08 月 23 日 标签:golangmac

安装Visual Studio Code在此不详细说明了,网上资料一堆,在此简单说明下安装过程的坑:

先后安装好Visual Studio Code、golang扩展插件、以及扩展插件所依赖的包后,调试发现报错,主要原因是 dlv这个依赖包安装出了问题,我们一般是用go get 来安装的:

go get -u -v github.com/derekparker/delve/cmd/dlv

这在windows系统下是没问题的,但在mac下不行,网上说是因为签名权限等,因此最好用brew命令来安装,例如:

brew install go-delve/delve/delve

但安装失败:

...
...
security: SecKeychainSearchCopyNext: The specified item could not be found in the keychain.
==> Generating dlv-cert
==> openssl req -new -newkey rsa:2048 -x509 -days 3650 -nodes -config dlv-cert.cfg -extensions codesign_reqext -batch -out dlv-cert.cer -keyout dlv-cert.key
==> [SUDO] Installing dlv-cert as root
==> sudo security add-trusted-cert -d -r trustRoot -k /Library/Keychains/System.keychain dlv-cert.cer
Last 15 lines from /Users/gta/Library/Logs/Homebrew/delve/02.sudo:
2017-08-02 17:06:05 +0200

sudo
security
add-trusted-cert
-d
-r
trustRoot
-k
/Library/Keychains/System.keychain
dlv-cert.cer

If reporting this issue please do so at (not Homebrew/brew or Homebrew/core):
https://github.com/go-delve/homebrew-delve/issues

去github官方仓库去查,有人遇到类似的问题,如下解决:

https://github.com/go-delve/homebrew-delve/issues/19

https://github.com/go-delve/homebrew-delve/issues/17

I fixed this by manually installing the cert (unzip the cached .tar.gz, run gencert which lives in scripts):

$ cd ~/Library/Caches/Homebrew/delve-1.0.0-rc.1/scripts
$ ./gencert.sh
Password:
$

乐果   发表于   2017 年 08 月 23 日 标签:golangmac

0

文章评论