golang中有什么方法可以在控制器中设置http超时时间
1 回答

慕盖茨4494581
TA贡献1850条经验 获得超11个赞
设置时间间隔为5秒 如果get不到就断开连接,post方法类似 都在client里设置http的超时时间
timeout := time.Duration(5 * time.Second)
client := http.Client{
Timeout: timeout,}
client.Get(url)
- 1 回答
- 0 关注
- 703 浏览
添加回答
举报
0/150
提交
取消