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数据库过程中,常用脚本命令莫不是用户和密码.表空间.多表联合.执行语句等常规 ...
随机推荐
- Gradle构建微服务项目
先说一下初衷把:为啥突然要用Gradle,公司后期自研项目都使用Gradle构建...... 1.下载安装 这个就不说了,网上大家搜索一下,配置一下环境变量即可 2.Groovy的一些语法Gradle ...
- PBKDF2(Password-Based Key Derivation Function 2)算法
一.引言 在当今数字时代,保护用户数据和隐私的安全变得越来越重要.为实现这一目标,加密和密钥管理技术发挥着关键作用.PBKDF2(Password-Based Key Derivation Funct ...
- Math数学工具类、向上取整,向下取整,四舍五入,最大值
package com.guoba.math; public class MathTest { /* Math数学工具类,包含以下方法: .ceil() 向上取整 .floor() 向下取整 .rou ...
- Pikachu漏洞靶场 URL重定向
URL重定向 点击 我就是我,放荡不羁的我 可以发现url是这样的: http://192.168.171.30/pikachu/vul/urlredirect/urlredirect.php?url ...
- Java 中常见类型的判空方式
引用类型(Reference Types): 使用 == 运算符判断是否为 null. 使用 != 运算符判断是否不为 null. 使用 Objects.isNull() 方法判断是否为 null. ...
- 解读 SSDB、LevelDB 和 RocksDB 到 GaussDB(for Redis) 的迁移
摘要:本期将详细介绍 SSDB.LevelDB 和 RocksDB 到 GaussDB(for Redis)的迁移. 本文分享自华为云社区<华为云PB级数据库GaussDB(for Redis) ...
- 从原理到实践,手把手带你轻松get数仓双集群容灾
摘要:本文通过介绍双集群的架构.log结构.分析步骤来介绍双集群容灾的问题分析方法. 本文分享自华为云社区<从原理到实践,手把手带你轻松get数仓双集群容灾>,原文作者:Puyol . 双 ...
- vue2升级vue3:getCurrentInstance—Composition api/hooks中如何获取$el
在vue2中,我们进程看到 this.$el 操作.但是在vue3 如何获取组件的当前 dom 元素呢? 可以利用 getCurrentInstance getCurrentInstance Vue ...
- JS遍历循环方法性能对比:for/while/for in/for of/map/foreach/every
这周codeReview例会,又遇到map与foreach到底谁问题.单独图方便,我会选择用map一个函数搞定一切.但是从语义的角度来讲,如果只是单纯遍历,还是推荐选择foreach.其实formap ...
- ELT in ByteHouse 实践与展望
更多技术交流.求职机会,欢迎关注字节跳动数据平台微信公众号,回复[1]进入官方交流群 谈到数据仓库, 一定离不开使用Extract-Transform-Load (ETL)或 Extract-Load ...