Each package is stored in its own folder
// denote package
package name
// all files in the same package have access to other items in the package
// to make functions public use a capital letter
func Public() {
}
func private() {
}
package main
import (
"fmt"
"path/from/root"
)
func main() {
// program is run here
}
Init function
The contents of an init() function will be run before main().
Commonly used for
- Checking network connections
- Checking database connections
- Cache
- Expensive operations