Packages, main and init
Every program starts in package main. init runs before main. Exported names start with a capital letter.
Example
package main
import "fmt"
func init() { fmt.Println("init runs") }
func main() {
fmt.Println("main runs")
}Result
init runs main runs
Exercise
Entry function.
func () {}
Quiz Test
These free lessons are for learning. Join a full course for projects, mentor feedback and a verified certificate.