在 go 1.1.2 之前,这段代码打印了最后一个 log.Println 并随后执行了代码,因为 1.2 我必须将 http.ListenAndServe() 作为单独的 go 例程运行。 1.1.2 的更新日志没有指出任何此类更改,我也不知道这是否是让网络服务器与其他代码一起运行的正确方法。
log.Println("Starting WebAPI Server")
http.HandleFunc("/", bot.httpHandler())
http.ListenAndServe(":8181", nil) // with preceeding "go" in 1.2 to make my program working
log.Println("Started WebAPI Server")
最佳答案
很抱歉,http.ListenAndServe 一直处于阻塞状态。
关于asynchronous - net/http 中从 1.1.2 到 1.2 的不同行为,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21662341/