uage-go">// Connection event handlers are invoked asynchronously
// and the state of the connection may have changed when
// the callback is invoked.
nc, err := nats.Connect(&#34;demo.nats.io&#34;,
	nats.DisconnectHandler(func(nc *nats.Conn) {
		// handle disconnect event
	}),
	nats.ReconnectHandler(func(nc *nats.Conn) {
		// handle reconnect event
	}))
if err != nil {
	log.Fatal(err)
}
defer nc.Close()

// Do something with the connection

</code></pre>
	</div>
	
	<div class="tab__content">
	<pre id="recon