英文:
Golang Private Modules (v1.17) -- package found but does not contain the package
问题
回顾了许多文章后,遇到了这个问题:
1)在我的git账户中创建了一个私有包'mypackage'
2)在git中,我有MyCompany/mypackage
3)在另一个项目中,我想导入这个包:
...
import (
"github.com/MyCompany/mypackage'
)
4)当我运行:
go mod tidy
我得到以下错误:
github.com/MyCompany/mypackage: 找到模块github.com/MyCompany/mypackage@latest(v0.0.0-20220126203606-a88fea44b771),但不包含包github.com/MyCompany/mypackage
不确定如何解决这个问题。
在我的.gitconfig文件中,我有:
insteadOf = https://github.com/
go env
显示以下设置:
GOPRIVATE="github.com/MyCompany/*"
GONOPROXY="github.com/MyCompany/*"
GONOSUMDB="github.com/MyCompany/*"
我还缺少哪些其他配置?
go.mod文件如下所示:
module github.com/MyCompany/mypackage
go 1.17
require (
github.com/go-redis/redis/v8 v8.11.4
github.com/pkg/errors v0.9.1
)
require (
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
)
英文:
Reviewing numerous articles, running into this issue:
-
Created a private package, 'mypackage' in my git account
-
In git, I have MyCompany/mypackage
-
In another project, I want to import the package:
... import ( "github.com/MyCompany/mypackage' )
-
When I run:
go mod tidy
I get the following error:
github.com/MyCompany/mypackage: module github.com/MyCompany/mypackage@latest found (v0.0.0-20220126203606-a88fea44b771), but does not contain package github.com/MyCompany/mypackage
Not sure how to resolve this.
In my .gitconfig I have:
insteadOf = https://github.com/
<!-- -->
go env
shows these settings:
GOPRIVATE="github.com/MyCompany/*"
GONOPROXY="github.com/MyCompany/*"
GONOSUMDB="github.com/MyCompany/*"
What other configurations am I missing?
The go.mod file looks like:
module github.com/MyCompany/mypackage
go 1.17
require (
github.com/go-redis/redis/v8 v8.11.4
github.com/pkg/errors v0.9.1
)
require (
github.com/cespare/xxhash/v2 v2.1.2 // indirect
github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect
)
答案1
得分: 1
已添加一个语义版本标签(git tag v1.0.0,git push --tags),然后可以下载。
英文:
Added a semver tag (git tag v1.0.0, git push --tags) then was able to download
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论