...

/

Using git for Distribution

Using git for Distribution

This lesson discusses the Go's flexibility to share code with whole programming community.

What we discussed previously is fine for a local package, but how do we distribute it to the programmer community? We need a source version-control system in the cloud, like the popular git. To install and set up git, consult here.

Instructions

We will lead you through creating a git-repository for the package uc. Go to the package directory uc and create a git repository in it:

git init 

This message appears:

Initialized empty git repository in .../uc

Every git project needs a README file with a description of the package. So open your favorite text editor and put some comments there. Then add all the files to the repository with:

git add README uc.go uc_test.go

and mark it as the first version:

git commit -m "initial revision"

Now go to the GitHub-website where you must log in. If you don’t have a login yet, click here where you can create a free account for open source projects. Choose a username and password, give a valid email-address and Create an Account. Then you will get a list with the git commands. We have already seen the commands for the local repository. An excellent help system will guide you if you encounter any problems. For creating a new repository uc in the cloud, issue the instructions (substitute NNNN with your username):

git remote add origin git@github.com:NNNN/uc.git
git push -u origin master

You’re done. Go check the GitHub page of your package: https://github.com/NNNN/uc If one wants to install your cloud-project to their local machine, they have to execute the command:

go get github.com/NNNN/uc

Now that you’re familiar with how to use git for distributing your packages, in the next lesson, you’ll learn how to import packages from the external environment.

Access this course and 40+ top-rated courses and projects.