How to Build Your First Temporal Workflow in Go
Temporal is a workflow engine that keeps multi-step processes running reliably for hours, days or months. You write ordinary functions for the workflow and its activities; Temporal persists every step, so a crash resumes where it left off instead of starting over.
The mental model trips people up at first. Here is the shortest path from install to a running workflow you can inspect.
What is Temporal and when should I use it?
Temporal is a durable execution platform. It records workflow state in its own store, so retries, timeouts and long waits survive process restarts. The Temporal server handles orchestration while your workers execute code. Reach for it when a process spans multiple services, needs retries with backoff, or must wait on human input — the cases where a queue plus cron gets brittle.
How do I install and start the server?
The fastest local setup is the Temporal CLI.
brew install temporal
temporal server start-dev
This spins up a dev server with a Web UI at localhost:8233. No database or config needed — start-dev uses an in-memory store, which is fine for learning but loses data on restart.
How do I write a workflow and an activity?
Two pieces. The workflow is deterministic orchestration; activities do the real work (calling APIs, touching databases).
func GreetWorkflow(ctx workflow.Context, name string) (string, error) {
ao := workflow.ActivityOptions{ScheduleToCloseTimeout: time.Minute}
ctx = workflow.WithActivityOptions(ctx, ao)
var result string
err := workflow.ExecuteActivity(ctx, Greet, name).Get(ctx, &result)
return result, err
}
func Greet(ctx context.Context, name string) (string, error) {
return "Hello " + name, nil
}
Register both in a worker, then start the workflow with a client call. The rule that matters: never do network I/O inside a workflow function — put it in an activity. Breaking that rule causes non-determinism errors.
How do I inspect a running workflow?
Open the Web UI at localhost:8233. You see the workflow, its event history, each activity attempt, and any retries. That event history is the feature that makes Temporal worth learning — you can replay it to debug a failure that happened three days ago.
Is Temporal free?
Temporal is open source under the MIT license, and the dev server is free. Temporal Cloud is the paid managed option, priced on actions and storage; the exact rate depends on tier and volume, so check their calculator. Self-hosting production is free of license cost but you own the Cassandra/MySQL backend and upgrades.
Where does Temporal add friction?
Determinism constraints are real: no random numbers, no direct time or I/O in workflow code. Teams used to free-form async code hit this immediately. Local dev also differs from production, since you swap the in-memory store for a real database. And for a simple nightly job, Temporal is overkill — a cron entry does less and costs nothing.
Quick Summary
- Temporal is a durable execution engine; workflow state survives crashes and long waits.
- Start locally with
temporal server start-dev; UI on port 8233. - Keep workflows deterministic and push all I/O into activities.
- Open source and free to self-host; Cloud is paid. Overkill for trivial cron jobs.
