package main import ( "fmt" "html/template" "net/http" ) // Define the HTML template const indexHTML = ` Go Web Server

Hello from Go!

Welcome to your Go web server.

` func homeHandler(w http.ResponseWriter, r *http.Request) { fmt.Fprint(w, indexHTML) } func main() { // Register the handler http.HandleFunc("/", homeHandler) // Start the server fmt.Println("Server starting on http://localhost:8080") if err := http.ListenAndServe(":8080", nil); err != nil { fmt.Printf("Server failed: %v\n", err) } }