写PHP的时候遇到一个问题
*如何在把响应发送给客户端之后,继续执行后续任务? *
在stackoverflow上找到解决方案,如下
https://stackoverflow.com/questions/15273570/continue-processing-php-after-sending-http-response
想知道,如何在Golang中实现这种需求,google了一会没能找到,汗... 求助,能赐几行代码更好,多谢:)
<a href="/user/polaris" title="@polaris">@polaris</a> <a href="/user/SugarAYuan" title="@SugarAYuan">@SugarAYuan</a> 写了下面的例程,帮看看有问题吗
```
package main
import (
"fmt"
"net/http"
"time"
)
func main() {
http.HandleFunc("/test", Handler)
http.ListenAndServe(":8080", nil)
}
func Handler(w http.ResponseWriter, r *http.Request) {
w.Write([]byte("Hello World"))
go GoOnExecuting()
}
func GoOnExecuting() {
for i := 0; i < 10; i++ {
time.Sleep(1 * time.Second)
fmt.Println(i)
}
}
```
#3