[Golang] http.Post致使goroutine泄漏

記錄一個用http.Post的問題blog

if _, err := http.Post("http://127.0.0.1:8080", "", nil); nil != err {
	panic(err)
}// 會致使goroutine泄漏

  

if resp, err := http.Post("http://127.0.0.1:8080", "", nil); nil != err {
	panic(err)
} else {
	defer resp.Body.Close() // 必需要關閉
}
相關文章
相關標籤/搜索