Skip to content

Instantly share code, notes, and snippets.

@selfup
Last active February 25, 2016 22:42
Show Gist options
  • Save selfup/7ee17199ed18da99fa9e to your computer and use it in GitHub Desktop.
Save selfup/7ee17199ed18da99fa9e to your computer and use it in GitHub Desktop.

Dependencies:

  • wget
  • vim

Steps

1:

cd ~/
wget https://storage.googleapis.com/golang/go1.6.linux-amd64.tar.gz
sudo tar -C /usr/local -xzf go1.6.linux-amd64.tar.gz
echo "export PATH=$PATH:/usr/local/go/bin" >> .bashrc
. .bashrc
mkdir Go
echo "export GOPATH=$HOME/Go" >> .bashrc

2:

Make sure you replace user with your github username

If you are not comfortable with vim, use nano or emacs!

mkdir Go/src && mkdir Go/src/github.com && mkdir Go/src/github.com/user && mkdir Go/src/github.com/user/hello
touch Go/src/github.com/user/hello/hello.go
vim Go/src/github.com/user/hello/hello.go

3:

Now paste the following into the file:

package main

import "fmt"

func main() {
    fmt.Printf("hello, world\n")
}

4:

Now to test it all works correctly:

go install github.com/user/hello
$GOPATH/bin/hello

Success:

You should get an output of: hello, world

I referenced the official golang google documentation for this: DOCS LINK

  • Some of their steps are not very clear to people not very comfortable with the command line
  • No mention of wget to pull down the tarball from their provided link
  • Otherwise, very good documentation
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment