1

Trying to import a private repo as package in golang. Did:

git config --global url.git@github.com:.insteadOf https://github.com/

So in theory all references to https are replaced by the ssh version.

github.com/XXX/util

Is my private repo which is a go module.

I do a go get -v and get:

[gabriel@xiridio backend]$ go get -v
go: finding module for package github.com/XXX/util
go: downloading github.com/XXX/util v0.0.0-20200411022955-454673685ff5
go: finding module for package github.com/XXX/util
main.go:12:2: github.com/XXX/util@v0.0.0-20200411022955-454673685ff5: verifying module: github.com/XXX/util@v0.0.0-20200411022955-454673685ff5: reading https://sum.golang.org/lookup/github.com/!X!X!X/util@v0.0.0-20200411022955-454673685ff5: 410 Gone
        server response:
        not found: github.com/XXX/util@v0.0.0-20200411022955-454673685ff5: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /tmp/gopath/pkg/mod/cache/vcs/f1fdc5cc42a6995f954688df06783c05d28e4a60e9aaf6930a88a2487b913907: exit status 128:
                fatal: could not read Username for 'https://github.com': terminal prompts disabled

Looks like there is a "version" issue and also for some reason there is still references to https. What else can I do?

Gabriel
  • 4,854
  • 14
  • 56
  • 83

1 Answers1

2

Just to be sure, I prefer using quotes for the git config command:

git config --global url."git@github.com:".insteadOf "https://github.com/"

See this gist as an example.

It includes:

An alternative to using git@github.com is to generate a personal access token on your GitHub account, grant it repo access, and then use the following instead:

git config --global url."https://${GITHUB_TOKEN}:x-oauth-basic@github.com/".insteadOf "https://github.com/"

Check also "go get results in 'terminal prompts disabled' error for GitHub private repo", which mentions the use of GOPRIVATE.

Community
  • 1
  • 1
VonC
  • 1,129,465
  • 480
  • 4,036
  • 4,755