Go for Tooling

Go compiles to a single static binary and is the language most cloud-native tools (Docker, Kubernetes, Terraform) are written in.

Beginner · about 30 hours · difficulty 3/5

Go is a strong alternative if you want to build tools rather than scripts. It produces one static binary per platform, so distribution is trivial: copy the file and run it. Kubernetes, Docker, Terraform, Prometheus and most CNCF projects are written in Go, so knowing it lets you read their source, write Kubernetes controllers and contribute plugins.

What to learn

  • Packages, modules (go mod), types, structs, interfaces and error values.
  • Goroutines and channels for concurrent work such as checking hundreds of hosts in parallel.
  • The standard library: net/http, encoding/json, os/exec, flag, context for timeouts.
  • Cross-compiling with GOOS and GOARCH, and building small container images from a static binary.
  • CLI frameworks such as cobra if your tool grows subcommands.

Pitfalls

Ignoring returned errors, leaking goroutines without a context cancel, and over-engineering a 30-line task that a shell script would solve.

Good enough to move on: you can build and cross-compile a CLI that makes concurrent HTTP calls with timeouts and handles errors explicitly.

Key concepts

  • Modules, packages and types
  • Error handling idioms
  • Goroutines, channels and context
  • net/http and encoding/json
  • Cross-compilation
  • cobra CLIs

Other options for this step

  • Python for Automation: Python is the most common glue language in operations work: readable, batteries-included and supported by every cloud SDK.
  • Bash as Your First Language: Going deep on Bash first gets you productive on servers quickly, as long as you know when to switch to a real language.
  • JavaScript / Node.js for Automation: If you already know JavaScript, Node.js is a practical automation language with strong SDKs and a huge package ecosystem.

Mini project

Build a Go binary that pings a list of hosts concurrently with a 2 second timeout each, then cross-compile it for Linux and macOS and run it from a scratch-based container image.

Check yourself

What does passing a context with a deadline into an HTTP request protect you from?

Free resources