utils

package
v1.2.1 Latest Latest
Warning

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

Go to latest
Published: May 1, 2025 License: AGPL-3.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Contains

func Contains[T comparable](slice []T, item T) bool

func DurationToPtrFloat64

func DurationToPtrFloat64(source time.Duration) *float64

func Filter

func Filter[T any](slice []T, predicate func(T) bool) []T

func Float64ToDuration

func Float64ToDuration(source float64) time.Duration

func Map

func Map[T, K any](slice []T, fn func(T) K) []K

func MapAdditionalInfo

func MapAdditionalInfo(src []byte) (map[string]any, error)

func MapAdditionalInfoToByte

func MapAdditionalInfoToByte(src map[string]any) ([]byte, error)

func MapIdx

func MapIdx[T, K any](slice []T, fn func(T, int) K) []K

func MapKeyValueInterface

func MapKeyValueInterface(src map[string]interface{}) map[string]interface{}

func MapKeysSlice

func MapKeysSlice[K comparable, V, T any](m map[K]V, fn func(K, V) T) []T

func NetIPToString

func NetIPToString(ip net.IP) string

func NetURLToString

func NetURLToString(u *url.URL) string

func NumberSequence

func NumberSequence(start int) iter.Seq[int]

func P

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

P returns a pointer to the value passed as an argument.

func ParseJSONResponse

func ParseJSONResponse(body *http.Response, target any) error

Helper function to decode JSON response

func PgDateToTime

func PgDateToTime(pgDate pgtype.Date) time.Time

func PgTimestampToTime

func PgTimestampToTime(t pgtype.Timestamp) time.Time

func PgTimestampToTimePtr

func PgTimestampToTimePtr(t pgtype.Timestamp) *time.Time

func Reduce

func Reduce[T, K any](slice []T, fn func(K, T) K, initial K) K

func ReduceIdx

func ReduceIdx[T, K any](slice []T, fn func(K, T, int) K, initial K) K

func RootDir

func RootDir() string

RootDir returns the root directory of the project.

func StringPtrToString

func StringPtrToString(source *string) string

func StringToDuration

func StringToDuration(s string) time.Duration

func StringToNetIP

func StringToNetIP(s string) net.IP

func StringToTime

func StringToTime(s string) time.Time

func StringToURL

func StringToURL(s string) *url.URL

func TimeDurationToString

func TimeDurationToString(t time.Duration) string

func TimeDurationToTimeDuration

func TimeDurationToTimeDuration(t time.Duration) time.Duration

func TimeToPgDate

func TimeToPgDate(date time.Time) (pgtype.Date, error)

func TimeToPgTimestamp

func TimeToPgTimestamp(t *time.Time) pgtype.Timestamp

func TimeToPtrTime

func TimeToPtrTime(t time.Time) *time.Time

func TimeToString

func TimeToString(t time.Time) string

func TimeToTime

func TimeToTime(t time.Time) time.Time

func TimeToTimePtr

func TimeToTimePtr(t *time.Time) *time.Time

func URLToString

func URLToString(u *url.URL) string

Helper function to parse an url to a string

func URLToURL

func URLToURL(u *url.URL) *url.URL

func UUIDToPGUUID

func UUIDToPGUUID(userID uuid.UUID) pgtype.UUID

func UUIDToString

func UUIDToString(u uuid.UUID) string

Helper function to parse a UUID to a string

Types

This section is empty.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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