dependencies from private repository are not fetching even after using go mod tidy and go get "github.com/name/custom_repo"

huangapple go评论80阅读模式
英文:

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 /)。然后创建了一个带有与上述相同的 GitHub 链接(github.com/shubhamgholave/packages)的 go.mod 文件。

dependencies from private repository are not fetching even after using go mod tidy and go get "github.com/name/custom_repo"

在 main.go 的导入部分中,我写了 import "github.com/shubhamgholave/packages/slacker 或 slack(因为所有所需的依赖项都在像 slacker、slack、websocket 这样的包中)。但是当我尝试运行 go get github.com/shubhamgholave/packagesgo get github.com/shubhamgholave/package/slackergo mod tidy 时,它仍然给我报错。

dependencies from private repository are not fetching even after using go mod tidy and go get "github.com/name/custom_repo"

我尝试使用 go mod tidygo 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).

dependencies from private repository are not fetching even after using go mod tidy and go get "github.com/name/custom_repo"

In main.go import section I said import &quot;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.

dependencies from private repository are not fetching even after using go mod tidy and go get "github.com/name/custom_repo"

I tried using go mod tidy and go mod edit -replace=&quot;original/repo=custom_preivate_repo@version&quot; 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.

huangapple
  • 本文由 发表于 2023年6月6日 21:50:01
  • 转载请务必保留本文链接:https://go.coder-hub.com/76415388.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定