Documentation
¶
Overview ¶
Package utils is a legacy aggregate of byte, string, hash, context, password, slice, semver, and tokenizer helpers.
New helpers should live in the package that owns the concept. Existing exports remain for compatibility.
Index ¶
- Constants
- func ABTest(data, salt []byte, groups ...uint64) uint64
- func BatchSlice[K any](size int, result []K) <-chan []K
- func Between(data string, keys ...string) string
- func ByteSliceToString(b []byte) string
- func CRC16(field string) uint16
- func CRC32(field string) uint32
- func CommonString(str string) string
- func EmailDomain(email string) string
- func EmailUserName(email string) string
- func GetBitLSB(b byte, bit int) bool
- func GetByteLSB(value int64, byteNumber int) byte
- func GetShortID() ([]byte, error)
- func GetTinyID() ([]byte, error)
- func GetUniqueID() string
- func HashName(name string) string
- func JamCRC32(value []byte) []byte
- func LSBBitValue(bitIdx int, isSet bool) byte
- func LSBBytesToInt(data []byte) int
- func LeftNibble(input byte) int
- func MaskField(str string, keepUnmaskedFront int, keepUnmaskedEnd int) string
- func NFDLowerString(str string) string
- func NFKDLowerString(str string) string
- func PadMessageToBlocksize(message []byte, blocksize int) []byte
- func RandStringBytes(n int) string
- func RightNibble(input byte) int
- func RotateLeft(val []byte, rotations int) []byte
- func RotateRight(val []byte, rotations int) []byte
- func SafeGet[T any](ptr *T, defaultValue T) T
- func SanitizeEmail(email string) string
- func Shingle(text string, k int) set.GenericDataSet[string]
- func SimHash(data []byte) uint64
- func SimHashCompare(val1, val2 uint64) uint8
- func SplitBetweenTokens(data string, keys ...string) []string
- func SplitByChunks(s string, chunkSize int) []string
- func UnsignedByteToInt(b byte) int
- func XOR(a1, a2 []byte) []byte
- func XORAlt(a1, a2 []byte) []byte
- type ContextKey
- type Password
- type Str
Constants ¶
const ( EmailTagStart = "+" EmailAt = "@" )
Variables ¶
This section is empty.
Functions ¶
func BatchSlice ¶
func ByteSliceToString ¶
ByteSliceToString cast given bytes to string, without allocation memory
func CommonString ¶ added in v1.1.0
func EmailDomain ¶ added in v1.1.0
func EmailUserName ¶ added in v1.1.0
func GetByteLSB ¶ added in v1.1.0
func LSBBitValue ¶ added in v1.1.0
func LSBBytesToInt ¶ added in v1.1.0
func LeftNibble ¶ added in v1.1.0
func NFDLowerString ¶ added in v1.1.0
func NFKDLowerString ¶ added in v1.1.0
func PadMessageToBlocksize ¶ added in v1.1.0
func RandStringBytes ¶ added in v1.0.8
func RightNibble ¶ added in v1.1.0
func RotateLeft ¶ added in v1.1.0
RotateLeft byte-rotates a byte array left by the given number of rotations
func RotateRight ¶ added in v1.1.0
RotateRight byte-rotates a byte array left by the given number of rotations
func SafeGet ¶
func SafeGet[T any](ptr *T, defaultValue T) T
SafeGet return value of pointer, and return default value if it nil
func SanitizeEmail ¶ added in v1.1.0
func SimHashCompare ¶ added in v1.1.0
func SplitBetweenTokens ¶ added in v1.1.0
SplitBetweenTokens takes string and one or two tokens, and cuts everything between two tokens, or between two copies of first token.
func SplitByChunks ¶
func UnsignedByteToInt ¶ added in v1.1.0
Types ¶
type Password ¶
type Password string
Password describe masked field
func (Password) MarshalJSON ¶
MarshalJSON block to show value in json