Files
go-golden/update.go
Jim Myhrberg 3185b09d09 refactor(golden): major refactor and improvements
This includes sanitizing golden file names to avoid characters and names
which are invalid on some operating systems. So this should now work on
Linux, macOS, and Window.
2021-09-17 02:21:32 +01:00

24 lines
495 B
Go

package golden
import "os"
var truthyStrings = []string{"1", "y", "t", "yes", "on", "true"}
type UpdateFunc func() bool
// EnvUpdateFunc checks if the GOLDEN_UPDATE environment variable is set to
// one of "1", "y", "t", "yes", "on", or "true".
//
// This is also the default UpdateFunc used to determine the return value of
// Update().
func EnvUpdateFunc() bool {
env := os.Getenv("GOLDEN_UPDATE")
for _, v := range truthyStrings {
if env == v {
return true
}
}
return false
}