From 0f6a5ac6c5d66416d4db58d6273d8940ab8f4668 Mon Sep 17 00:00:00 2001 From: Bo-Yi Wu Date: Mon, 19 Dec 2022 16:43:05 +0800 Subject: [PATCH] fix(lint): from golangci-lint warning. https://github.com/appleboy/gorush/issues/704 --- doc.go | 49 +++++++++++++++++++++---------------------- main.go | 8 ++++++- router/server.go | 2 +- router/server_test.go | 9 ++++++-- 4 files changed, 39 insertions(+), 29 deletions(-) diff --git a/doc.go b/doc.go index 284f3b8..6fb12cc 100644 --- a/doc.go +++ b/doc.go @@ -2,54 +2,53 @@ // // Details about the gorush project are found in github page: // -// https://github.com/appleboy/gorush +// https://github.com/appleboy/gorush // // The pre-compiled binaries can be downloaded from release page. // // Send Android notification // -// $ gorush -android -m="your message" -k="API Key" -t="Device token" +// $ gorush -android -m="your message" -k="API Key" -t="Device token" // // Send iOS notification // -// $ gorush -ios -m="your message" -i="API Key" -t="Device token" +// $ gorush -ios -m="your message" -i="API Key" -t="Device token" // // The default endpoint is APNs development. Please add -production flag for APNs production push endpoint. // -// $ gorush -ios -m="your message" -i="API Key" -t="Device token" -production +// $ gorush -ios -m="your message" -i="API Key" -t="Device token" -production // // Run gorush web server // -// $ gorush -c config.yml +// $ gorush -c config.yml // // Get go status of api server using httpie tool: // -// $ http -v --verify=no --json GET https://localhost:8088/api/stat/go +// $ http -v --verify=no --json GET https://localhost:8088/api/stat/go // // Simple send iOS notification example, the platform value is 1: // -// { -// "notifications": [ -// { -// "tokens": ["token_a", "token_b"], -// "platform": 1, -// "message": "Hello World iOS!" -// } -// ] -// } +// { +// "notifications": [ +// { +// "tokens": ["token_a", "token_b"], +// "platform": 1, +// "message": "Hello World iOS!" +// } +// ] +// } // // Simple send Android notification example, the platform value is 2: // -// { -// "notifications": [ -// { -// "tokens": ["token_a", "token_b"], -// "platform": 2, -// "message": "Hello World Android!" -// } -// ] -// } +// { +// "notifications": [ +// { +// "tokens": ["token_a", "token_b"], +// "platform": 2, +// "message": "Hello World Android!" +// } +// ] +// } // // For more details, see the documentation and example. -// package main diff --git a/main.go b/main.go index 3fa2a90..2c1618c 100644 --- a/main.go +++ b/main.go @@ -453,7 +453,13 @@ func pinger(cfg *config.ConfYaml) error { Timeout: time.Second * 10, Transport: transport, } - resp, err := client.Get("http://localhost:" + cfg.Core.Port + cfg.API.HealthURI) + req, _ := http.NewRequestWithContext( + context.Background(), + http.MethodGet, + "http://localhost:"+cfg.Core.Port+cfg.API.HealthURI, + nil, + ) + resp, err := client.Do(req) if err != nil { return err } diff --git a/router/server.go b/router/server.go index 4f014e0..9642fe0 100644 --- a/router/server.go +++ b/router/server.go @@ -247,7 +247,7 @@ func markFailedNotification( // HandleNotification add notification to queue list. func handleNotification( - ctx context.Context, + _ context.Context, cfg *config.ConfYaml, req notify.RequestPush, q *queue.Queue, diff --git a/router/server_test.go b/router/server_test.go index 97fd20b..9515f69 100644 --- a/router/server_test.go +++ b/router/server_test.go @@ -75,8 +75,13 @@ func testRequest(t *testing.T, url string) { Timeout: time.Second * 10, Transport: tr, } - - resp, err := client.Get(url) + req, _ := http.NewRequestWithContext( + context.Background(), + http.MethodGet, + url, + nil, + ) + resp, err := client.Do(req) defer func() { if err := resp.Body.Close(); err != nil { log.Println("close body err:", err)