-
Notifications
You must be signed in to change notification settings - Fork 0
Kamal Mustafa edited this page Oct 10, 2017
·
4 revisions
This is my Go quickstart.
- Create the directory. My preference is
$HOME/go
:-
mkdir $HOME/go
mkdir $HOME/go/work # this is where we store our Go code.
- 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.
- 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
- 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.
- Done. Test your new Go with
go version
.
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
.
Join our Telegram channel t.me/devkini or follow twitter.com/devkini for latest updates in software development.