连接到默认服务器

Some libraries also provide a special way to connect to a default url, which is generally nats://localhost:4222:

nc, err := nats.Connect(nats.DefaultURL)
if err != nil {
    log.Fatal(err)
}
defer nc.Close()

// Do something with the connection

最后更新于