From d9a4c3a2e7d0274382619d2d0649732c1fccbd6e Mon Sep 17 00:00:00 2001 From: Dan Buch Date: Thu, 18 Oct 2012 09:17:47 -0400 Subject: [PATCH] Picking up the go tour again after a (very) brief interlude with D. Le sigh. --- gotime/src/exercise-http-handlers.go | 9 +++++++++ gotime/src/hello-web.go | 19 +++++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 gotime/src/exercise-http-handlers.go create mode 100644 gotime/src/hello-web.go diff --git a/gotime/src/exercise-http-handlers.go b/gotime/src/exercise-http-handlers.go new file mode 100644 index 0000000..f1f5062 --- /dev/null +++ b/gotime/src/exercise-http-handlers.go @@ -0,0 +1,9 @@ +package main + +import ( + "net/http" +) + +func main() { + http.ListenAndServe("localhost:4000", nil) +} diff --git a/gotime/src/hello-web.go b/gotime/src/hello-web.go new file mode 100644 index 0000000..e6856ae --- /dev/null +++ b/gotime/src/hello-web.go @@ -0,0 +1,19 @@ +package main + +import ( + "fmt" + "net/http" +) + +type Hello struct{} + +func (h Hello) ServeHTTP( + w http.ResponseWriter, + r *http.Request) { + fmt.Fprint(w, "Hello!\n") +} + +func main() { + var h Hello + http.ListenAndServe("localhost:4000", h) +}