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 25 Golang
Go语言带缓冲的通道实现
Apr 26 Golang
Go标准容器之Ring的使用说明
May 05 Golang
Golang二维数组的使用方式
May 28 Golang
golang 实用库gotable的具体使用
Jul 01 Golang
详解Go语言Slice作为函数参数的使用
Jul 02 Golang
Golang表示枚举类型的详细讲解
Sep 04 Golang
Go语言基础切片的创建及初始化示例详解
Nov 17 Golang
Go语言实现一个简单的并发聊天室的项目实战
Mar 18 Golang
golang定时器
Apr 14 Golang
GO语言字符串处理函数之处理Strings包
Apr 14 Golang
在ubuntu下安装go开发环境的全过程
Aug 05 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
重新封装zend_soap实现http连接安全认证的php代码
2011/01/12 PHP
ThinkPHP 连接Oracle数据库的详细教程[全]
2012/07/16 PHP
php stripslashes和addslashes的区别
2014/02/03 PHP
php+ajax登录跳转登录实现思路
2016/07/31 PHP
原生javascript图片自动或手动切换示例附演示源码
2013/09/04 Javascript
JavaScript实现快速排序的方法
2015/07/31 Javascript
用JS实现图片轮播效果代码(一)
2016/06/26 Javascript
jQuery Easyui datagrid/treegrid 清空数据
2016/07/09 Javascript
node.js 和HTML5开发本地桌面应用程序
2016/12/13 Javascript
Bootstrap的基本应用要点浅析
2016/12/19 Javascript
JavaScript简单计算人的年龄示例
2017/04/15 Javascript
vue-router 中router-view不能渲染的解决方法
2017/05/23 Javascript
Node.js 实现简单的接口服务器的实例代码
2017/05/23 Javascript
vue+ElementUI实现订单页动态添加产品数据效果实例代码
2017/07/13 Javascript
小程序云开发如何实现图片上传及发表文字
2019/05/17 Javascript
详解Typescript 内置的模块导入兼容方式
2020/05/31 Javascript
使用vue构建多页面应用的示例
2020/10/22 Javascript
三剑客:offset、client和scroll还傻傻分不清?
2020/12/04 Javascript
[00:36]DOTA2上海特级锦标赛 Archon战队宣传片
2016/03/04 DOTA
[02:03]永远的信仰DOTA2 中国军团历届国际邀请赛回顾
2016/06/26 DOTA
python求素数示例分享
2014/02/16 Python
Python实现的密码强度检测器示例
2017/08/23 Python
Django+Ajax+jQuery实现网页动态更新的实例
2018/05/28 Python
python topN 取最大的N个数或最小的N个数方法
2018/06/04 Python
python中利用numpy.array()实现俩个数值列表的对应相加方法
2019/08/26 Python
Python.append()与Python.expand()用法详解
2019/12/18 Python
python获取网络图片方法及整理过程详解
2019/12/20 Python
pytorch 求网络模型参数实例
2019/12/30 Python
PyTorch中的Variable变量详解
2020/01/07 Python
html5+css3进度条倒计时动画特效代码【推荐】
2016/03/08 HTML / CSS
印度网上购物首选目的地:Flipkart
2016/08/01 全球购物
晚会主持词开场白
2014/03/17 职场文书
班干部学习委员竞选稿
2015/11/20 职场文书
纪检干部学习心得体会
2016/01/23 职场文书
《梅花魂》教学反思
2016/02/18 职场文书
如何在CSS中绘制曲线图形及展示动画
2021/05/24 HTML / CSS