From 665ab96cfab6759859d620a7c1d4efc7437137ea Mon Sep 17 00:00:00 2001 From: Tai Groot Date: Thu, 30 May 2024 22:54:09 -0700 Subject: [PATCH] always return error value --- vidnumerator.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/vidnumerator.go b/vidnumerator.go index 8133ac9..9aefb0d 100644 --- a/vidnumerator.go +++ b/vidnumerator.go @@ -72,11 +72,11 @@ func IsVideoCapture(path string) (bool, error) { } // this function checks the ioctl for VIDIOC_QUERYCAP to see if the device is a video capture device -func EnumeratedVideoDevices() []string { +func EnumeratedVideoDevices() ([]string, error) { // list all files in the /dev directory d, err := os.ReadDir("/dev") if err != nil { - return []string{} + return []string{}, err } // iterate over the files in the directory devNames := []string{} @@ -89,9 +89,13 @@ func EnumeratedVideoDevices() []string { continue } fname = filepath.Join("/dev/", fname) - if isVidCap, _ := IsVideoCapture(fname); isVidCap { + isVidCap, err := IsVideoCapture(fname) + if err != nil { + return []string{}, err + } + if isVidCap { devNames = append(devNames, fname) } } - return devNames + return devNames, nil }