This commit is contained in:
兔子
2023-06-13 18:07:55 +08:00
parent 6c9aef2090
commit f760f1f0a9
3 changed files with 43 additions and 2 deletions

View File

@@ -24,6 +24,17 @@ func Ternary[T any](IF bool, TRUE T, FALSE T) T {
return FALSE
}
// Default - 设置默认值
func Default[T any](param T, value ...T) (result T) {
if IsEmpty(param) {
if len(value) > 0 {
return value[0]
}
return result
}
return param
}
// Replace - 字符串替换
func Replace(value any, params map[string]any) (result string) {
result = cast.ToString(value)