Examples
Runnable Go examples from the core repository, and how to start a server they can connect to.
A runnable getting-started example lives in the examples/go directory of the core repository. Its go.mod carries a replace directive pointing at the in-repo SDK, so the example always builds against the SDK source in the same checkout. The examples are exercised in CI via scripts/run-examples-from-readme.sh --language go.
Starting the server
The Go SDK speaks the VSR (Viewstamped Replication) wire protocol, so the examples run against the VSR server. The examples log in as iggy/iggy, and root credentials are applied only on the very first startup, when no data directory exists yet. Start the server with the default root credentials:
cargo run --bin iggy-server -- --fresh --with-default-root-credentialsIf an example fails to log in, the server data directory (local_data by default) was created with different credentials: delete it and start the server again with the defaults. This setup is intended only for development and testing.
Getting started
The producer creates sample-stream and sample-topic (if missing) and sends 5 batches of 10 messages to partition 0. The consumer polls them from offset 0 and exits after 5 batches. Stream, topic, and partition IDs are 0-based.
Run both from the examples/go directory:
go run ./getting-started/producer/main.go
go run ./getting-started/consumer/main.goRun multiple producers and consumers at once to see how messages are distributed across clients.
Both binaries accept the same flags:
--tcp-server-address- server address, default127.0.0.1:8090--tls- enable TLS--tls-ca-file- path to a CA certificate file--tls-domain- TLS server domain name for SNI
TLS
Start the server with TLS enabled, using the development certificates from the repository:
IGGY_TCP_TLS_ENABLED=true \
IGGY_TCP_TLS_CERT_FILE=core/certs/iggy_cert.pem \
IGGY_TCP_TLS_KEY_FILE=core/certs/iggy_key.pem \
cargo run --bin iggy-serverThen run the examples with the TLS flags (paths relative to examples/go):
go run ./getting-started/producer/main.go --tcp-server-address localhost:8090 --tls --tls-ca-file ../../core/certs/iggy_ca_cert.pem
go run ./getting-started/consumer/main.go --tcp-server-address localhost:8090 --tls --tls-ca-file ../../core/certs/iggy_ca_cert.pemFor the code walkthrough, see the quick start on the intro page, which follows the same example.
