Golang setting up environment
Contents
Create a new project
If you want to create a new Go project which should be hosted at github.com later, you should create this project under $GOPATH/src/github.com/myname/myproject. It's important that the path matches the URL of the github.com repo, because the go tool will follow the same convention. So, let's create the project root and initialize a new git repository there:
mkdir -p $GOPATH/src/github.com/myname/myproject cd $GOPATH/src/github.com/myname/myproject git init
Because I do not like to type such long paths, I normally create symbolic links for the projects I am currently working on in my home folder:
ln -s $GOPATH/src/github.com/myname/myproject ~/myproject
Write your application
Start coding and don't forget to git add and git commit your files. Also, do not use relative imports like import "./utils" for sub-packages. They are currently undocumented and shouldn't be used at all, because they won't work with the go tool. Use imports like github.com/myname/myproject/utils instead.
Publish your project
Create a new repository at github.com, upload your SSH public key if you haven't done that before and push your changes to the remote repository:
git remote add origin git@github.com:myname/myproject.git git push origin master
Continue working on your project
If you have set the GOPATH in your .bashrc and if you have created a symlink to your project in your home folder, you can just type cd myproject/ and edit some files there. Afterwards, you can commit the changes using git commit -a and send them to github.com by doing a git push.
Used Materials
https://stackoverflow.com/questions/10130341/go-go-get-go-install-local-packages-and-version-control