utils

package
v0.0.0-...-3b26d93 Latest Latest
Warning

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

Go to latest
Published: Apr 5, 2024 License: Apache-2.0 Imports: 17 Imported by: 12

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CleanPath

func CleanPath(path string) string

func EnvBool

func EnvBool(name string, def bool) bool

EnvBool looks up environment variable by name and converts the string value to bool. It returns default value if env does not exist or conversion to bool fails

func FindAnyWith

func FindAnyWith[T any](items []T, matchFn func(item *T) bool) *T

func FindInSlice

func FindInSlice[T comparable](items []T, x T) int

FindInSlice finds an item in a slice and returns the index. It will return -1 if not found

func FromPbJson

func FromPbJson[T proto.Message](reader io.Reader, obj T) error

func FromPbToYaml

func FromPbToYaml[T proto.Message](writer io.Writer, obj T) error

func FromYamlToPb

func FromYamlToPb[T proto.Message](reader io.Reader, obj T) error

func Int64

func Int64(max int64) int64

Int64 returns a cryptographically secure 64 bit random number

func Introspect

func Introspect(v interface{}) string

Serialize an interface using JSON or return error string

func IsEmptyString

func IsEmptyString(s string) bool

func MapStruct

func MapStruct[T any](source interface{}, dest *T) error

func NewUniqueId

func NewUniqueId() string

func SafelyGetValue

func SafelyGetValue[T any](target *T) T

func ToPbJson

func ToPbJson[T proto.Message](obj T, indent string) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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