go mod init with private bitbucket repositories, contains disallowed path separator character ':'

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

go mod init with private bitbucket repositories, contains disallowed path separator character ':'

问题

使用:

go version go1.16.4 darwin/amd64

我有一个私有的bitbucket.org仓库,URL如下:

git@bitbucket.org:chmorgan/some_repo.git

根据bitbucket的URL格式,你可以使用git clone git@bitbucket.org:chmorgan/some_repo.git来克隆它,克隆工作正常。

当我尝试创建一个新的模块时,我得到以下错误:

go: invalid module path "git@bitbucket.org:chmorgan/some_repo.git": contains disallowed path separator character ':'

请注意,我已经在~/.gitconfig中配置了git:

        insteadOf = https://bitbucket.org/

这在早期的golang版本中曾经起作用,我记得它在golang 1.12或1.13版本中起作用。有人知道出了什么问题吗?

英文:

Using:

% go version
go version go1.16.4 darwin/amd64

I've got a private bitbucket.org repository with a url like:

git@bitbucket.org:chmorgan/some_repo.git

Per the bitbucket url format you would do 'git clone git@bitbucket.org:chmorgan/some_repo.git' to clone it and cloning works fine.

When I try to make a new module I get:

go mod init git@bitbucket.org:chmorgan/some_repo.git
go: invalid module path "git@bitbucket.org:chmorgan/some_repo.git": contains disallowed path separator character ':'

Note that I've already configured git in ~/.gitconfig:

insteadOf = https://bitbucket.org/

This used to work with earlier golfing versions, I think it worked with golang 1.12 or 1.13. Anyone know what's up?

答案1

得分: 1

go mod init命令的参数是“模块路径”,它作为每个模块内每个包的包导入路径的前缀。因此,go mod init命令的参数必须作为包导入路径是有效的。

(更多详细信息请参阅https://golang.org/doc/code)

对于从git@bitbucket.org:chmorgan/some_repo.git克隆的存储库,我们通常会使用的包导入路径是bitbucket.org/chmorgan/some_repo

英文:

The argument to go mod init is the “module path”, which is used as a prefix of the package import path for every package within the module. As a result, the argument to go mod init must be valid as a package import path.

(See https://golang.org/doc/code for more detail.)

The package import path we would normally use for a repo cloned from git@bitbucket.org:chmorgan/some_repo.git is bitbucket.org/chmorgan/some_repo.

huangapple
  • 本文由 发表于 2021年6月1日 08:18:50
  • 转载请务必保留本文链接:https://go.coder-hub.com/67781378.html
匿名

发表评论

匿名网友

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

确定