Packages
Every Go program is constructed from packages. They are the fundamental unit of code organization and reuse.
Executable Packages
A package named main is special. It tells the Go compiler that this package should be compiled as an executable program rather than a library. It requires an entry point function: func main().
package main
import "fmt"
func main() {
fmt.Println("Hello, World!")
}
Library Packages
Any package with a name other than main is a library package. These do not have an entry point and are used to export functionality (functions, types, variables) to other packages.
Importing
You use the import keyword to bring in functionality from other packages.
import (
"fmt"
"math/rand"
)