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
golang DNS服务器的简单实现操作
Apr 30 Golang
解决go在函数退出后子协程的退出问题
Apr 30 Golang
go 实现简易端口扫描的示例
May 22 Golang
go语言使用Casbin实现角色的权限控制
Jun 26 Golang
go goroutine 怎样进行错误处理
Jul 16 Golang
Go语言基础函数基本用法及示例详解
Nov 17 Golang
golang生成vcf通讯录格式文件详情
Mar 25 Golang
Golang原生rpc(rpc服务端源码解读)
Apr 07 Golang
Go语言 详解net的tcp服务
Apr 14 Golang
golang用type-switch判断interface的实际存储类型
Apr 14 Golang
golang的文件创建及读写操作
Apr 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 htmlspecialchars加强版
2010/02/16 PHP
全新的PDO数据库操作类php版(仅适用Mysql)
2012/07/22 PHP
PHP微信网页授权的配置文件操作分析
2019/05/29 PHP
return false;和e.preventDefault();的区别
2010/07/11 Javascript
javascript AOP 实现ajax回调函数使用比较方便
2010/11/20 Javascript
javascript常见操作汇总
2014/09/03 Javascript
Bootstrap按钮组件详解
2016/04/26 Javascript
javascript对象的相关操作小结
2016/05/16 Javascript
Vue中this.$router.push参数获取方法
2018/02/27 Javascript
浅谈React之状态(State)
2018/09/19 Javascript
Vue用mixin合并重复代码的实现
2020/11/27 Vue.js
vue编写简单的购物车功能
2021/01/08 Vue.js
[01:10:02]IG vs Winstrike 2018国际邀请赛小组赛BO2 第一场 8.19
2018/08/21 DOTA
[01:01:01]完美世界DOTA2联赛循环赛 GXR vs FTD BO2第一场 10.29
2020/10/29 DOTA
Eclipse + Python 的安装与配置流程
2013/03/05 Python
详解Django中间件执行顺序
2018/07/16 Python
Django中的Model操作表的实现
2018/07/24 Python
Python设计模式之简单工厂模式实例详解
2019/01/22 Python
对python中字典keys,values,items的使用详解
2019/02/03 Python
Python动态导入模块:__import__、importlib、动态导入的使用场景实例分析
2020/03/30 Python
详解python中GPU版本的opencv常用方法介绍
2020/07/24 Python
Pytorch1.5.1版本安装的方法步骤
2020/12/31 Python
pycharm 关闭search everywhere的解决操作
2021/01/15 Python
python 如何读、写、解析CSV文件
2021/03/03 Python
深入理解css中vertical-align属性
2017/04/18 HTML / CSS
使用HTML5在网页中嵌入音频和视频播放的基本方法
2016/02/22 HTML / CSS
美国球鞋寄卖网站:Stadium Goods
2018/05/09 全球购物
自荐信范文
2013/12/10 职场文书
道德演讲稿
2014/05/21 职场文书
小学生自我评价100字(15篇)
2014/09/18 职场文书
2014酒店客房部工作总结
2014/12/16 职场文书
六五普法先进个人主要事迹材料
2015/11/03 职场文书
你为什么是穷人?可能是这5个缺点造成
2019/07/11 职场文书
Java中多线程下载图片并压缩能提高效率吗
2021/07/01 Java/Android
Win10 和 Win11可以共存吗? win10/11产品生命周期/服务更新介绍
2021/11/21 数码科技
Redis配置外网可访问(redis远程连接不上)的方法
2022/12/24 Redis