fix(lint): warning from golangci-lint tool

https://github.com/appleboy/gorush/issues/704

Signed-off-by: Bo-Yi.Wu <appleboy.tw@gmail.com>
This commit is contained in:
Bo-Yi.Wu
2022-12-20 22:03:29 +08:00
parent 89bc97d15e
commit 4ef30a0cdc
16 changed files with 145 additions and 122 deletions

View File

@@ -159,6 +159,7 @@ func autoTLSServer(cfg *config.ConfYaml, q *queue.Queue) *http.Server {
Cache: autocert.DirCache(cfg.Core.AutoTLS.Folder),
}
//nolint:gosec
return &http.Server{
Addr: ":https",
TLSConfig: &tls.Config{GetCertificate: m.GetCertificate},

View File

@@ -28,6 +28,7 @@ func RunHTTPServer(ctx context.Context, cfg *config.ConfYaml, q *queue.Queue, s
}
if len(s) == 0 {
//nolint:gosec
server = &http.Server{
Addr: cfg.Core.Address + ":" + cfg.Core.Port,
Handler: routerEngine(cfg, q),
@@ -40,6 +41,7 @@ func RunHTTPServer(ctx context.Context, cfg *config.ConfYaml, q *queue.Queue, s
if cfg.Core.AutoTLS.Enabled {
return startServer(ctx, autoTLSServer(cfg, q), cfg)
} else if cfg.Core.SSL {
//nolint
config := &tls.Config{
MinVersion: tls.VersionTLS10,
}
@@ -49,6 +51,7 @@ func RunHTTPServer(ctx context.Context, cfg *config.ConfYaml, q *queue.Queue, s
}
config.Certificates = make([]tls.Certificate, 1)
//nolint:gocritic
if cfg.Core.CertPath != "" && cfg.Core.KeyPath != "" {
config.Certificates[0], err = tls.LoadX509KeyPair(cfg.Core.CertPath, cfg.Core.KeyPath)
if err != nil {

View File

@@ -26,8 +26,9 @@ import (
)
var (
goVersion = runtime.Version()
q *queue.Queue
goVersion = runtime.Version()
q *queue.Queue
testKeyPath = "../certificate/certificate-valid.pem"
)
func TestMain(m *testing.M) {
@@ -471,7 +472,7 @@ func TestSenMultipleNotifications(t *testing.T) {
cfg := initTest()
cfg.Ios.Enabled = true
cfg.Ios.KeyPath = "../certificate/certificate-valid.pem"
cfg.Ios.KeyPath = testKeyPath
err := notify.InitAPNSClient(cfg)
assert.Nil(t, err)
@@ -507,7 +508,7 @@ func TestDisabledAndroidNotifications(t *testing.T) {
cfg := initTest()
cfg.Ios.Enabled = true
cfg.Ios.KeyPath = "../certificate/certificate-valid.pem"
cfg.Ios.KeyPath = testKeyPath
err := notify.InitAPNSClient(cfg)
assert.Nil(t, err)
@@ -543,7 +544,7 @@ func TestSyncModeForNotifications(t *testing.T) {
cfg := initTest()
cfg.Ios.Enabled = true
cfg.Ios.KeyPath = "../certificate/certificate-valid.pem"
cfg.Ios.KeyPath = testKeyPath
err := notify.InitAPNSClient(cfg)
assert.Nil(t, err)
@@ -654,7 +655,7 @@ func TestDisabledIosNotifications(t *testing.T) {
cfg := initTest()
cfg.Ios.Enabled = false
cfg.Ios.KeyPath = "../certificate/certificate-valid.pem"
cfg.Ios.KeyPath = testKeyPath
err := notify.InitAPNSClient(cfg)
assert.Nil(t, err)