Use sliceUtils.ContainsString instead of stringInSlice.

This commit is contained in:
scruzin 2019-11-22 17:18:11 +10:30
parent 41945c9868
commit 85c4c7857a
1 changed files with 3 additions and 12 deletions

View File

@ -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
}