Install Go On Mac Os X
Install Go on Mac OS X
Akbar S. Ahmed | Feb 23, 2015

Step-by-step instructions

In this post we will install Go on Mac OS X. Installation is quick and simple.

Install Go

curl -O https://storage.googleapis.com/golang/go1.4.2.darwin-amd64-osx10.8.tar.gz

gzip -dc go1.4.2.darwin-amd64-osx10.8.tar.gz | tar xf -

rm go1.4.2.darwin-amd64-osx10.8.tar.gz

sudo mv go /usr/local

Add go to your PATH

vi ~/.bash_profile

Paste the following into your .bash_profile file.

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

Source your .bash_profile file.

source ~/.bash_profile

Configure the go environment

vi ~/.bash_profile

Paste the following into your .bash_profile file.

# Go
export GOPATH=$HOME/repos/go
export PATH=$PATH:$GOPATH/bin

Source your .bash_profile file.

source ~/.bash_profile

Package setup

Change akbarahmed to your GitHub login.

mkdir -p $GOPATH/src/github.com/akbarahmed && cd $_

mkdir hello && cd $_

vi hello.go

Paste the following into hello.go.

package main

import "fmt"

func main() {
    fmt.Printf("Hello from go.\n")
}

Compile the hello.go program then run it.

go install

hello
# Expected output: Hello from go.

Congrats, you are now ready to begin developing applications with Go.




Subscribe to our newsletter

Contact Information

ABOUT EXPONENTIAL.IO

We specialize in helping professional developers, like you, expand your skill set. Our courses are focused on enabling you to learn everything necessary to use a new technology in a live, production application.

LOCATION

All courses are made with love in
Palo Alto, CA.

Subscribe to our newsletter