2012-12-15 32 views
0

我是Go的初學者,我不明白在功能Execute的數據流中寫入數據「home.html」的調用在哪裏。http.ResponseWriter是那個清除但功能Execute我不能看到類似的東西write .. fmt.Fprint..我只看到ExecuteGolang - 函數「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") 

} 
+3

這不是遞歸。 HTML /模板使用文本/模板 –

+0

是的,這是我的誤解。它是用'walk'方法的文本/模板編寫的http://golang.org/src/pkg/text/template/exec.go?s=2630:2700#L95 s.wr.Write(n.Text) ; –

回答