fs: create fs.Enum for easy creation of parameters from a list of choices

This commit is contained in:
Nick Craig-Wood
2023-09-26 16:49:09 +01:00
parent 3553cc4a5f
commit 60a6ef914c
4 changed files with 256 additions and 2 deletions

View File

@ -24,8 +24,7 @@ func camelToSnake(in string) string {
// StringToInterface turns in into an interface{} the same type as def
func StringToInterface(def interface{}, in string) (newValue interface{}, err error) {
typ := reflect.TypeOf(def)
switch typ.Kind() {
case reflect.String:
if typ.Kind() == reflect.String && typ.Name() == "string" {
// Pass strings unmodified
return in, nil
}