Lesson 1 of 60 · Go
Welcome & Course Overview
Duration: 10 minutes
Welcome to Go Programming
Go is a productive language designed for simplicity, clear syntax, and fast compile times. In this lesson, you will learn how Go source files are structured, what a package is, and how to run a basic program.
A Go program is made from one or more packages. The package main is special because it builds an executable program. The main function is the entry point that runs when your program starts.
Go source files are formatted consistently by gofmt, so your code stays readable. A simple Go file looks like this.
// hello.go
package main
import "fmt"
func main() {
fmt.Println("?? Hello, Go!")
}
Save the file as hello.go and run it with:
go run hello.go
The go run command compiles and runs your program in one step. When you are ready to keep the compiled binary, build it with:
go build hello.go
This builds an executable named hello.exe on Windows or hello on macOS and Linux. Use go env to inspect your Go settings, such as the install location and module mode.