Picking up the go tour again
after a (very) brief interlude with D. Le sigh.
This commit is contained in:
parent
49612a9881
commit
d9a4c3a2e7
9
gotime/src/exercise-http-handlers.go
Normal file
9
gotime/src/exercise-http-handlers.go
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
http.ListenAndServe("localhost:4000", nil)
|
||||||
|
}
|
19
gotime/src/hello-web.go
Normal file
19
gotime/src/hello-web.go
Normal file
@ -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)
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user