utils

package
v0.0.0-...-6c83f61 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: GPL-3.0 Imports: 7 Imported by: 0

Documentation

Overview

Package utils provides some general purpose functions

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetFormFile

func GetFormFile(form *multipart.Form, field string) ([]byte, error)

func MapGetKeyAsType

func MapGetKeyAsType[T any](key string, m map[string]any) (T, error)

MapGetKeyAsType retrieves a key from a map and converts it to a given type

func MapValues

func MapValues[T comparable, U any](input map[T]U) []U

MapValues returns a slice of all values

func SendCached

func SendCached(c *fiber.Ctx, img []byte) error

func SliceContainsAny

func SliceContainsAny[T comparable](slice []T, items []T) bool

SliceContainsAny checks if a slice contains any of the given items

func SliceDereference

func SliceDereference[T any](input []*T) []T

SliceDereference converts a []*T slice to []T

func SliceFilter

func SliceFilter[T any](input []T, filter func(T) bool) []T

SliceFilter returns a new slice consisting of elements that passed the filter function

func SliceFind

func SliceFind[T any](input []T, equal func(T) bool) (T, bool)

SliceFind returns the first item determined by the equal function, the null value not found The second argument returns true if found, false otherwise

func SliceFlatten

func SliceFlatten[T any](slice [][]T) []T

SliceFlatten flattens 2D slices to 1D

func SliceMap

func SliceMap[T any, U any](input []T, mapFunc func(T) U) []U

SliceMap maps a slice of type T to a slice of type U

func SliceMerge

func SliceMerge[T any](slices ...[]T) []T

SliceMerge merges multiple slices together

func SliceReference

func SliceReference[T any](input []T) []*T

SliceReference converts a []T slice to []*T

func SliceRepeat

func SliceRepeat[T any](value T, count int) []T

SliceRepeat constructs a slice of length `count` of element `value`

func SliceSanitize

func SliceSanitize[T comparable](slice []T) []T

SliceSanitize removes all null values according to T{}

func SliceToMap

func SliceToMap[T any, U comparable](input []T, toKey func(T) U) map[U]T

SliceToMap maps a slice to a map with key -> result of toKey function value -> slice entry

func SliceUnique

func SliceUnique[T comparable](input []T) []T

SliceUnique filters out all duplicate elements

Types

This section is empty.

Jump to

Keyboard shortcuts

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