gitlab snippets

Fixing "go get" and "terminal prompts disabled" when pulling private and public repos from gitlab

Tagged github, gitlab, golang  Languages bash

This frustrating error when running go get can be fixed by following these instructions:

go: downloading v0.0.0-20200816045911-18af1d03e51a
cmd/go-xxx/main.go:4:2:[email protected]: verifying module:[email protected]: reading[email protected]: 410 Gone
    server response:
    not found:[email protected]: invalid version: git fetch -f origin refs/heads/*:refs/heads/* refs/tags/*:refs/tags/* in /tmp/gopath/pkg/mod/cache/vcs/1dd4008ad7804a122a243831f561ea1000480bb532c0388829d0f37bc7349fef: exit status 128:
        fatal: could not read Username for '': terminal prompts disabled

Make sure you have the latest go and git versions.

Then run the following commands:

git config --global url.ssh://[email protected]/.insteadOf
git config --global url.ssh://[email protected]/.insteadOf
go env -w GOPRIVATE=",,"

Specify the Gitlab token in ~/.git-credentials or ~/.netrc.

Now you can enjoy simple things such as pulling your repos from the internet, but you need to remember to set GIT_TERMINAL_PROMPT too: