utils

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: May 8, 2026 License: GPL-3.0 Imports: 18 Imported by: 0

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

View Source
const (
	EmailTagStart = "+"
	EmailAt       = "@"
)

Variables

This section is empty.

Functions

func ABTest added in v1.1.0

func ABTest(data, salt []byte, groups ...uint64) uint64

func BatchSlice

func BatchSlice[K any](size int, result []K) <-chan []K

func Between

func Between(data string, keys ...string) string

Between function to get content between two keys

func ByteSliceToString

func ByteSliceToString(b []byte) string

ByteSliceToString cast given bytes to string, without allocation memory

func CRC16 added in v1.1.0

func CRC16(field string) uint16

func CRC32

func CRC32(field string) uint32

func CommonString added in v1.1.0

func CommonString(str string) string

func EmailDomain added in v1.1.0

func EmailDomain(email string) string

func EmailUserName added in v1.1.0

func EmailUserName(email string) string

func GetBitLSB added in v1.1.0

func GetBitLSB(b byte, bit int) bool

func GetByteLSB added in v1.1.0

func GetByteLSB(value int64, byteNumber int) byte

func GetShortID

func GetShortID() ([]byte, error)

GetShortID return short id

func GetTinyID

func GetTinyID() ([]byte, error)

GetTinyID return tiny id

func GetUniqueID

func GetUniqueID() string

GetUniqueID return unique id

func HashName added in v1.0.8

func HashName(name string) string

func JamCRC32 added in v1.1.0

func JamCRC32(value []byte) []byte

func LSBBitValue added in v1.1.0

func LSBBitValue(bitIdx int, isSet bool) byte

func LSBBytesToInt added in v1.1.0

func LSBBytesToInt(data []byte) int

func LeftNibble added in v1.1.0

func LeftNibble(input byte) int

func MaskField

func MaskField(str string, keepUnmaskedFront int, keepUnmaskedEnd int) string

func NFDLowerString added in v1.1.0

func NFDLowerString(str string) string

func NFKDLowerString added in v1.1.0

func NFKDLowerString(str string) string

func PadMessageToBlocksize added in v1.1.0

func PadMessageToBlocksize(message []byte, blocksize int) []byte

func RandStringBytes added in v1.0.8

func RandStringBytes(n int) string

func RightNibble added in v1.1.0

func RightNibble(input byte) int

func RotateLeft added in v1.1.0

func RotateLeft(val []byte, rotations int) []byte

RotateLeft byte-rotates a byte array left by the given number of rotations

func RotateRight added in v1.1.0

func RotateRight(val []byte, rotations int) []byte

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 SanitizeEmail(email string) string

func Shingle added in v1.1.0

func Shingle(text string, k int) set.GenericDataSet[string]

func SimHash added in v1.1.0

func SimHash(data []byte) uint64

func SimHashCompare added in v1.1.0

func SimHashCompare(val1, val2 uint64) uint8

func SplitBetweenTokens added in v1.1.0

func SplitBetweenTokens(data string, keys ...string) []string

SplitBetweenTokens takes string and one or two tokens, and cuts everything between two tokens, or between two copies of first token.

func SplitByChunks

func SplitByChunks(s string, chunkSize int) []string

func UnsignedByteToInt added in v1.1.0

func UnsignedByteToInt(b byte) int

func XOR added in v1.1.0

func XOR(a1, a2 []byte) []byte

func XORAlt added in v1.1.0

func XORAlt(a1, a2 []byte) []byte

Types

type ContextKey

type ContextKey string

ContextKey contains context key

type Password

type Password string

Password describe masked field

func (Password) MarshalJSON

func (p Password) MarshalJSON() ([]byte, error)

MarshalJSON block to show value in json

func (Password) String

func (p Password) String() string

String return hide password value

func (Password) Value

func (p Password) Value() string

Value return exactly password value

type Str

type Str struct {
	Pass Password
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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