Files
2024-10-24 09:53:02 +07:00

26 lines
517 B
Go

package helper
import "strings"
func Args2String(args []string) (string, error) {
if len(args) != 1 {
return "", ErrorParamCountMismatch
}
return args[0], nil
}
func Args2StringString(args []string) (string, string, error) {
if len(args) != 2 {
return "", "", ErrorParamCountMismatch
}
return args[0], args[1], nil
}
func Args2Bool(args []string) (bool, error) {
if len(args) != 1 {
return false, ErrorParamCountMismatch
}
val := strings.ToUpper(args[0])
return val == "1" || val == "TRUE", nil
}