修复逻辑问题

This commit is contained in:
2026-04-15 16:56:24 +08:00
parent b8c8c7d7b1
commit 9b3546b45f
23 changed files with 331 additions and 161 deletions

View File

@@ -53,6 +53,18 @@ func X[T comparable](v T) *T {
return &v
}
// N 零值视为 nil
func N[T comparable](v *T) *T {
if v == nil {
return nil
}
var zero T
if *v == zero {
return nil
}
return v
}
// ====================
// 数组
// ====================
@@ -110,3 +122,21 @@ func CombineErrors(errs []error) error {
}
return combinedErr
}
// ====================
// 业务
// ====================
func MaskPhone(phone string) string {
if len(phone) < 11 {
return phone
}
return phone[:3] + "****" + phone[7:]
}
func MaskIdNo(idNo string) string {
if len(idNo) < 18 {
return idNo
}
return idNo[:3] + "*********" + idNo[14:]
}