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