Go 疑难杂症汇总
1. revision v0.0.0: unknown revision v0.0.0
go get -u github.com/uudashr/gopkgs/cmd/gopkgs 报错:
[root@lubanseven home]$ go get -u github.com/uudashr/gopkgs/cmd/gopkgs
go: downloading github.com/uudashr/gopkgs v1.3.2
go: downloading github.com/uudashr/gopkgs/cmd/gopkgs v0.0.0-20191024034442-58e9141cd7d6
go: downloading github.com/uudashr/gopkgs v2.0.1+incompatible
go: github.com/uudashr/gopkgs/cmd/gopkgs upgrade => v0.0.0-20191024034442-58e9141cd7d6
go get: github.com/uudashr/gopkgs/cmd/gopkgs@v0.0.0-20191024034442-58e9141cd7d6 requires
github.com/uudashr/gopkgs/v2@v2.1.0 requires
github.com/uudashr/gopkgs@v0.0.0: reading github.com/uudashr/gopkgs/go.mod at revision v0.0.0: unknown revision v0.0.0
根据 Cannot install gopkgs tool,换个 gopkgs 安装:
[root@lubanseven delve]$ go get github.com/uudashr/gopkgs/v2/cmd/gopkgs
go: downloading github.com/uudashr/gopkgs/v2 v2.1.2
go: found github.com/uudashr/gopkgs/v2/cmd/gopkgs in github.com/uudashr/gopkgs/v2 v2.1.2
go: downloading github.com/karrick/godirwalk v1.12.0
go: downloading github.com/pkg/errors v0.8.1
2. invalid version: unknown revision
2.1 现象及解决方法
go run cmd/main.go 时报错:
[root@lubanseven go]# go run svc/lubanseven/cmd/lubanseven/main.go
vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/metrics.go:21:2: cannot find package "." in:
/home/lubanseven/go/src/AANM/go/vendor/io/fs
查看项目 go.mod 文件发现文件定义版本(1.16) 和当前 go version 版本(1.15.15) 不一致。于是删掉 go.mod 文件,重新 go mod init <project_name>,执行 go mod tidy 报错:
go: github.com/hashicorp/vault@v1.9.1 requires
github.com/hashicorp/vault/api/auth/approle@v0.0.0-00010101000000-000000000000: invalid version: unknown revision 000000000000
查阅文档发现 go mod tidy 调用的是 go get,接着调用的是 git 下载 github 的包。于是使用 go get 命令手动下载 vault:
go get -u github.com/hashicorp/vault
报错:
ssh:connect to host github.com port 22: Connection timed out.
ssh 连接的报错,有可能 port 端口不是 22,也有可能是别的原因,这里并未深究,将下载方式从 ssh 切换到 https:
git config --global url.git@github.com:.insteadOf https://github.com/
接着执行 go get 手动下载 go: github.com/hashicorp/vault 继续报错:
Permission denied (publickey).
fatal: Could not read from remote repository.
提示 Permission denied,将 public key 添加到 github 上,继续执行 go get -u,继续报错:
go: github.com/hashicorp/vault@v1.9.1 requires
github.com/hashicorp/vault/api/auth/approle@v0.0.0-00010101000000-000000000000: invalid version: unknown revision 000000000000
看来路走错了,接着搜文档,发现和之前把 go.mod 删掉有关系。之前的 go.mod 中有 replace 字段定义包版本的行为,现在新建的包并没有 replace,也没有 require。
将之前包版本的 require 复制到当前 go.mod(只复制了 require 并未复制 replace),接着执行 go mod tidy,下载完成。
3. cannot find package "." in:*******
执行 go run cmd/main.go 报错:
[root@lubanseven go]# go run svc/lubanseven/cmd/lubanseven/main.go
vendor/k8s.io/client-go/plugin/pkg/client/auth/exec/metrics.go:21:2: cannot find package "." in:
/home/lubanseven/go/src/AANM/go/vendor/io/fs
还是原来那个错...
查阅文档发现 GOPATH 包路径不对,当前执行路径是:
[root@lubanseven go]# pwd
/home/lubanseven/vsWorkspace/dev/go
// GOPATH 路径
[root@lubanseven ~]# go env | grep -i path
GOPATH="/root/go"
于是按照文档要求将代码复制到 GOPATH 路径下,挫是挫了点,但是此刻能运行已经什么都不在乎了。接着执行,还是报一样的错...
冷静思考一番,还是从开始的 go.mod 入手,开始的 go.mod 定义了 go 版本是 1.16 这里我们换了版本出现了这一系列问题,会不会是 go 版本的问题呢?于是,将 go 版本从 1.15 换到 1.16,接着执行 go run cmd/main.go 执行成功...
4. fatal: unable to find remote helper for 'https'
go mod tidy 报错:
[root@lubanseven home]$ go mod tidy
Gin imports
github.com/gin-gonic/gin: git ls-remote -q origin in /root/go/pkg/mod/cache/vcs/a923aa3ae357f66c754ef34c3358c689f5d969293b012aef737373496ea3e ef3: exit status 128:
fatal: unable to find remote helper for 'https'
根据 unable-to-find-remote-helper-for-https-during-git-clone 设置:
$ yum install curl-devel
$ # cd to wherever the source for git is
$ cd /usr/local/src/git-1.7.9
$ ./configure
$ make
$ make install
由于没找到 git configure 目录,直接 yum remove git,然后 yum install git。接着执行 go mod tidy 报错:
go: finding module for package github.com/gin-gonic/gin
Gin imports
github.com/gin-gonic/gin: module github.com/gin-gonic/gin: Get "https://proxy.golang.org/github.com/gin-gonic/gin/@v/list": proxyconnect tcp: EOF
看报错信息和代理有关系,重新配置代理,执行 go mod tidy 成功安装 Gin。
5. Get "https://xxx": unexpected EOF
go get -v github.com/rogpeppe/godef 报错:
go get github.com/rogpeppe/godef: module github.com/rogpeppe/godef: Get "https://goproxy.cn/github.com/rogpeppe/godef/@v/list": unexpected EOF
根据 go get not working with unexpected EOF 取消 https_proxy,重新 go get,成功!
注意:也要留意 http_proxy 的情况,配置 http_proxy 也会遇到此类问题。
6. fatal: unable to access xxx Encountered end of file
git clone https://github.com/go-delve/delve 通过 clone 的方式安装 delve,报错:
[root@lubanseven home]$ git clone https://github.com/go-delve/delve
Cloning into 'delve'...
fatal: unable to find remote helper for 'https'
出现了问题 4 一样的报错,但前面已经配置过了为什么还会报错呢?和前面的处理应该没关系。怀疑归怀疑,按照问题 4 的解决方式重新走一遍,报同样的错。
根据 Unable to find remote helper for https 设置 PATH 环境变量:
[root@lubanseven home]$ PATH=$PATH:/usr/libexec/git-core
[root@lubanseven home]$ git clone https://github.com/go-delve/delve
Cloning into 'delve'...
fatal: unable to access 'https://github.com/go-delve/delve/': Encountered end of file
现在报 Encountered end of file 错误,根据 fatal: unable to access xxx Encountered end of file 设置 git config:
[root@lubanseven home]$ git config --global http.proxy
[root@lubanseven home]$ git config --global --unset http.proxy
[root@lubanseven home]$ git clone https://github.com/go-delve/delve
Cloning into 'delve'...
warning: You appear to have cloned an empty repository.
重新 clone 成功。
7. package embed is not in GOROOT (/usr/local/go/src/embed)
编译项目代码报错:package embed is not in GOROOT (/usr/local/go/src/embed)。发现 embed 是 golang1.6 的内置函数,当前 golang 版本为 1.4。
遂尝试升级 golang 版本,根据 升级 Golang 尝试实现多版本 golang 管理。在 $GOPATH/pkg/mod/golang.org/dl/ 下找到对应
go 版本(如果没有的话需要先下载: go get golang.org/dl/go<version> ),编译 main.go 为对应版本号:
$ go build -o go1.16.4 main.go
执行 ./go1.16.4 download 下载 go 软件包:
$ ./go1.16.4 download
go1.16.4: download failed: Head "https://dl.google.com/go/go1.16.4.linux-amd64.tar.gz": dial tcp 142.250.74.78:443: i/o timeout
遇到了 i/o timeout 问题,查看 go env proxy 是否正确设置:
$ go env | grep proxy -i
GONOPROXY=""
GOPROXY="https://goproxy.cn,direct"
$ go env | grep 111 -i
GO111MODULE="on"
正确配置,在看这里的 142.250.74.78 是什么地址呢?
通过 wget 直接下载 https://dl.google.com/go/go1.16.4.linux-amd64.tar.gz 看看:
$ wget https://dl.google.com/go/go1.16.4.linux-amd64.tar.gz
--2022-02-20 15:16:34-- https://dl.google.com/go/go1.16.4.linux-amd64.tar.gz
Resolving dl.google.com (dl.google.com)... 142.250.74.110, 2a00:1450:400f:802::200e
Connecting to dl.google.com (dl.google.com)|142.250.74.110|:443...
解析的是域名 dl.google.com 的 ip,众所周知的原因访问不了 google 的服务器。配置代理,继续 wget:
$ export https_proxy=https://10.144.xxx.xxx:8080
$ wget https://dl.google.com/go/go1.16.4.linux-amd64.tar.gz
--2022-02-20 15:30:07-- https://dl.google.com/go/go1.16.4.linux-amd64.tar.gz
Connecting to 10.144.xxx.xxx:8080... connected.
Proxy request sent, awaiting response... 200 OK
Length: 129044044 (123M) [application/x-gzip]
Saving to: ‘go1.16.4.linux-amd64.tar.gz’
0% [ ] 120,225 36.0KB/s eta 68m 14s
可以访问并下载!
理论上这么走通之后,可以实现多版本 go 管理了。不过这里后续没有走这条路(主要想折腾下多版本 go...),而是将原来的 go 删掉,重新安装新版本 go。
新版本安装完后,执行 go run main.go,程序成功运行。
8. Could not import Golang package
vscode 提示:Could not import Golang package,原因是前面在升级过程中将 GOPATH 替换了,导致 vscode原有窗口加载的 mod 找不到了。
解决方法是重启 vscode,重新加载 workspace,GOPATH 找到,问题解决。
9. vs code remote connect
通过 vs code remote-ssh 远程连接 server。
添加 keypair 到本地。ssh-keygen -t rsa -m PEM -f wenhu.pem 生成 pem 格式密钥。
将以 RSA 开头的密钥拷到本地,并将 OPENSSL 的密码添加到 authorized_keys。
remote-ssh 远程连接成功。
还有种方式是将已经连接成功的 keypair 拷到 server 上,执行类似添加 authorized_keys 操作,连接。
参考
- 在解决问题过程中,参考了以下资料,效果不错适合参考:
- Why does "go get" use HTTPS when cloning a repository?
- Go Modules、Go Module Proxy 和 goproxy.cn
- proxy.golang.org: does not work in China
Go 疑难杂症汇总的更多相关文章
- 原创:LNMP架构部署个人博客网站 禁止转载复制
nginx编译安装步骤 ①. 检查软件安装的系统环境 cat /etc/redhat-release uname -r ②. 安装nginx的依赖包(pcre-devel openssl-devel) ...
- Nginx初步入门
1.Nginx介绍 官网:nginx.org Nginx ("engine x") 是一个开源的.支持高性能.高并发的WWW服务和代理服务软件. 它是由俄罗斯人IgorSysoev ...
- APM(pixhawk)飞控疑难杂症解决方法汇总(持续更新)
本文转自下面博主 https://blog.csdn.net/junzixing/article/details/79310159 APM/Pixhawk常用链接汇总(持续更新) https://bl ...
- TCP协议疑难杂症全景解析
说明: 1).本文以TCP的发展历程解析容易引起混淆,误会的方方面面2).本文不会贴大量的源码,大多数是以文字形式描述,我相信文字看起来是要比代码更轻松的3).针对对象:对TCP已经有了全面了解的人. ...
- 【转载】TCP协议疑难杂症全景解析
说明: 1).本文以TCP的发展历程解析容易引起混淆,误会的方方面面2).本文不会贴大量的源码,大多数是以文字形式描述,我相信文字看起来是要比代码更轻松的3).针对对象:对TCP已经有了全面了解的人. ...
- 常用 Gulp 插件汇总 —— 基于 Gulp 的前端集成解决方案(三)
前两篇文章讨论了 Gulp 的安装部署及基本概念,借助于 Gulp 强大的 插件生态 可以完成很多常见的和不常见的任务.本文主要汇总常用的 Gulp 插件及其基本使用,需要读者对 Gulp 有一个基本 ...
- 异常处理汇总 ~ 修正果带着你的Net飞奔吧!
经验库开源地址:https://github.com/dunitian/LoTDotNet 异常处理汇总-服 务 器 http://www.cnblogs.com/dunitian/p/4522983 ...
- Carousel 旋转画廊特效的疑难杂症
疑难杂症 该画廊特效的特点就是前后元素有层级关系. 我想很多人应该看过或者用过这个插件carousel.js,网上也有相关的教程.不知道这个插件的原型是哪个,有知道的朋友可以告诉我. 该插件相对完美, ...
- UWP开发必备:常用数据列表控件汇总比较
今天是想通过实例将UWP开发常用的数据列表做汇总比较,作为以后项目开发参考.UWP开发必备知识点总结请参照[UWP开发必备以及常用知识点总结]. 本次主要讨论以下控件: GridView:用于显示数据 ...
- Oracle手边常用70则脚本知识汇总
Oracle手边常用70则脚本知识汇总 作者:白宁超 时间:2016年3月4日13:58:36 摘要: 日常使用oracle数据库过程中,常用脚本命令莫不是用户和密码.表空间.多表联合.执行语句等常规 ...
随机推荐
- GZY.Quartz.MUI(基于Quartz的UI可视化操作组件) 2.6.0发布 兼容.Net8.0
前言 为了迎接.Net8.0 2.6.0终于发布了~ 更新内容: 兼容.NET8.0 新增界面按分组名称排序功能 优化本地持久化时文件路径异常的问题 优化数据库持久化时偶现的异常问题 新增简易授权,增 ...
- SpringBoot整合Swagger3
1.导入相关依赖 <!--swagger--> <dependency> <groupId>io.springfox</groupId> <art ...
- SpringCloudAlibaba-OSS文件上传
一.引入相关依赖 <dependencyManagement> <dependencies> <dependency> <groupId>com.ali ...
- 2.elasticsearch中的mapping
mapping 顾名思义,代表了映射关系.是文档中字段和数据类型的映射关系 为什么要了解mapping 虽然elasticsearch中已尽有的动态mapping(Dynamic Mapping),而 ...
- IBM DS5020存储更换硬盘操作
前期准备:笔记本.网线 连接存储控制器操作,在笔记本上安装DS Storage Manager 11 Client,然后在笔记本IP设备为192.168.128.X(A控制器管理口1和2的管理IP地址 ...
- mac 编译php 7.2+扩展编译 的坑史(不是swoole的坑),php的一个坑,这个坑还没填满,问题根源还没有找到 !
目前网上找到的文章全是php 7.1,但是brew己经没有7.1了,最新是7.2,这让我怀疑是不是我的版本问题,导致swoole编译时总是编译不过去.后来发现任何扩展都编不过去,提示: Configu ...
- 浏览器工作原理和实践(二)——JavaScript
<浏览器工作原理与实践>是极客时间上的一个浏览器学习系列,在学习之后特在此做记录和总结. 一.执行流程 实际上变量和函数声明在代码里的位置是不会改变的,而且是在编译阶段被 JavaScri ...
- 华为云AOM 2.0版本发布
摘要:AOM作为华为云面向租户的统一运维门户,将在7月1日重磅发布2.0版本. 本文分享自华为云社区<华为云AOM发布2.0版本,3大特性亮相>,作者:华为云PaaS小助手. 6月16日华 ...
- 基于RNN和CTC的语音识别模型,探索语境偏移解决之道
摘要:在本文介绍的工作中,我们展示了一个基于RNN和CTC的语音识别模型,在这个模型中,基于WFST的解码能够有效地融合词典和语言模型. 本文分享自华为云社区<语境偏移如何解决?专有领域端到端A ...
- 如何使用Tomcat实现WebSocket即时通讯服务服务端
摘要:HTTP协议是"请求-响应"模式,浏览器必须先发请求给服务器,服务器才会响应该请求.即服务器不会主动发送数据给浏览器. 本文分享自华为云社区<Tomcat支持WebSo ...