Using standard command “go get” for private golang packages on gitlab.com

I’m keeping my projects privately on gitlab.com and want to use for some of my golang packages standard “go get” command instead of using git clone/pull. When I’m trying to use standard commands I’m getting the error

go get gitlab.com/bykovme/my_package_here
# cd .; git clone https://gitlab.com/bykovme/my_package_here.git /home/bykov/gopath/src/gitlab.com/bykovme/my_package_here
Cloning into '/home/bykov/gopath/src/gitlab.com/bykovme/my_package_here'...
fatal: could not read Username for 'https://gitlab.com': terminal prompts disabled

As I’m using SSH keys to access the git repository, the following command solves the issue giving possibility to use standard go packages commands

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

You can check if it was applied using the following command

cat ~/.gitconfig

The output of the command above should be like the text below

[url "git@gitlab.com:"]
    insteadOf = https://gitlab.com/

The command

go get gitlab.com/bykovme/my_package_here

is working now.

PS. The same solution is working for github.com

, , , , , , , ,

  1. Leave a comment

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: