title: Call function of specific type in Go
body: <p>I'm a complete Go newbie, so sorry for the question in advance.  </p>
  
  <p>I'm trying to work with a so-defined interface to connect to a message broker:  </p>
  
  <pre><code>// Broker is an interface used for asynchronous messaging.
  type Broker interface {
      Options() Options
      Address() string
      Connect() error
      Disconnect() error
      Init(...Option) error
      Publish(string, *Message, ...PublishOption) error
      Subscribe(string, Handler, ...SubscribeOption) (Subscriber, error)
      String() string
  }
  
  // Handler is used to process messages via a subscription of a topic.
  // The handler is passed a publication interface which contains the
  // message and optional Ack method to acknowledge receipt of the message.
  type Handler func(Publication) error
  
  // Publication is given to a subscription handler for processing
  type Publication interface {
      Topic() string
      Message() *Message
      Ack() error
  }
  </code></pre>
  
  <p>I'm trying to use the <code>Subscribe</code>-function to subscribe to a channel and thats the point where I'm struggeling right now.
  My current approach is the following one:  </p>
  
  <pre><code>natsBroker.Subscribe(
          "QueueName",
          func(p broker.Publication) {
              fmt.Printf(p.Message)
          },
      )
  </code></pre>
  
  <p>The error output is <code>cannot use func literal (type func(broker.Publication)) as type broker.Handler in argument to natsBroker.Subscribe</code>.<br>
  But how do I ensure that the function type actually is a <code>broker.Handler</code>?  </p>
  
  <p>Thx for your time in advance!</p>
  
  <h2>Update</h2>
  
  <p>In case anybody is interested, the error return type was missing which caused the error, so it should look similar to that:  </p>
  
  <p>natsBroker.Subscribe(
      "QueueName",
      broker.Handler(func(p broker.Publication) error {
          fmt.Printf(p.Topic())
          return nil
      }),
  )</p>