Go の標準パッケージである net/http を使えば簡単に HTTP サーバーを立てることができる。とは言うものの、自分はそのへんが実際どうなってるのか全然わかってない。つらい。ということで、Go の勉強も兼ねて net/http の動きを少しだけ追ってみることにした。 まず、net/http を用いたよく見かけるサンプルコードを書いてみる。 package main import ( "fmt" "log" "net/http" ) func poyo(w http.ResponseWriter, r *http.Request) { fmt.Fprintf(w, "poyo!") } func main() { http.HandleFunc("/", poyo) if err := http.ListenAndServe(":9090", nil); err != nil { l
![net/http の動きを少しだけ追ってみた - Go](https://cdn-ak-scissors.b.st-hatena.com/image/square/735280aa4318bfa8083e2be270e08e3cab996195/height=288;version=1;width=512/https%3A%2F%2Fm0t0k1ch1st0ry.com%2Fimg%2Fcommon%2Fauthor_256.jpg)