Skip to content

Instantly share code, notes, and snippets.

@ymotongpoo
Last active December 21, 2015 00:09
Show Gist options
  • Select an option

  • Save ymotongpoo/6218100 to your computer and use it in GitHub Desktop.

Select an option

Save ymotongpoo/6218100 to your computer and use it in GitHub Desktop.
GoでローカルでWebサーバ上げてHello, Worldする一番簡単な例。go run hello.goして、 http://localhost:8000/ にアクセスすれば "Hello, Gopher!" と表示されるはず
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/", hello)
http.ListenAndServe(":8000", nil)
}
func hello(w http.ResponseWriter, r *http.Request) {
fmt.Fprintln(w, "Hello, Gopher!")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment