In Go, the entry point is the parameterless main function in the main package. It runs when the program starts and returns no value. section 2.1.1
Use the entry point to start an executable application:
- Place a simple main function in main.go while building a small program. section 3.1
- Parse, validate, and pass command-line input to application logic in a CLI. section 6.4
- Create and run an HTTP server, handle startup errors, and keep the process running. section 8.1.2
- Keep main.go at the project root for a single binary; place several binaries under cmd/{binary_name}/main.go. section 6.1
Minimal runnable entry point
package main import "fmt" func main() { fmt.Println("Hello world") } Running go run main.go executes main and prints Hello world. section 2.1.1
Listing 2.1 main.go
package main
import "fmt"
func main() {
fmt.Println("Hello world")
}
Inspect the complete minimal main.go listing, then compare it with the go run command and output. section 2.1.1









