第15章 15.2-http服务器

package main

import "fmt"
import "net/http"

func HttpHelloGo(w http.ResponseWriter, req *http.Request) {
    fmt.Fprintf(w, "Hello,"+req.URL.Path[1:])
}

func main() {
    fmt.Println("开始启动http服务器")
    http.HandleFunc("/hellogo", HttpHelloGo)
    http.ListenAndServe(":8081", nil)
}

你可能感兴趣的:(第15章 15.2-http服务器)