utils

package
v0.31.0 Latest Latest
Warning

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

Go to latest
Published: Apr 25, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Base64Encode added in v0.27.0

func Base64Encode(message []byte) string

Base64Encode encodes a []byte to a base64 representation as string

func CmdHelp

func CmdHelp(cmd *cobra.Command, _ []string)

CmdHelp is used to explicitly set the Run function for non-leaf commands to the command help function, so that we can catch invalid commands This is a workaround needed due to the open issue on the Cobra repo: https://github.com/spf13/cobra/issues/706

func ConvertInt64PToFloat64P added in v0.2.3

func ConvertInt64PToFloat64P(i *int64) *float64

ConvertInt64PToFloat64P converts an int64 pointer to a float64 pointer This function will return nil if the input is nil

func ConvertTimePToDateTimeString added in v0.22.0

func ConvertTimePToDateTimeString(t *time.Time) string

ConvertTimePToDateTimeString converts a time.Time pointer to a string represented as "2006-01-02 15:04:05" This function will return an empty string if the input is nil

func Float64Ptr added in v0.2.3

func Float64Ptr(f float64) *float64

Float64Ptr returns a pointer to a float64 Needed because the Ptr function only returns pointer to float

func Int64Ptr added in v0.2.3

func Int64Ptr(i int64) *int64

Int64Ptr returns a pointer to an int64 Needed because the Ptr function only returns pointer to int

func JoinStringKeys added in v0.21.0

func JoinStringKeys(m map[string]any, sep string) string

JoinStringKeys concatenates the string keys of a map, each separatore by the [sep] string.

func JoinStringKeysPtr added in v0.21.0

func JoinStringKeysPtr(m map[string]any, sep string) string

JoinStringKeysPtr concatenates the string keys of a map pointer, each separatore by the [sep] string.

func JoinStringPtr added in v0.24.0

func JoinStringPtr(vals *[]string, sep string) string

JoinStringPtr concatenates the strings of a string slice pointer, each separatore by the [sep] string.

func Ptr

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

Ptr Returns the pointer to any type T

func PtrByteSizeDefault added in v0.24.0

func PtrByteSizeDefault(size *int64, defaultValue string) string

PtrByteSizeDefault return the value of an in64 pointer to a string representation of bytesize. If the pointer is nil, it returns the [defaultValue].

func PtrString added in v0.20.0

func PtrString[T any](t *T) string

PtrString creates a string representation of a passed object pointer or returns an empty string, if the passed object is _nil_.

func PtrStringDefault added in v0.24.0

func PtrStringDefault[T any](v *T, defaultValue string) string

PtrStringDefault return the value of a pointer [v] as string. If the pointer is nil, it returns the [defaultValue].

func PtrValue added in v0.26.0

func PtrValue[T any](t *T) (r T)

PtrValue returns the dereferenced value if the pointer is not nil. Otherwise the types zero element is returned

func Truncate added in v0.31.0

func Truncate(s *string, maxLen int) string

Truncate trims the passed string (if it is not nil). If the input string is longer than the given length, it is truncated to _maxLen_ and a ellipsis (…) is attached. Therefore the resulting string has at most length _maxLen-1_

func ValidateURLDomain added in v0.12.0

func ValidateURLDomain(value string) error

func ValidateUUID

func ValidateUUID(value string) error

ValidateUUID validates if the provided string is a valid UUID

Types

This section is empty.

Jump to

Keyboard shortcuts

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