Go programming fundamentals

A runnable Go command defines package main and a main function. This example declares a variable and prints it.

A simple example

Follow one calculation

  1. Start with 2 and 3
  2. Do this Add, then print
  3. Result 5
The addition finishes before the program prints its result.
main.go
package main

import "fmt"


func main() {
    fmt.Println(2 + 3)
}
Output
5