Documentation
¶
Index ¶
- func Mask[T any](target T) (ret T, err error)
- type MaskAnyFunc
- type MaskFloat64Func
- type MaskIntFunc
- type MaskStringFunc
- type MaskUintFunc
- type Masker
- func (m *Masker) Cache(enable bool)
- func (m *Masker) Float64(tag string, value float64) (float64, error)
- func (m *Masker) Int(tag string, value int) (int, error)
- func (m *Masker) Mask(target any) (ret any, err error)
- func (m *Masker) MaskChar() string
- func (m *Masker) MaskFilledString(arg, value string) (string, error)
- func (m *Masker) MaskFixedString(arg, value string) (string, error)
- func (m *Masker) MaskHashString(arg, value string) (string, error)
- func (m *Masker) MaskRandomFloat64(arg string, value float64) (float64, error)
- func (m *Masker) MaskRandomInt(arg string, value int) (int, error)
- func (m *Masker) MaskZero(arg string, value any) (any, error)
- func (m *Masker) RegisterMaskAnyFunc(maskType string, maskFunc MaskAnyFunc)
- func (m *Masker) RegisterMaskField(fieldName, maskType string)
- func (m *Masker) RegisterMaskFloat64Func(maskType string, maskFunc MaskFloat64Func)
- func (m *Masker) RegisterMaskIntFunc(maskType string, maskFunc MaskIntFunc)
- func (m *Masker) RegisterMaskStringFunc(maskType string, maskFunc MaskStringFunc)
- func (m *Masker) RegisterMaskUintFunc(maskType string, maskFunc MaskUintFunc)
- func (m *Masker) SetMaskChar(s string)
- func (m *Masker) SetTagName(s string)
- func (m *Masker) String(tag, value string) (string, error)
- func (m *Masker) Uint(tag string, value uint) (uint, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Masker ¶
type Masker struct {
// contains filtered or unexported fields
}
var Default *Masker
func (*Masker) Cache ¶
Cache can be toggled to cache the type information of the struct. default true
func (*Masker) Mask ¶
Mask returns an object with the mask applied to any given object. The function's argument can accept any type, including pointer, map, and slice types, in addition to struct.
func (*Masker) MaskFilledString ¶
MaskFilledString masks the string length of the value with the same length. If you pass a number like "2" to arg, it masks with the length of the number.(**)
func (*Masker) MaskFixedString ¶
MaskFixedString masks with a fixed length (8 characters).
func (*Masker) MaskHashString ¶
MaskHashString masks and hashes (sha1) a string.
func (*Masker) MaskRandomFloat64 ¶
MaskRandomFloat64 converts a float64 to a random number. For example, if you pass "100.3" to arg, it sets a random number in the range of 0.000 to 99.999.
func (*Masker) MaskRandomInt ¶
MaskRandomInt converts an integer (int) into a random number. For example, if you pass "100" as the arg, it sets a random number in the range of 0-99.
func (*Masker) RegisterMaskAnyFunc ¶
func (m *Masker) RegisterMaskAnyFunc(maskType string, maskFunc MaskAnyFunc)
RegisterMaskAnyFunc registers a masking function that can be applied to any type. The function will be applied when the string set in the first argument is assigned as a tag to a field in the structure.
func (*Masker) RegisterMaskField ¶
RegisterMaskField allows you to register a mask tag to be applied to the value of a struct field or map key that matches the fieldName. If a mask tag is set on the struct field, it will take precedence.
func (*Masker) RegisterMaskFloat64Func ¶
func (m *Masker) RegisterMaskFloat64Func(maskType string, maskFunc MaskFloat64Func)
RegisterMaskFloat64Func registers a masking function for float64 values. The function will be applied when the string set in the first argument is assigned as a tag to a field in the structure.
func (*Masker) RegisterMaskIntFunc ¶
func (m *Masker) RegisterMaskIntFunc(maskType string, maskFunc MaskIntFunc)
RegisterMaskIntFunc registers a masking function for int values. The function will be applied when the string set in the first argument is assigned as a tag to a field in the structure.
func (*Masker) RegisterMaskStringFunc ¶
func (m *Masker) RegisterMaskStringFunc(maskType string, maskFunc MaskStringFunc)
RegisterMaskStringFunc registers a masking function for string values. The function will be applied when the string set in the first argument is assigned as a tag to a field in the structure.
func (*Masker) RegisterMaskUintFunc ¶
func (m *Masker) RegisterMaskUintFunc(maskType string, maskFunc MaskUintFunc)
RegisterMaskUintFunc registers a masking function for uint values. The function will be applied when the uint slice set in the first argument is assigned as a tag to a field in the structure.
func (*Masker) SetMaskChar ¶
SetMaskChar changes the character used for masking
func (*Masker) SetTagName ¶
SetTagName allows you to change the tag name from "mask" to something else.