xxxxxxxxxx
//Create a handler which handles redirection to https like:
func redirectToTls(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, "https://localhost:443"+r.RequestURI, http.StatusMovedPermanently)
}
// Then redirect http traffic:
go func() {
if err := http.ListenAndServe(":80", http.HandlerFunc(redirectToTls)); err != nil {
log.Fatalf("ListenAndServe error: %v", err)
}
}()