Setting GOPRIVATE to make go get bypass default GOPROXY and checkout from your private repo. go env -w GOPRIVATE=github.com/<user>/<repo>
If you want to append to existing GOPRIVATE, run: go env -w GOPRIVATE=$(go env GOPRIVATE),github.com/<user>/repo_a
You can also add multiple private repos or using wildcard (_). go env -w GOPRIVATE=github.com/<user>/repo_a,github.com/<user>/repo_b go env -w GOPRIVATE=github.com/<user>/_
If you don’t want to modify the go global environment file, you can run a one-time command GOPRIVATE=github.com/<user>/<repo> go get github.com/<user>/<repo>
After setting GOPRIVATE, you should choose an authentication method to for git that called by go get.
Option 1: Terminal Prompt (Recommended)
I am personally recommend this option because it will save your credential in system keychain instead of file.
If you get terminal prompts disabled error after you running go get that means you have not save your credential. To enable terminal prompts, just run: GIT_TERMINAL_PROMPT=1 go get github.com/<user>/<repo>