From 12f4dc75f0da1f4e58fb13e1602a263727b8680c Mon Sep 17 00:00:00 2001 From: eleksir Date: Tue, 24 Jun 2025 16:13:36 +0300 Subject: [PATCH] Fix linter warnings --- internal/lib/batteries.go | 7 +++++-- internal/lib/spawn.go | 13 +++++++------ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/internal/lib/batteries.go b/internal/lib/batteries.go index 78f79bf..54944d9 100644 --- a/internal/lib/batteries.go +++ b/internal/lib/batteries.go @@ -29,7 +29,7 @@ func (c *MyConfig) UpdateBatteryInfo() { } var ( - batteries []*battery.Battery = []*battery.Battery{} + batteries = []*battery.Battery{} Batts string ch int status string @@ -52,6 +52,7 @@ func (c *MyConfig) UpdateBatteryInfo() { if err != nil { log.Printf("Unable to read file %s: %s", file, err) + continue } @@ -65,6 +66,7 @@ func (c *MyConfig) UpdateBatteryInfo() { if err != nil { log.Printf("Unable to read file %s: %s", statusFile, err) + continue } @@ -91,6 +93,7 @@ func (c *MyConfig) UpdateBatteryInfo() { if err != nil { log.Printf("Unable to convert string from file %s to integer", file) + continue } @@ -100,9 +103,9 @@ func (c *MyConfig) UpdateBatteryInfo() { } } } else { - batteries, _ = battery.GetAll() // In theory, this module should give for each entry its separate err, but in practice it gives // one single err for all entries, so we cannot detemine whist exatly entry errored. + batteries, _ = battery.GetAll() } var ( diff --git a/internal/lib/spawn.go b/internal/lib/spawn.go index ebff62d..3ae17b2 100644 --- a/internal/lib/spawn.go +++ b/internal/lib/spawn.go @@ -14,6 +14,7 @@ import ( func (c *MyConfig) Spawner() { for prg := range c.Channels.RunChan { <-time.After(25 * time.Millisecond) + devnullR, _ := os.Open(os.DevNull) devnullW, _ := os.OpenFile(os.DevNull, os.O_WRONLY|os.O_APPEND, 0644) @@ -68,9 +69,9 @@ func RunProcess(command []string) string { switch len(command) { case 1: - cmd = exec.Command(command[0], "") + cmd = exec.Command(command[0], "") //nolint: gosec default: - cmd = exec.Command(command[0], command[1:]...) + cmd = exec.Command(command[0], command[1:]...) //nolint: gosec } cmd.Dir = "/" @@ -87,10 +88,10 @@ func RunProcess(command []string) string { } return "" - } else { - if stderr.String() != "" { - log.Printf("%s: %s", strings.Join(command, " "), stderr.String()) - } + } + + if stderr.String() != "" { + log.Printf("%s: %s", strings.Join(command, " "), stderr.String()) } return strings.TrimRight(stdout.String(), "\n")