Last active
December 21, 2015 00:09
-
-
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!" と表示されるはず
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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