xutil

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2024 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Letters          = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
	LowerLetters     = "abcdefghijklmnopqrstuvwxyz"
	Digits           = "0123456789"
	LettersAndDigits = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
	LowLettersDigits = "abcdefghijklmnopqrstuvwxyz0123456789"
)

Variables

This section is empty.

Functions

func BcryptCheckPassword

func BcryptCheckPassword(hashed, password string) (ok bool)

func BcryptGeneratePassword

func BcryptGeneratePassword(password string) (string, error)

func CtxValue

func CtxValue[T any](ctx context.Context, key interface{}) (T, bool)

func CtxValueQty

func CtxValueQty[T any](ctx context.Context, key interface{}) T

func DecimalFromString

func DecimalFromString(s string) decimal.Decimal

func FindFirst

func FindFirst[T any](arr []T, f func(T) bool) (T, bool)

func IsNil

func IsNil(v any) bool

func MD5Hex

func MD5Hex(v string) string

func MD5HexBytes

func MD5HexBytes(v []byte) string

func Pointer

func Pointer[T comparable](v T) *T

func RandBytes

func RandBytes(n int) []byte

func RandDigits

func RandDigits(n int) string

func RandLetters

func RandLetters(n int) string

func RandLettersAndDigits

func RandLettersAndDigits(n int) string

func RandLowLettersDigits

func RandLowLettersDigits(n int) string

func RandLowerLetters

func RandLowerLetters(n int) string

func RandStr

func RandStr(str string, n int) string

func RandStringPointer

func RandStringPointer(n int) *string

func RoundDecimalToTickSize

func RoundDecimalToTickSize(price decimal.Decimal, tickSize float32) decimal.Decimal

func Seconds

func Seconds[T constraints.Integer](cnt T) time.Duration

func SecondsNum

func SecondsNum[T constraints.Integer](d time.Duration) T

func SplitHostPort

func SplitHostPort(addr string) (host string, port string)

func ToList

func ToList[T, U any](tList []T, toFn ToFn[T, U], skipFn SkipToFn[T, U]) []U

Types

type SkipToFn

type SkipToFn[T, U any] func(t T, u U) bool

func SkipToNil

func SkipToNil[T any, U interface{}]() SkipToFn[*T, *U]

type ToFn

type ToFn[T, U any] func(t T) U

Jump to

Keyboard shortcuts

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