Go's standard library covers most of what a cloud application needs without third-party packages: net/http for calling cloud APIs and serving traffic, context for timeouts and cancellation, encoding/json for payloads, log/slog for structured logs, and os/signal for graceful shutdown. Cloud provider SDKs (AWS, Google Cloud, Azure) sit on top of these building blocks and are the right choice for authenticated service calls.
The older advice of using ioutil and the AWS SDK for Go v1 is outdated. io/ioutil has been deprecated since Go 1.16, and AWS SDK for Go v1 reached end of support in July 2025, so new code should use io, os and AWS SDK for Go v2.
net/httpnet/httpCloud services expose REST or JSON APIs, and net/http is all you need to talk to them. Two rules matter in production: never use the default client without a timeout, and always tie requests to a context.Context so they stop when the caller gives up.
The generic helper decodes any response type, checks the status code, and closes the body. Reuse one http.Client for the whole process so connections are pooled instead of reopened for every call.
Copying a file into a bytes.Buffer before sending it wastes memory on large objects. Pass the *os.File directly as the request body and the transport streams it. Object stores such as Amazon S3, Google Cloud Storage and Azure Blob Storage commonly accept a plain HTTP PUT to a presigned or signed URL.
Setting ContentLength avoids chunked encoding, which some storage endpoints reject. Accept any 2xx status, because services return 200, 201 or 204 depending on the API.
Goroutines make fan-out cheap, but a bare sync.WaitGroup loses errors and does not cancel the remaining work. The golang.org/x/sync/errgroup package, maintained by the Go team outside the standard library, adds both and lets you cap concurrency.
Since Go 1.22 each loop iteration has its own i and u, so closures capture the right values without copying them. Each goroutine writes to its own slice index, so no mutex is needed.
For authenticated calls to a provider, use its official SDK rather than signing requests by hand. For AWS that is AWS SDK for Go v2 (github.com/aws/aws-sdk-go-v2), which replaces the session package of v1 with config.LoadDefaultConfig and takes a context on every call.
Credentials come from the default chain: environment variables, shared config files, or the IAM role attached to the container, function or VM. Google Cloud (cloud.google.com/go) and Azure (github.com/Azure/azure-sdk-for-go) follow the same pattern of default credentials plus context-aware calls.
Cloud platforms such as Kubernetes and Cloud Run start, stop and health-check your process. A well-behaved service reads configuration from the environment, exposes a health endpoint, logs structured JSON, and drains in-flight requests on SIGTERM.
The method-and-path pattern GET /healthz works in http.ServeMux from Go 1.22 onward. Shutdown stops accepting new connections and waits for active requests, which prevents dropped requests during rolling deployments.
| Practice | Why it matters |
|---|---|
| Set timeouts on clients and servers | A hung dependency cannot exhaust your goroutines and connections |
Pass context.Context everywhere | Cancellation and deadlines propagate through the whole call chain |
| Read secrets from the environment or a secret manager | Credentials never land in source control or images |
Use log/slog with JSON output | Log platforms can index fields such as err and addr |
| Retry only idempotent calls, with backoff | Avoids duplicate writes and retry storms |
| Use workload identity or IAM roles | No long-lived access keys to rotate or leak |
Build a static binary with CGO_ENABLED=0 | Small images that start fast on any platform |
No. The standard library gives you HTTP, TLS, JSON and concurrency primitives. Provider SDKs for AWS, Google Cloud and Azure are separate modules you add with go get.
No. v1 reached end of support in July 2025. Use AWS SDK for Go v2, which is modular, context-aware and actively maintained.
It compiles to a single static binary, starts quickly, uses little memory, and has cheap concurrency. Kubernetes, Docker and Terraform are all written in Go.
Set http.Client.Timeout or a deadline on the request context. The default http.Client has no timeout, so a stalled server can block a goroutine indefinitely.
Use net/http with timeouts and contexts for cloud APIs, stream uploads instead of buffering them, bound concurrency with errgroup, and reach for AWS SDK for Go v2 or the equivalent official SDK when you need signed, authenticated service calls. Add structured logging, a health endpoint and graceful shutdown, and your Go service behaves well on any cloud platform.