Skip to content
Kamal Mustafa edited this page Oct 10, 2017 · 4 revisions

This is my Go quickstart.

Ubuntu

Install & Setup

  1. Create the directory. My preference is $HOME/go:-
mkdir $HOME/go
mkdir $HOME/go/work # this is where we store our Go code.
  1. Define the essential path in your ~/.profile:-
export GOROOT=$HOME/go/go
export GOPATH=$HOME/go/work
PATH="$HOME/bin:$HOME/.local/bin:$PATH:$GOROOT/bin"

Make sure to source ~/.profile to apply the changes.

  1. Download the official Go binary at https://golang.org/dl/:-
cd $HOME/go
wget https://storage.googleapis.com/golang/go1.9.1.linux-amd64.tar.gz
  1. Extract the tarball into $HOME/go/go, essentially $GOROOT you defined above.
tar xzf go1.9.1.linux-amd64.tar.gz

You should now has $HOME/go/go directory.

  1. Done. Test your new Go with go version.

Usage

Now let's test our new Go to build Caddy web server.

go get github.com/mholt/caddy/caddy

You can find the newly built binary in $GOPATH/bin/caddy. For convenience, you can add $GOPATH/bin to your $PATH so you can just type caddy.

Clone this wiki locally