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语言中GOPATH GOROOT的作用和设置方式
May 05 Golang
golang gopm get -g -v 无法获取第三方库的解决方案
May 05 Golang
Golang Gob编码(gob包的使用详解)
May 07 Golang
go web 预防跨站脚本的实现方式
Jun 11 Golang
Go 语言下基于Redis分布式锁的实现方式
Jun 28 Golang
golang 语言中错误处理机制
Aug 30 Golang
Go语言读取txt文档的操作方法
Jan 22 Golang
深入理解go缓存库freecache的使用
Feb 15 Golang
Go语言的协程上下文的几个方法和用法
Apr 11 Golang
Golang数据类型和相互转换
Apr 12 Golang
Go Grpc Gateway兼容HTTP协议文档自动生成网关
Jun 16 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代码飞起来的40条小技巧(提升php效率)
2010/04/12 PHP
PHP+Mysql+jQuery实现发布微博程序 jQuery篇
2011/10/08 PHP
PHP函数实现分页含文本分页和数字分页
2014/10/23 PHP
php中HTTP_REFERER函数用法实例
2014/11/21 PHP
Laravel 5 框架入门(四)完结篇
2015/04/09 PHP
PHP定时执行任务的3种方法详解
2015/12/21 PHP
IE8 中使用加速器(Activities)
2010/05/14 Javascript
DOM节点深度克隆函数cloneNode()用法实例
2015/01/12 Javascript
JQuery 设置checkbox值二次无效的解决方法
2016/07/22 Javascript
JS实现太极旋转思路分析
2016/12/09 Javascript
javascript实现一个网页加载进度loading
2017/01/04 Javascript
JavaScript数据结构之二叉树的遍历算法示例
2017/04/13 Javascript
Vue+Mock.js模拟登录和表格的增删改查功能
2018/07/26 Javascript
React 条件渲染最佳实践小结(7种)
2020/09/27 Javascript
vue3.0实现点击切换验证码(组件)及校验
2020/11/18 Vue.js
使用Python脚本来控制Windows Azure的简单教程
2015/04/16 Python
Python中常见的数据类型小结
2015/08/29 Python
Python解惑之True和False详解
2017/04/24 Python
python中reload(module)的用法示例详解
2017/09/15 Python
详解Django之auth模块(用户认证)
2018/04/17 Python
python tkinter界面居中显示的方法
2018/10/11 Python
在Mac下使用python实现简单的目录树展示方法
2018/11/01 Python
浅谈python多进程共享变量Value的使用tips
2019/07/16 Python
pandas数据选取:df[] df.loc[] df.iloc[] df.ix[] df.at[] df.iat[]
2020/04/24 Python
Python如何在单元测试中给对象打补丁
2020/08/03 Python
python 使用xlsxwriter循环向excel中插入数据和图片的操作
2021/01/01 Python
佳能英国官方网站:Canon UK
2017/08/08 全球购物
材料加工硕士生求职信
2013/10/10 职场文书
《搭石》教学反思
2014/04/07 职场文书
《改造我们的学习》心得体会
2014/11/07 职场文书
先进学校事迹材料
2014/12/30 职场文书
长城导游词
2015/01/30 职场文书
环保建议书作文400字
2015/09/14 职场文书
2016中秋节晚会开场白
2015/11/26 职场文书
会议承办单位欢迎词
2019/07/09 职场文书
浅谈Redis存储数据类型及存取值方法
2021/05/08 Redis