utils

package
v0.0.0-...-609bd80 Latest Latest
Warning

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

Go to latest
Published: Mar 11, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func FirstNonZero

func FirstNonZero[T comparable](vars ...T) T

func GetFirstOrDefault

func GetFirstOrDefault[T any](variable []T) T

GetFirstOrDefault gets the first element of a slice, or the default value of the type if the slice is empty

func ResetTimeFields

func ResetTimeFields[T any](input T) T

ResetTimeFields resets all time.Time fields in a struct to the zero value This is done when comparing structs to ignore time.Time fields, since they are not guaranteed to be equal using == (they have their own Equal() method)

func UpdateIfDiff

func UpdateIfDiff[T subsystems.SsResource](dbResource T, fetchFunc func() (T, error), updateFunc func(T) (T, error), recreateFunc func(T) error) error

UpdateIfDiff is a common function that services use to update subsystem resources if there is a diff in the database and live model.

This is the core functionality that enables repairing subsystem resources.

Types

type UpdateDbSubsystem

type UpdateDbSubsystem func(string, string, interface{}) error

UpdateDbSubsystem is a common interface that services use to update subsystem resources

Jump to

Keyboard shortcuts

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