Frontend Labs
⋯

Day 1 — Go Toolchain & Your First Program

Learning Objectives

  • Understand the Go workspace model (GOPATH vs modules)
  • Run the full build/test/format cycle
  • Know where to look when engineers say "it works locally"

Key Concepts

Tool What it does When you use it
go build Compiles to binary CI, deployment
go run Compile + run Development
go test ./... Run all tests Before every commit
go mod tidy Sync go.mod/go.sum After adding/removing imports
go vet ./... Static analysis CI required
gofmt -w . Format code Pre-commit hook

Setup

# Install Go (macOS)
brew install go

# Verify
go version  # go version go1.22.x darwin/arm64

# Create your workspace
mkdir -p ~/go/src/secproxy
cd ~/go/src/secproxy
go mod init github.com/yourname/secproxy

Exercise: System Info Reporter

Build a program that prints a formatted system report. This is the kind of diagnostic tool your SREs run on a new server.

// main.go
package main

import (
    "fmt"
    "os"
    "runtime"
    "time"
)

func main() {
    hostname, err := os.Hostname()
    if err != nil {
        hostname = "unknown"
    }

    fmt.Printf("=== System Report ===\n")
    fmt.Printf("Time:       %s\n", time.Now().Format(time.RFC3339))
    fmt.Printf("Hostname:   %s\n", hostname)
    fmt.Printf("OS/Arch:    %s/%s\n", runtime.GOOS, runtime.GOARCH)
    fmt.Printf("CPUs:       %d\n", runtime.NumCPU())
    fmt.Printf("Go version: %s\n", runtime.Version())
    fmt.Printf("PID:        %d\n", os.Getpid())
}

Run it:

go run main.go
go build -o sysinfo .
./sysinfo

Real-World Context

Every Go service at Cloudflare, Fastly, or your internal team prints something like this at startup. It's also in every incident runbook: "what version is running?" This program tells you.


Generated from week1.md · 8 Oct 2026 16:36