diff options
author | Daniel Milde <daniel@milde.cz> | 2021-02-03 14:53:22 +0100 |
---|---|---|
committer | Daniel Milde <daniel@milde.cz> | 2021-02-03 14:53:22 +0100 |
commit | df60f8e30fcb5fda1eb037c4a2c4d9a48723de76 (patch) | |
tree | 13ab2e882c2e56b1c6057f7278b6f4cf3e266987 | |
parent | ee9018c84b516695c42715136077c9ffe96a914a (diff) |
fixed build of non-linux OSesv4.4.0
-rw-r--r-- | cmd/run.go | 6 | ||||
-rw-r--r-- | device/dev_linux.go | 3 | ||||
-rw-r--r-- | device/dev_other.go | 3 |
3 files changed, 7 insertions, 5 deletions
@@ -88,11 +88,7 @@ func Run(flags *RunFlags, args []string, istty bool, writer io.Writer, testing b if flags.ShowDisks { if runtime.GOOS == "linux" { ui.SetIgnoreDirPaths(flags.IgnoreDirs) - ui.ListDevices( - device.LinuxDevicesInfoGetter{ - MountsPath: "/proc/mounts", - }, - ) + ui.ListDevices(device.Getter) } else { fmt.Fprint(writer, "Listing devices is not yet supported for this platform") return diff --git a/device/dev_linux.go b/device/dev_linux.go index 7f20b9b..1c232fc 100644 --- a/device/dev_linux.go +++ b/device/dev_linux.go @@ -15,6 +15,9 @@ type LinuxDevicesInfoGetter struct { MountsPath string } +// Getter is current instance of DevicesInfoGetter +var Getter DevicesInfoGetter = LinuxDevicesInfoGetter{MountsPath: "/proc/mounts"} + // GetDevicesInfo returns usage info about mounted devices (by calling Statfs syscall) func (t LinuxDevicesInfoGetter) GetDevicesInfo() ([]*Device, error) { file, err := os.Open(t.MountsPath) diff --git a/device/dev_other.go b/device/dev_other.go index 5878ef4..301e03c 100644 --- a/device/dev_other.go +++ b/device/dev_other.go @@ -7,6 +7,9 @@ import "errors" // OtherDevicesInfoGetter retruns info for other devices type OtherDevicesInfoGetter struct{} +// Getter is current instance of DevicesInfoGetter +var Getter DevicesInfoGetter = OtherDevicesInfoGetter{} + // GetDevicesInfo returns usage info about mounted devices (by calling Statfs syscall) func (t OtherDevicesInfoGetter) GetDevicesInfo() ([]*Device, error) { return nil, errors.New("Only Linux platform is supported for listing devices") |