簡體   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