Documentation
¶
Index ¶
- func ClearEmptyStringPointer(v *string) *string
- func Contains(needle []string, haystack string, caseInsensitive bool) bool
- func FNV1Hash(val string) uint32
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomString(n int) (string, error)
- func GenerateRandomStringFrom(letters string, n int) (string, error)
- func Interpolate(val string, lookup LookupFunc) (string, error)
- func InterpolateString(val string, env ...map[string]any) (any, error)
- func JSONStringify(val any, pretty ...bool) string
- func Mask(s string) string
- func MaskArguments(args []string) []string
- func MaskEmail(val string) string
- func MaskHeaders(h http.Header, maskHeaders []string) map[string]string
- func MaskURL(urlString string) (string, error)
- func MaskValue(arg string) string
- func Modulo(value string, num int) int
- func NewHash(val ...interface{}) string
- func NewHash64(val ...interface{}) uint64
- func SHA256(data []byte, extra ...[]byte) string
- func StringPointer(v string) *string
- type LookupFunc
- type MaskedString
- func (ms MaskedString) Bytes() []byte
- func (ms MaskedString) GoString() string
- func (ms MaskedString) MarshalJSON() ([]byte, error)
- func (ms MaskedString) MarshalText() ([]byte, error)
- func (ms MaskedString) MarshalYAML() (any, error)
- func (ms MaskedString) String() string
- func (ms MaskedString) Text() string
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ClearEmptyStringPointer ¶
ClearEmptyStringPointer will set the pointer to nil if the string is not nil but an empty string
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomString ¶
GenerateRandomString returns a securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomStringFrom ¶ added in v1.0.79
func Interpolate ¶ added in v1.0.97
func Interpolate(val string, lookup LookupFunc) (string, error)
Interpolate replaces { } in string with values from lookup function.
func InterpolateString ¶
InterpolateString replaces { } in string with values from environment maps.
func JSONStringify ¶
JSONStringify converts any value to a JSON string.
func MaskArguments ¶
MaskArguments masks sensitive information in the given arguments.
func MaskHeaders ¶
MaskHeaders will return a stringified version of headers masking the headers passed in by name
func MaskURL ¶
MaskURL returns a masked version of the URL string attempting to hide sensitive information.
func NewHash ¶
func NewHash(val ...interface{}) string
NewHash returns a hash of one or more input variables using xxhash algorithm
func StringPointer ¶
StringPointer will set the pointer to nil if the string is not nil but an empty string
Types ¶
type LookupFunc ¶ added in v1.0.97
type MaskedString ¶ added in v1.0.79
type MaskedString string
MaskedString is a custom string type that masks its value when formatted or text-marshaled.
func NewMaskedString ¶ added in v1.0.79
func NewMaskedString(s string) MaskedString
NewMaskedString returns a string using the special type MaskedString.
func (MaskedString) Bytes ¶ added in v1.0.79
func (ms MaskedString) Bytes() []byte
Bytes returns the unmasked byte slice value.
func (MaskedString) GoString ¶ added in v1.0.79
func (ms MaskedString) GoString() string
GoString implements fmt.GoStringer so %#v also prints masked.
func (MaskedString) MarshalJSON ¶ added in v1.0.79
func (ms MaskedString) MarshalJSON() ([]byte, error)
MarshalJSON implements json.Marshaler for real (unmasked) JSON output.
func (MaskedString) MarshalText ¶ added in v1.0.79
func (ms MaskedString) MarshalText() ([]byte, error)
MarshalText implements encoding.TextMarshaler for masked text output.
func (MaskedString) MarshalYAML ¶ added in v1.0.79
func (ms MaskedString) MarshalYAML() (any, error)
MarshalYAML implements yaml.Marshaler for real (unmasked) YAML output.
func (MaskedString) String ¶ added in v1.0.79
func (ms MaskedString) String() string
String implements fmt.Stringer to return a masked representation.
func (MaskedString) Text ¶ added in v1.0.79
func (ms MaskedString) Text() string
Text returns the unmasked text value.