package main
import (
"fmt"
"net/http"
)
func printHello(w http.ResponseWriter, r *http.Request) {
fmt.Println("hello word!")
fmt.Fprintf(w, "Hello World !") //回复
}
func main() {
fmt.Println("start!")
http.HandleFunc("/", printHello) // 匹配根路由/hello
err := http.ListenAndServe("0.0.0.0:8080", nil) //监听8080 端口
if err != nil {
fmt.Println("http listen failed")
}
fmt.Println("end!")
}