mask

package
v0.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 2, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DefaultMasker

func DefaultMasker[T any](m Masker[T]) defaultMasker

DefaultMasker takes a masker and return the default masker associated with.

func Email

func Email(email string, opts ...func(*Config[EmailConfig])) (string, error)

func IPv4Addr

func IPv4Addr(ip string, opts ...func(*Config[IPv4AddrConfig])) (string, error)

func Of

func Of(kind string) (m defaultMasker, found bool)

Of returns the specific default masker of the given kind.

func Register

func Register(kind string, m defaultMasker)

Register registers a default masker to handle a specific kind of sensitive data.

Types

type Config

type Config[T any] struct {
	Symbol rune
	Kind   T
}

Config is the generic mask config required by any registered mask.

The Type parameter represents the mask specific config.

func DefaultConfig

func DefaultConfig[T any](t T) Config[T]

DefaultConfig wraps the specific mask config and returns a generic one with defaults.

type EmailConfig

type EmailConfig struct {
	MaskDomain bool // default false
}

type IPv4AddrConfig

type IPv4AddrConfig struct {
	OctetsToMask   int  // default 1
	OneOctetSymbol bool // default false
}

type Masker

type Masker[T any] func(val string, opts ...func(*Config[T])) (string, error)

Masker presents the function type that masks must satisfy.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL