5秒钟超时

This commit is contained in:
Jerry Yan 2025-03-01 17:48:15 +08:00
parent 06f7e007f0
commit b295a8d315

View File

@ -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)