Go
Overview
Go is an open-source programming language that makes it easy to build simple, reliable, and efficient software. It is statically typed and compiled, ships with a garbage collector, and provides built-in concurrency primitives (goroutines and channels) designed for network services and tooling. Read this for the module system, concurrency model, and the standard toolchain.
Official sources
Install / setup
Download the installer for your platform from https://go.dev/dl/ and follow the instructions at https://go.dev/doc/install. Verify the install:
go version
Core concepts
- Goroutines and channels: lightweight concurrent functions started with
go, communicating over typed channels ("share memory by communicating").
- Modules: dependency management via
go.mod/go.sum; a module is a versioned collection of packages.
- Interfaces are implicit: a type satisfies an interface simply by implementing its methods — no explicit
implements.
- Explicit error handling: functions return
error values that callers check; no exceptions for ordinary control flow.
- Structs and methods: data is grouped in structs; methods attach to types via receivers; no class inheritance, composition instead.
- The standard toolchain:
go build, go run, go test, go fmt, and go vet are part of the official distribution.
- Defer/panic/recover:
defer schedules cleanup; panic/recover are for truly exceptional conditions, not normal errors.
Best practices
- Format code with
gofmt/go fmt — canonical formatting is part of the language culture and is non-negotiable in idiomatic Go.
- Handle every returned
error; wrap with context using fmt.Errorf("...: %w", err) rather than discarding it.
- Use
context.Context to carry cancellation and deadlines through call chains, especially for servers.
- Keep interfaces small and define them at the consumer; prefer composition over inheritance.
Common pitfalls
- Ignoring returned errors (
val, _ := ...) → silently drops failures; check and propagate them.
- Loop-variable capture in goroutines/closures → in older Go versions the variable was shared; capture explicitly or rely on the per-iteration scoping of recent Go.
- Unbuffered channel deadlocks → a send blocks until a receiver is ready; ensure a consumer exists or use buffering/
select.
- Data races on shared state → guard with channels,
sync.Mutex, or run go test -race to detect them.
Examples
package main
import (
"fmt"
"sync"
)
func main() {
var wg sync.WaitGroup
results := make(chan int, 3)
for i := 1; i <= 3; i++ {
wg.Add(1)
go func(n int) {
defer wg.Done()
results <- n * n
}(i)
}
wg.Wait()
close(results)
for r := range results {
fmt.Println(r)
}
}
Further reading
Related skills
- (sibling language skills under ../)
1---2name: go3description: Compiled, concurrent language for simple, reliable network services; consult for goroutines, modules, and tooling.4domain: language5category: language6tags: [go, golang, concurrency, goroutines, modules]7official_sources:8 - https://go.dev/doc/9 - https://github.com/golang/go10 - https://go.dev/dl/11verified: 2026-06-1612metadata:13 source: https://skillmd.com/skills/gabriel7silva/go14---1516# Go1718## Overview19Go is an open-source programming language that makes it easy to build simple, reliable, and efficient software. It is statically typed and compiled, ships with a garbage collector, and provides built-in concurrency primitives (goroutines and channels) designed for network services and tooling. Read this for the module system, concurrency model, and the standard toolchain.2021## Official sources22- Docs: https://go.dev/doc/23- Repo: https://github.com/golang/go24- Install / download: https://go.dev/dl/2526## Install / setup27Download the installer for your platform from https://go.dev/dl/ and follow the instructions at https://go.dev/doc/install. Verify the install:28```bash29go version30```3132## Core concepts33- Goroutines and channels: lightweight concurrent functions started with `go`, communicating over typed channels ("share memory by communicating").34- Modules: dependency management via `go.mod`/`go.sum`; a module is a versioned collection of packages.35- Interfaces are implicit: a type satisfies an interface simply by implementing its methods — no explicit `implements`.36- Explicit error handling: functions return `error` values that callers check; no exceptions for ordinary control flow.37- Structs and methods: data is grouped in structs; methods attach to types via receivers; no class inheritance, composition instead.38- The standard toolchain: `go build`, `go run`, `go test`, `go fmt`, and `go vet` are part of the official distribution.39- Defer/panic/recover: `defer` schedules cleanup; `panic`/`recover` are for truly exceptional conditions, not normal errors.4041## Best practices42- Format code with `gofmt`/`go fmt` — canonical formatting is part of the language culture and is non-negotiable in idiomatic Go.43- Handle every returned `error`; wrap with context using `fmt.Errorf("...: %w", err)` rather than discarding it.44- Use `context.Context` to carry cancellation and deadlines through call chains, especially for servers.45- Keep interfaces small and define them at the consumer; prefer composition over inheritance.4647## Common pitfalls48- Ignoring returned errors (`val, _ := ...`) → silently drops failures; check and propagate them.49- Loop-variable capture in goroutines/closures → in older Go versions the variable was shared; capture explicitly or rely on the per-iteration scoping of recent Go.50- Unbuffered channel deadlocks → a send blocks until a receiver is ready; ensure a consumer exists or use buffering/`select`.51- Data races on shared state → guard with channels, `sync.Mutex`, or run `go test -race` to detect them.5253## Examples54```go55package main5657import (58 "fmt"59 "sync"60)6162func main() {63 var wg sync.WaitGroup64 results := make(chan int, 3)65 for i := 1; i <= 3; i++ {66 wg.Add(1)67 go func(n int) {68 defer wg.Done()69 results <- n * n70 }(i)71 }72 wg.Wait()73 close(results)74 for r := range results {75 fmt.Println(r)76 }77}78```7980## Further reading81- A Tour of Go: https://go.dev/tour/82- Effective Go: https://go.dev/doc/effective_go8384## Related skills85- (sibling language skills under ../)