Skip to content

Hello World

In Go, every Go source file (even the main.go file) must declare a package at the top of the file. This is a requirement of the Go language. The package declaration indicates which package the file belongs to and helps organize the code.

  • Create a main.go file
touch main.go
  • Declare a package
package main
import "fmt"
func main() {
fmt.Println("Hello world")
}
  • Run the program
go run main.go

Go Hello World Output