utils

package
v0.0.0-...-aee0edf Latest Latest
Warning

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

Go to latest
Published: Jul 16, 2025 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanTag

func CleanTag(value string) string

func DerefType

func DerefType(value reflect.Type) reflect.Type

Dereferences the value if it is a pointer.

func DerefTypeOf

func DerefTypeOf(value any) reflect.Type

Dereferences the value if it is a pointer.

func DerefValue

func DerefValue(value reflect.Value) reflect.Value

Dereferences the value if it is a pointer.

func DerefValueOf

func DerefValueOf(value any) reflect.Value

Dereferences the value if it is a pointer.

func GetRandomFrom

func GetRandomFrom[T any](values ...T) T

func InstantiateSliceElement

func InstantiateSliceElement[T any](value *[]T) *T

func IsInterface

func IsInterface(value reflect.Value) bool

Reports whether value is interface.

func IsMap

func IsMap(value reflect.Value) bool

Reports whether value is map.

func IsNil

func IsNil(value reflect.Value) bool

Reports whether value is nil.

func IsPointer

func IsPointer(value reflect.Value) bool

Reports whether value is pointer.

func IsSlice

func IsSlice(value reflect.Value) bool

Reports whether value is slice.

func IsStruct

func IsStruct(value reflect.Value) bool

Reports whether value is struct.

func Len

func Len(value reflect.Value) int

Returns v's length.

func LenOf

func LenOf(value any) int

Returns v's length.

func MapCopy

func MapCopy[K comparable, V any](value map[K]V) map[K]V

func MapKeys

func MapKeys[K comparable, V any](container map[K]V) []K

func MapSlice

func MapSlice[M any, N any](slice []M, handler func(element M) N) []N

func MapValues

func MapValues[K comparable, V any](container map[K]V) []V

func NewRandomGenerator

func NewRandomGenerator() *rand.Rand

func ParseBool

func ParseBool(value string) (bool, error)

Returns the boolean value represented by the string.

func PointerOf

func PointerOf[T any](value T) *T

func SafeDivide

func SafeDivide[T Number](v1, v2 T) T

func SaveToFile

func SaveToFile(filename string, data []byte) error

func SliceToMap

func SliceToMap[M any, K comparable, V any](slice []M, keyHandler func(element M) (K, V)) map[K]V

func SliceToMultimap

func SliceToMultimap[K comparable, V any](slice []V, keyHandler func(element V) K) map[K][]V

Types

type Number

type Number interface {
	float32 | float64 | int | int8 | int16 | int32 | int64 | uint | uint8 | uint16 | uint32 | uint64
}

type Vector2D

type Vector2D struct {
	X, Y float64
}

func (*Vector2D) Distance

func (vector *Vector2D) Distance() float64

func (*Vector2D) String

func (vector *Vector2D) String() string

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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