title: How to access a variable that I can't pass to function
body: <p>So I use paho.mqtt to recieve MQTT messages, the received messages are printed like this</p>
  <pre><code>var messagePubHandler mqtt.MessageHandler = func(client mqtt.Client, msg mqtt.Message) {
      fmt.Printf(&quot;Received message: %s from topic: %s\n&quot;, msg.Payload(), msg.Topic())
  } 
  </code></pre>
  <p>if I now need to access (from that function) for example c that is initialized in main how do I do that?</p>
  <pre><code>opts.SetDefaultPublishHandler(messagePubHandler)
  opts.OnConnect = connectHandler
  opts.OnConnectionLost = connectLostHandler
  client := mqtt.NewClient(opts)
  d := net.Dialer{Timeout: 5000*time.Millisecond}
  c, err := d.Dial(&quot;tcp&quot;, &quot;127.0.0.1:1234&quot;)
  </code></pre>
  <p>I looked at pointers but that doesn't seem to work (or I just don't understand how) and I don't see how I can pass c</p>