Golang 爬蟲

Get the content of a web page (golang):
https://www.daniweb.com/programming/computer-science/code/495192/get-the-content-of-a-web-page-golang

package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
url := "http://tour.golang.org/welcome/1"
fmt.Printf("HTML code of %s ...\n", url)
resp, err := http.Get(url)
// handle the error if there is one
if err != nil {
panic(err)
}
// do this now so it won't be forgotten
defer resp.Body.Close()
// reads html as a slice of bytes
html, err := ioutil.ReadAll(resp.Body)
if err != nil {
panic(err)
}
// show the HTML code as a string %s
fmt.Printf("%s\n", html)
}


為什麼 Response.Body 需要被關閉?
https://www.jianshu.com/p/407fada3cc9d
簡言之,與其額外處理各種錯誤導致的資源無法回收,使用後就 close Response.Body 是最好的做法。

容易踩到的 50 個坑
35. 關閉 HTTP 的響應體 (譯本這段的程式碼有誤,應參見原文)
https://segmentfault.com/a/1190000013739000#articleHeader38

原文:
http://devs.cloudimmunity.com/gotchas-and-common-mistakes-in-go-golang/
Closing HTTP Response Body

https://stackoverflow.com/questions/32818472/do-we-need-to-close-the-response-object-if-an-error-occurs-while-calling-http-ge



正則處理:
https://www.kancloud.cn/kancloud/web-application-with-golang/44184


程式語言編年史

程式語言編年史原文 下面這張圖片描繪了整個程式語言的歷史。包括各種程式語言的發明人、程式語言的特點和適用領域、被什麼網站或公司使用等 (檢視 完整高清圖 )。 之所以會有那麼多不同的程式語言是因為設計程式語言的初衷不同、對語言學習曲線的追求不同、不同程式之間的執行成本差異...