From df60f8e30fcb5fda1eb037c4a2c4d9a48723de76 Mon Sep 17 00:00:00 2001 From: Daniel Milde Date: Wed, 3 Feb 2021 14:53:22 +0100 Subject: [PATCH] fixed build of non-linux OSes --- cmd/run.go | 6 +----- device/dev_linux.go | 3 +++ device/dev_other.go | 3 +++ 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/cmd/run.go b/cmd/run.go index 1924946a5..fa6648eaa 100644 --- a/cmd/run.go +++ b/cmd/run.go @@ -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 7f20b9b82..1c232fca9 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 5878ef4a4..301e03c5d 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")