go语言-在mac下brew升级golang


Posted in Golang onApril 25, 2021

在命令行下直接运行:

brew upgrade go

补充:mac下更新delve调试go语言

概述

delve 是golang调试程序。但如果版本不配套, mac下goland 调试,step over会不起作用,直接变成执行完毕或者到下一个断点。 需要更新调试器delve解决。

go get安装

mac下安装delve,官方教程是两步。

$ xcode-select --install
xcode-select: error: command line tools are already installed, use "Software Update" to install updates
$ go get -u github.com/derekparker/delve/cmd/dlv

但go get 一直不返回。

homebrew 安装

zhouhh@/Users/zhouhh $ brew install go-delve/delve/delve
Updating Homebrew...
==> Installing delve from go-delve/delve
==> Downloading https://github.com/derekparker/delve/archive/v1.0.0.tar.gz
Already downloaded: /Users/zhouhh/Library/Caches/Homebrew/delve-1.0.0.tar.gz
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/zhouhh/Library/Logs/Homebrew/delve/02.sudo:
2018-08-09 17:07:38 +0800
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
These open issues may also help:
Upgrade to delve fails https://github.com/go-delve/homebrew-delve/issues/20
/usr/local/Homebrew/Library/Homebrew/exceptions.rb:426:in `block in dump': undefined method `check_for_bad_install_name_tool' for #<Homebrew::Diagnostic::Checks:0x007fc5df858bd8> (NoMethodError)
Did you mean?  check_for_tap_ruby_files_locations
 from /usr/local/Homebrew/Library/Homebrew/exceptions.rb:425:in `each'
 from /usr/local/Homebrew/Library/Homebrew/exceptions.rb:425:in `dump'
 from /usr/local/Homebrew/Library/Homebrew/brew.rb:138:in `rescue in <main>'
 from /usr/local/Homebrew/Library/Homebrew/brew.rb:30:in `<main>'

这是因为证书有问题。 可以到homebrew缓存下载的delve里处理一下。

zhouhh@/Users/zhouhh $ cd $HOME/Library/Caches/Homebrew
zhouhh@/Users/zhouhh/Library/Caches/Homebrew $ ls del*
delve-1.0.0.tar.gz
zhouhh@/Users/zhouhh/Library/Caches/Homebrew $ tar zxvf delve-1.0.0.tar.gz
zhouhh@/Users/zhouhh/Library/Caches/Homebrew $ sh delve-1.0.0/scripts/gencert.sh
Password:

再安装成功

zhouhh@/Users/zhouhh/Library/Caches/Homebrew $ CGO_ENABLED=1 brew install go-delve/delve/delve
==> Installing delve from go-delve/delve
==> Downloading https://github.com/derekparker/delve/archive/v1.0.0.tar.gz
Already downloaded: /Users/zhouhh/Library/Caches/Homebrew/delve-1.0.0.tar.gz
==> dlv-cert is already installed, no need to create it
==> make build BUILD_SHA=v1.0.0
==> Caveats
If you get "could not launch process: could not fork/exec", you need to try
in a new terminal.
When uninstalling, to remove the dlv-cert certificate, run this command:
    $ sudo security delete-certificate -t -c dlv-cert /Library/Keychains/System.keychain
Alternatively, you may want to delete from the Keychain (with the Imported private key).
==> Summary
?  /usr/local/Cellar/delve/1.0.0: 6 files, 10.6MB, built in 13 seconds

安装成功

修改ide环境

安装完最新的 delve 后,如 brew install delve, 然后在IntelliJ或goland中点击

Help → Edit Custom Properties...

添加新行

dlv.path=/usr/local/bin/dlv

保存重启,解决step over(F8) 直接运行完毕的bug。

以上为个人经验,希望能给大家一个参考,也希望大家多多支持三水点靠木。如有错误或未考虑完全的地方,望不吝赐教。

Golang 相关文章推荐
一文读懂go中semaphore(信号量)源码
Apr 03 Golang
golang 生成对应的数据表struct定义操作
Apr 28 Golang
基于Go Int转string几种方式性能测试
Apr 28 Golang
解决golang在import自己的包报错的问题
Apr 29 Golang
golang日志包logger的用法详解
May 05 Golang
浅谈golang package中init方法的多处定义及运行顺序问题
May 06 Golang
入门学习Go的基本语法
Jul 07 Golang
golang用type-switch判断interface的实际存储类型
Apr 14 Golang
Golang 结构体数据集合
Apr 22 Golang
详解Go语言中配置文件使用与日志配置
Jun 01 Golang
Go gRPC进阶教程gRPC转换HTTP
Jun 16 Golang
GoFrame框架数据校验之校验结果Error接口对象
Jun 21 Golang
go原生库的中bytes.Buffer用法
Apr 25 #Golang
Go缓冲channel和非缓冲channel的区别说明
Apr 25 #Golang
Go语言使用select{}阻塞main函数介绍
win10下go mod配置方式
Go语言-为什么返回值为接口类型,却返回结构体
Apr 24 #Golang
go:垃圾回收GC触发条件详解
Apr 24 #Golang
基于go interface{}==nil 的几种坑及原理分析
Apr 24 #Golang
You might like
php 获取文件行数的方法总结
2016/10/11 PHP
php 静态属性和静态方法区别详解
2017/04/09 PHP
thinkPHP框架动态配置用法实例分析
2018/06/14 PHP
利用PHP扩展Xhprof分析项目性能实践教程
2018/09/05 PHP
Laravel框架创建路由的方法详解
2019/09/04 PHP
解密效果
2006/06/23 Javascript
把html页面的部分内容保存成新的html文件的jquery代码
2009/11/12 Javascript
基于JQuery的抓取博客园首页RSS的代码
2011/12/01 Javascript
node.js中的querystring.stringify方法使用说明
2014/12/10 Javascript
jQuery结合ajax实现动态加载文本内容
2015/05/19 Javascript
jquery实现一个简单的表单验证实例
2016/03/30 Javascript
微信小程序 122100版本更新问题解决方案
2016/12/22 Javascript
全面解析vue中的数据双向绑定
2017/05/10 Javascript
JavaScript实现的简单加密解密操作示例
2018/06/01 Javascript
使用layui前端框架弹出form表单以及提交的示例
2019/10/25 Javascript
Python Django使用forms来实现评论功能
2016/08/17 Python
Python 多进程并发操作中进程池Pool的实例
2017/11/01 Python
ubuntu安装mysql pycharm sublime
2018/02/20 Python
python高阶爬虫实战分析
2018/07/29 Python
python代码 输入数字使其反向输出的方法
2018/12/22 Python
Python3爬楼梯算法示例
2019/03/04 Python
python实现维吉尼亚加密法
2019/03/20 Python
python实现图片上添加图片
2019/11/26 Python
基于Python的自媒体小助手---登录页面的实现代码
2020/06/29 Python
HTML5中使用postMessage实现Ajax跨域请求的方法
2016/04/19 HTML / CSS
h5使用canvas画布实现手势解锁
2019/01/04 HTML / CSS
印尼穆斯林时尚购物网站:Hijabenka
2016/12/10 全球购物
欧洲有机婴儿食品最大的市场:Organic Baby Food(供美国和加拿大)
2018/03/28 全球购物
2014年社会实践活动总结范文
2014/04/29 职场文书
委托书的写法
2014/08/30 职场文书
干部职工纪律作风整改措施思想汇报
2014/10/11 职场文书
2014年班长个人工作总结
2014/11/14 职场文书
给老婆的保证书怎么写
2015/05/08 职场文书
贷款收入证明格式
2015/06/24 职场文书
Python pandas读取CSV文件的注意事项(适合新手)
2021/06/20 Python
使用scrapy实现增量式爬取方式
2022/06/21 Python