string

package
v1.0.32 Latest Latest
Warning

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

Go to latest
Published: Apr 7, 2025 License: MIT Imports: 17 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ClearEmptyStringPointer

func ClearEmptyStringPointer(v *string) *string

ClearEmptyStringPointer will set the pointer to nil if the string is not nil but an empty string

func Contains

func Contains(needle []string, haystack string, caseInsensitive bool) bool

Contains returns true if the search string is found in the slice

func FNV1Hash

func FNV1Hash(val string) uint32

FNV1Hash will take a string and return a FNV-1 hash value as a uint32

func GenerateRandomBytes

func GenerateRandomBytes(n int) ([]byte, error)

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

func GenerateRandomString(n int) (string, error)

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 InterpolateString

func InterpolateString(val string, env ...map[string]interface{}) (string, error)

InterpolateString replaces { } in string with values from environment maps.

func JSONStringify

func JSONStringify(val any, pretty ...bool) string

JSONStringify converts any value to a JSON string.

func Mask

func Mask(s string) string

Mask will mask a string by replacing the middle with asterisks.

func MaskArguments

func MaskArguments(args []string) []string

MaskArguments masks sensitive information in the given arguments.

func MaskEmail

func MaskEmail(val string) string

MaskEmail masks the email address attempting to hide sensitive information.

func MaskHeaders

func MaskHeaders(h http.Header, maskHeaders []string) map[string]string

MaskHeaders will return a stringified version of headers masking the headers passed in by name

func MaskURL

func MaskURL(urlString string) (string, error)

MaskURL returns a masked version of the URL string attempting to hide sensitive information.

func Modulo

func Modulo(value string, num int) int

Modulo will take the value and return a modulo with the num length

func NewHash

func NewHash(val ...interface{}) string

NewHash returns a hash of one or more input variables using xxhash algorithm

func NewHash64

func NewHash64(val ...interface{}) uint64

func SHA256

func SHA256(data []byte, extra ...[]byte) string

SHA256 will return a sha 256 hash of the data in hex format

func StringPointer

func StringPointer(v string) *string

StringPointer will set the pointer to nil if the string is not nil but an empty string

Types

This section is empty.

Jump to

Keyboard shortcuts

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