utils

package
v1.31.17 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2024 License: Apache-2.0 Imports: 14 Imported by: 43

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Coalesce added in v1.11.0

func Coalesce[T comparable](arr ...T) T

Coalesce returns the first non-zero element

func Deref added in v1.13.0

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

func GetEnvOrDefault

func GetEnvOrDefault(names ...string) string

GetEnvOrDefault returns the first non-empty environment variable

func Interpolate

func Interpolate(arg string, vars interface{}) string

Interpolate templatises the string using the vars as the context

func InterpolateStrings

func InterpolateStrings(arg []string, vars interface{}) []string

InterpolateStrings templatises each string in the slice using the vars as the context

func NormalizeVersion added in v1.1.1

func NormalizeVersion(version string) string

NormalizeVersion appends "v" to version string if it's not exist

func Ptr added in v1.11.0

func Ptr[T any](value T) *T

func RandomKey

func RandomKey(length int) string

func RandomString

func RandomString(length int) string

RandomString returns a random string consisting of the characters in randomChars, with the length customized by the parameter

func ShortTimestamp

func ShortTimestamp() string

ShortTimestamp returns a shortened timestamp using week of year + day of week to represent a day of the e.g. 1st of Jan on a Tuesday is 13

func Stringify added in v1.6.4

func Stringify(val any) (string, error)

Stringify converts the given value to a string. If the value is already a string, it is returned as is.

Types

type NamedLock added in v1.19.0

type NamedLock struct {
	// contains filtered or unexported fields
}

func (*NamedLock) TryLock added in v1.19.0

func (n *NamedLock) TryLock(name string, timeout time.Duration) Unlocker

type Unlocker added in v1.19.0

type Unlocker interface {
	Release()
}

Jump to

Keyboard shortcuts

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