From b4570f1aa177a6cbbad05bb825ae900f0bea0a4c Mon Sep 17 00:00:00 2001 From: scruzin Date: Fri, 22 Nov 2019 17:19:27 +1030 Subject: [PATCH 1/2] 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 -} From d661b4b34ea9021ecfc3b6b4213e355b66567e30 Mon Sep 17 00:00:00 2001 From: scruzin Date: Fri, 22 Nov 2019 17:19:52 +1030 Subject: [PATCH 2/2] Use ausocean/utils v1.2.11. --- go.mod | 2 +- go.sum | 2 ++ 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/go.mod b/go.mod index c00cf273..2938c256 100644 --- a/go.mod +++ b/go.mod @@ -4,7 +4,7 @@ go 1.13 require ( bitbucket.org/ausocean/iot v1.2.7 - bitbucket.org/ausocean/utils v1.2.10 + bitbucket.org/ausocean/utils v1.2.11 github.com/Comcast/gots v0.0.0-20190305015453-8d56e473f0f7 github.com/go-audio/audio v0.0.0-20181013203223-7b2a6ca21480 github.com/go-audio/wav v0.0.0-20181013172942-de841e69b884 diff --git a/go.sum b/go.sum index ab6b1cd9..fc00a4a5 100644 --- a/go.sum +++ b/go.sum @@ -3,6 +3,8 @@ bitbucket.org/ausocean/iot v1.2.7/go.mod h1:aAWgPo2f8sD2OPmxae1E5/iD9+tKY/iW4pcQ bitbucket.org/ausocean/utils v1.2.9/go.mod h1:uXzX9z3PLemyURTMWRhVI8uLhPX4uuvaaO85v2hcob8= bitbucket.org/ausocean/utils v1.2.10 h1:JTS7n+K+0o/FQFWKjdGgA1ElZ4TQu9aHX3wTJXOayXw= bitbucket.org/ausocean/utils v1.2.10/go.mod h1:uXzX9z3PLemyURTMWRhVI8uLhPX4uuvaaO85v2hcob8= +bitbucket.org/ausocean/utils v1.2.11 h1:zA0FOaPjN960ryp8PKCkV5y50uWBYrIxCVnXjwbvPqg= +bitbucket.org/ausocean/utils v1.2.11/go.mod h1:uXzX9z3PLemyURTMWRhVI8uLhPX4uuvaaO85v2hcob8= cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= cloud.google.com/go v0.38.0 h1:ROfEUZz+Gh5pa62DJWXSaonyu3StP6EA6lPEXPI6mCo=