Remove unused methods

Signed-off-by: faizanahmad055 <faizan.ahmad55@outlook.com>
This commit is contained in:
faizanahmad055
2026-06-12 12:43:43 +02:00
parent 3847ce5927
commit 6556d4dac5
2 changed files with 0 additions and 82 deletions
-43
View File
@@ -1,43 +0,0 @@
package util
import (
"reflect"
"strconv"
"github.com/sirupsen/logrus"
)
// InterfaceSlice converts an interface to an interface array
func InterfaceSlice(slice interface{}) []interface{} {
s := reflect.ValueOf(slice)
if s.Kind() != reflect.Slice {
logrus.Errorf("InterfaceSlice() given a non-slice type")
}
ret := make([]interface{}, s.Len())
for i := 0; i < s.Len(); i++ {
ret[i] = s.Index(i).Interface()
}
return ret
}
// ParseBool returns result in bool format after parsing.
// It handles concrete bool/string types as well as any named type whose
// underlying kind is bool or string (e.g. type MyBool bool).
func ParseBool(value interface{}) bool {
if value == nil {
return false
}
v := reflect.ValueOf(value)
switch v.Kind() {
case reflect.Bool:
return v.Bool()
case reflect.String:
result, _ := strconv.ParseBool(v.String())
return result
default:
return false
}
}
-39
View File
@@ -8,45 +8,6 @@ import (
"github.com/stakater/Reloader/internal/pkg/options"
)
// custom named types to verify reflect-based extraction
type myBool bool
type myString string
func TestParseBool(t *testing.T) {
tests := []struct {
name string
input interface{}
want bool
}{
// concrete bool
{"true bool", true, true},
{"false bool", false, false},
// concrete string
{"string true", "true", true},
{"string 1", "1", true},
{"string false", "false", false},
{"string 0", "0", false},
{"string invalid", "banana", false},
// custom named bool kind
{"myBool true", myBool(true), true},
{"myBool false", myBool(false), false},
// custom named string kind
{"myString true", myString("true"), true},
{"myString false", myString("false"), false},
// nil and unsupported
{"nil", nil, false},
{"int", 42, false},
}
for _, tc := range tests {
t.Run(tc.name, func(t *testing.T) {
if got := ParseBool(tc.input); got != tc.want {
t.Errorf("ParseBool(%v) = %v, want %v", tc.input, got, tc.want)
}
})
}
}
func TestConvertToEnvVarName(t *testing.T) {
data := "www.stakater.com"
envVar := ConvertToEnvVarName(data)