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中interface{}转为数组的操作
Apr 30 Golang
浅谈golang package中init方法的多处定义及运行顺序问题
May 06 Golang
Go语言实现Snowflake雪花算法
Jun 08 Golang
go web 预防跨站脚本的实现方式
Jun 11 Golang
go select编译期的优化处理逻辑使用场景分析
Jun 28 Golang
golang中字符串MD5生成方式总结
Jul 04 Golang
深入理解go缓存库freecache的使用
Feb 15 Golang
Go语言实现一个简单的并发聊天室的项目实战
Mar 18 Golang
Golang使用Panic与Recover进行错误捕获
Mar 22 Golang
简单聊聊Golang中defer预计算参数
Mar 25 Golang
如何解决goland,idea全局搜索快捷键失效问题
Apr 03 Golang
Go中使用gjson来操作JSON数据的实现
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
require(),include(),require_once()和include_once()的异同
2007/01/02 PHP
mysql时区问题
2008/03/26 PHP
PHP函数篇详解十进制、二进制、八进制和十六进制转换函数说明
2011/12/05 PHP
我的php学习笔记(毕业设计)
2012/02/21 PHP
子窗体与父窗体传值示例js代码
2013/08/01 Javascript
input链接页面、打开新网页等等的具体实现
2013/12/30 Javascript
jQuery表格排序组件-tablesorter使用示例
2014/05/26 Javascript
一款基jquery超炫的动画导航菜单可响应单击事件
2014/11/02 Javascript
js实现n秒倒计时后才可以点击的效果
2015/12/20 Javascript
javascript中类的定义方式详解(四种方式)
2015/12/22 Javascript
jQuery实现iframe父窗体和子窗体的相互调用
2016/06/17 Javascript
js获取html的span标签的值方法(超简单)
2016/07/26 Javascript
jquery Form轻松实现文件上传
2017/05/24 jQuery
JavaScript实现获取用户单击body中所有A标签内容的方法
2017/06/05 Javascript
webpack+react+antd脚手架优化的方法
2018/04/02 Javascript
Mac下安装vue
2018/04/11 Javascript
javascript自定义右键菜单插件
2019/12/16 Javascript
javascript实现时间日期的格式化的方法汇总
2020/08/06 Javascript
JS页面动态绘图工具SVG,Canvas,VML介简介
2020/10/16 Javascript
python 获取本机ip地址的两个方法
2013/02/25 Python
python对DICOM图像的读取方法详解
2017/07/17 Python
说说如何遍历Python列表的方法示例
2019/02/11 Python
Python Pandas分组聚合的实现方法
2019/07/02 Python
python输出决策树图形的例子
2019/08/09 Python
pandas数据选取:df[] df.loc[] df.iloc[] df.ix[] df.at[] df.iat[]
2020/04/24 Python
Pycharm 设置默认解释器路径和编码格式的操作
2021/02/05 Python
什么是TCP/IP
2014/07/27 面试题
中药专业大学生医药工作求职信
2013/10/25 职场文书
行政管理专业推荐信
2013/11/02 职场文书
药学专业个人的自我评价
2013/12/31 职场文书
《庐山的云雾》教学反思
2014/04/22 职场文书
小学优秀班集体申报材料
2014/05/25 职场文书
晚自修旷课检讨书怎么写
2014/11/17 职场文书
2016年大学生暑假爱心支教活动策划书
2015/11/26 职场文书
2016年庆祝六一儿童节活动总结
2016/04/06 职场文书
Vue vee-validate插件的简单使用
2021/06/22 Vue.js