utils

package
v0.0.0-...-151615b Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2025 License: Apache-2.0 Imports: 14 Imported by: 4

Documentation

Index

Constants

View Source
const (
	GRPCServiceTimeout = 3 * time.Minute
)

Variables

This section is empty.

Functions

func Contains

func Contains[T comparable](slice []T, value T) bool

Contains checks if the given slice contains the given value.

func ConvertTypeToString

func ConvertTypeToString[T any](value T) string

ConvertTypeToString converts the given value to string.

func GenerateRandomNumber

func GenerateRandomNumber(lower, upper int64) (int64, error)

GenerateRandomNumber generates a random positive number between lower and upper. The return value should be between [lower, upper), and error is nil when success. If the error is not nil, the return value is 0.

func GetFunctionInfo

func GetFunctionInfo(f interface{}, getInfoFn func() string) string

GetFunctionInfo take a function as interface{} and a function for getting the info.

func GetFunctionName

func GetFunctionName(f interface{}) string

GetFunctionName returns the <package>.<function name> of the given function.

func GetFunctionPath

func GetFunctionPath(f interface{}) string

GetFunctionPath returns the full path of the given function.

func GetGRPCAddress

func GetGRPCAddress(address string) string

func IsStringInSlice

func IsStringInSlice(list []string, item string) bool

IsStringInSlice checks if the given string 'item' is present in the 'list' of strings.

func RandomID

func RandomID(randomIDLenth int) string

RandomID returns a random string with the specified length. If the specified length is less than or equal to 0, the default length will be used.

func SortKeys

func SortKeys[K constraints.Ordered, V any](mapObj map[K]V) ([]K, error)

SortKeys sorts the keys of a map in ascending order.

func UUID

func UUID() string

UUID returns a random UUID string.

Types

This section is empty.

Jump to

Keyboard shortcuts

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