// the find
eclipse-paho/paho.mqtt.golang
MQTT 3.1/3.1.1 client library for Go, part of the Eclipse Paho project. Handles pub/sub over TCP, TLS, and WebSockets with QoS 0/1/2 and auto-reconnect. The target audience is anyone building IoT or messaging systems in Go that need a mature, spec-compliant MQTT client.
1. Battle-tested and spec-compliant — this is the reference Go MQTT client, used in production IoT deployments for years, not a weekend project. 2. The async token pattern (t.Wait() / t.Done()) is a reasonable fit for Go's concurrency model and lets you fire-and-forget or block explicitly. 3. Persistent message stores (file and memory) are built in with a clean interface, so QoS 1/2 delivery guarantees survive reconnects. 4. The README's troubleshooting section is genuinely useful — it calls out the SetOrderMatters deadlock footgun and the CleanSession retained-message race condition explicitly, which saves hours of debugging.
1. MQTT v5 is explicitly not supported here — you need the separate paho.golang repo for that, which has a completely different API. If you start with this library and later need v5 features (user properties, reason codes, topic aliases), you're rewriting. 2. The global logger vars (mqtt.ERROR, mqtt.DEBUG) are package-level state, which makes structured logging and per-client log routing awkward in any non-trivial multi-client setup. 3. The README warns that reusing a Client after Disconnect is 'not completely safe' without giving you a clear invariant — that's a code smell indicating the internal state machine has edge cases the authors haven't fully resolved. 4. No context.Context support in the public API, so cancellation and deadline propagation require workarounds; this is a real gap for anything running in a server with graceful shutdown requirements.