最佳答案
Go 文档中的 http 包有以下示例:
http.Handle("/foo", fooHandler)
http.HandleFunc("/bar", func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Hello, %q", html.EscapeString(r.URL.Path))
})
我有点难以理解 Handle 和 HandleFunc 之间的区别,以及为什么需要两个。有人能试着用清晰的语言向一只新地鼠解释一下吗?