Thuta Learning
BasicProgrammingbeginner

Get Started (Setup)

Relax. We'll talk through this in plain words — no textbook voice.

You need the Go toolchain to run Go code on your local computer. Once it's set up, go run lets you run code directly, and go build produces an executable file.

go
# Check Go installation
 go version

# Run a Go file directly
 go run hello.go

# Build an executable file
 go build hello.go

go version checks whether Go was installed successfully. go run hello.go compiles and runs in one step, and go build hello.go produces an executable binary you can run later.

You should see
go version go1.xx.x ... Hello, Go!

Info

As your project grows, go mod init project-name starting a module with it becomes important for managing dependencies.

Easy traps

  • If you run go run hello.go without opening Command Prompt/Terminal in the folder where the file actually is, you'll get a file not found error.