Coding log: Importing Go Private Repository Module

Command

go get github.com/private/repository

Error log

  ~/Projects/cl•••••/cl•••••-apig-backend   feat/wire-user-service ?1 ❯ go get github.com/vin••••/cl•••••-user-backend                                                             19:55:07
go: downloading github.com/vin••••/cl•••••-user-backend v0.0.0-20200929080324-a2a441d021c4
go get github.com/vin••••/cl•••••-user-backend: github.com/vin••••/cl•••••-user-backend@v0.0.0-20200929080324-a2a441d021c4: verifying module: github.com/vin••••/cl•••••-user-backend@v0.0.0-20200929080324-a2a441d021c4: reading https://sum.golang.org/lookup/github.com/vin••••/cl•••••-user-backend@v0.0.0-20200929080324-a2a441d021c4: 410 Gone
server response:
not found: github.com/vin••••/cl•••••-user-backend@v0.0.0-20200929080324-a2a441d021c4: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /tmp/gopath/pkg/mod/cache/vcs/5da391d116fed8602d941e30a1d28705cbaa3c05b25f164bb45478e05199c464: exit status 128:
fatal: could not read Username for 'https://github.com': terminal prompts disabled

How to Fix

If you’re using ssh for your git:

$ git config --global url.git@github.com:.insteadOf https://github.com/$ cat ~/.gitconfig
[url "git@github.com:"]insteadOf = https://github.com/

If you’re using go modules, whitelist your private repo so go will not look for it from public repository.

n.p. it support wildcard, in case you need to whitelist all repo inside your account/organization, use wildcard *

export GOPRIVATE=github.com/private/repoorgo env -w GOPRIVATE="github.com/orgname/*"

Have fun!

--

--