如文档中所隐含的,有些
ResponseWriter可以实现该
Flusher接口。
这意味着您可以执行以下操作:
func handle(res http.ResponseWriter, req *http.Request) { fmt.Fprintf(res, "sending first line of data") if f, ok := res.(http.Flusher); ok { f.Flush() } else { log.Println("Damn, no flush"); } sleep(10) //not real pre fmt.Fprintf(res, "sending second line of data")}请注意,缓冲可能会在网络或客户端的许多其他地方发生。



