From 85c4c7857adc64240e618bfd9be990a709771ff6 Mon Sep 17 00:00:00 2001 From: scruzin Date: Fri, 22 Nov 2019 17:18:11 +1030 Subject: [PATCH] Use sliceUtils.ContainsString instead of stringInSlice. --- device/raspivid/raspivid.go | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/device/raspivid/raspivid.go b/device/raspivid/raspivid.go index 3c5ba7bc..baf1a148 100644 --- a/device/raspivid/raspivid.go +++ b/device/raspivid/raspivid.go @@ -35,6 +35,7 @@ import ( "bitbucket.org/ausocean/av/device" "bitbucket.org/ausocean/av/revid/config" "bitbucket.org/ausocean/utils/logger" + "bitbucket.org/ausocean/utils/sliceutils" ) // To indicate package when logging. @@ -180,12 +181,12 @@ func (r *Raspivid) Set(c config.Config) error { c.Saturation = defaultRaspividSaturation } - if c.Exposure == "" || !stringInSlice(c.Exposure, ExposureModes[:]) { + if c.Exposure == "" || !sliceutils.ContainsString(ExposureModes[:], c.Exposure) { errs = append(errs, errBadExposure) c.Exposure = defaultRaspividExposure } - if c.AutoWhiteBalance == "" || !stringInSlice(c.AutoWhiteBalance, AutoWhiteBalanceModes[:]) { + if c.AutoWhiteBalance == "" || !sliceutils.ContainsString(AutoWhiteBalanceModes[:], c.AutoWhiteBalance) { errs = append(errs, errBadAutoWhiteBalance) c.AutoWhiteBalance = defaultRaspividAutoWhiteBalance } @@ -277,13 +278,3 @@ func (r *Raspivid) Stop() error { } return r.out.Close() } - -// stringInSlice returns true if want is in slice. -func stringInSlice(want string, slice []string) bool { - for _, s := range slice { - if s == want { - return true - } - } - return false -}