```go
package main
import (
"fmt"
"net/http"
)
func main() {
http.HandleFunc("/", handler)
http.HandleFunc("/hello", hello)
http.ListenAndServe("localhost:8884", nil)
}
func handler(w http.ResponseWriter, req *http.Request) {
req.ParseForm()
if len(req.Form["name"]) > 0 {
fmt.Fprint(w, "你好,", req.Form["name"][0])
} else {
fmt.Fprint(w, "hello")
}
}
```
修改后go run ,只有改了端口号再访问修改的代码才会生效,原先的端口后全被占着,怎么破,大神求解!!!
更多评论