From b295a8d315425deca50097454b1845e36800d4f0 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Sat, 1 Mar 2025 17:48:15 +0800 Subject: [PATCH] =?UTF-8?q?5=E7=A7=92=E9=92=9F=E8=B6=85=E6=97=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/sync_task.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/api/sync_task.go b/api/sync_task.go index d11f8c2..1e750fa 100644 --- a/api/sync_task.go +++ b/api/sync_task.go @@ -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)