意外的模块路径 go-modules
Unexpected module path go-modules
我在 Github 上有一个存储库,其中仅包含一些 Go 结构,可在我的整个服务中用作模型。
https://github.com/pocockn/models
然后我想将其导入到我的服务中,我在两个存储库中都使用了 Go Modules。当我 运行 'go get' 在我的服务中出现以下错误。
go: finding github.com/pocockn/models/api/football latestgo: finding
github.com/pocockn/models/api latest go: finding
github.com/pocockn/models latest go:
github.com/pocockn/models@v0.0.0-20190511152220-d7675ec24338: parsing
go.mod: unexpected module path "models"
模型库中我的 go.mod 文件如下所示
module models
go 1.12
require github.com/jinzhu/gorm v1.9.8
您 go.mod
中的模块名称应为 github.com/pocockn/models
,与存储库路径匹配。它也可以是自定义 domain/path,假设该域具有托管代码或正确的 headers 以重定向到您的存储库(使用 https://github.com/GoogleCloudPlatform/govanityurls 之类的东西)。
(看起来你可能已经这样做了。如果其他人发现这个问题,请在这里回答。)
我在 Github 上有一个存储库,其中仅包含一些 Go 结构,可在我的整个服务中用作模型。
https://github.com/pocockn/models
然后我想将其导入到我的服务中,我在两个存储库中都使用了 Go Modules。当我 运行 'go get' 在我的服务中出现以下错误。
go: finding github.com/pocockn/models/api/football latestgo: finding github.com/pocockn/models/api latest go: finding github.com/pocockn/models latest go: github.com/pocockn/models@v0.0.0-20190511152220-d7675ec24338: parsing go.mod: unexpected module path "models"
模型库中我的 go.mod 文件如下所示
module models
go 1.12
require github.com/jinzhu/gorm v1.9.8
您 go.mod
中的模块名称应为 github.com/pocockn/models
,与存储库路径匹配。它也可以是自定义 domain/path,假设该域具有托管代码或正确的 headers 以重定向到您的存储库(使用 https://github.com/GoogleCloudPlatform/govanityurls 之类的东西)。
(看起来你可能已经这样做了。如果其他人发现这个问题,请在这里回答。)