无法安装专用Go模块



我有一个私有项目,它在github.com/company/company-product使用一个私有模块。当我尝试构建项目时,我得到:

go: github.com/company/company-product@v1.0.4: reading github.com/company/company-product/go.mod at revision v1.0.4: unknown revision v1.0.4

我尝试过的东西:

  • 已检查标记是否存在
  • go env -w GO111MODULE=on
  • go env -w GOPRIVATE=github.com/company/company-product
  • export GOPRIVATE=github.com/company/*
  • export GONOPROXY=github.com/company/*
  • export GONOSUMDB=github.com/company/*
  • 将git配置为使用ssh://git@github.com/而不是https://github.com/
  • 将git配置为使用ssh://$PERSONAL_ACCESS_TOKEN@github.com/而不是https://github.com/
  • 删除$GOPATH/pkg中的所有内容
  • go clean
  • go mod downloadgo mod tidygo mod vendor(均产生上述误差(
  • 已重新启动我的计算机
  • 已连接到我公司的VPN

但是我仍然得到同样的错误。

看起来关键是按照特定的顺序做事:

  1. 重新安装Go
  2. 将环境变量GOPRIVATE、GONOPROXY、GONOSUMDB设置为github.com/company/*
  3. 删除文件夹$GOPATH/pkg
  4. 将Git设置为使用ssh://git@github.com/而不是https://github.com/
  5. 运行go get github.com/company/company-product

适用于我的解决方案;

  1. go env-w GOPRIVATE=github.com/company
  2. git-config—全局url"https://username:accesstoken@github.com";。代替";https://github.com">
  3. env GIT_TERMINAL_PROMPT=1访问github.com/company/privaterepo

最新更新