helpers

package
v0.0.0-...-c341a93 Latest Latest
Warning

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

Go to latest
Published: Feb 26, 2025 License: Apache-2.0 Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var EmptyStruct struct{}

Functions

func DatesEqual

func DatesEqual(d1, d2 *time.Time) bool

DatesEqual compares 2 *time.Time. If either is nil, returns false. Otherwise, returns true if the years, months, and days are the same.

func OneToMany

func OneToMany[valT Mapper[keyT, retT], keyT comparable, retT any](keys []keyT, vals []valT) [][]retT

OneToMany takes a list of keys and a list of values which map one-to-many (key-to-value) ex: vals could be a list of contract numbers where more than one value has the same mapped ID

func OneToOne

func OneToOne[valT Mapper[keyT, retT], keyT comparable, retT any](keys []keyT, vals []valT) []retT

OneToOne takes a list of keys and a list of values which map one-to-one (key-to-value)

func PointerTo

func PointerTo[T any](val T) *T

PointerTo takes in any item and returns a pointer to that item

Types

type Mapper

type Mapper[keyT comparable, valT any] interface {
	GetMappingKey() keyT
	GetMappingVal() valT // in cases where the return value is not embedded, this should simply be a pointer to the original struct
}

Mapper can be implemented so that it can use OneToMany below to map a flat list of values to a flat list of their relative keys

Jump to

Keyboard shortcuts

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