package main import ( "fmt" "io/ioutil" "net/http" ) func main() { url := "https://developer.mozilla.org/zh-CN/docs/Web/HTTP/Status/429" method := "GET" client := &http.Client{} req, err := http.NewRequest(method, url, nil) if err != nil { fmt.Println(err) return } req.Header.Add("User-Agent", "Apifox/1.0.0 (https://apifox.com)") req.Header.Add("Accept", "*/*") req.Header.Add("Host", "developer.mozilla.org") res, err := client.Do(req) if err != nil { fmt.Println(err) return } defer res.Body.Close() body, err := ioutil.ReadAll(res.Body) if err != nil { fmt.Println(err) return } fmt.Println(string(body)) }