如下所示,对于回购,git ls-emote命令成功.

git ls-remote https://internal.net/dir1/dir2/dir3/repo
warning: redirecting to https://internal.net/dir1/dir2/dir3/repo.git/
xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx    HEAD
yyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy    refs/heads/master

但是,当使用Go Get时,cmd失败,找不到存储库.错误输出试图在存储库 struct 上方的1个目录中查找.git.

go get internal.net/dir1/dir2/dir3/repo@master
go: internal.net/dir1/dir2/dir3/repo@master: invalid version: git ls-remote -q origin in /Users/{{UserId}}/go/pkg/mod/cache/vcs/xyz...: exit status 128:
    remote: The project you were looking for could not be found or you don't have permission to view it.
    fatal: repository 'https://internal.net/dir1/dir2.git/' not found

我的Goprivate是 GOPRIVATE=internal.net

为了围棋的成功,我在这里错过了什么?

推荐答案

将VCS后缀添加到专用模块路径以标记存储库根前缀:

go get internal.net/dir1/dir2/dir3/repo.git@master

请参见Direct access to private modules:

resolve module paths to repository URLs,可能仍需要内部HTTP服务器.例如,当GO命令下载模块corp.example.com/mod时,它将向https://corp.example.com/mod?go-get=1发送GET请求,并且它将在响应中查找存储库URL.要避免这种要求,请确保每个私有模块路径都有一个VCS后缀(如.git)来标记存储库根前缀.例如,当GO命令下载模块corp.example.com/repo.git/mod时,它将在https://corp.example.com/repo.gitssh://corp.example.com/repo.git处克隆Git储存库,而不需要进行额外的请求.

请注意,VCS后缀是模块路径的一部分,因此应该在使用模块路径的所有位置都包括它.包括:

  1. module指令

    module internal.net/dir1/dir2/dir3/repo.git
    
  2. require指令

    require internal.net/dir1/dir2/dir3/repo.git v0.0.1
    
  3. 进口报关单

    import "internal.net/dir1/dir2/dir3/repo.git/pkg/util"
    
  4. 还有更多.

Go相关问答推荐

如何从google.golang.org/grpc/stats包中将golang中不同事件的输出进行组合,以获取func HandlePRC

Go编译器标志-修剪路径不完全工作

GetSecretValue,get identity:get credentials:无法刷新缓存的凭据

使用ciph.AEAD.Seal()查看内存使用情况

减少在围棋中映射DTO时的重复代码量

在Uber FX中实现后台进程正常关闭的正确方式是什么?

如何防止程序B存档/删除围棋中程序A当前打开的文件?

使用GOTK3和librsvg在Go中如何加载内联SVG?

golang 上基于标头的版本控制

Go:如何在将 float64 转换为 float32 时判断精度损失

AddE 上的 Apache Tinkerpop gremlin-go 驱动程序 Next() 返回E0903:没有剩余结果

确保 Go 1.20 编译时的严格可比性?

从数据库中带有 imageurl 的文件夹中获取图像,并在我的浏览器中用 golang 中的 echo 显示

为什么 reflect.TypeOf(new(Encoder)).Elem() != reflect.TypeOf(interfaceVariable)?

如何将具有嵌入式 struct 的 struct 展平为 json

将shell输出绑定到Go中的 struct 的最佳方法?

未定义 protoc protoc-gen-go 时间戳

为什么此代码在运行命令 error="exec: not started" 时出现错误?

go mod tidy 错误消息:但是 go 1.16 会 Select

不理解切片和指针