langext

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: Apache-2.0 Imports: 13 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddToSet

func AddToSet[T comparable](set []T, add T) []T

func ArrAll

func ArrAll(arr interface{}, fn func(int) bool) bool

func ArrAllErr

func ArrAllErr(arr interface{}, fn func(int) (bool, error)) (bool, error)

func ArrAny

func ArrAny(arr interface{}, fn func(int) bool) bool

func ArrAnyErr

func ArrAnyErr(arr interface{}, fn func(int) (bool, error)) (bool, error)

func ArrEqualsExact

func ArrEqualsExact[T comparable](arr1 []T, arr2 []T) bool

func ArrFirst added in v0.0.8

func ArrFirst[T comparable](arr []T, comp func(v T) bool) (T, bool)

func ArrLast added in v0.0.8

func ArrLast[T comparable](arr []T, comp func(v T) bool) (T, bool)

func ArrNone

func ArrNone(arr interface{}, fn func(int) bool) bool

func ArrNoneErr

func ArrNoneErr(arr interface{}, fn func(int) (bool, error)) (bool, error)

func ArrUnique

func ArrUnique[T comparable](array []T) []T

func BoolCount added in v0.0.7

func BoolCount(arr ...bool) int

func BytesXOR added in v0.0.5

func BytesXOR(a []byte, b []byte) ([]byte, error)

func Coalesce

func Coalesce[T any](v *T, def T) T

func CoalesceBool

func CoalesceBool(b *bool, def bool) bool

func CoalesceInt

func CoalesceInt(i *int, def int) int

func CoalesceInt32

func CoalesceInt32(i *int32, def int32) int32

func CoalesceString

func CoalesceString(s *string, def string) string

func CoalesceStringer

func CoalesceStringer(s fmt.Stringer, def string) string

func CoalesceTime

func CoalesceTime(t *time.Time, def time.Time) time.Time

func CompareIntArr

func CompareIntArr(arr1 []int, arr2 []int) bool

func ConvertStringerArray

func ConvertStringerArray[T fmt.Stringer](inarr []T) []string

func DeRefStringer

func DeRefStringer(v fmt.Stringer) *string

func FileExists added in v0.0.5

func FileExists(filename string) bool

func ForceArray

func ForceArray[T any](v []T) []T

func FormatBool added in v0.0.5

func FormatBool(v bool, strTrue string, strFalse string) string

func FormatBytes added in v0.0.5

func FormatBytes(b int64) string

func FormatBytesToSI

func FormatBytesToSI(b uint64) string

func InArray

func InArray[T comparable](needle T, haystack []T) bool

func Indent added in v0.0.5

func Indent(str string, pad string) string

func IsNil

func IsNil(i interface{}) bool

func MapKeyArr added in v0.0.5

func MapKeyArr[T comparable, V any](v map[T]V) []T

func NewBracesUUID added in v0.0.5

func NewBracesUUID() (string, error)

func NewHexUUID added in v0.0.5

func NewHexUUID() (string, error)

func NewParensUUID added in v0.0.5

func NewParensUUID() (string, error)

func NewRawHexUUID added in v0.0.5

func NewRawHexUUID() (string, error)

func NewUUID added in v0.0.5

func NewUUID() ([16]byte, error)

func NewUpperHexUUID added in v0.0.5

func NewUpperHexUUID() (string, error)

func NumToStringOpt added in v0.0.5

func NumToStringOpt[V IntConstraint](v *V, fallback string) string

func PatchJson added in v0.0.5

func PatchJson[JV string | []byte](rawjson JV, key string, value any) (JV, error)

func PatchRemJson added in v0.0.5

func PatchRemJson[JV string | []byte](rawjson JV, key string) (JV, error)

func PrettyPrintJson added in v0.0.5

func PrettyPrintJson(str string) (string, bool)

func Ptr

func Ptr[T any](v T) *T

func PtrFloat32

func PtrFloat32(v float32) *float32

func PtrFloat64

func PtrFloat64(v float64) *float64

func PtrInt32

func PtrInt32(v int32) *int32

func PtrInt64

func PtrInt64(v int64) *int64

func RandBase62 added in v0.0.5

func RandBase62(rlen int) string

func RandBytes added in v0.0.5

func RandBytes(size int) []byte

func Range added in v0.0.7

func Range[T IntegerConstraint](start T, end T) []T

func ReverseArray

func ReverseArray[T any](v []T)

func StrLimit

func StrLimit(val string, maxlen int, suffix string) string

func StrPadLeft

func StrPadLeft(str string, pad string, padlen int) string

func StrPadRight

func StrPadRight(str string, pad string, padlen int) string

func StrRunePadLeft added in v0.0.5

func StrRunePadLeft(str string, pad string, padlen int) string

func StrRunePadRight added in v0.0.5

func StrRunePadRight(str string, pad string, padlen int) string

func StrSplit

func StrSplit(val string, sep string, allowEmpty bool) []string

func TryPrettyPrintJson added in v0.0.5

func TryPrettyPrintJson(str string) string

Types

type A added in v0.0.5

type A []any

type ComplexConstraint added in v0.0.6

type ComplexConstraint interface {
	~complex64 | ~complex128
}

type FloatConstraint added in v0.0.6

type FloatConstraint interface {
	~float32 | ~float64
}

type H added in v0.0.5

type H map[string]any

type IntConstraint added in v0.0.5

type IntConstraint interface {
	int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64
}

type IntegerConstraint added in v0.0.6

type IntegerConstraint interface {
	SignedConstraint | UnsignedConstraint
}

type NumberConstraint added in v0.0.6

type NumberConstraint interface {
	IntegerConstraint | FloatConstraint
}

type OrderedConstraint added in v0.0.6

type OrderedConstraint interface {
	IntegerConstraint | FloatConstraint | ~string
}

type SignedConstraint added in v0.0.6

type SignedConstraint interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

type UnsignedConstraint added in v0.0.6

type UnsignedConstraint interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

Jump to

Keyboard shortcuts

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