golang中有什么方法可以在控制器中設(shè)置http超時(shí)時(shí)間
1 回答

慕蓋茨4494581
TA貢獻(xiàn)1850條經(jīng)驗(yàn) 獲得超11個(gè)贊
設(shè)置時(shí)間間隔為5秒 如果get不到就斷開(kāi)連接,post方法類似 都在client里設(shè)置http的超時(shí)時(shí)間
timeout := time.Duration(5 * time.Second)
client := http.Client{
Timeout: timeout,}
client.Get(url)
- 1 回答
- 0 關(guān)注
- 724 瀏覽
添加回答
舉報(bào)
0/150
提交
取消