Skip to content

Instantly share code, notes, and snippets.

@orejuelajd
Last active November 2, 2016 20:32
Show Gist options
  • Save orejuelajd/aa5d35f5a74f996d6388749750bb57f4 to your computer and use it in GitHub Desktop.
Save orejuelajd/aa5d35f5a74f996d6388749750bb57f4 to your computer and use it in GitHub Desktop.

Step 1. Download Go!

You can download Golang from its official web: https://golang.org/dl/ and download tar.gz package.

Step 2. Install Go!

Extract this tar.gz package and the apply this command to the folder:

sudo chown -R root:root ./go

Copy the "go" folder in this route /usr/local/ with:

sudo mv go /usr/local

**Note: ** /usr/local/go is the officially recommended location by golang official page.

Step 3. Setting Go Paths

Configure the go paths. In the terminal write this:

sudo nano ~/.profile

And end of the file add this line:

export GOPATH=$HOME/work export PATH=$PATH:/usr/local/go/bin:$GOPATH/bin

Caution: You have to create the "work" folder in /home before next step.

With the appropriate line pasted into your profile, save and close the file. Next, refresh your profile by running in terminal:

source ~/.profile

Step 4. Test the install

In /home/work create this folders... mkdir -p work/src/github.com/user/hello

In "hello" folder you nedd to create a .go file, in this case "helloworld.go"

nano ~/work/src/github.com/user/hello/helloworld.go

Inside the helloworld.go write this lines:

package main

import "fmt"

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

This program will print "Hello world" if it successfully runs.

Source:

https://www.digitalocean.com/community/tutorials/how-to-install-go-1-6-on-ubuntu-16-04#step-1-%E2%80%94-installing-go

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