HTTP
Http · Go语言中文文档
GET请求示例
package main
import (
"fmt"
"io/ioutil"
"net/http"
)
func main() {
// resp, err := http.Get("https://www.5lmh.com/")
resp, err := http.Get("http://www.5lmh.com/")
if err != nil {
fmt.Println("get failed, err:", err)
return
}
defer resp.Body.Close()
body, err := ioutil.ReadAll(resp.Body)
if err != nil {
fmt.Println("read from resp.Body failed,err:", err)
return
}
fmt.Print(string(body))
}
// get failed, err: Get "https://www.5lmh.com/":
// x509: certificate is valid for topgoer.com, not www.5lmh.com
http编程
服务端
客户端
Last updated