If you were to go get
a private repository with go
, you would see something like this
$ go get github.com/zMrKrabz/flyent
go: downloading github.com/zMrKrabz/flyent v0.0.0-20210612205723-a495958a84ab
go get: github.com/zMrKrabz/flyent@v0.0.0-20210612205723-a495958a84ab: verifying module: github.com/zMrKrabz/flyent@v0.0.0-20210612205723-a495958a84ab: reading https://sum.golang.org/lookup/github.com/z!mr!krabz/flyent@v0.0.0-20210612205723-a495958a84ab: 410 Gone
server response:
not found: github.com/zMrKrabz/flyent@v0.0.0-20210612205723-a495958a84ab: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /tmp/gopath/pkg/mod/cache/vcs/d455a9bff29b25fc089b95289e07ca4a6886822823a65d8b41247eae8baf04a7: exit status 128:
fatal: could not read Username for 'https://github.com': terminal prompts disabled
In order to resolve this, use Github with SSH and set the GOPROXY to direct or set GOPRIVATE=.
- Create a SSH key following this guide: https://jdblischak.github.io/2014-09-18-chicago/novice/git/05-sshkeys.html
- Add your SSH key to github following this guide: https://docs.github.com/en/github/authenticating-to-github/connecting-to-github-with-ssh
- Run
git config --global url.git@github.com:.insteadof=https://github.com
- To make sure that this is set, run
git config --global --list
- Set the
GOPRIVATE
to a regex string that matches the private packages you're getting. For the sake of simplicity, I just do$ export GOPRIVATE=github.com/<USERNAME>/*
Because if one of my private packages uses a private package, it will be able to get that private package as well. - Rerun your go get command.