Slide 12
Slide 12 text
Hello, Go !
package main
import (
"fmt"
"net/http"
)
func main() {
helloConst := func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "hi there !")
}
helloVariable := func(w http.ResponseWriter, r *http.Request) {
title := r.URL.Path[len("/hello/"):]
fmt.Fprintf(w, "hello, "+title)
}
http.HandleFunc("/hello/", helloVariable)
http.HandleFunc("/", helloConst)
http.ListenAndServe(":8082", nil)
}