chore: use cast.ToBoolE (#17030)

This commit is contained in:
andig 2024-11-01 18:21:47 +01:00 • committed by GitHub
parent c6d9e1bed8
commit f946781c74
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 0 additions and 24 deletions

View file

@ -16,11 +16,6 @@ import (
var re = regexp.MustCompile(`(?i)\${(\w+)(:([a-zA-Z0-9%.]+))?}`)
// Truish returns true if value is truish (true/1/on)
func Truish(s string) bool {
return s == "1" || strings.ToLower(s) == "true" || strings.ToLower(s) == "on"
}
// FormatValue will apply specific formatting in addition to standard sprintf
func FormatValue(format string, val interface{}) string {
switch typed := val.(type) {

View file

@ -9,25 +9,6 @@ import (
"github.com/stretchr/testify/require"
)
func TestTruish(t *testing.T) {
cases := []struct {
k string
v bool
}{
{"", false},
{"false", false},
{"0", false},
{"off", false},
{"true", true},
{"1", true},
{"on", true},
}
for _, c := range cases {
assert.Equal(t, c.v, Truish(c.k))
}
}
func TestReplace(t *testing.T) {
cases := []struct {
k string