如何在处理函数中发出 http.Get 请求?例如,这个简单的代码“应该”在 localhost:8080 浏览器中返回空白页面,但它会出错。我在学校错过了什么?
package main
import "net/http"
func index(w http.ResponseWriter, r *http.Request) {
_, err := http.Get("www.google.com")
if err != nil {
panic(err)
}
}
func main() {
http.HandleFunc("/", index)
http.ListenAndServe(":8080", nil)
}
四季花海
江户川乱折腾
随时随地看视频慕课网APP
相关分类