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 相关文章推荐
一文读懂go中semaphore(信号量)源码
Apr 03 Golang
Go语言中break label与goto label的区别
Apr 28 Golang
浅谈Golang 嵌套 interface 的赋值问题
Apr 29 Golang
golang 实现Location跳转方式
May 02 Golang
Goland使用Go Modules创建/管理项目的操作
May 06 Golang
Go语言设计模式之结构型模式
Jun 22 Golang
试了下Golang实现try catch的方法
Jul 01 Golang
手把手教你导入Go语言第三方库
Aug 04 Golang
golang操作redis的客户端包有多个比如redigo、go-redis
Apr 14 Golang
Golang bufio详细讲解
Apr 21 Golang
Golang 实现WebSockets
Apr 24 Golang
详解Go语言中Get/Post请求测试
Jun 01 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
将文件夹压缩成zip文件的php代码
2009/12/14 PHP
php数据结构与算法(PHP描述) 查找与二分法查找
2012/06/21 PHP
深入apache配置文件httpd.conf的部分参数说明
2013/06/28 PHP
MyEclipse常用配置图文教程
2014/09/11 PHP
WordPress开发中自定义菜单的相关PHP函数使用简介
2016/01/05 PHP
PHP入门教程之表单与验证实例详解
2016/09/11 PHP
给大家分享几个常用的PHP函数
2017/01/15 PHP
js 获取class的元素的方法 以及创建方法getElementsByClassName
2013/03/11 Javascript
JS教程:window.location使用方法的区别介绍
2013/10/04 Javascript
Bootstrap基本插件学习笔记之Tooltip提示工具(18)
2016/12/08 Javascript
Bootstrap实现圆角、圆形头像和响应式图片
2016/12/14 Javascript
BootStrap表单验证实例代码
2017/01/13 Javascript
Node.js的特点详解
2017/02/03 Javascript
运用jQuery写的验证表单(实例讲解)
2017/07/06 jQuery
vue-router 源码之实现一个简单的 vue-router
2018/07/02 Javascript
微信小程序的注册页面包含倒计时验证码、获取用户信息
2019/05/22 Javascript
JS Array.from()将伪数组转换成数组的方法示例
2020/03/23 Javascript
uni-app从安装到卸载的入门教程
2020/05/15 Javascript
python检查字符串是否是正确ISBN的方法
2015/07/11 Python
Python实现的RSS阅读器实例
2015/07/25 Python
Python实现基于TCP UDP协议的IPv4 IPv6模式客户端和服务端功能示例
2018/03/22 Python
Python使用matplotlib绘制三维图形示例
2018/08/25 Python
利用python GDAL库读写geotiff格式的遥感影像方法
2018/11/29 Python
python日志logging模块使用方法分析
2019/05/23 Python
python实现字符串完美拆分split()的方法
2019/07/16 Python
基于Python获取照片的GPS位置信息
2020/01/20 Python
python tkinter的消息框模块(messagebox,simpledialog)
2020/11/07 Python
AmazeUI 网格的实现示例
2020/08/13 HTML / CSS
澳大利亚礼品篮网站:Macarthur Baskets
2019/10/14 全球购物
员工拾金不昧表扬信
2014/01/09 职场文书
加拿大探亲邀请信
2014/01/28 职场文书
致1500米运动员广播稿
2014/02/07 职场文书
教师一帮一活动总结
2014/07/08 职场文书
教师个人自我评价
2015/03/04 职场文书
科技馆观后感
2015/06/08 职场文书
类和原型的设计模式之复制与委托差异
2022/07/07 Javascript