When a Go team should build Temporal applications with the Go SDK
A Go team should build on the Temporal Go SDK when a business process must run for hours, days or longer, survive process crashes and deployments, and retry external calls without the team writing its own state machine. The SDK lets you express that process as ordinary Go functions. Temporal records every step of the workflow so that an interrupted process resumes where it stopped, which is the main reason it fits better than a message queue with hand-built retry logic or a cron job that has no memory of earlier runs. If the work is a single fire-and-forget task with no need for a recorded history, a queue or scheduled job is usually simpler to run and easier to justify.
The SDK divides the system into three parts. Workflows hold the business logic and orchestration, and they must be deterministic, so they cannot call the network, read the clock or start goroutines directly. Activities perform the side effects, such as calling a payment API, writing to a database or sending an email, and Temporal retries them under the policy you configure. Workers are Go processes that poll a task queue and execute workflow and activity code. Your team decides which services run workers, which task queues they listen on and how they are deployed, and those choices shape operations more than the workflow code does. Temporal also offers official SDKs for other languages, and the Go SDK is one of several; sibling pages cover the Java, Python, TypeScript, .NET, Ruby and PHP options, so compare them before committing a service to Go.
Which Go constructs to replace inside workflows
Workflow functions run again during replay, so any Go construct whose result can differ between runs will break determinism. The cards below cover the constructs that most often slip into workflow code and the Temporal call that replaces each one. Check every workflow file against this list before it goes into review.
Timers and sleeps
Calling time.Sleep or time.After inside a workflow blocks a real goroutine and is not recorded in history, so replay cannot reproduce the wait. Use workflow.Sleep(ctx, duration) for delays and workflow.NewTimer when you need a cancellable timer. Time read through workflow.Now(ctx) replaces time.Now(). Any wall-clock call, including one buried in a helper, belongs in an activity if its value matters.
Goroutines and channels
Go's go statement and native channels run outside the Temporal scheduler, so their ordering is not stored in event history. Use workflow.Go to start concurrent work and workflow.NewChannel or workflow.NewBufferedChannel for communication between those coroutines. Sync primitives such as sync.Mutex should be replaced by workflow-aware equivalents. Review any select statement, because Go's runtime chooses ready cases randomly.
Selectors for waiting on events
A plain Go select over channels is not deterministic inside a workflow. Use workflow.NewSelector to wait on signals, timers, and activity futures, then call Select in a loop. Each case you add should be a stable, named event so replay takes the same branch. Ask reviewers to confirm that every future added to a selector is either awaited or cancelled before the workflow completes.
Random and UUID generation
Calls to math/rand, crypto/rand, or uuid.New() return different values on each execution, so a replayed workflow can take a different path. Use workflow.SideEffect when you need a value generated once and recorded in history. Generate identifiers that must be stable across retries inside an activity, then return them to the workflow. Keep the workflow's own random seed out of business logic entirely.
Logging and external side effects
Writing logs from workflow code repeats entries during replay, which clutters output and can mislead incident responders. Use workflow.GetLogger(ctx), which suppresses messages during replay. Calls to databases, HTTP APIs, email, or payment systems must run in activities, where Temporal retries them under the activity's retry policy. Use workflow.SideEffect only for small, non-retriable reads such as a generated value, not for I/O.
Go SDK options and when each fits
This table compares the build choices a Go team makes before writing workflows: activity style, payload handling, versioning, task queue layout and worker topology. Read each row for the option that fits your team size and release rhythm, then check the maintenance cost in the right-hand column before committing.
| Decision | Option and when it fits | Maintenance cost to plan for |
|---|---|---|
| Activity implementation style | Struct methods on a registered struct when activities share clients or config; plain functions when each activity is self-contained and stateless | Struct registration ties activity names to a struct type, so renaming or moving a method is a compatibility change for running workflows |
| Data encoding and payloads | Default JSON encoding with explicit, versioned Go structs for workflow inputs and results; a custom data converter or codec only when payloads must be encrypted or use another format | Adding or renaming struct fields needs backward-compatible changes, and any custom codec must be deployed to every worker and the codec server that reads histories |
| Versioning in workflow code | workflow.GetVersion for small logic changes to workflows that are still running; Worker Versioning when a change is large enough to justify deploying new workers alongside old ones | GetVersion branches accumulate in code until they are removed, while Worker Versioning adds deployment and build-ID management to the release process |
| Task queue layout | One task queue per workflow type or service boundary when teams deploy independently and need separate capacity; a shared queue when workflows are few and scale together | Each queue needs its own worker pool, metrics and autoscaling settings, so more queues mean more dashboards and more on-call decisions |
| Single worker or separate workers per service | A single worker binary for a small team with one codebase; separate worker binaries when services have different dependencies, release cadence or security boundaries | Separate binaries multiply build pipelines, shared library upgrades and Go module version drift across repositories |
| Testing approach | Time-skipping test environment for workflow logic with mocked activities; replay tests in CI once real histories exist | Replay test fixtures must be collected from real executions and refreshed when workflow code changes, which needs a standing owner |
How to set up a Go Temporal project in sequence
This sequence takes a team from an empty Go module to a worker that runs a workflow and a client that starts it, with a check at each step so problems surface early. The order matters because each step depends on the one before it, and the checks confirm that the code, the Temporal Service and the worker agree before you build on top.
Install the Go SDK module
Create a Go module for the project and add the Temporal Go SDK as a dependency using the standard go modules workflow. Pin the SDK version in go.mod so that every developer and every build pulls the same version, and record which SDK version matches the server version you plan to run. Confirm the module resolves and compiles with an empty main package before you write any Temporal code. Done means
go buildsucceeds on a clean checkout and the SDK version is pinned in go.mod.Connect a client to a Temporal Service
Choose the target for development: the local development server for early work, or a deployed endpoint on infrastructure you control or on Temporal Cloud. Write a small program that creates a client with the target host, namespace and any TLS or API key settings the endpoint requires, and keep those values in configuration rather than in code. Confirm the connection by running a simple call such as a namespace describe or a client connect with a timeout, and check that it fails clearly when the endpoint is wrong. Done means the program connects to the intended namespace and reports the expected service details.
Define workflow and activity signatures
Write the workflow function and the activity functions with their input and output types, keeping inputs and results as serializable structs. Workflow code must be deterministic, so this step is also where you agree on the rules the team will follow: no direct calls to time, random numbers, network or file access inside workflows, and any side effects placed in activities. Confirm the code compiles and that the workflow calls activities only through the workflow context. Done means the signatures compile and a reviewer can point to where each side effect lives.
Register workflows and activities in a worker
Create a worker bound to a named task queue, then register the workflow and each activity with it. Use the same task queue name in the client and the worker, and keep the names in shared constants so a typo cannot split the queue. Confirm the worker starts and polls without errors, and that the registered names match what the client will request. Done means the worker logs that it is polling the expected task queue.
Start the worker process
Run the worker as its own process, connected to the same Temporal Service and namespace as the client. Keep the worker separate from the client code so that you can restart workers without touching callers. Watch the startup output for connection or registration errors, and confirm the worker stays running. Done means the worker process is up and connected, and the Temporal Service shows a poller on the task queue.
Start a workflow from a client
Run the client program to start a workflow execution with a stable workflow ID and the task queue used by the worker. Choose the workflow ID carefully, because reusing IDs affects duplicate handling later. Confirm the client receives a run ID and that the worker completes the activities and the workflow. Done means the result returned to the client matches what the workflow should produce.
Check the execution in the Web UI and replay the history
Open the Web UI for the namespace and confirm the workflow appears with the expected status, history events and activity results. Then export the first event history and run it through a replay test against the current workflow code, which should succeed without non-determinism errors. Treat a passing replay as the baseline for later changes. Done means the execution is visible in the Web UI with a completed status and the replay of the first history succeeds.
Testing Go workflows with the test framework
The Go SDK's test framework lets you run workflow code in a test suite environment without a running Temporal Service, and it is where most behavioral checks for a workflow should start. Build the suite around testsuite.WorkflowTestSuite and create a testsuite.TestWorkflowEnvironment for each test. Register the workflow and its activities with the environment, then replace each activity with a mock using OnActivity and Return so the test controls what each call produces, including errors that trigger retries or compensation. Unit tests written this way catch logic errors in branching, signal handling, timer use and compensation paths, and they run quickly enough to execute on every commit.
The test environment skips time forward when the workflow is waiting on a timer or on an activity retry, so a test that sleeps for days in production finishes in moments. Confirm this behavior with the exact SDK version your team pins, because the test environment's handling of timers, retry policies and child workflows has changed across releases. Unit tests with mocked activities do not exercise your real activity code, serialization of payloads, worker registration, or the server's history and retry behavior. Those gaps belong to integration tests against a development server, and to end-to-end runs in a non-production namespace. Keep the two layers separate in CI so a failing mock is never mistaken for a failing deployment.
Replay testing is the main guard against non-determinism when workflow code changes. The test environment cannot tell you whether a modified function will still replay existing executions, because its mocks never produce the recorded event history that a running workflow depends on. Export real histories from executions that are still open or recently closed, store them as test fixtures, and replay them against the candidate code in CI before each deployment. The Temporal replay testing before deployments guidance and the sibling pages on testing Temporal workflows and replay testing cover fixture collection, versioning and patching in depth, so use those for the detailed procedure.
How to structure Go workers for production
Keep the same worker code path in every environment, but give each environment its own Temporal namespace, task queue names and worker fleet. Sharing a namespace between staging and production lets test workflows consume production task queues and mix histories, which makes incidents much harder to trace.
- Namespace per environment: Create separate namespaces for development, staging and production so histories, search attributes and access permissions stay apart.
- Environment in queue names: Use a pattern such as
orders-prodandorders-stagingso a misconfigured worker can only poll the queue it was meant for. - Configuration from the deployment: Pass the server address, namespace, TLS material and concurrency limits through environment variables or mounted files so one binary moves between environments unchanged.
- Explicit concurrency per environment: Set worker concurrency in each environment and confirm the Go SDK defaults in the worker options reference before relying on them.
- Separate identities: Issue each environment its own client certificate or credential so production access can be revoked without touching staging.
Check that each worker logs its namespace and task queue at startup so an operator can confirm the target before traffic arrives.
A Go worker can host both workflow and activity code, and it registers whichever functions you give it. Splitting them into separate processes lets you size and scale each side independently. Activities usually call external systems and wait on I/O, while workflow tasks are short, deterministic and must replay quickly.
- Workflow workers: Register only workflows on a workflow task queue. These processes need no credentials for downstream systems, which narrows what a compromised process can reach.
- Activity workers: Register activities on their own task queue, with access only to the systems they call. Scale these according to the load on those systems.
- Separate concurrency limits: Set workflow task and activity execution limits independently, and confirm the option names in the Go SDK reference for your version.
- Shared definitions: Keep workflow and activity definitions in one module so the names used in workflow calls match what activity workers register.
- Combined workers for development: A single process is simpler to run locally, but it mixes two failure profiles in one place, so move to split workers before production.
Check that every activity name a workflow calls has a registered handler on the queue it targets, since a missing registration only surfaces when that call runs.
A dedicated worker per service gives each team its own deployment, queues and release cadence, which limits the impact of a bad release. A shared worker serves several workflow types from one process. That means fewer deployments to operate, but the services become coupled through release timing and shared resource use.
- Queues named by owner: Name each queue after the owning service, such as
billing-activities, so ownership and backlog are visible in the Web UI. - Slot contention: One slow activity can consume the concurrency slots that other workflows need, so place heavy or unreliable external calls on their own queue.
- Shared code versions: A shared worker must carry every workflow version that still has open executions, so one service's deploy can change behavior for others.
- Operational load: Count the deployments, dashboards and alerts each option creates for your team before choosing.
- Splitting later: Moving from shared to dedicated workers is easier when queue names are set per workflow type from the start, so decide this during design review.
Check which queues each workflow type polls and whether one service's deployment can restart the workers that serve another.
Running workflows keep their recorded event history, and a new deployment replays that history against the code now running. If the new code issues commands in a different order, replay fails with a non-determinism error. Plan rollouts so old and new code can both serve running executions until those executions finish.
- Graceful shutdown: Stop workers with a termination signal, let in-flight tasks finish within the configured stop timeout, and confirm that timeout in the Go SDK worker options.
- Termination grace period: Set the Kubernetes termination grace period longer than the worker stop timeout, or in-flight tasks are killed mid-execution.
- Versioned changes: Guard changed workflow logic with
workflow.GetVersionso histories recorded on the old code still replay. - Build ID routing: Confirm whether your SDK and server versions support worker build ID versioning, and whether old workers must keep polling for open executions.
- Drain before removal: Keep old workers running until no open executions depend on the old code path, and check this in the Web UI before retiring them.
Check that replay tests run against recorded histories in CI before every rollout, so non-determinism is caught before a worker reaches production.
Security considerations for Go Temporal applications
Temporal workflow code, its inputs and its event history all cross trust boundaries, and the default self-hosted settings leave much of that open. The cards below cover the decisions an engineering and security team should make before the first Go workflow reaches a shared Temporal Service, and the checks that confirm each one is in place.
Encrypt payloads with a custom codec
Temporal stores workflow and activity inputs and results in event history in readable form unless you apply a custom codec. Implement the Go SDK's payload codec to encrypt payloads before they leave the worker, and run a codec server so the Web UI and CLI can decode them for authorized operators. Decide who holds the keys, how keys rotate, and whether history exports keep the encrypted form. Confirm that a history dump from the database shows ciphertext only.
Self-hosted security docsKeep secrets out of inputs and history
Workflow inputs, activity arguments and return values are recorded in history, which is retained for as long as the namespace retention setting allows. Pass references such as a secret manager path or a short-lived token identifier instead of the secret itself, and let activities fetch the credential at execution time. Review log statements in workers and interceptors, since they often echo the same values. Test by searching a sample history for known test secrets.
Enforce mTLS and authentication
Self-hosted Temporal supports mTLS with separate settings for internode and frontend traffic. Configure the Go client with the client certificate and key the frontend expects, and verify the server name against the certificate chain. Map client certificate or JWT claims to namespace roles with a ClaimMapper, so each worker identity can reach only its own namespaces. Ask your platform team who issues and rotates these certificates before the first deployment.
Replace the noopAuthorizer default
If no Authorizer is configured, self-hosted Temporal uses the default noopAuthorizer, which allows every API request with no authentication or access control. Any service that can reach the frontend can start, signal, terminate or read any workflow in any namespace. Configure an Authorizer plugin that matches your ClaimMapper roles, and test it with a client that holds a role for one namespace only. Treat this as a go-live blocker.
Authorization settingsPlace services on private networks
The Temporal deployment documentation says Temporal services should run on hosts that are not reachable from the public internet, with network access limited to trusted internal networks. Place the frontend, history, matching and worker services, plus the persistence and visibility stores, on private subnets. Limit which application workers and operator hosts can reach the frontend port. Confirm with a scan from outside your network that no Temporal port answers.
Deployment docsHow the client, workflows, activities and Temporal Service fit together
The flow starts with a Go client calling the Temporal Service to start a workflow execution. The service records the event history and schedules workflow tasks onto a task queue. Go workers poll that queue, run the deterministic workflow code, and hand side-effecting work to activities, which report results back so the service can record them. Check where the frontend and internode traffic cross the boundary, since the self-hosted service has no access control unless you configure an Authorizer and mTLS.
Go client, Temporal Service and Go workers, with the trust boundary around the service.
Limits to confirm before you commit to the Go SDK
The Go SDK work depends on decisions made outside the code: which Go and SDK versions your team can support, which database and visibility store run underneath, and how the server will be upgraded. Confirm each item below in your own environment before you agree a scope, because several of them change the build sequence.
Go version and SDK release
Confirm which Go toolchain your standards allow and which Temporal Go SDK release your team will pin. Workflow code, activity code and worker binaries should be built against the same SDK release, and upgrades to the SDK can change replay behavior, so the pinned version belongs in the scope document. Ask the partner which SDK release the design targets and how that choice will be tested before any upgrade.
Persistence and visibility backends
Confirm which database holds workflow state and which store serves visibility queries. Persistence and visibility are separate choices with separate version lists, and SQLite is meant only for development and testing. If you need list and search queries across many executions, plan Elasticsearch or OpenSearch for visibility before you build search features into the application.
Persistence docsWorkflow history and payload size
Confirm the history size and payload size your workflows are expected to reach, and the limits enforced by the server and the SDK in your target release. Long-running workflows that loop without continue-as-new and large inputs passed between activities are the usual causes of trouble. Ask for the exact limits for your server version and design the workflow boundaries and payload strategy around them.
Target Temporal Server version
Confirm the Temporal Server version your environment will run, and check that it matches the SDK you pin. Server releases move quickly, and patch releases are published for several minor lines at once. Record the target version in the scope, then confirm that the Go SDK release you choose supports it before development begins.
Temporal releasesServer upgrade path
Confirm how you will move the server from its current version to the target. Temporal documents that backward compatibility is guaranteed between successive minor versions, so upgrades should move one minor version at a time, with schema upgrades run first when release notes call for them. Ask who owns each step and how the upgrade will be rehearsed against workflows that are still running.
Upgrade guideSelf-hosted or Temporal Cloud
Confirm whether the deployment will be self-hosted in infrastructure you control or run on Temporal Cloud. The answer decides who operates the frontend, persistence and visibility, how TLS and authentication are configured in the Go client, and which support tiers and SLAs apply. Ask the partner to show the client connection settings for both options before the worker design is fixed.
Temporal Cloud pricingQuestions teams ask before building Temporal apps in Go
What drives the cost of building a Temporal application in Go?
The main cost driver is the number of workflows and activities that touch external systems, along with how many of them must be correct under retries, partial failures and code changes. Cost splits into design work (deciding workflow boundaries, retry policies and versioning approach), build work (workflow code, activities, workers and client code), and test and operations work (replay tests in CI, worker deployment and observability). Ongoing costs include running the Temporal Service, whether you self-host it or buy Temporal Cloud, and the engineering time to keep workers and the service upgraded. Ask any partner for a quote that lists these components separately, with the number of workflow types, integrations and environments named in the written scope.
How long does a first Temporal workflow take to build in Go?
A first workflow with a few activities and a simple retry policy is a contained piece of work, but the timeline is driven by factors outside the workflow code. The schedule usually expands with the number of external systems the activities call, how idempotent those calls are, the team's familiarity with Go's concurrency model, and whether a Temporal Service and CI pipeline already exist. Replay testing and a production worker layout add time that a prototype skips. No fixed duration is supplied for this work, so ask for a timeline in the written scope that names the workflows, integrations and environments it covers.
What must our team provide before building Temporal apps in Go?
Your team needs Go engineers who can read and write concurrent code, a named owner for the workflow designs, and access to a Temporal Service in a non-production environment. The service can be self-hosted on infrastructure you control or a Temporal Cloud namespace, and the choice affects who operates it. CI access is needed so replay tests and unit tests run on every change to workflow code. You will also need access to the systems the activities call, test credentials, and a decision on how payloads are encrypted and who holds the keys. List these in the scope so gaps are visible before work begins.
Can an in-house team build Temporal applications in Go without a partner?
Yes, many teams build Temporal applications in Go with their own engineers, especially where they already run Go services and have operated stateful infrastructure. The usual gaps are in determinism rules for workflow code, versioning strategy for changes to running workflows, test design using the Go test framework, and production worker structure. A partner is most useful where those skills are missing or where the deadline is fixed. Assess your team against those four areas, and check whether the people who will be on call can operate the Temporal Service and workers as well as the code.
Which Temporal Cloud pricing components affect the cost of a Go application?
Temporal Cloud pay-as-you-go pricing starts at 50 US dollars per million actions, with active storage at 0.042 US dollars per GB-hour and retained storage at 0.00105 US dollars per GB-hour, according to Temporal's pricing page. Actions depend on how many workflow and activity operations your application generates, so retries, long-running workflows and chatty activity designs raise them. Storage depends on how much workflow history is kept active and retained. The SLA tier, 99.9% or 99.99% with high availability, and SAML SSO are listed on the same page, and support add-ons are priced separately, with Business starting at 500 US dollars per month. Enterprise and Mission Critical support are quoted by sales. Estimate action volume from your workflow design before comparing with self-hosting costs, and confirm current figures on the pricing page.
Does self-hosting Temporal change how the Go application is built?
The Go application code is largely the same, because workers connect to the Temporal Service through the client configuration. Self-hosting changes the operating model: you choose the deployment method, persistence store, visibility store, network exposure and upgrade process. The Temporal deployment documentation says services should run on hosts not reachable from the public internet, and self-hosted installs accept all API requests unless an Authorizer is configured. Confirm these settings during design, because they affect how workers authenticate and which namespaces they can reach. Ask the partner to name which of these decisions sit in their scope and which stay with your team.
What do Go teams most often get wrong when building Temporal workflows?
The most common mistakes are using non-deterministic Go constructs in workflow code, such as direct time calls, random values, goroutines that Temporal does not manage, or map iteration that affects control flow. Teams also change workflow logic while executions are still running, which breaks replay unless versioning is handled. Other frequent issues are activities that are not idempotent, retry policies that retry non-retryable errors, and workers that cannot shut down cleanly during deployment. Each of these can be caught earlier with unit tests on the Go test framework and replay tests run against captured histories in CI. Ask for those tests to be part of the scope rather than added later.
How DeployOpen scopes and supports Go Temporal work
DeployOpen plans and builds Temporal applications in Go as part of a fixed-scope engagement, with the scope agreed in writing before work starts. The work runs inside your infrastructure, and the result is documented so your own engineers can review and change the workflow code afterward.
How we scope
- The written scope names the workflows, activities and task queues to be built, and which ones are in and out of the engagement.
- We confirm the determinism rules, versioning approach and replay testing your Go code must follow before design starts.
- Scope records your Temporal deployment choice, self-hosted or Temporal Cloud, and the workers and environments each one requires.
How we build
- We implement workflows and activities in Go, replacing non-deterministic calls with Temporal-safe equivalents such as workflow time, selectors and workflow-aware goroutines.
- We write unit and integration tests with the Temporal Go test framework and add replay tests that run recorded event histories against new code.
- We structure workers for production, covering task queue layout, worker options, graceful shutdown and the configuration each environment needs.
How we hand over
- Handover includes source code, test suites, worker deployment manifests and a written record of workflow versioning decisions.
- We document the determinism rules and patching steps your team needs to change workflows safely after go-live.
- Runbooks cover worker deployment, restart behavior and the checks to run before each release of workflow code.
How we support
- Engagements are fixed-scope, and ongoing support, upgrades and continuous testing are available as a retainer.
- A retainer can cover Temporal Server upgrades and changes to workflow code, with each change reviewed against replay tests.
- To get a quote, send your target Temporal deployment model, your Go version and the workflows you expect to build, and we will return a written scope.

