From 74ce016ace33465e0c2e48a5d1f501df2740a86f Mon Sep 17 00:00:00 2001 From: Rath Rene Date: Mon, 9 Oct 2023 20:44:02 +0200 Subject: [PATCH] lint fixes --- lib/cnf/cnf_file/rules_parse_test.go | 6 +++--- lib/main/service.go | 8 ++------ lib/proc/fwd/util_test.go | 11 +++++++++-- lib/u/helpers_test.go | 2 +- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/lib/cnf/cnf_file/rules_parse_test.go b/lib/cnf/cnf_file/rules_parse_test.go index 9362926..fe2f91a 100644 --- a/lib/cnf/cnf_file/rules_parse_test.go +++ b/lib/cnf/cnf_file/rules_parse_test.go @@ -105,15 +105,15 @@ func TestVars(t *testing.T) { Vars: []cnf.Var{testVarFP, testVar1, testVar2}, } - vf, vn, v := usedVar("no-var") + vf, _, _ := usedVar("no-var") if vf == true { t.Error("Var #1") } - vf, vn, v = usedVar("$non-existent-var") + vf, _, _ = usedVar("$non-existent-var") if vf == true { t.Error("Var #2") } - vf, vn, v = usedVar("$test1") + vf, vn, v := usedVar("$test1") if vf == false || vn == true || v.Name != testVar1.Name { t.Error("Var #3") } diff --git a/lib/main/service.go b/lib/main/service.go index e36411a..4ed8e77 100644 --- a/lib/main/service.go +++ b/lib/main/service.go @@ -1,7 +1,6 @@ package main import ( - "context" "fmt" "net" "os" @@ -36,9 +35,7 @@ func (svc *service) signalHandler() { case syscall.SIGINT, syscall.SIGQUIT, syscall.SIGTERM: log.Warn("service", "Received shutdown signal") - _, cancel := context.WithTimeout(context.Background(), 5*time.Second) - defer cancel() - svc.shutdown(cancel) + svc.shutdown() } } } @@ -52,8 +49,7 @@ func (svc *service) start() { log.Info("service", "Started") } -func (svc *service) shutdown(cancel context.CancelFunc) { - cancel() +func (svc *service) shutdown() { for _, srv := range svc.servers { srv.Listener.Close() } diff --git a/lib/proc/fwd/util_test.go b/lib/proc/fwd/util_test.go index c2cad23..0364329 100644 --- a/lib/proc/fwd/util_test.go +++ b/lib/proc/fwd/util_test.go @@ -1,6 +1,7 @@ package fwd import ( + "fmt" "net" "testing" @@ -11,7 +12,10 @@ import ( func TestTargetReachable(t *testing.T) { cnf.C = &cnf.Config{} - defaults.Set(cnf.C) // probe timeout + err := defaults.Set(cnf.C) // probe timeout + if err != nil { + fmt.Printf("Failed to set default probe-timeout: %v", err) + } testTarget := net.ParseIP("1.1.1.1") if !TargetIsReachable("tcp", testTarget, 53) { @@ -24,7 +28,10 @@ func TestTargetReachable(t *testing.T) { func TestFirstReachableTarget(t *testing.T) { cnf.C = &cnf.Config{} - defaults.Set(cnf.C) // probe timeout + err := defaults.Set(cnf.C) // probe timeout + if err != nil { + fmt.Printf("Failed to set default probe-timeout: %v", err) + } testTarget1 := net.ParseIP("135.181.170.219") testTarget2 := net.ParseIP("1.1.1.1") diff --git a/lib/u/helpers_test.go b/lib/u/helpers_test.go index 4d114d0..d456d7d 100644 --- a/lib/u/helpers_test.go +++ b/lib/u/helpers_test.go @@ -126,7 +126,7 @@ func TestIsIP(t *testing.T) { t.Errorf("Failed to check for IP #1") } - valid, ip = IsIP("test.at") + valid, _ = IsIP("test.at") if valid { t.Errorf("Failed to check for IP #2") }