这是个HTTP的回调,我看了HTTP模块的实现源码,w跟req都是类指针,为什么一个是,一个不是?
// hello world, the web server
func HelloServer(w http.ResponseWriter, req *http.Request) {
io.WriteString(w, "hello, world!\n")
}
为什么不是这样
// hello world, the web server
func HelloServer(w *http.ResponseWriter, req *http.Request) {
io.WriteString(w, "hello, world!\n")
}
有疑问加站长微信联系(非本文作者)
![](https://static.golangjob.cn/static/img/footer.png?imageView2/2/w/280)
http.ResponseWriter 是一个接口;而 http.Request 是一个 struct。
看源码还不够仔细啊。