Getting Started

Install Go, set up modules, and run your first program.

Go is a compiled, statically typed language with built-in concurrency primitives. It’s the backbone of many cloud-native tools (Docker, Kubernetes, Terraform).

Install

macOS:

brew install go

Linux:

# Download from https://go.dev/dl/ or:
sudo apt-get install golang-go

Windows: Download the MSI installer from go.dev/dl.

Verify:

go version
# go version go1.22.0 darwin/amd64

Modules

Go projects use modules for dependency management:

mkdir myapp && cd myapp
go mod init github.com/you/myapp

This creates a go.mod file. Add dependencies:

go get github.com/gin-gonic/gin@latest

First Program

Create main.go:

package main

import "fmt"

func main() {
    fmt.Println("Hello, Go!")
}

Run it:

go run main.go

Build a binary:

go build -o myapp
./myapp

Next: Basics