Thursday, August 15, 2013

Installing and Configuring Go


In preparation for a few beginner workshops, I created videos for people to follow to install and configure the Go development tools. Just adding them here.

On Mac OSX:


On Ubuntu Linux:


The steps that I've followed are pretty much this (with my username 'vj'):
  • Download the zip or .tar.gz file for your platform from https://code.google.com/p/go/downloads/list
  • Create a folder called golang wherever you prefer. I prefer to have it in my home folder like so: /home/vj/coding/golang since I want to keep all my programming language folders in a "coding" folder in my home dir.
  • Extract the .zip or .tar.gz file you downloaded earlier. It will contain a single "go" folder. Move this into your golang folder. So you will now have something similar to /home/vj/coding/golang/go
  • Append the path to the go command line tools (/home/vj/coding/golang/go/bin) to your $PATH. On Ubuntu in my bash shell, to ~/.bashrc I added the entry export PATH=$PATH:/home/vj/coding/golang/go/bin
  • I created one new folder in the golang folder called gopath". The Go tools will have use for this path later to download and install external packages.
  • Add two additional entries to your .bashrc, export GOROOT=/home/vj/coding/golang/go and export GOPATH=/home/vj/coding/golang/gopath
  • Source the .bashrc if required so that the environment variables are available in your current shell, or restart the shell.

With that you should now be ready to compile and run your go programs. Note that you don't need any special editors or IDEs to work with Go. All your regular text editors will work.
The process to be followed for Windows is pretty much the same. You can have your golang folder as c:/coding/golang and add your environment variables as you would normally do on windows: right click My Computer -> Click Properties -> Click Advanced System Settings -> Click Environment Variables. Add new GOROOT and GOPATH values, and append the required value to the Path variable.

9 comments:

  1. Kudos!!! for creating such a great education site.

    ReplyDelete
  2. I'm a new mac user. I added the GOROOT and GOPATH environment variables when I started learning Golang few days ago. But now when I echo $GOROOT and $GOPATH it's returning blank. Also tried these steps:

    touch .bash_profile
    open -a TextEdit.app .bash_profile
    export GOROOT=/home/my_coding_dir/coding/golang/go


    So can you explain more about these two points, in the sense that why am I seeing this behaviour?

    1) Add two additional entries to your .bashrc, export GOROOT=/home/my_coding_dir/coding/golang/go and export GOPATH=/home/my_coding_dir/coding/golang/gopath

    2) Source the .bashrc if required so that the environment variables are available in your current shell, or restart the shell.


    What am I doing wrong here?

    ReplyDelete
  3. By the way this did not help either:

    touch .bashrc
    open -a TextEdit.app .bashrc
    export GOROOT=/home/my_coding_dir/coding/golang/go

    ReplyDelete
  4. For ubuntu just use...

    sudo apt-get install golang

    ReplyDelete
  5. I cant wait to check out some of these blogs! I’ve really wanted to start learning more about cars and auto repairs lately and I think this will help a lot. I think it can save my family some money if we knew how to do some repairs at home.! Thanks again for all the options.

    bike spa services in mumbai
    house cleaning services in mumbai
    car wash services in mumbai

    ReplyDelete
  6. It is really a great and useful piece of info. I’m glad that you shared this helpful info with us. Please keep us informed like this. Thank you for sharing.
    Back to original

    ReplyDelete
  7. Superb. I really enjoyed very much with this article here. Really it is an amazing article I had ever read. I hope it will help a lot for all. Thank you so much for this amazing posts and please keep update like this excellent article.thank you for sharing such a great blog with us. expecting for your.
    Digital Marketing Company in India

    ReplyDelete
  8. I just see the post i am so happy to the communication science post of information's.So I have really enjoyed and reading your blogs for these posts.Any way I’ll be replay for your great thinks and I hope you post again soon.

    Salesforce Training in Chennai

    ReplyDelete

  9. I definitely think that this should be well thought out and done in a smart way, it is important to get out there and market your business.

    This is a great information and examples, thanks for sharing!



    digitalbrief exchange digital marketing

    ReplyDelete

If you think others also will find these tutorials useful, kindly "+1" it above and mention the link in your own blogs, responses, and entries on the net so that others also may reach here. Thank you.