I started working on a Go project and it uses some private modules from Github private repos and whenever I try to run go run main.go it gives me a below 410 Gone error:
verifying reading : 410 Gone
I can easily clone private repo from terminal which means my ssh keys are configured correctly. I read here that I need to set GOPRIVATE environment variable but I am not sure how to do that.
Can anyone answer or point to the relevant tutorial?
Go: v1.13, OS: macOS Mojave
63 Answers
Short Answer:
go env -w GOPRIVATE=OR
If you want to allow all private repos from your organization
go env -w GOPRIVATE=Long Answer:
Check "Module configuration for non-public modules" for more information:
The GOPRIVATE environment variable controls which modules the go command considers to be private (not available publicly) and should therefore not use the proxy or checksum database. The variable is a comma-separated list of glob patterns (in the syntax of Go's path.Match) of module path prefixes. For example,
GOPRIVATE=*.corp.example.com,causes the go command to treat as private any module with a path prefix matching either pattern, including and
. .
The 'go env -w' command (see 'go help env') can be used to set these variables for future go command invocations.
Note on the usage of ssh:
If you use ssh to access git repo (locally hosted), you might want to add the following to your ~/.gitconfig:
[url "ssh://git@"] insteadOf = for the go commands to be able to access the git server.
Just a follow up on the usage of ssh, this is the command used to get it working:
GitHub:
git config --global url.":".insteadOf ""Bitbucket:
git config --global url.":".insteadOf "" If zsh use:
go env -w GOPRIVATE='gitlab.my_firm_name.com/*'
otherwise get
zsh: no matches found: GOPRIVATE=gitlab.my_firm_name.com/*