How to clone a GitHub project to go work space

In this post I’ll explain how you can clone a project from git hub to your go work space
If you don’t have a project on GitHub to play with ; then please read this post to create one

So lets start

Go to GitHub project page to copy git URL

Try to clone the repository using ‘go get’ with the URL we copied

[email protected]:~> go get
package https:/ "https://" not allowed in import path
[email protected]:>;

It failed with message indicating that we cannot use “https:..” while mentioning URL

Now lets try without “https://”

[email protected]:~> go get
package invalid version control suffix in path
[email protected]:~>

Failed again saying invalid version control suffix – which means we cannot use .git suffix in URL

Now lets try again without .git suffix

[email protected]:~> go get
go: missing Git command. See
package exec: "git": executable file not found in $PATH
[email protected]:~>

Failed again with messaging saying , we need “git” binary

Install git package

Go to root and install ‘git’ package using one of the procedure below based on your distro.

For Fedora Based distros like RedHat or CentOS

# dnf install git-all

For Debian based distros like Ubuntu

# apt-get install git-all

Now lets try to execute go get again

[email protected]~>; go get
# invalid character literal (more than one character) cannot use '\u0000' (type rune) as type string in argument to fmt.Printf
[email protected]:~>

Failed once again with messages indicating syntax errors in our source .go file

Correct the syntax errors as mentioned by editing the file from GitHub

Now execute go get again

[email protected]:~&amp;gt; go get</pre>
[email protected]:~> ls -lR $GOPATH/src
total 1836
drwxr-xr-x 3 linxlabs users 4096 Oct 14 01:55

total 4
drwxr-xr-x 3 linxlabs users 4096 Oct 14 01:55 OpenLinXlabs

total 4
drwxr-xr-x 3 linxlabs users 4096 Oct 14 01:56 Golang-Tutor

total 44
-rw-r--r-- 1 linxlabs users 72 Oct 14 01:56 hello.go
-rw-r--r-- 1 linxlabs users 35141 Oct 14 01:56 LICENSE
-rw-r--r-- 1 linxlabs users 52 Oct 14 01:56
[email protected]:~>

voila.! it worked.

Now you can see the project directories and files

In my next post I’ll explain basics of git and how to push changes from command line to your github repository

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *