Documentation ¶
Index ¶
- Variables
- func B2S(b []byte) string
- func Contains[T comparable](arr []T, val T) bool
- func DestructureMap[K comparable, V any](mp map[K]V) ([]K, []V)
- func DifferentArray[T comparable](a []T, b []T) bool
- func EmptyChannel[T any](ch chan T)
- func Filter[T any](a []T, fn func(x T) bool) []T
- func GenerateRandomBytes(n int) ([]byte, error)
- func GenerateRandomString(s int) (string, error)
- func IsPointer(v interface{}) bool
- func IsPowerOfTwo(n int64) bool
- func IsSliceArray(v interface{}) bool
- func IsSliceArrayPointer(v interface{}) bool
- func JitterTime(lower, upper time.Duration) time.Duration
- func Map[A any, T any](a []A, fn func(x A) T) []T
- func PanicHandler(handle func(err interface{}))
- func PointerOf[T any](v T) *T
- func PrependSlice[T any](s []T, v T) []T
- func S2B(s string) (b []byte)
- func SliceIndexOf[T comparable](arr []T, val T) int
- func SliceRemove[T any](s []T, i int) []T
- func Ternary[T any](condition bool, whenTrue T, whenFalse T) T
- func ToAny(i any) any
- func ToJSON[T any](d T) []byte
- type Color
- func (c Color) GetAlpha() uint8
- func (c Color) GetBlue() uint8
- func (c Color) GetGreen() uint8
- func (c Color) GetRed() uint8
- func (c Color) ParseHex(v string, alpha uint8) (Color, error)
- func (c Color) ParseRGB(r, g, b, a uint8) Color
- func (c Color) SetAlpha(v uint8) Color
- func (c Color) SetBlue(v uint8) Color
- func (c Color) SetGreen(v uint8) Color
- func (c Color) SetRGB(r, g, b uint8) Color
- func (c Color) SetRGBA(r, g, b, a uint8) Color
- func (c Color) SetRed(v uint8) Color
- func (c Color) Sum() int32
- func (c Color) ToHex(alpha bool) string
- func (c Color) ToRGB() [3]uint8
- func (c Color) ToRGBA() [4]uint8
- type Key
- type Queue
- type Set
- type Throttler
Constants ¶
This section is empty.
Variables ¶
var BitField = bitField{}
Functions ¶
func B2S ¶
b2s converts byte slice to a string without memory allocation. See https://groups.google.com/forum/#!msg/Golang-Nuts/ENgbUzYvCuU/90yGx7GUAgAJ .
Note it may break if string and/or slice header will change in the future go versions.
func Contains ¶
func Contains[T comparable](arr []T, val T) bool
func DestructureMap ¶
func DestructureMap[K comparable, V any](mp map[K]V) ([]K, []V)
func DifferentArray ¶
func DifferentArray[T comparable](a []T, b []T) bool
func EmptyChannel ¶
func EmptyChannel[T any](ch chan T)
func GenerateRandomBytes ¶
GenerateRandomBytes returns securely generated random bytes. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func GenerateRandomString ¶
GenerateRandomString returns a URL-safe, base64 encoded securely generated random string. It will return an error if the system's secure random number generator fails to function correctly, in which case the caller should not continue.
func IsSliceArray ¶
func IsSliceArray(v interface{}) bool
func IsSliceArrayPointer ¶
func IsSliceArrayPointer(v interface{}) bool
func PanicHandler ¶
func PanicHandler(handle func(err interface{}))
func PrependSlice ¶
func PrependSlice[T any](s []T, v T) []T
func S2B ¶
S2B converts string to a byte slice without memory allocation.
Note it may break if string and/or slice header will change in the future go versions.
func SliceIndexOf ¶
func SliceIndexOf[T comparable](arr []T, val T) int
func SliceRemove ¶
Types ¶
type Color ¶
type Color int32
Color is a utility to efficiently format colors into a 32-bit integer with alpha channel support
type Set ¶
type Set[T comparable] map[T]struct{}