- wget
- vim
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
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
Now paste the following into the file:
package main
import "fmt"
func main() {
fmt.Printf("hello, world\n")
}
Now to test it all works correctly:
go install github.com/user/hello
$GOPATH/bin/hello
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