util

package
v0.5.0 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: 7 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func BoolToStr

func BoolToStr(b bool, ifTrue string, ifFalse string) string

func DefaultBoolIfNil

func DefaultBoolIfNil(b *bool, defaultB bool) bool

func DefaultIfError

func DefaultIfError(fn StringerWithError, defaultS string) string

func DefaultIfNil

func DefaultIfNil(s *string, defaultS string) string

func DefaultIfNotInMap added in v0.2.0

func DefaultIfNotInMap(m map[string]string, key string, def string) string

func DefaultString

func DefaultString(s string, defaultS string) string

func EnsureMap added in v0.4.0

func EnsureMap[T comparable, U any](m map[T]U) map[T]U

EnsureMap takes a map as input and guarantees that it is not nil. If the input map is nil, it initializes and returns a new empty map of the same type. If the input map is already initialized, it simply returns the map unchanged.

func GetFromMap added in v0.4.0

func GetFromMap[K comparable, V any](in map[K]V, key K) (V, bool)

func GetResourceOwner

func GetResourceOwner(owner *string) (string, string, error)

func IsEmptyString

func IsEmptyString(s *string) bool

func LabelArrayToMap

func LabelArrayToMap(labels []string) map[string]string

func LabelMapToArray

func LabelMapToArray(labels *map[string]string) []string

func LabelsMatchLabelSelector

func LabelsMatchLabelSelector(labels map[string]string, labelSelector map[string]string) bool

func Max added in v0.4.0

func Max[N Number](n1, n2 N) N

func MergeLabels

func MergeLabels(labels ...map[string]string) map[string]string

func Min added in v0.4.0

func Min[N Number](n1, n2 N) N

func Must

func Must(err error)

func MustString

func MustString(fn StringerWithError) string

func OwnerQueryParamsToArray

func OwnerQueryParamsToArray(ownerQueryParam *string) []string

func ResourceOwner added in v0.4.0

func ResourceOwner(kind string, name string) string

func SetResourceOwner

func SetResourceOwner(kind string, name string) *string

func SingleQuote

func SingleQuote(input []string) []string

func SliceToPtrWithNilDefault

func SliceToPtrWithNilDefault(s []string) *[]string

func TimeStampString added in v0.4.0

func TimeStampString() string

func TimeStampStringPtr

func TimeStampStringPtr() *string

func ToPtrWithNilDefault added in v0.4.0

func ToPtrWithNilDefault[T comparable](i T) *T

Types

type Duration

type Duration time.Duration

func (Duration) MarshalJSON

func (d Duration) MarshalJSON() ([]byte, error)

func (Duration) String

func (d Duration) String() string

func (*Duration) UnmarshalJSON

func (d *Duration) UnmarshalJSON(b []byte) error

type Number added in v0.4.0

type Number interface {
	constraints.Integer | constraints.Float
}

type StringerWithError

type StringerWithError func() (string, error)

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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