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 相关文章推荐
Golang二维切片初始化的实现
Apr 08 Golang
Go语言操作数据库及其常规操作的示例代码
Apr 21 Golang
Go语言使用select{}阻塞main函数介绍
Apr 25 Golang
golang 实现对Map进行键值自定义排序
Apr 28 Golang
Golang中interface{}转为数组的操作
Apr 30 Golang
K8s部署发布Golang应用程序的实现方法
Jul 16 Golang
golang实现一个简单的websocket聊天室功能
Oct 05 Golang
golang为什么要统一错误处理
Apr 03 Golang
golang用type-switch判断interface的实际存储类型
Apr 14 Golang
实现GO语言对数组切片去重
Apr 20 Golang
Golang解析JSON对象
Apr 30 Golang
go goth封装第三方认证库示例详解
Aug 14 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 swfupload图片上传的实例代码
2013/09/30 PHP
适合PHP初学者阅读的4本经典书籍
2016/09/23 PHP
php版阿里云OSS图片上传类详解
2016/12/01 PHP
Eclipse PHPEclipse 配置的具体步骤
2017/08/08 PHP
PHP防止sql注入小技巧之sql预处理原理与实现方法分析
2019/12/13 PHP
IE中直接运行显示当前网页中的图片 推荐
2006/08/31 Javascript
用JS实现的一个include函数
2007/07/21 Javascript
javascript下给元素添加事件的方法与代码
2007/08/13 Javascript
javascript中如何处理引号编码&amp;#034;
2013/08/15 Javascript
使用jQuery获得内容以及内容的属性
2015/02/26 Javascript
js实现从中间开始往上下展开网页窗口的方法
2015/03/02 Javascript
jQuery实现行文字链接提示效果的方法
2015/03/10 Javascript
AngularJS基础学习笔记之表达式
2015/05/10 Javascript
3个可以改善用户体验的AngularJS指令介绍
2015/06/18 Javascript
一个仿微博登陆邮箱提示框js开发案例
2016/07/28 Javascript
CSS3 media queries结合jQuery实现响应式导航
2016/09/30 Javascript
深入剖析Node.js cluster模块
2018/05/23 Javascript
Vue框架里使用Swiper的方法示例
2018/09/20 Javascript
js 实现在2d平面上画8的方法
2018/10/10 Javascript
详解vue-element Tree树形控件填坑路
2019/03/26 Javascript
使用React手写一个对话框或模态框的方法示例
2019/04/25 Javascript
Python实现简单登录验证
2016/04/13 Python
Python线程同步的实现代码
2018/10/03 Python
selenium跳过webdriver检测并模拟登录淘宝
2019/06/12 Python
python在新的图片窗口显示图片(图像)的方法
2019/07/11 Python
Django单元测试中Fixtures用法详解
2020/02/25 Python
基于python图书馆管理系统设计实例详解
2020/08/05 Python
常用的四种CSS透明属性介绍
2014/04/12 HTML / CSS
Paradox London官方网站:英国新娘鞋婚礼鞋品牌
2019/08/29 全球购物
七年级音乐教学反思
2014/01/26 职场文书
财务总监岗位职责
2014/03/07 职场文书
支部鉴定材料
2014/06/02 职场文书
法人单位授权委托书范文
2014/10/06 职场文书
缓刑人员思想汇报
2014/10/11 职场文书
升学宴答谢词
2015/01/05 职场文书
留学推荐信怎么写
2015/03/26 职场文书