diff --git a/blockdevice/stats.go b/blockdevice/stats.go index 44d942c3..1db99d68 100644 --- a/blockdevice/stats.go +++ b/blockdevice/stats.go @@ -180,7 +180,7 @@ type BlockQueueStats struct { type IODeviceStats struct { IODoneCount uint64 - IOErrCount uint64 + IOErrCount uint64 } // DeviceMapperInfo models the devicemapper files that are located in the sysfs tree for each block device @@ -486,20 +486,20 @@ func (fs FS) SysBlockDeviceUnderlyingDevices(device string) (UnderlyingDeviceInf // IO error count: /sys/block//device/ioerr_cnt func (fs FS) SysBlockDeviceIOStat(device string) (IODeviceStats, error) { var ( - ioDeviceStats IODeviceStats - err error + ioDeviceStats IODeviceStats + err error ) for file, p := range map[string]*uint64{ - "iodone_cnt": &ioDeviceStats.IODoneCount, - "ioerr_cnt": &ioDeviceStats.IOErrCount, + "iodone_cnt": &ioDeviceStats.IODoneCount, + "ioerr_cnt": &ioDeviceStats.IOErrCount, } { - var val uint64 - val, err = util.ReadHexFromFile(fs.sys.Path(sysBlockPath, device, sysDevicePath, file)) - if err != nil { - return IODeviceStats{}, err - } else { - *p = val - } + var val uint64 + val, err = util.ReadHexFromFile(fs.sys.Path(sysBlockPath, device, sysDevicePath, file)) + if err != nil { + return IODeviceStats{}, err + } else { + *p = val + } } return ioDeviceStats, nil } diff --git a/ext4/ext4.go b/ext4/ext4.go index 2e0dfdb4..635d6a72 100644 --- a/ext4/ext4.go +++ b/ext4/ext4.go @@ -16,26 +16,26 @@ package ext4 import ( "fmt" - "strings" "path/filepath" + "strings" "github.com/prometheus/procfs/internal/fs" "github.com/prometheus/procfs/internal/util" ) const ( - sysFSPath = "fs" - sysFSExt4Path = "ext4" + sysFSPath = "fs" + sysFSExt4Path = "ext4" ) // Stats contains statistics for a single Btrfs filesystem. // See Linux fs/btrfs/sysfs.c for more information. type Stats struct { - Name string + Name string - Errors uint64 - Warnings uint64 - Messages uint64 + Errors uint64 + Warnings uint64 + Messages uint64 } // FS represents the pseudo-filesystems proc and sys, which provides an @@ -74,8 +74,8 @@ func NewFS(procMountPoint string, sysMountPoint string) (FS, error) { // ProcStat returns stats for the filesystem. func (fs FS) ProcStat() ([]*Stats, error) { matches, err := filepath.Glob(fs.sys.Path("fs/ext4/*")) - if (err != nil) { - return nil, err + if err != nil { + return nil, err } stats := make([]*Stats, 0, len(matches)) @@ -86,17 +86,17 @@ func (fs FS) ProcStat() ([]*Stats, error) { name := filepath.Base(m) s.Name = name for file, p := range map[string]*uint64{ - "errors_count": &s.Errors, - "warning_count": &s.Warnings, - "msg_count": &s.Messages, + "errors_count": &s.Errors, + "warning_count": &s.Warnings, + "msg_count": &s.Messages, } { - var val uint64 - val, err = util.ReadUintFromFile(fs.sys.Path(sysFSPath, sysFSExt4Path, name, file)) - if err != nil { - fmt.Errorf("failed to read ext4 stats from %s: %w", file, err) - } else { - *p = val - } + var val uint64 + val, err = util.ReadUintFromFile(fs.sys.Path(sysFSPath, sysFSExt4Path, name, file)) + if err != nil { + fmt.Errorf("failed to read ext4 stats from %s: %w", file, err) + } else { + *p = val + } } stats = append(stats, s) diff --git a/internal/util/parse.go b/internal/util/parse.go index a912c8c2..3be09c9c 100644 --- a/internal/util/parse.go +++ b/internal/util/parse.go @@ -115,7 +115,7 @@ func ParseBool(b string) *bool { func ReadHexFromFile(path string) (uint64, error) { data, err := os.ReadFile(path) if err != nil { - return 0, err + return 0, err } return strconv.ParseUint(strings.TrimSpace(string(data[2:])), 16, 64) }