fix: coding style and file format for chapter 11, 12, 13, 14 and 15.

This commit is contained in:
Bo-Yi Wu
2017-02-11 12:32:16 +08:00
parent c5413075c1
commit 4abbfabb52
63 changed files with 2662 additions and 2622 deletions

View File

@@ -1,24 +1,24 @@
// webhello2.go
package main
import (
"net/http"
"fmt"
"strings"
)
func helloHandler(w http.ResponseWriter, r *http.Request) {
remPartOfURL := r.URL.Path[len("/hello/"):] //get everything after the /hello/ part of the URL
fmt.Fprintf(w, "Hello %s!", remPartOfURL)
}
func shouthelloHandler(w http.ResponseWriter, r *http.Request) {
remPartOfURL := r.URL.Path[len("/shouthello/"):] //get everything after the /shouthello/ part of the URL
fmt.Fprintf(w, "Hello %s!", strings.ToUpper(remPartOfURL))
}
func main() {
http.HandleFunc("/hello/", helloHandler)
http.HandleFunc("/shouthello/", shouthelloHandler)
http.ListenAndServe("localhost:9999", nil)
}
// webhello2.go
package main
import (
"fmt"
"net/http"
"strings"
)
func helloHandler(w http.ResponseWriter, r *http.Request) {
remPartOfURL := r.URL.Path[len("/hello/"):] //get everything after the /hello/ part of the URL
fmt.Fprintf(w, "Hello %s!", remPartOfURL)
}
func shouthelloHandler(w http.ResponseWriter, r *http.Request) {
remPartOfURL := r.URL.Path[len("/shouthello/"):] //get everything after the /shouthello/ part of the URL
fmt.Fprintf(w, "Hello %s!", strings.ToUpper(remPartOfURL))
}
func main() {
http.HandleFunc("/hello/", helloHandler)
http.HandleFunc("/shouthello/", shouthelloHandler)
http.ListenAndServe("localhost:9999", nil)
}