title: Golang RedirectHandler() returns interface, ends up with *http.redirectHandler
body: <p>Please do not be aggressive with my post, I am trying to learn Go, but facing some challenges in my understanding.</p>
  <p>This is my sample code:</p>
  <pre><code>package main
  
  import (
          &quot;log&quot;
          &quot;net/http&quot;
          &quot;reflect&quot;
          &quot;fmt&quot;
  )
  
  func main() {
          mux := http.NewServeMux()
  
          rh := http.RedirectHandler(&quot;http://example.org&quot;, 307)
          fmt.Println(&quot;The type of the object, returned by the RedirectHandler is&quot;)
          fmt.Println(reflect.TypeOf(rh))
          fmt.Println(&quot;End with type observation&quot;)
          mux.Handle(&quot;/foo&quot;, rh)
  
          log.Println(&quot;Listening ...&quot;)
          http.ListenAndServe(&quot;:3000&quot;, mux)
  }
  </code></pre>
  <p>My questions are:</p>
  <ol>
  <li>RedirectHandler returns a Handler interface, is this a common pattern and what is the benefit ?</li>
  <li>Does that mean that the inside the function you schould have a struct that implements that interface and then return the struct ? If not, how in the world do we return an interface, as essentially it's just a set of non-implemented methods ?</li>
  <li>If you run my code, you would see that the type of the variable 'rh' is *http.redirectHandler. For such a pointer I am not able to find anything in the http package, so we started from 'returns an interface' to end up with 'here's your pointer, that does not exists in the doc'.</li>
  <li>Those are just my confusing thoughts, I would appreciate comments who want to help me with my confusion.</li>
  </ol>