Last active
February 17, 2016 13:10
-
-
Save tenntenn/3a0ebca74c3595916359 to your computer and use it in GitHub Desktop.
HTTPサーバの例
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", hello) | |
http.ListenAndServe(":8080", nil) | |
} | |
func hello(w http.ResponseWriter, r *http.Request) { | |
fmt.Fprint(w, "hello, golang!") | |
} |
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
$ curl http://localhost:8080/hello | |
hello, golang! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment