Skip to content

Commit

Permalink
chore: use cast.ToBoolE (#17030)
Browse files Browse the repository at this point in the history
  • Loading branch information
andig authored Nov 1, 2024
1 parent c6d9e1b commit f946781
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 24 deletions.
5 changes: 0 additions & 5 deletions util/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
19 changes: 0 additions & 19 deletions util/format_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit f946781

Please sign in to comment.