英文:
dependencies from private repository are not fetching even after using go mod tidy and go get "github.com/name/custom_repo"
问题
问题是我为了版本锁定而分叉了依赖库,并将其推送到了一个私有仓库(github.com/shubhamgholave/packages /
在 main.go 的导入部分中,我写了 import "github.com/shubhamgholave/packages/slacker
或 slack(因为所有所需的依赖项都在像 slacker、slack、websocket 这样的包中)。但是当我尝试运行 go get github.com/shubhamgholave/packages
或 go get github.com/shubhamgholave/package/slacker
或 go mod tidy
时,它仍然给我报错。
我尝试使用 go mod tidy
和 go mod edit -replace="original/repo=custom_preivate_repo@version"
,还有 go get github.com/shubhamgholave/packages/slacker
,以及同样的命令直到 packages。
英文:
The issue was that I forked dependency repositories for version lock and pushed it into a private repository (github.com/shubhamgholave/packages /<multiple packages>). Then created a go.mod with same github link as given above (github.com/shubhamgholave/packages).
In main.go import section I said import "github.com/shubhamgholave/packages/slacker
or slack(as all the required dependencies are inside packages like slacker, slack, websocket). But it keeps giving me errors when I try to go get github.com/shubhamgholave/packages
or go get github.com/shubhamgholave/package/slacker
or go mod tidy
.
I tried using go mod tidy
and go mod edit -replace="original/repo=custom_preivate_repo@version"
and also go get github.com/shubhamgholave/packages/slacker
and same command until packages.
答案1
得分: 1
问题是,我复制了依赖库以进行版本锁定,并将其推送到私有库中。
如果要进行版本锁定,您可以依赖于Go工具链,它会为您完成。请参阅Checksum数据库。
如果您想确保构建所使用的所有文件都存储在单个文件树中,您应该使用Vendoring。
您的方法是可行的,因为模块有自己的go.mod
文件,该文件定义了模块的导入路径。将go.mod
文件放在根目录中不会改变这个事实。
英文:
> The issue was that I forked dependency repositories for version lock and pushed it into a private repository
If for version lock, you can rely on the Go tool chain which will do it for you. See Checksum database.
If you want to ensure that all files used for a build are stored in a single file tree, you should use Vendoring instead.
Your approach does work because the modules have their own go.mod
file, which defines the import path of the modules. Placing a go.mod
file in the root directory does not change this fact.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论