Merged in deprecate-stringinslice (pull request #288)

Deprecate stringinslice (take 2)

Approved-by: Saxon Milton <saxon.milton@gmail.com>
Approved-by: Alan Noble <anoble@gmail.com>
This commit is contained in:
Alan Noble 2019-11-22 07:01:25 +00:00
commit f7fb7d0a42
3 changed files with 6 additions and 13 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
}

2
go.mod
View File

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

2
go.sum
View File

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