DEV Community

Clavin June
Clavin June

Posted on • Originally published at on

Go Get Golang Private Module

Sunday Snippet #2 go get golang private module

I assume before fetching golang private module, you already have put your public SSH key on your git repository.

$ mkdir example && cd example
$ go mod init example
go: creating new go.mod: module example
# this is my private repo, this attempt will produce error
$ go get
go get module git ls-remote -q origin in [redacted]: exit status 128:
    fatal: could not read Username for '': terminal prompts disabled
Confirm the import path was entered correctly.
If this is a private repository, see for additional information.

# change the https to ssh, go get will try fetching your private module using your SSH key
$ git config --global --add url."".insteadOf ""
$ go get
go get: added v1.0.0
# success! But if above method still doesn't work set GOPRIVATE first
$ go env -w GOPRIVATE="*"
# then, go get again
Enter fullscreen mode Exit fullscreen mode

Top comments (0)