Skip to content

Commit 0896fdd

Browse files
author
Lorenz Kästle
committed
Fix linter warnings
1 parent 06a62ec commit 0896fdd

File tree

4 files changed

+30
-32
lines changed

4 files changed

+30
-32
lines changed

cmd/filesystem.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,9 +155,7 @@ var diskCmd = &cobra.Command{
155155

156156
if filesystemList[index].Error == nil {
157157
sc.Output = fmt.Sprintf("%s (%.2f%% used space, %.2f%% free inodes)", sc.Output, filesystemList[index].UsageStats.UsedPercent, 100-filesystemList[index].UsageStats.InodesUsedPercent)
158-
} else {
159158
}
160-
161159
overall.AddSubcheck(sc)
162160
}
163161

internal/common/filter/filter.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ import (
55
)
66

77
type Filterable interface {
8-
GetFilterableValue(uint) string
8+
GetFilterableValue(val uint) string
99
}
1010

1111
type Options struct {

internal/filesystem/filesystem.go

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import (
44
"context"
55
"errors"
66
"regexp"
7-
"syscall"
87

98
"github.com/shirou/gopsutil/v3/disk"
109
)
@@ -35,14 +34,7 @@ func GetDiskUsageSingle(ctx context.Context, fs *FilesystemType) {
3534
select {
3635
case tmp := <-resChan:
3736
if tmp.err != nil {
38-
if errors.Is(tmp.err, syscall.Errno(syscall.EACCES)) {
39-
// Treat Permission denied differently?
40-
// Not sure why this is tested for that specifically
41-
fs.Error = tmp.err
42-
} else {
43-
fs.Error = tmp.err
44-
}
45-
37+
fs.Error = tmp.err
4638
return
4739
}
4840

internal/sensors/sensors.go

Lines changed: 28 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,14 @@ type Device struct {
2929
Sensors []Sensor
3030
}
3131

32+
const (
33+
inputFileSuffix string = "_input"
34+
critThresholdFileSuffix string = "_crit"
35+
lowestValueFileSuffix string = "_lowest"
36+
highestValueFileSuffix string = "_highest"
37+
maxValueFileSuffix string = "_max"
38+
)
39+
3240
func (d *Device) String() string {
3341
result := d.Name
3442
result += ": "
@@ -263,7 +271,7 @@ func readHumiditySensor(devicePath string, index int) (Sensor, error) {
263271
sensor.Perfdata.Label = label
264272

265273
// Look for input (the actual value)
266-
value, err := readIntFromFile(basePath + "_input")
274+
value, err := readIntFromFile(basePath + inputFileSuffix)
267275

268276
if err != nil {
269277
return sensor, err
@@ -285,7 +293,7 @@ func readEnergySensor(devicePath string, index int) (Sensor, error) {
285293
sensor.Perfdata.Label = label
286294

287295
// Look for input (the actual value)
288-
value, err := readIntFromFile(basePath + "_input")
296+
value, err := readIntFromFile(basePath + inputFileSuffix)
289297
if err != nil {
290298
return sensor, err
291299
}
@@ -307,7 +315,7 @@ func readCurrSensor(devicePath string, index int) (Sensor, error) {
307315
sensor.Perfdata.Label = label
308316

309317
// Look for input (the actual value)
310-
value, err := readIntFromFile(basePath + "_input")
318+
value, err := readIntFromFile(basePath + inputFileSuffix)
311319
if err != nil {
312320
return sensor, err
313321
}
@@ -317,14 +325,14 @@ func readCurrSensor(devicePath string, index int) (Sensor, error) {
317325

318326
// == Min
319327
// Is there a currN_lowest file? Use it for max value
320-
value, err = readIntFromFile(basePath + "_lowest")
328+
value, err = readIntFromFile(basePath + lowestValueFileSuffix)
321329
if err == nil {
322330
sensor.Perfdata.Min = float64(value) / 1000
323331
}
324332

325333
// == Max
326334
// Is there a currN_highest file? Use it for max value
327-
value, err = readIntFromFile(basePath + "_highest")
335+
value, err = readIntFromFile(basePath + highestValueFileSuffix)
328336
if err == nil {
329337
sensor.Perfdata.Max = float64(value) / 1000
330338
}
@@ -343,7 +351,7 @@ func readCurrSensor(devicePath string, index int) (Sensor, error) {
343351
critPresent = true
344352
}
345353
// Is there a currN_crit file? If yes, use that as upper critical
346-
value, err = readIntFromFile(basePath + "_crit")
354+
value, err = readIntFromFile(basePath + critThresholdFileSuffix)
347355
if err == nil {
348356
tmp.Upper = float64(value) / 1000
349357
critPresent = true
@@ -391,7 +399,7 @@ func readFanSensor(devicePath string, index int) (Sensor, error) {
391399
sensor.Perfdata.Label = label
392400

393401
// Look for input (the actual value)
394-
value, err := readIntFromFile(basePath + "_input")
402+
value, err := readIntFromFile(basePath + inputFileSuffix)
395403
if err != nil {
396404
return sensor, err
397405
}
@@ -403,7 +411,7 @@ func readFanSensor(devicePath string, index int) (Sensor, error) {
403411

404412
// == Max
405413
// Is there a tempN_highest file? Use it for max value
406-
value, err = readIntFromFile(basePath + "_max")
414+
value, err = readIntFromFile(basePath + maxValueFileSuffix)
407415
if err == nil {
408416
sensor.Perfdata.Max = float64(value)
409417
}
@@ -424,7 +432,7 @@ func readVoltageSensor(_, devicePath string, index int) (Sensor, error) {
424432
sensor.Perfdata.Label = label
425433

426434
// Look for input (the actual value)
427-
value, err := readIntFromFile(basePath + "_input")
435+
value, err := readIntFromFile(basePath + inputFileSuffix)
428436
if err != nil {
429437
return sensor, err
430438
}
@@ -440,7 +448,7 @@ func readVoltageSensor(_, devicePath string, index int) (Sensor, error) {
440448
}
441449
warnPresent := false
442450
// Is there a inN_max file? If yes, use that as warning
443-
value, err = readIntFromFile(basePath + "_max")
451+
value, err = readIntFromFile(basePath + maxValueFileSuffix)
444452
if err == nil {
445453
tmpWarn.Upper = float64(value) / 1000
446454
warnPresent = true
@@ -458,7 +466,7 @@ func readVoltageSensor(_, devicePath string, index int) (Sensor, error) {
458466
}
459467
critPresent := false
460468
// Is there a inN_crit file? If yes, use that as critical
461-
value, err = readIntFromFile(basePath + "_crit")
469+
value, err = readIntFromFile(basePath + critThresholdFileSuffix)
462470
if err == nil {
463471
tmpCrit.Upper = float64(value) / 1000
464472
critPresent = true
@@ -476,14 +484,14 @@ func readVoltageSensor(_, devicePath string, index int) (Sensor, error) {
476484
}
477485

478486
// == Min
479-
value, err = readIntFromFile(basePath + "_lowest")
487+
value, err = readIntFromFile(basePath + lowestValueFileSuffix)
480488
if err == nil {
481489
sensor.Perfdata.Min = float64(value) / 1000
482490
}
483491

484492
// == Max
485493
// Is there a tempN_highest file? Use it for max value
486-
value, err = readIntFromFile(basePath + "_highest")
494+
value, err = readIntFromFile(basePath + highestValueFileSuffix)
487495
if err == nil {
488496
sensor.Perfdata.Max = float64(value) / 1000
489497
}
@@ -503,7 +511,7 @@ func readPowerSensor(_, devicePath string, index int) (Sensor, error) {
503511
sensor.Perfdata.Label = label
504512

505513
// Look for input (the actual value)
506-
value, err := readIntFromFile(basePath + "_input")
514+
value, err := readIntFromFile(basePath + inputFileSuffix)
507515

508516
if err != nil {
509517
return sensor, err
@@ -551,7 +559,7 @@ func readPowerSensor(_, devicePath string, index int) (Sensor, error) {
551559
}
552560
critPresent := false
553561
// Is there a powerN_crit file? If yes, use that as critical
554-
value, err = readIntFromFile(basePath + "_crit")
562+
value, err = readIntFromFile(basePath + critThresholdFileSuffix)
555563
if err == nil {
556564
tmpCrit.Upper = float64(value)
557565
critPresent = true
@@ -574,7 +582,7 @@ func readTempSensor(_, devicePath string, index int) (Sensor, error) {
574582
sensor.Perfdata.Label = label
575583

576584
// Look for input (the actual value)
577-
value, err := readIntFromFile(basePath + "_input")
585+
value, err := readIntFromFile(basePath + inputFileSuffix)
578586

579587
if err != nil {
580588
return sensor, err
@@ -591,7 +599,7 @@ func readTempSensor(_, devicePath string, index int) (Sensor, error) {
591599
}
592600
warnPresent := false
593601
// Is there a tempN_max file? If yes, use that as warning
594-
value, err = readIntFromFile(basePath + "_max")
602+
value, err = readIntFromFile(basePath + maxValueFileSuffix)
595603

596604
if err == nil {
597605
tmpWarn.Upper = float64(value / 1000)
@@ -611,7 +619,7 @@ func readTempSensor(_, devicePath string, index int) (Sensor, error) {
611619

612620
critPresent := false
613621
// Is there a tempN_crit file? If yes, use that as critical
614-
value, err = readIntFromFile(basePath + "_crit")
622+
value, err = readIntFromFile(basePath + critThresholdFileSuffix)
615623

616624
if err == nil {
617625
tmpCrit.Upper = float64(value / 1000)
@@ -640,15 +648,15 @@ func readTempSensor(_, devicePath string, index int) (Sensor, error) {
640648

641649
// == Min
642650
// Is there a tempN_lowest file? Use it for min value
643-
value, err = readIntFromFile(basePath + "_lowest")
651+
value, err = readIntFromFile(basePath + lowestValueFileSuffix)
644652

645653
if err == nil {
646654
sensor.Perfdata.Min = value
647655
}
648656

649657
// == Max
650658
// Is there a tempN_highest file? Use it for max value
651-
value, err = readIntFromFile(basePath + "_highest")
659+
value, err = readIntFromFile(basePath + highestValueFileSuffix)
652660

653661
if err == nil {
654662
sensor.Perfdata.Max = value

0 commit comments

Comments
 (0)