package main import ( "fmt" emitter "github.com/emitter-io/go" "time" ) func main() { // Create the options with default values o := emitter.NewClientOptions() o.AddBroker("tcp://localhost:1883") o.SetClientID("go-emitter-publish") // Create a new emitter client and connect to the broker c := emitter.NewClient(o) sToken := c.Connect() if sToken.Wait() && sToken.Error() != nil { panic("Error on Client.Connect(): " + sToken.Error().Error()) } for i := 0; i < 1000; i ++ { text := fmt.Sprintf("Message %d", i) token := c.Publish("abqGF3nbCeYIYzOckDrU1vOq6uuU16rb", "test/counter", text) token.Wait() time.Sleep(5 * time.Second) } }