1

I'm trying to convert to use go modules in my repo now, but it keeps failing with exit 128. Repository not found The requested repository does not exist, or you do not have permission to access it. fatal: Could not read from remote repository.

Please make sure you have the correct access rights and the repository exists.

My repos are private repos and i have git configured to use ssh insteadOf https when I run go get ./... with NO modules GO111MODULE=off I'm able to get the repos.

However, when I switch to modules on GO111MODULE=on I get the error mentioned above. My current go vars are

GO111MODULE=on
GOPROXY=direct
GOSUMDB=off

I've read the articles like this and this to setup git url insteadOf.

and here is my git setting

[url "ssh://git@git.company.com:port"]
    insteadOf = https://git.company.com

Ideas?

Thanks

Victor
  • 173
  • 1
  • 10

1 Answers1

3

On newer version of Golang, you must specify the repository private on your golang environment because the private repository can't do checksum. So for the solution is like below :

go env -w GOPRIVATE=github.com/username/*

or

export GOPRIVATE="github.com/username/*"

replace github.com which your version control like bitbucket, etc. And replace username with your username or your company.

  • Sorry for the late response as this was not high priority for me. I did add a GOPRIVATE env var as well as I had to update my git config which used insteadOf. My cofiguration was incorrect. Thanks! – Victor Mar 20 '20 at 18:57
  • 2
    The star after in the end is not needed as go treat it as prefix https://pkg.go.dev/cmd/go@master#hdr-Configuration_for_downloading_non_public_code – Denis Palnitsky Nov 18 '21 at 13:19