Skip to content

Instantly share code, notes, and snippets.

@tenntenn
Last active February 17, 2016 13:10
Show Gist options
  • Save tenntenn/3a0ebca74c3595916359 to your computer and use it in GitHub Desktop.
Save tenntenn/3a0ebca74c3595916359 to your computer and use it in GitHub Desktop.
HTTPサーバの例
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!")
}
$ 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