package handle
import (
"html/template"
"net/http"
"utils"
)
var regMap = make(map[string]func(http.ResponseWriter, *http.Request))
regMap["/view"] = func (w http.ResponseWriter, r *http.Request) {
renderTemplate(w, "edit.html", "a")
} // ***这行报:non-declaration statement outside function body***
func Register() {
for url, method := range regMap {
http.HandleFunc(url, method)
}
}
为什么? 等待~
更多评论
把
regMap["/view"] = func(w http.ResponseWriter, r *http.Request) {
renderTemplate(w, "edit.html", "a")
}
放在函数里面。
#2