An open API service indexing awesome lists of open source software.

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

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",
})
```