Go语言封装Http协议GET和POST请求

Golang语言社区 · 2019-01-02 07:34:44

defer resp.Body.Close() ----把这行放到if error 语句后面去,因为一旦error != nil,resp值是nil,则此处会出错

if error != nil {
    panic(error)
}
#1