Go integrates with other technologies mainly through its standard library (net/http, encoding/json, database/sql, net), through code generation for gRPC and OpenAPI, and through client libraries for databases and message brokers. The best practices are to use timeouts and contexts on every call, keep integration code behind interfaces, handle errors and retries deliberately, and test against fakes.
Most Go integration work is networked: calling REST or gRPC services, reading from databases, and publishing or consuming messages. Calling C libraries or other languages directly is covered by cgo and shared libraries, a separate topic.
net/http is production-grade for both servers and clients. Do not use http.DefaultClient without a timeout, and use io.ReadAll (the io/ioutil package is deprecated since Go 1.16).
Two details matter. Check the status code before decoding, because error responses often have a different shape. Reuse one http.Client so connections are pooled.
encoding/json handles JSON with struct tags. Use json.NewDecoder(...).DisallowUnknownFields() for strict inputs, and the omitempty tag to leave empty fields out. Go 1.25 also ships an experimental encoding/json/v2 behind a build flag, so keep to encoding/json for production code unless you have tested it.
For service-to-service calls across languages, gRPC with Protocol Buffers gives typed contracts and generated clients:
.proto file that defines messages and services.protoc and the protoc-gen-go and protoc-gen-go-grpc plugins (or buf generate).grpc.NewClient.For REST contracts, generate server stubs and clients from an OpenAPI document with a tool such as oapi-codegen, so the code and the specification cannot drift apart.
database/sql is the common interface, and each database provides a driver (for example pgx for PostgreSQL or go-sql-driver/mysql for MySQL). Always use parameterised queries, pass a context and close rows.
For messaging, Go has maintained clients for Kafka, NATS, RabbitMQ, Redis and cloud services such as SQS and Pub/Sub. Design consumers to be idempotent, because most brokers deliver at least once.
| Practice | Why |
|---|---|
Set timeouts and pass context.Context | Prevents slow dependencies from exhausting goroutines |
Wrap errors with %w | Lets callers use errors.Is and errors.As |
| Hide clients behind small interfaces | Makes tests use fakes and allows swapping providers |
| Retry only idempotent calls, with backoff and jitter | Avoids duplicate side effects and retry storms |
| Keep secrets in environment variables or a secret manager | Keeps credentials out of source control |
Log with log/slog and add metrics and traces | Makes integration failures diagnosable |
Test with net/http/httptest | Runs without the real network |
Use net/http with a custom http.Client that sets a timeout. A third-party HTTP client is rarely needed.
gRPC suits internal service calls that need typed contracts and streaming. REST with JSON suits public APIs and browser clients. Many systems use both.
Use cgo, a C-compatible shared library or a separate process that talks over gRPC or HTTP. Network interfaces are usually easier to maintain.
ioutil removed from the example?io/ioutil has been deprecated since Go 1.16. Use io.ReadAll and os.ReadFile instead.
Go integrates well with other systems through net/http, encoding/json, database/sql, gRPC and broker clients. Wrap every external call in timeouts and contexts, return wrapped errors, retry only safe operations, hide dependencies behind interfaces and test with httptest. These habits make integrations dependable under real-world failure.