|
package main
|
|
|
|
import (
|
|
"fmt"
|
|
"time"
|
|
|
|
"github.com/nats-io/nats.go"
|
|
)
|
|
|
|
func main() {
|
|
nc, err := nats.Connect(nats.DefaultURL)
|
|
defer nc.Close()
|
|
if nil != err {
|
|
fmt.Println(err)
|
|
return
|
|
}
|
|
|
|
for {
|
|
nc.Publish("foo", []byte("Hello Publish!"))
|
|
time.Sleep(1 * time.Second)
|
|
}
|
|
}
|