fix(lint): from golangci-lint warning.
https://github.com/appleboy/gorush/issues/704
This commit is contained in:
parent
99f9956b48
commit
0f6a5ac6c5
49
doc.go
49
doc.go
|
@ -2,54 +2,53 @@
|
||||||
//
|
//
|
||||||
// Details about the gorush project are found in github page:
|
// 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.
|
// The pre-compiled binaries can be downloaded from release page.
|
||||||
//
|
//
|
||||||
// Send Android notification
|
// 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
|
// 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.
|
// 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
|
// Run gorush web server
|
||||||
//
|
//
|
||||||
// $ gorush -c config.yml
|
// $ gorush -c config.yml
|
||||||
//
|
//
|
||||||
// Get go status of api server using httpie tool:
|
// 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:
|
// Simple send iOS notification example, the platform value is 1:
|
||||||
//
|
//
|
||||||
// {
|
// {
|
||||||
// "notifications": [
|
// "notifications": [
|
||||||
// {
|
// {
|
||||||
// "tokens": ["token_a", "token_b"],
|
// "tokens": ["token_a", "token_b"],
|
||||||
// "platform": 1,
|
// "platform": 1,
|
||||||
// "message": "Hello World iOS!"
|
// "message": "Hello World iOS!"
|
||||||
// }
|
// }
|
||||||
// ]
|
// ]
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// Simple send Android notification example, the platform value is 2:
|
// Simple send Android notification example, the platform value is 2:
|
||||||
//
|
//
|
||||||
// {
|
// {
|
||||||
// "notifications": [
|
// "notifications": [
|
||||||
// {
|
// {
|
||||||
// "tokens": ["token_a", "token_b"],
|
// "tokens": ["token_a", "token_b"],
|
||||||
// "platform": 2,
|
// "platform": 2,
|
||||||
// "message": "Hello World Android!"
|
// "message": "Hello World Android!"
|
||||||
// }
|
// }
|
||||||
// ]
|
// ]
|
||||||
// }
|
// }
|
||||||
//
|
//
|
||||||
// For more details, see the documentation and example.
|
// For more details, see the documentation and example.
|
||||||
//
|
|
||||||
package main
|
package main
|
||||||
|
|
8
main.go
8
main.go
|
@ -453,7 +453,13 @@ func pinger(cfg *config.ConfYaml) error {
|
||||||
Timeout: time.Second * 10,
|
Timeout: time.Second * 10,
|
||||||
Transport: transport,
|
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 {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
|
@ -247,7 +247,7 @@ func markFailedNotification(
|
||||||
|
|
||||||
// HandleNotification add notification to queue list.
|
// HandleNotification add notification to queue list.
|
||||||
func handleNotification(
|
func handleNotification(
|
||||||
ctx context.Context,
|
_ context.Context,
|
||||||
cfg *config.ConfYaml,
|
cfg *config.ConfYaml,
|
||||||
req notify.RequestPush,
|
req notify.RequestPush,
|
||||||
q *queue.Queue,
|
q *queue.Queue,
|
||||||
|
|
|
@ -75,8 +75,13 @@ func testRequest(t *testing.T, url string) {
|
||||||
Timeout: time.Second * 10,
|
Timeout: time.Second * 10,
|
||||||
Transport: tr,
|
Transport: tr,
|
||||||
}
|
}
|
||||||
|
req, _ := http.NewRequestWithContext(
|
||||||
resp, err := client.Get(url)
|
context.Background(),
|
||||||
|
http.MethodGet,
|
||||||
|
url,
|
||||||
|
nil,
|
||||||
|
)
|
||||||
|
resp, err := client.Do(req)
|
||||||
defer func() {
|
defer func() {
|
||||||
if err := resp.Body.Close(); err != nil {
|
if err := resp.Body.Close(); err != nil {
|
||||||
log.Println("close body err:", err)
|
log.Println("close body err:", err)
|
||||||
|
|
Loading…
Reference in New Issue