package main import ( "net/http" "text/template" "github.com/gorilla/mux" "github.com/redis/go-redis/v9" ) var ( client *redis.Client templates *template.Template ) func main() { client = redis.NewClient(&redis.Options{ Addr: "localhost:6379", DB: 0, }) templates = template.Must(template.ParseGlob("templates/*.html")) r := mux.NewRouter() r.HandleFunc("/", indexHandler).Methods("GET") http.Handle("/", r) http.ListenAndServe(":8080", nil) } func indexHandler(w http.ResponseWriter, r *http.Request) { templates.ExecuteTemplate(w, "index.html", nil) }