Hello World

A sample go program is show here.

package main

import "fmt"

func main() {
  message := greetMe("world")
  fmt.Println(message)
}

func greetMe(name string) string {
  return "Hello, " + name + "!"
}

Run the program as below:

$ go run hello.go

This is the normal shape of a tiny Go program: main runs first, and fmt.Println writes output.

Variables

Normal Declaration:

var msg string
msg = "Hello"

Shortcut:

msg := "Hello"

This shows both var and the short := form. The short form is the one you will use most inside functions.

Constants
const Phi = 1.618

Use constants for values that should not change, such as fixed ratios, limits, or labels.