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语言中切片与内存复制 memcpy 的实现操作
Apr 27 Golang
golang 生成对应的数据表struct定义操作
Apr 28 Golang
golang 接口嵌套实现复用的操作
Apr 29 Golang
Golang 使用Map实现去重与set的功能操作
Apr 29 Golang
golang DNS服务器的简单实现操作
Apr 30 Golang
Go语言实现Base64、Base58编码与解码
Jul 26 Golang
golang 语言中错误处理机制
Aug 30 Golang
Go语言基础函数基本用法及示例详解
Nov 17 Golang
一文搞懂Golang 时间和日期相关函数
Dec 06 Golang
Go 内联优化让程序员爱不释手
Jun 21 Golang
Go本地测试解耦任务拆解及沟通详解Go本地测试的思路沟通的重要性总结
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语法速查表
2006/12/06 PHP
php实现的仿阿里巴巴实现同类产品翻页
2009/12/11 PHP
php利用反射实现插件机制的方法
2015/03/14 PHP
Laravel利用gulp如何构建前端资源详解
2018/06/03 PHP
php将从数据库中获得的数据转换成json格式并输出的方法
2018/08/21 PHP
JS 进度条效果实现代码整理
2011/05/21 Javascript
CodeMirror2 IE7/IE8 下面未知运行时错误的解决方法
2012/03/29 Javascript
JQuery 在线引用及测试引用是否成功
2014/06/24 Javascript
禁用页面部分JavaScript不是全部而是部分
2014/09/03 Javascript
JavaScript实现按Ctrl键打开新页面
2014/09/04 Javascript
node.js中的emitter.emit方法使用说明
2014/12/10 Javascript
jquery制作 随机弹跳的小球特效
2015/02/01 Javascript
javascript实现base64 md5 sha1 密码加密
2015/09/09 Javascript
理解javascript正则表达式
2016/03/08 Javascript
举例讲解jQuery对DOM元素的向上遍历、向下遍历和水平遍历
2016/07/07 Javascript
VUE实现一个分页组件的示例
2017/09/13 Javascript
删除table表格行的实例讲解
2017/09/21 Javascript
微信小程序实现下拉菜单切换效果
2020/03/30 Javascript
vue和better-scroll实现列表左右联动效果详解
2019/04/29 Javascript
javascript实现前端分页效果
2020/06/24 Javascript
js实现浏览器打印功能的示例代码
2020/07/15 Javascript
[03:03]DOTA2 2017国际邀请赛开幕战队入场仪式
2017/08/09 DOTA
Python通过poll实现异步IO的方法
2015/06/04 Python
python 回调函数和回调方法的实现分析
2016/03/23 Python
Python延时操作实现方法示例
2018/08/14 Python
值得收藏的10道python 面试题
2019/04/15 Python
python使用pip安装模块出现ReadTimeoutError: HTTPSConnectionPool的解决方法
2019/10/04 Python
css3中用animation的steps属性制作帧动画
2019/04/25 HTML / CSS
本科毕业生专业自荐书范文
2014/02/05 职场文书
出纳员岗位责任制
2014/02/11 职场文书
连锁酒店店长职责范本
2014/02/13 职场文书
财政局党的群众路线教育实践活动整改方案
2014/09/21 职场文书
护士求职自荐信范文
2015/03/04 职场文书
中秋节主题班会
2015/08/14 职场文书
golang 实现对Map进行键值自定义排序
2021/04/28 Golang
SQL Server中常用截取字符串函数介绍
2022/03/16 SQL Server