Documentation ¶
Index ¶
- func ArraysEqual[T comparable](a *[]T, b *[]T) bool
- func ExtractTypeName(t interface{}) string
- func InArrayOrSlice[T comparable](sliceOrArray []T, element T) bool
- func MapsEqual[K comparable, V comparable](a *map[K]V, b *map[K]V) bool
- func PointerValuesEqual[T comparable](a *T, b *T) bool
- func StringToSnakeCase(str string) string
- func UniqueArrayOrSlice[T comparable](sliceOrArray []T) []T
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func ArraysEqual ¶ added in v0.0.3
func ArraysEqual[T comparable](a *[]T, b *[]T) bool
ArraysEqual checks if two arrays are equal and returns the result. Note that this function requires comparable types!
The arguments are passed by reference to allow nil comparisons. When nil is passed, true will be returned if both slice references are nil. If only one slice is nil, the result will be false.
Note that the order of elements is also checked.
func ExtractTypeName ¶ added in v0.0.3
func ExtractTypeName(t interface{}) string
ExtractTypeName extracts the type name of the struct/interface of an variable.
This means, something like: *entities.Guild Results in: Guild
func InArrayOrSlice ¶ added in v0.3.0
func InArrayOrSlice[T comparable](sliceOrArray []T, element T) bool
InArrayOrSlice checks if the provided element is in the provided sliceOrArray.
func MapsEqual ¶ added in v0.0.3
func MapsEqual[K comparable, V comparable](a *map[K]V, b *map[K]V) bool
MapsEqual checks if two maps have the same content Note that this function requires comparable types for key and value!
The arguments are passed by reference to allow nil comparisons. When nil is passed, true will be returned if both maps references are nil. If only one map reference is nil, the result will be false.
Note that the order of elements is ignored.
func PointerValuesEqual ¶ added in v0.3.0
func PointerValuesEqual[T comparable](a *T, b *T) bool
PointerValuesEqual compares two comparable variables which values are pointers. The function first checks for nil and then dereferences the pointers.
func StringToSnakeCase ¶
StringToSnakeCase turns the given string into snake-case.
Examples:
- ThisIsATest => this_is_a_test
func UniqueArrayOrSlice ¶ added in v0.3.0
func UniqueArrayOrSlice[T comparable](sliceOrArray []T) []T
UniqueArrayOrSlice returns the passed slice or array without any duplicates in it.
Types ¶
This section is empty.