How to Run a Go Program

go run vs go build

Cli
Use go run for quick testing and go build to create a permanent executable file for deployment.

Use go run to compile and execute code immediately for testing, and go build to create a standalone executable for deployment. go run compiles your code to a temporary binary and runs it, while go build produces a persistent file you can distribute.

# Run immediately (testing)
go run main.go

# Build executable (deployment)
go build -o myapp main.go
./myapp