Go Hello World
Every Go program starts with a main package and a main function. This is the entry point of your application.
Your First Program
Create a file named hello.go:
How to Run it
You can run Go programs directly from your terminal:
Understanding the Code
package main: This tells the Go compiler that this file should compile as an executable program rather than a shared library.import "fmt": We import the "fmt" (format) package from the standard library to use itsPrintlnfunction.func main(): This is the first function that runs when you start your program.fmt.Println(): Prints text to the console and adds a newline at the end. Note that exported functions in Go always start with a Capital Letter.
The Go Playground
If you don't have Go installed locally yet, you can write and run Go code directly in your browser at go.dev/play.