📝 update readme.md
This commit is contained in:
parent
b0e2a0086a
commit
9a91f7af91
20
readme.md
20
readme.md
@ -22,27 +22,29 @@ type User struct {
|
|||||||
Email string `json:"email" sen:"email,*"`
|
Email string `json:"email" sen:"email,*"`
|
||||||
}
|
}
|
||||||
|
|
||||||
data := User{
|
func main() {
|
||||||
|
data := User{
|
||||||
Name: "lixh",
|
Name: "lixh",
|
||||||
Age: 18,
|
Age: 18,
|
||||||
Phone: "13888888888",
|
Phone: "13888888888",
|
||||||
Email: "lixh@gmail.com",
|
Email: "lixh@gmail.com",
|
||||||
}
|
}
|
||||||
|
|
||||||
// 添加自定义处理函数
|
// 添加自定义处理函数
|
||||||
// Add custom handler
|
// Add custom handler
|
||||||
sensitive.AddHandler("email", func(src, p string) string {
|
sensitive.AddHandler("email", func(src, p string) string {
|
||||||
// 将@符号后面的替换为*
|
// 将@符号后面的替换为*
|
||||||
// Replace the after @ sign with *
|
// Replace the after @ sign with *
|
||||||
idx := strings.Index(src, "@")
|
idx := strings.Index(src, "@")
|
||||||
dst := src[:idx+1] + strings.Repeat(p, utf8.RuneCountInString(src)-idx-1)
|
dst := src[:idx+1] + strings.Repeat(p, utf8.RuneCountInString(src)-idx-1)
|
||||||
|
|
||||||
return dst
|
return dst
|
||||||
})
|
})
|
||||||
|
|
||||||
if err := sensitive.Desensitize(data); err != nil {
|
if err := sensitive.Desensitize(data); err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
|
}
|
||||||
|
bs, _ := json.Marshal(response)
|
||||||
|
log.Printf("after processing data: %v", string(bs))
|
||||||
}
|
}
|
||||||
bs, _ := json.Marshal(response)
|
|
||||||
log.Printf("after processing data: %v", string(bs))
|
|
||||||
```
|
```
|
Loading…
Reference in New Issue
Block a user