0
我是Go的初學者,我不明白在功能Execute
的數據流中寫入數據「home.html」的調用在哪裏。http.ResponseWriter是那個清除但功能Execute
我不能看到類似的東西write .. fmt.Fprint..
我只看到Execute
Golang - 函數「Execute」在哪裏寫入流?
http://golang.org/src/pkg/html/template/template.go?s=1245:1315#L40
//my Function
func homeHandler(c http.ResponseWriter, req *http.Request) {
var homeTempl = template.Must(template.ParseFiles("home.html"))
//here is my misunderstanding
homeTempl.Execute(c, req.Host)
//Thats consistent
fmt.Fprint(c, "hallo")
}
這不是遞歸。 HTML /模板使用文本/模板 –
是的,這是我的誤解。它是用'walk'方法的文本/模板編寫的http://golang.org/src/pkg/text/template/exec.go?s=2630:2700#L95 s.wr.Write(n.Text) ; –