Initial cloud-services repo - gateway service + pkg modules

This commit is contained in:
Chris Rai
2026-01-30 23:14:52 -05:00
commit fbb820d7b3
1037 changed files with 171318 additions and 0 deletions

30
pkg/logger/mask.go Normal file
View File

@@ -0,0 +1,30 @@
package logger
import (
"regexp"
"strings"
)
// MaskEmail removes all identifying chars except first from email username
func MaskEmail(s string) string {
tmp := strings.Split(s, "@")
addr := tmp[0]
domain := tmp[1]
if len(addr) <= 0 || len(domain) <= 0 {
return ""
}
addr = addr[:1] + strings.Repeat("*", len(addr)-1)
return addr + "@" + domain
}
// MaskPassword replaces all characters
func MaskPassword(s string) string {
return strings.Repeat("*", len(s))
}
// MaskPhoneNumber replaces all nums except first from number string
func MaskPhoneNumber(s string) string {
m := regexp.MustCompile(`\B\d`)
return m.ReplaceAllString(s, "*")
}