Fix Error return value of is not checked (errcheck)

This commit is contained in:
Holger Obermaier
2026-02-04 14:39:44 +01:00
parent 0f7792b4cb
commit 5df7b0eb48

View File

@@ -52,8 +52,11 @@ func (m *CustomCmdCollector) Init(config json.RawMessage) error {
m.setup() m.setup()
for _, c := range m.config.Commands { for _, c := range m.config.Commands {
cmdfields := strings.Fields(c) cmdfields := strings.Fields(c)
command := exec.Command(cmdfields[0], strings.Join(cmdfields[1:], " ")) command := exec.Command(cmdfields[0], cmdfields[1:]...)
command.Wait() if err := command.Wait(); err != nil {
log.Print(err)
continue
}
_, err = command.Output() _, err = command.Output()
if err == nil { if err == nil {
m.commands = append(m.commands, c) m.commands = append(m.commands, c)
@@ -88,8 +91,11 @@ func (m *CustomCmdCollector) Read(interval time.Duration, output chan lp.CCMessa
} }
for _, cmd := range m.commands { for _, cmd := range m.commands {
cmdfields := strings.Fields(cmd) cmdfields := strings.Fields(cmd)
command := exec.Command(cmdfields[0], strings.Join(cmdfields[1:], " ")) command := exec.Command(cmdfields[0], cmdfields[1:]...)
command.Wait() if err := command.Wait(); err != nil {
log.Print(err)
continue
}
stdout, err := command.Output() stdout, err := command.Output()
if err != nil { if err != nil {
log.Print(err) log.Print(err)