examples/docs/basics-publish/main.go
raw| 1 | package main |
| 2 | |
| 3 | import "github.com/nats-io/nats.go" |
| 4 | |
| 5 | func main() { |
| 6 | nc, err := nats.Connect(nats.DefaultURL) |
| 7 | if err != nil { |
| 8 | panic(err) |
| 9 | } |
| 10 | defer nc.Close() |
| 11 | |
| 12 | // NATS-DOC-START |
| 13 | // Publish a message to the 'weather.updates' subject |
| 14 | nc.Publish("weather.updates", []byte("Temperature: 72°F")) |
| 15 | // NATS-DOC-END |
| 16 | } |