Lesson 31 of 60
GoBuilding and Publishing a Go Binary
20 minutes
Course progress52%
Building Executables
This lesson explains the main concept clearly with beginner-friendly examples and background so you can learn why the code works.
go build compiles a binary for the host OS/architecture.
$ go build -o myapp ./cmd/myapp
Cross‑compilation
# Build Linux binary on macOS
env GOOS=linux GOARCH=amd64 go build -o myapp-linux