5秒钟超时
This commit is contained in:
parent
06f7e007f0
commit
b295a8d315
@ -9,6 +9,7 @@ import (
|
||||
"io"
|
||||
"log"
|
||||
"net/http"
|
||||
"time"
|
||||
)
|
||||
|
||||
func SyncTask() ([]dto.Task, error) {
|
||||
@ -28,7 +29,9 @@ func SyncTask() ([]dto.Task, error) {
|
||||
return nil, err
|
||||
}
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
client := &http.Client{}
|
||||
client := &http.Client{
|
||||
Timeout: 5 * time.Second, // 设置超时时间为5秒
|
||||
}
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
log.Println("Error sending request:", err)
|
||||
|
Loading…
x
Reference in New Issue
Block a user