这是我的实际代码:
func cURL(cURL string, follow bool) (*string, error) {
var err error
var resp *http.Response
var req *http.Request
var u *url.URL
if u, err = url.Parse(cURL); nil != err {
if logLevel >= 30 {
log.Print("ERROR: ", err)
}
return nil, err
}
if req, err = http.NewRequest("GET", u.Scheme+"://"+u.Host+u.Path, nil); err != nil {
if logLevel >= 40 {
log.Print("ERROR: ", err)
}
return nil, err
}
req.URL.RawQuery = u.RawQuery
client := &http.Client{
Timeout: 3 * time.Second, //timeout connexion
}
if resp, err = client.Do(req); nil != err {
if logLevel >= 50 {
log.Print("ERROR: ", err)
}
return nil, err
}
defer resp.Body.Close()
var body []byte
if body, err = ioutil.ReadAll(resp.Body); nil != err {
if logLevel >= 30 {
log.Print("ERROR: ", err)
}
return nil, err
}
var html string
html = string(body)
return &html, nil
}
同时在终端中打印此错误,我想隐藏此内容:
2017/09/29 18:19:28 Unsolicited response received on idle HTTP channel starting with "HTTP/1.0 408 Request Time-out\r\nServer: AkamaiGHost\r\nMime-Version: 1.0\r\nDate: Fri, 29 Sep 2017 16:18:21 GMT\r\nContent-Type: text/html\r\nContent-Length: 218\r\nExpires: Fri, 29 Sep 2017 16:18:21 GMT\r\n\r\n<HTML><HEAD>\n<TITLE>Request Timeout</TITLE>\n</HEAD><BODY>\n<H1>Request Timeout</H1>\nThe server timed out while waiting for the browser's request.<P>\nReference 
我想隐藏此错误,而不是在终端中打印,我该怎么做?哪里错了?我使用此功能检查大型列表网址,如果有特定的关键字,该列表真的是50亿美元的大笔网址。