2020-11-18 05:28:07 +00:00
|
|
|
package registry
|
|
|
|
|
|
|
|
import (
|
|
|
|
"os"
|
|
|
|
"path/filepath"
|
|
|
|
"strings"
|
|
|
|
"time"
|
|
|
|
|
|
|
|
"github.com/huandu/xstrings"
|
|
|
|
)
|
|
|
|
|
2022-06-14 19:59:53 +00:00
|
|
|
var funcMap = map[string]any{
|
2020-11-18 05:28:07 +00:00
|
|
|
"upper": strings.ToUpper,
|
|
|
|
"lower": strings.ToLower,
|
|
|
|
"title": strings.Title,
|
|
|
|
"snake": xstrings.ToSnakeCase,
|
|
|
|
"kebab": xstrings.ToKebabCase,
|
|
|
|
"pascal": xstrings.ToCamelCase,
|
|
|
|
"camel": func(in string) string {
|
|
|
|
return xstrings.FirstRuneToLower(xstrings.ToCamelCase(in))
|
|
|
|
},
|
2022-06-15 14:59:21 +00:00
|
|
|
"trim_prefix": strings.TrimPrefix,
|
|
|
|
"trim_suffix": strings.TrimSuffix,
|
|
|
|
"replace": strings.ReplaceAll,
|
|
|
|
"env": os.Getenv,
|
2020-11-18 05:28:07 +00:00
|
|
|
"sep": func() string {
|
|
|
|
return string(filepath.Separator)
|
|
|
|
},
|
|
|
|
"time": func(fmt string) string {
|
|
|
|
return time.Now().Format(fmt)
|
|
|
|
},
|
|
|
|
}
|