Fixed Error return value of is not checked (errcheck)

This commit is contained in:
Holger Obermaier
2026-02-05 14:48:49 +01:00
parent a77cc19ddb
commit 8f49c7aa67
9 changed files with 81 additions and 16 deletions

View File

@@ -137,9 +137,17 @@ func (m *SchedstatCollector) Read(interval time.Duration, output chan lp.CCMessa
file, err := os.Open(string(SCHEDSTATFILE))
if err != nil {
cclog.ComponentError(m.name, err.Error())
cclog.ComponentError(
m.name,
fmt.Sprintf("Read(): Failed to open file '%s': %v", string(SCHEDSTATFILE), err))
}
defer file.Close()
defer func() {
if err := file.Close(); err != nil {
cclog.ComponentError(
m.name,
fmt.Sprintf("Read(): Failed to close file '%s': %v", string(SCHEDSTATFILE), err))
}
}()
scanner := bufio.NewScanner(file)
for scanner.Scan() {