WARNING: This gist was created in 2013 and targets the legacy GOPATH mode. If you're reading this in 2021 or later, you're likely better served by reading https://tip.golang.org/cmd/go/#hdr-Configuration_for_downloading_non_public_code and https://golang.org/ref/mod#private-modules.
$ ssh -A vm
$ git config --global url."git@github.com:".insteadOf "https://github.com/"
$ cat ~/.gitconfig
[url "git@github.com:"]
insteadOf = https://github.com/
$ go get github.com/private/repo && echo Success!
Success!
Sources:
I wrote a script called gogetprivate, which first tries go get, and then falls back to git clone. My version on works with bitbucket right now (since that's where my private repos are) but I imagine it could be made to work with github as well.
https://github.com/drichardson/gogetprivate