Shenglian / -WORK_TIP

工作上小技巧
4 stars 1 forks source link

[golang] Golang Http - Get/Post #152

Closed Shenglian closed 5 years ago

Shenglian commented 5 years ago

get


func httpGet() {
resp. err := http.Get("url", strings.NewReader("name=cjb"))
if err != nil {
// handler error
}

defer resp.Body.Colse()

body, err := ioutil.ReadAll(resp.Body) if err != nil { // handler error }

fmt.Println(string(body)) }