Blog
Para quem já sabe o básico e quer ir fundo. Aqui o assunto é como os modelos funcionam em produção: memória, roteamento, ferramentas, agentes. O lado técnico que pouca gente explica direito.
Go nasceu em 2007 no Google (Rob Pike, Ken Thompson, Robert Griesemer) como reação ao C++ complicado e Java verboso. Go 1.0 em 2012; compatibilidade backward forte desde então. Versões marcantes: 1.11 (modules), 1.18 (generics — grande adição), 1.21 (loopvar scoping fix), 1.22-1.24 (range over func, profile-guided optimization). Compilador único oficial (gc) — fast build, static binary com runtime pequeno embutido (scheduler, GC). Diferencial: simplicidade deliberada (menos de 25 keywords), goroutines baratíssimas (stack 2KB inicial), gofmt como padrão, compilation time ~instantâneo. Mercado 2026: DevOps tooling (Docker, Kubernetes, Terraform, Prometheus), backend high-scale (Uber, Cloudflare, Netflix edge), CLIs profissionais. Go 1.22+ é o padrão atual.
Go philosophy: pequena linguagem, composable, explicit. Go fmt. Go workspace conventions. GOPATH era — agora go modules (go.mod). "Do not communicate by sharing memory; share memory by communicating."
Goroutines (lightweight ~2KB, millions OK), channels (send/receive synchronization primitive). Unbuffered (sync) vs buffered. select statement. Fan-in, fan-out patterns. Race conditions e race detector.
context.Context canonical pra cancelation + deadline + request-scoped values. context.WithCancel, WithTimeout, WithDeadline. Pass context como first arg sempre. Leaked goroutines = missing context.
"The bigger the interface, the weaker the abstraction" — Rob Pike. io.Reader, io.Writer (1 method). Aceita interfaces, retorna structs. Implicit implementation (duck typing estrutural). Composition > inheritance.
if err != nil { return err } é idiomático (polarizing). errors.Is (sentinel match), errors.As (type assertion), errors.Wrap (errors.Join Go 1.20+). Custom error types. panic reservado pra programmer errors.
Generics finally (Go 1.18, 2022). Type parameters em funções + types. Constraints (comparable, any, custom interfaces). slices/maps packages (Go 1.21+) pra operations generic. Tradeoff: simplicity vs power.
pprof (cpu, memory, goroutine, mutex profiles) built-in. Escape analysis (stack vs heap). Allocations count. Benchmarking (testing.B). sync.Pool pra reutilizar. sync/atomic pra lock-free.
Build: CLI (cobra) + REST API (net/http + chi router) integradas. Unit + integration tests. Goroutine pool. Context-aware. Graceful shutdown. Config via env + viper. Dockerfile minimal (scratch ~10MB).