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判断为空nil的实现代码
Apr 24 Golang
Go语言带缓冲的通道实现
Apr 26 Golang
golang中切片copy复制和等号复制的区别介绍
Apr 27 Golang
解决golang post文件时Content-Type出现的问题
May 02 Golang
go设置多个GOPATH的方式
May 05 Golang
golang gopm get -g -v 无法获取第三方库的解决方案
May 05 Golang
Go timer如何调度
Jun 09 Golang
Go语言基础知识点介绍
Jul 04 Golang
Go语言并发编程 sync.Once
Oct 16 Golang
golang为什么要统一错误处理
Apr 03 Golang
Go微服务项目配置文件的定义和读取示例详解
Jun 21 Golang
Go gorilla/sessions库安装使用
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
Docker搭建自己的PHP开发环境
2018/02/24 PHP
学习YUI.Ext 第六天--关于树TreePanel(Part 1)
2007/03/10 Javascript
js word表格动态添加代码
2010/06/07 Javascript
jquery实现的一个导航滚动效果具体代码
2013/05/27 Javascript
js使用正则实现ReplaceAll全部替换的方法
2014/07/18 Javascript
jQuery实现拖动调整表格单元格大小的代码实例
2015/01/13 Javascript
浅析AngularJS中的生命周期和延迟处理
2015/06/18 Javascript
jquery控制页面部分刷新的方法
2015/06/24 Javascript
Jquery使用小技巧汇总
2015/12/29 Javascript
Node.js中如何合并两个复杂对象详解
2016/12/31 Javascript
js实现下拉菜单效果
2017/03/01 Javascript
vue.js实现刷新当前页面的方法教程
2017/07/05 Javascript
判断div滑动到底部的scroll实例代码
2017/11/15 Javascript
刷新页面后让控制台的js代码继续执行
2019/09/20 Javascript
vuecli3.x中轻松4步带你使用tinymce的步骤
2020/06/25 Javascript
Python学习笔记之解析json的方法分析
2017/04/21 Python
详解Python之unittest单元测试代码
2018/01/24 Python
python实现m3u8格式转换为mp4视频格式
2018/02/28 Python
Python爬虫基础之XPath语法与lxml库的用法详解
2018/09/13 Python
网易2016研发工程师编程题 奖学金(python)
2019/06/19 Python
详解在Python中以绝对路径或者相对路径导入文件的方法
2019/08/30 Python
python实现将一维列表转换为多维列表(numpy+reshape)
2019/11/29 Python
Python随机数函数代码实例解析
2020/02/09 Python
Django CSRF认证的几种解决方案
2020/03/03 Python
python 安装库几种方法之cmd,anaconda,pycharm详解
2020/04/08 Python
Python实现自动整理文件的脚本
2020/12/17 Python
银行会计职员个人的自我评价
2013/09/29 职场文书
信电学院毕业生自荐书
2014/05/24 职场文书
学校工作推荐信范文
2014/07/11 职场文书
授权委托书格式
2014/07/31 职场文书
高中同学会活动方案
2014/08/14 职场文书
搞笑的爱情检讨书
2014/10/01 职场文书
领导干部群众路线教育实践活动剖析材料
2014/10/10 职场文书
大学生读书笔记大全
2015/07/01 职场文书
python-for x in range的用法(注意要点、细节)
2021/05/10 Python
Python3中PyQt5简单实现文件打开及保存
2021/06/10 Python