繁体   English   中英

无法安装私有 Go 模块

[英]Cannot install private Go module

我有一个私有项目,它在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、GONOPROSXY、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 环境 -w GOPRIVATE=github.com/company
  2. git 配置 --global url."https://username:accesstoken@github.com".insteadOf "https://github.com"
  3. env GIT_TERMINAL_PROMPT=1 go 得到 github.com/company/privaterepo

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM