英文:
go: github.com/myorg/myrepo@v0.0.4: reading github.com/myorg/myrepo/go.mod at revision v0.0.4: unknown revision v0.0.4
问题
go: github.com/myorg/myrepo@v0.0.4: 在版本 v0.0.4 上读取 github.com/myorg/myrepo/go.mod: 未知版本 v0.0.4
当我在一个不同的私有仓库 github.com/myorg/myrepo2
中执行 go mod tidy
并尝试从我的私有仓库 github.com/myorg/myrepo
获取时,遇到了上述阻塞问题。
github.com/myorg/myrepo
主分支的 go.mod 内容如下(在项目根目录):
module github.com/myorg/myrepo
go 1.15
require (
github.com/abadojack/whatlanggo v1.0.1
github.com/mmcdole/gofeed v1.1.3
github.com/stretchr/testify v1.3.0
)
该仓库实际上有一个名为 v0.0.4
的标签/发布版本。
此外,我已经尝试了以下所有方法:
- https://golang.cafe/blog/how-to-fix-go-mod-unknown-revision.html
- https://stackoverflow.com/questions/65609301/installing-private-go-module-unknown-revision-error/65609901#65609901
- https://go.dev/ref/mod#private-modules
也就是说,我已经尝试配置 ~/.gitconfig
、GOPRIVATE
和其他环境变量、~/$HOME/.netrc
,甚至生成了一个 GitHub 访问令牌。值得注意的是,我在这台机器上还有一个与 GitHub 账户关联的 SSH 密钥,并且 ~/.ssh/config
的内容如下:
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed12345
Host github.com
Hostname ssh.github.com
Port 443
我还排除了这里描述的子模块问题 https://stackoverflow.com/questions/64893018/reading-github-com-username-kit-go-database-go-database-go-mod-at-revision-go-da
对于这个问题,我感到困惑,所以任何帮助将不胜感激。
英文:
go: github.com/myorg/myrepo@v0.0.4: reading github.com/myorg/myrepo/go.mod at revision v0.0.4: unknown revision v0.0.4
I'm hitting the above blocker when go mod tidy
inside a different private repo call it: github.com/myorg/myrepo2
and attempting to fetch from my private repo github.com/myorg/myrepo
Contents of github.com/myorg/myrepo
master branch go.mod (at the root project level)
module github.com/myorg/myrepo
go 1.15
require (
github.com/abadojack/whatlanggo v1.0.1
github.com/mmcdole/gofeed v1.1.3
github.com/stretchr/testify v1.3.0
)
The repo has in fact a tag / release named v0.0.4
Additionally, I've tried everything described in the following:
- https://golang.cafe/blog/how-to-fix-go-mod-unknown-revision.html
- https://stackoverflow.com/questions/65609301/installing-private-go-module-unknown-revision-error/65609901#65609901
- https://go.dev/ref/mod#private-modules
That is to say, I've tried configuring ~/.gitconfig
, GOPRIVATE
and other env vars, ~/$HOME/.netrc
,and even generating a GitHub access token. I should note that I also have an SSH key associated with Github account on this machine and ~/.ssh/config
contents as below:
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_ed12345
Host github.com
Hostname ssh.github.com
Port 443
I also ruled out the submodule issue described here https://stackoverflow.com/questions/64893018/reading-github-com-username-kit-go-database-go-database-go-mod-at-revision-go-da
I'm at a loss on this one so any help would be appreciated.
答案1
得分: 1
如果Go通过HTTPS访问您的私有存储库,那么SSH设置将不会被使用。根据您的链接,可以尝试以下操作(在执行go clean -modcache
之后):
git config --global \
url."https://${GITHUB_TOKEN}@github.com".insteadOf \
"https://github.com"
go mod download
如果您想使用SSH:
git config --global url."ssh://git@github.com:acme-corporation".insteadOf "https://github.com/acme-corporation"
(将acme-corporation
替换为您的GitHub用户帐户,假设您的私有存储库不在组织中)
(检查ssh -Tv git@github.com
是否作为您进行了身份验证)
然后设置export GIT_SSH_COMMAND='ssh -Tv'
:这样,您将能够准确查看SSH调用期间的情况,并确保确实使用了您的私钥。
> 我最终检查了.gitconfig
文件中的每个条目,并最终删除了除用户条目之外的所有内容,这样就解决了问题。
>
> [user]
> name = First Last
> email = email@exmaple.com
英文:
If Go is accessing your private repository through HTTPS, then any SSH setting would not be used at all.
From your link, this should have helped (after a go clean -modcache
):
git config --global \
url."https://${GITHUB_TOKEN}@github.com".insteadOf \
"https://github.com"
go mod download
If you want to use/try SSH:
git config --global url."ssh://git@github.com:acme-corporation".insteadOf "https://github.com/acme-corporation"
(replace acme-corporation
by your GitHub user account, assuming your private repository is not in an organization)
(check ssh -Tv git@github.com
does authenticate as you)
Then export GIT_SSH_COMMAND='ssh -Tv'
: that way, you will see exactly what is considered during the SSH calls, and make sure your private key is indeed used.
The OP j-diaz confirms in the comments an issue in their Git configuration:
> I ended up revising every entry in my .gitconfig
file and ended up removing everything except the user entry and that made it work.
>
> [user]
> name = First Last
> email = email@exmaple.com
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论