Skip to content

Instantly share code, notes, and snippets.

@baijum
Last active December 19, 2015 15:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save baijum/5976608 to your computer and use it in GitHub Desktop.
Save baijum/5976608 to your computer and use it in GitHub Desktop.
Go Programming Notes

Go Programming Notes

Installation

To install Go in a 64 bit GNU/Linux:

cd $HOME
wget -c https://go.googlecode.com/files/go1.1.2.linux-amd64.tar.gz
tar zxvf go1.1.2.linux-amd64.tar.gz
mkdir mygo

You can download source and binary packages of Go from from here: https://code.google.com/p/go/downloads/list

To set PATH and other environment variables, add these lines at the end of `$HOME/.bashrc`:

export GOROOT=$HOME/go
export PATH=$PATH:$GOROOT/bin

export GOPATH=$HOME/mygo
export PATH=$PATH:$GOPATH/bin

Running a program

To run a program:

go run <program.go>

Here is an example hello world program:

package main

import "fmt"

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

Save the above code in a hello.go and run it like this:

go run hello.go

Resources

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