init code

This commit is contained in:
thuanle
2024-10-24 09:53:02 +07:00
commit a7559b3f9d
9 changed files with 1006 additions and 0 deletions

View File

@@ -0,0 +1,25 @@
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
}