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中实现给gif、png、jpeg图片添加文字水印
Apr 26 Golang
golang 在windows中设置环境变量的操作
Apr 29 Golang
Go语言 go程释放操作(退出/销毁)
Apr 30 Golang
解决goland 导入项目后import里的包报红问题
May 06 Golang
Goland使用Go Modules创建/管理项目的操作
May 06 Golang
手把手教你导入Go语言第三方库
Aug 04 Golang
Go语言特点及基本数据类型使用详解
Mar 21 Golang
Golang 1.18 多模块Multi-Module工作区模式的新特性
Apr 11 Golang
Go语言的协程上下文的几个方法和用法
Apr 11 Golang
Go语言入门exec的基本使用
May 20 Golang
GO中sync包自由控制并发示例详解
Aug 05 Golang
Go结合Gin导出Mysql数据到Excel表格
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
php 表单数据的获取代码
2009/03/10 PHP
PHP stream_context_create()作用和用法分析
2011/03/29 PHP
dhtmlxTree目录树增加右键菜单以及拖拽排序的实现方法
2013/04/26 PHP
解析PHP中的正则表达式以及模式匹配
2013/06/19 PHP
两个php日期控制类实例
2014/12/09 PHP
PHP cURL获取微信公众号access_token的实例
2018/04/28 PHP
jquery实现Li滚动时滚动条自动添加样式的方法
2015/08/10 Javascript
Jquery代码实现图片轮播效果(一)
2015/08/12 Javascript
JS仿hao123导航页面图片轮播效果
2016/09/01 Javascript
Bootstrap php制作动态分页标签
2016/12/23 Javascript
js中new一个对象的过程
2017/02/20 Javascript
ie下js不执行的几种可能
2017/02/28 Javascript
彻底搞懂JavaScript中的apply和call方法(必看)
2017/09/18 Javascript
javascript数组定义的几种方法
2017/10/06 Javascript
基于Bootstrap下拉框插件bootstrap-select使用方法详解
2018/08/07 Javascript
vue加载完成后的回调函数方法
2018/09/07 Javascript
基于vue.js实现购物车
2020/01/15 Javascript
微信小游戏中three.js离屏画布的示例代码
2020/10/12 Javascript
[59:26]DOTA2上海特级锦标赛D组资格赛#1 EG VS VP第二局
2016/02/28 DOTA
[53:49]LGD vs Fnatic 2018国际邀请赛小组赛BO2 第二场 8.18
2018/08/19 DOTA
Python3.6通过自带的urllib通过get或post方法请求url的实例
2018/05/10 Python
Python 字符串换行的多种方式
2018/09/06 Python
详解python while 函数及while和for的区别
2018/09/07 Python
python实现动态数组的示例代码
2019/07/15 Python
wxPython+Matplotlib绘制折线图表
2019/11/19 Python
python 消除 futureWarning问题的解决
2019/12/25 Python
Python 面向对象静态方法、类方法、属性方法知识点小结
2020/03/09 Python
Python如何解除一个装饰器
2020/08/07 Python
利用Python实现自动扫雷小脚本
2020/12/17 Python
介绍CSS3使用技巧5个
2009/04/02 HTML / CSS
资生堂英国官网:Shiseido英国
2020/12/30 全球购物
你常见到的runtime exception
2016/09/05 面试题
事假请假条范文
2014/04/11 职场文书
贷款委托书
2014/08/01 职场文书
导游词之藏龙百瀑景区
2019/12/30 职场文书
Win11 引入 Windows 365 云操作系统,适应疫情期间混合办公模式:启动时直接登录、模
2022/04/06 数码科技