Skip to content

Instantly share code, notes, and snippets.

@subfuzion
Last active June 11, 2023 17:44
Show Gist options
  • Save subfuzion/383dbfed1ee02933d9d384e4fc6977f7 to your computer and use it in GitHub Desktop.
Save subfuzion/383dbfed1ee02933d9d384e4fc6977f7 to your computer and use it in GitHub Desktop.
Installing go

Download

$ wget https://storage.googleapis.com/golang/go1.6.2.linux-amd64.tar.gz

Unarchive it

$ VERSION=1.6.2
$ OS=linux
$ ARCH=amd64

$ sudo tar -C /usr/local -xzf go$VERSION.$OS-$ARCH.tar.gz

Update your shell profile

export PATH=$PATH:/usr/local/go/bin

ONLY if installing go to a custom location:

export GOROOT=$HOME/go

Choose a path for your go workspace and update your shell environment; for example

export GOPATH=$HOME/projects/go
export PATH=$PATH:$GOPATH/bin

In your workspace, create a directory for your user projects; for example

$ mkdir -p $GOPATH/src/github.com/subfuzion

Test your environment

$ cd $GOPATH/src/github.com/subfuzion
$ mkdir hello
$ cd hello
$ vi hello.go
package main

import "fmt"

func main() {
    fmt.Printf("hello, world\n")
}
$ go fmt hello.go
# or
$ go fmt .

$ go install github.com/subfuzion/hello
# or
$ go install .

$ hello
hello, world

Switching go versions

Reference

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment