utils

package
v0.0.0-...-2c781aa Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2026 License: Apache-2.0 Imports: 17 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func ABTest

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

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 CommonString

func CommonString(str string) string

func EmailDomain

func EmailDomain(email string) string

func EmailUserName

func EmailUserName(email string) string

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

func HashName(name string) string

func MaskField

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

func NFDLowerString

func NFDLowerString(str string) string

func RandStringBytes

func RandStringBytes(n int) string

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

func SanitizeEmail(email string) string

func SimHash

func SimHash(data []byte) uint64

func SimHashCompare

func SimHashCompare(val1, val2 uint64) uint8

func Sort

func Sort(values []interface{}, comparator comparator.Comparator)

Sort sorts values (in-place) with respect to the given comparator.

Uses Go's sort (hybrid of quicksort for large and then insertion sort for smaller slices).

func SplitBetweenTokens

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

SplitBetweenTokens take string and one or two tokens, and cut everything between two tokens, or between two copies of first token

func SplitByChunks

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

Types

type SafeList

type SafeList[V any] struct {
	// contains filtered or unexported fields
}

func NewSafeList

func NewSafeList[K any](data ...K) *SafeList[K]

func (*SafeList[V]) Add

func (s *SafeList[V]) Add(value V)

func (*SafeList[V]) Count

func (s *SafeList[V]) Count() int

func (*SafeList[V]) List

func (s *SafeList[V]) List() []V

func (*SafeList[V]) Reset

func (s *SafeList[V]) Reset() []V

type SafeMap

type SafeMap[K string, V any] struct {
	// contains filtered or unexported fields
}

func NewSafeMap

func NewSafeMap[K string, V any](data map[K]V) *SafeMap[K, V]

func (*SafeMap[K, V]) Exists

func (s *SafeMap[K, V]) Exists(name K) bool

func (*SafeMap[K, V]) Get

func (s *SafeMap[K, V]) Get(name K) (V, bool)

func (*SafeMap[K, V]) GetMap

func (s *SafeMap[K, V]) GetMap() map[K]V

func (*SafeMap[K, V]) Remove

func (s *SafeMap[K, V]) Remove(name K)

func (*SafeMap[K, V]) Set

func (s *SafeMap[K, V]) Set(name K, value V)

Jump to

Keyboard shortcuts

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