https://github.com/vicanso/go-mask
mask and cut value for struct
https://github.com/vicanso/go-mask
Last synced: 2 months ago
JSON representation
mask and cut value for struct
- Host: GitHub
- URL: https://github.com/vicanso/go-mask
- Owner: vicanso
- License: mit
- Created: 2021-08-23T13:26:46.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2023-02-14T12:17:01.000Z (over 2 years ago)
- Last Synced: 2024-12-27T19:45:00.927Z (9 months ago)
- Language: Go
- Size: 28.3 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# go-mask
mask and cut value for struct.
priority:
- `NotMaskReg`
- `MaskReg`
- `CustomMask`
- `MaxLength````go
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",
})
```