Your First Temporal Workflow in Go#
This article establishes the patterns used throughout the Temporal series: dependency injection for testable activities, idempotency for safe retries, and a clean worker binary. Every subsequent article builds on these foundations.
All code lives in the companion repo at github.com/statherm/temporal-examples. For background, see Introduction to Temporal and Namespaces and Task Queues.
Project Structure#
The companion repo organizes code by domain:
temporal-examples/
cmd/worker/main.go # Worker binary
cmd/starter/main.go # Workflow starter CLI
internal/container/
activities.go # Activity implementations with DI
workflow.go # Workflow definitions
types.go # Interfaces and types
MakefileWorkflows and Activities#
A workflow is a deterministic function that orchestrates work. It takes workflow.Context, must not perform side effects, and dispatches work through activities. Activities use standard context.Context and perform real I/O: