Go is synchronous. Pass context.Context on every call. Cancel the context to stop waits and stream receives.
Process lifecycle
- Create one client per process (or per logical bot) and reuse it.
- Call
client.Close()on shutdown so WebSocket connections release cleanly. - Cancel work with
context.Context.
Configuration
Prefer explicit credentials from your secret store and pass Environment explicitly. Use FromEnv only for local scripts.
Wait for catalogs before decimal writes. Disable catalog hydration only if you exclusively use pre-scaled integers and understand the tradeoff.
Wire format
Binary Protobuf is the default Connect codec. JSON wire formats are for debugging, not hot
paths. With WireFormat: "json", API-key signatures hash the ProtoJSON body bytes (matching connect.WithProtoJSON()), not binary protobuf. A body/signature mismatch fails auth.
See Client configuration.
Related Topics
Authentication Configure Ed25519 API keys, Account ID, and env-based wiring for bots. Market data Read candles, public trades, order books, and market overview, no credentials required. Trading Place, modify, cancel, and batch spot orders; use triggers with the Go SDK. Streaming Subscribe with Messages() channels, handshake-before-return, and fail-closed overflow. Accounts & balances Funding vs trading balances, reserved amounts, subaccounts, policies, and transfer history. Deposits & withdrawals Deposit addresses, trading withdraws, internal transfers, and funding flows. Error handling Classify Go SDK errors with errors.As, retry with idempotency keys, handle queue overflow. Production trading operations Operate, test, troubleshoot, and upgrade an automated Go trading system safely.