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 28 Golang
go语言中json数据的读取和写出操作
Apr 28 Golang
golang协程池模拟实现群发邮件功能
May 02 Golang
完美解决golang go get私有仓库的问题
May 05 Golang
浅谈golang package中init方法的多处定义及运行顺序问题
May 06 Golang
Golang中异常处理机制详解
Jun 08 Golang
Go语言空白表示符_的实例用法
Jul 04 Golang
修改并编译golang源码的操作步骤
Jul 25 Golang
Go语言实现Base64、Base58编码与解码
Jul 26 Golang
Go 中的空白标识符下划线
Mar 25 Golang
Go web入门Go pongo2模板引擎
May 20 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 读取和修改大文件的某行内容的代码
2009/10/30 PHP
php实现将任意进制数转换成10进制的方法
2015/04/17 PHP
64位windows系统下安装Memcache缓存
2015/12/06 PHP
Yii开启片段缓存的方法
2016/03/28 PHP
jQuery 中使用JSON的实现代码
2011/12/01 Javascript
ie9 提示'console' 未定义问题的解决方法
2014/03/20 Javascript
js取模(求余数)隔行变色
2014/05/15 Javascript
JavaScript检查弹出窗口是否被阻拦的方法技巧
2015/03/13 Javascript
JS实现仿QQ面板的手风琴效果折叠菜单代码
2015/09/11 Javascript
JS操作COOKIE实现备忘记录的方法
2016/04/01 Javascript
vue完成项目后,打包成静态文件的方法
2018/09/03 Javascript
基于element-ui封装可搜索的懒加载tree组件的实现
2020/05/22 Javascript
Vue开发中常见的套路和技巧总结
2020/11/24 Vue.js
python安装PIL模块时Unable to find vcvarsall.bat错误的解决方法
2016/09/19 Python
python redis 删除key脚本的实例
2019/02/19 Python
在windows下使用python进行串口通讯的方法
2019/07/02 Python
Python+selenium点击网页上指定坐标的实例
2019/07/05 Python
python django下载大的csv文件实现方法分析
2019/07/19 Python
python yield关键词案例测试
2019/10/15 Python
pycharm 2019 最新激活方式(pycharm破解、激活)
2020/09/22 Python
Python实现Canny及Hough算法代码实例解析
2020/08/06 Python
python利用google翻译方法实例(翻译字幕文件)
2020/09/21 Python
python GUI计算器的实现
2020/10/09 Python
python操作toml文件的示例代码
2020/11/27 Python
Python编写万花尺图案实例
2021/01/03 Python
谈谈对css属性box-sizing的了解
2017/01/04 HTML / CSS
H5最强接口之canvas实现动态图形功能
2019/05/31 HTML / CSS
硕士研究生求职自荐信范文
2014/03/11 职场文书
愚人节活动策划方案
2014/03/11 职场文书
交通安全标语
2014/06/06 职场文书
幼儿园健康教育方案
2014/06/14 职场文书
开展批评与自我批评发言稿
2014/10/16 职场文书
应聘教师求职信范文
2015/03/20 职场文书
音乐课《小猫钓鱼》教学反思
2016/02/18 职场文书
MySQL 分页查询的优化技巧
2021/05/12 MySQL
国产动画《万圣街》日语配音版制作决定!
2022/03/20 国漫