Files
quicproquo/sdks/go/cmd/example/main.go
Christian Nennemann 2e081ead8e chore: rename quicproquo → quicprochat in docs, Docker, CI, and packaging
Rename all project references from quicproquo/qpq to quicprochat/qpc
across documentation, Docker configuration, CI workflows, packaging
scripts, operational configs, and build tooling.

- Docker: crate paths, binary names, user/group, data dirs, env vars
- CI: workflow crate references, binary names, artifact names
- Docs: all markdown files under docs/, SDK READMEs, book.toml
- Packaging: OpenWrt Makefile, init script, UCI config (file renames)
- Scripts: justfile, dev-shell, screenshot, cross-compile, ai_team
- Operations: Prometheus config, alert rules, Grafana dashboard
- Config: .env.example (QPQ_* → QPC_*), CODEOWNERS paths
- Top-level: README, CONTRIBUTING, ROADMAP, CLAUDE.md
2026-03-21 19:14:06 +01:00

56 lines
1.4 KiB
Go

// Command example demonstrates basic usage of the quicprochat Go SDK.
package main
import (
"context"
"fmt"
"os"
"quicprochat.dev/sdk/go/qpq"
)
func main() {
addr := "127.0.0.1:5001"
if len(os.Args) > 1 {
addr = os.Args[1]
}
ctx := context.Background()
client, err := qpq.Connect(ctx, qpq.Options{
Addr: addr,
InsecureSkipVerify: true,
})
if err != nil {
fmt.Fprintf(os.Stderr, "connect failed: %v\n", err)
os.Exit(1)
}
defer client.Close()
status, err := client.Health(ctx)
if err != nil {
fmt.Fprintf(os.Stderr, "health check failed: %v\n", err)
os.Exit(1)
}
fmt.Printf("Server health: %s\n", status)
fmt.Println("\nUsage:")
fmt.Println(" // Authenticate with a pre-existing session token")
fmt.Println(" client.SetSessionToken(token)")
fmt.Println()
fmt.Println(" // Resolve a user's identity key")
fmt.Println(" key, err := client.ResolveUser(ctx, \"alice\")")
fmt.Println()
fmt.Println(" // Create a DM channel")
fmt.Println(" chID, wasNew, err := client.CreateChannel(ctx, peerKey)")
fmt.Println()
fmt.Println(" // Send a message")
fmt.Println(" seq, err := client.Send(ctx, recipientKey, payload)")
fmt.Println()
fmt.Println(" // Receive messages")
fmt.Println(" msgs, err := client.Receive(ctx, recipientKey)")
fmt.Println()
fmt.Println(" // Long-poll for messages (5 second timeout)")
fmt.Println(" msgs, err := client.ReceiveWait(ctx, recipientKey, 5000)")
}