Skip to content

Go - Wyatt's Notes

Go programming language notes covering fundamentals, advanced concepts, and practical examples.

sources:

  • text: Standard textbook reference

Go is a programming language with a rich type system and ecosystem. These notes cover the language from fundamentals to advanced topics, with worked examples, practice problems, and flashcards.

Topics

What You Will Find

  • Fundamentals: Types, functions, control flow, and error handling patterns
  • Concurrency: Goroutines, channels, sync primitives, and the CSP model
  • Standard Library: fmt, strings, io, net/http, encoding/json, and os packages
  • Best Practices: Idiomatic Go patterns, project structure, and tooling

Why This Matters

Go was designed at Google for building large-scale network services and infrastructure. Its simplicity, fast compilation, and built-in concurrency make it ideal for microservices, CLI tools, and cloud-native applications. Understanding Go’s design philosophy — explicit error handling, composition over inheritance, and the “less is more” approach — produces reliable, maintainable software.

Intuition

Go prioritises simplicity and practicality: In a landscape of complex languages, Go’s small spec and focused feature set let developers write clear, maintainable code. The language stays out of your way so you can focus on solving problems.

Why it matters: Go is widely used in cloud infrastructure, DevOps tooling, and backend services where reliability and performance are critical.

The key insight: Go’s standard library is remarkably comprehensive — many projects need few or no external dependencies.

Common Mistakes

Assuming Go has classes: Go uses structs and interfaces for object-oriented patterns, but there are no classes, inheritance, or constructors. Composition via struct embedding replaces inheritance. This is a deliberate design choice, not a limitation.

Not using go vet and staticcheck: Go provides built-in static analysis tools. Running go vet ./... before committing catches common mistakes (printf format errors, unreachable code, incorrect struct tags). These tools are fast and should be part of your workflow.

Goroutine leaks: Goroutines that block on channels or I/O without a way to exit will leak. Always provide a mechanism for goroutines to terminate (context cancellation, done channels, or timeout). Monitor goroutine counts in production.

Cross-References

  • Basics: Fundamental Go concepts including types, functions, and control flow.
  • Intermediate: Error handling, interfaces, and generics.
  • Concurrency: Goroutines, channels, and race conditions.
  • Standard Library: Commonly used standard library packages.