go项目脚手架
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
sorbet/pkg/misc/fallback.go

14 lines
200 B

package misc
// Fallback 当值为空时返回默认值
func Fallback[T any](v T, fs ...T) T {
if !IsZero(v) {
return v
}
for _, f := range fs {
if !IsZero(f) {
return f
}
}
return v
}