// Package we're in (we always have to be in one).
package main
// We're using this one.
import "fmt"
func main() {
fmt.Printf("Hello, world!\n")
}
The usual starting place. Things to note:
- Any Go file starts by declaring a the name of the package
that the contents belongs to.
- The import statement allows us to use names from
another package, called fmt.
- The program starts with a main function, specifically
the function main.main since it is also inside package main.
It takes no arguments and returns no value.
- The Printf method belongs to the package fmt; fmt is
not an object. The method works much like the plain C function printf.
- Statements are generally terminated by the end-of-line, not a
semicolon.