Documentation
¶
Index ¶
- func IsEmpty(s string) bool
- func IsNotEmpty(s string) bool
- func MaskBankCard(cardNumber string) string
- func MaskEmail(email string) string
- func MaskPhone(phone string) string
- func MaskString(s string, start, end int) string
- func RandomString(length int) string
- func RandomStringWithCharset(length int, charset string) string
- func Title(s ...string) string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsNotEmpty ¶
func MaskBankCard ¶
MaskBankCard masks the middle part of a bank card number, keeping the first 4 and last 4 digits visible, with exactly 6 asterisks in between. Example: "6225123412341234" becomes "6225******1234"
func MaskEmail ¶
MaskEmail masks the local part of an email address, keeping the first and last character visible, with exactly 6 asterisks in between. Example: "user@example.com" becomes "u******r@example.com"
func MaskPhone ¶
MaskPhone masks the middle part of a phone number, keeping the first 3 and last 4 digits visible, with exactly 6 asterisks in between. Example: "13812345678" becomes "138******5678"
func MaskString ¶
MaskString masks the middle part of a string with exactly 6 asterisks (*), keeping the specified number of characters visible at the start and end. If the string is too short to mask, it will be padded with 6 asterisks. Parameters:
- s: the original string to mask
- start: number of characters to keep visible at the start
- end: number of characters to keep visible at the end
Example:
MaskString("1234567890", 3, 2) returns "123******90" MaskString("abc@example.com", 3, 4) returns "abc******e.com"
func RandomString ¶
func RandomStringWithCharset ¶
Types ¶
This section is empty.