contentintech
Languages

Go

Slices, maps, errors and concurrency primitives for everyday Go.

Tooling

go mod init example.com/appInitialize a module
go test ./...Run package tests
go vet ./...Run static correctness checks
gofmt -w main.goFormat a source file

Collections and errors

names := []string{"Ada", "Lin"}Create a slice
names = append(names, "Sam")Append and retain the resulting slice
scores := map[string]int{"Ada": 10}Create a map
value, ok := scores["Ada"]Distinguish missing keys from zero values

Functions and concurrency

func add(a, b int) int { return a + b }Define a typed function
if err != nil { return fmt.Errorf("load: %w", err) }Wrap an error while preserving its cause
go work()Start a goroutine; coordinate its lifecycle explicitly
ch := make(chan int, 1)Create a channel with capacity one

Section navigation