```go
package main
import (
"net/http"
"fmt"
"strconv"
)
var writera http.ResponseWriter
var i int64 = 0
func main() {
http.HandleFunc("/", func(writer http.ResponseWriter,
request *http.Request) {
fmt.Println("请求:", (i))
i++
writera = writer
name := request.FormValue("name")
outHtml("name=" + name)
})
port2 := 82
fmt.Println("http://localhost:" + strconv.Itoa(port2))
http.ListenAndServe(":"+strconv.Itoa(port2), nil)
}
func outHtml(c ...interface{}) {
for _, v := range c {
fmt.Fprintln(writera, v)
fmt.Println()
}
}
```
有疑问加站长微信联系(非本文作者)
![](https://static.golangjob.cn/static/img/footer.png?imageView2/2/w/280)