package main import ( "html/template" "log" "net/http" ) type Link struct { Text string Href string } type Data struct { Links []Link } var data = Data{ Links: []Link{ { Text: "", Href: "http://immich.dihei", }, { Text: "git", Href: "http://git.dihei", }, { Text: "git", Href: "http://git.dihei", }, { Text: "git", Href: "http://git.dihei", }, { Text: "git", Href: "http://git.dihei", }, { Text: "git", Href: "http://git.dihei", }, }, } // Handle the homepage request func homePage(w http.ResponseWriter, r *http.Request) { // Parse the HTML template tmpl, err := template.ParseFiles("templates/index.html") if err != nil { log.Fatal("Error parsing template: ", err) } // Execute the template and render it err = tmpl.Execute(w, data) if err != nil { log.Fatal("Error executing template: ", err) } } func main() { // Serve static files (CSS) http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.Dir("static")))) // Handle the homepage http.HandleFunc("/", homePage) // Start the server log.Println("Server started on http://localhost:8080") err := http.ListenAndServe(":8080", nil) if err != nil { log.Fatal("Error starting server: ", err) } }