# README
go-mask
mask and cut value for struct.
priority:
NotMaskReg
MaskReg
CustomMask
MaxLength
m := mask.New(
mask.RegExpOption(regexp.MustCompile("password")),
mask.MaxLengthOption(3),
mask.CustomMaskOption(regexp.MustCompile("desc"), func(key, value string) string {
max := 10
if len(value) <= max {
return value
}
return value[0:max] + "..."
}),
)
result := m.Struct(struct {
Name string `json:"name"`
Password string `json:"password"`
Desc string `json:"desc"`
}{
"test",
"password",
"desc",
})
# Functions
CustomMaskOption add custom mask regexp option.
Set max string length option for mask, if the length of rune is gt max, it will convert to %s ..
No description provided by the author
NotMaskRegExpOption sets not mask regexp option.
RegExpOption sets regexp option.