作者:sundy柳 | 来源:互联网 | 2023-05-28 16:58
![Golang发送http GET请求的示例代码](https://img1.php1.cn/3cd4a/24c6f/339/b147484c0f76d3ad.jpeg)
使用标准库http来实现
package tools
import (
"io/ioutil"
"net/http"
)
func Get(url string)string{
res, err :=http.Get(url)
if err != nil {
return ""
}
robots, err := ioutil.ReadAll(res.Body)
res.Body.Close()
if err != nil {
return ""
}
return string(robots)
}
以上就是Golang发送http GET请求的示例代码的详细内容,更多关于Golang发送http GET请求的资料请关注编程笔记其它相关文章!
原文链接:https://www.cnblogs.com/taoshihan/p/13674887.html