title: How do I rewrite / redirect from http to https in Go?
body: <p>I have put up TLS and it works. I know how to rewrite from http to https in nginx, but I do not use nginx anymore. I don't know how to do this in Go properly.</p>
  
  <pre><code>func main() {
  
      certificate := "/srv/ssl/ssl-bundle.crt"
      privateKey := "/srv/ssl/mykey.key"
  
      http.HandleFunc("/", rootHander)
      // log.Fatal(http.ListenAndServe(":80", nil))
      log.Fatal(http.ListenAndServeTLS(":443", certificate, privateKey, nil))
  }
  
  func rootHander(w http.ResponseWriter, r *http.Request) {
      w.Write([]byte("To the moon!"))
  }
  </code></pre>
  
  <p>How would I do this in a good way?</p>