Answer the question
In order to leave comments, you need to log in
Package command-line-arguments is not a main package Golang Error?
package mine
import (
"fmt"
"html/template"
"net/http"
)
func index(w http.ResponseWriter, r *http.Request) {
t, err := template.ParseFiles("templates/index.html", "templates/footer.html", "templates/header.html")
if err != nil {
fmt.Fprint(w, err.Error())
}
}
func handleFunc() {
http.HandleFunc("/", index)
http.ListenAndServe("4000", nil)
}
func main() {
handleFunc()
}
func index(w http.ResponseWriter, r *http.Request) {
t, err := template.ParseFiles("templates/index.html", "templates/footer.html", "templates/header.html")
if err != nil {
fmt.Fprint(w, err.Error())
}
}
package command-line-arguments is not a main package
Answer the question
In order to leave comments, you need to log in
You have an error only in the wrong package name (you need main) and in the unused variable t
so the code works
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question