CompileYourCake
CompileYourCake

Reputation: 414

Cannot install private Go module

I have a private project which uses a private module at github.com/company/company-product. When I try to build the project, I get:

go: github.com/company/[email protected]: reading github.com/company/company-product/go.mod at revision v1.0.4: unknown revision v1.0.4

Things I have tried:

And yet I still get the same error.

Upvotes: 2

Views: 4661

Answers (2)

ahmetlutfu
ahmetlutfu

Reputation: 325

the solution which worked for me;

  1. go env -w GOPRIVATE=github.com/company
  2. git config --global url."https://username:[email protected]".insteadOf "https://github.com"
  3. env GIT_TERMINAL_PROMPT=1 go get github.com/company/privaterepo

Upvotes: 0

CompileYourCake
CompileYourCake

Reputation: 414

It looks like the key was to do things in a certain order:

  1. Reinstall Go
  2. Set environment variables GOPRIVATE, GONOPROSXY, GONOSUMDB to github.com/company/*
  3. Remove the folder $GOPATH/pkg
  4. Setup Git to use ssh://[email protected]/ instead of https://github.com/
  5. Run go get github.com/company/company-product

Upvotes: 5

Related Questions