utils

package
v0.16.0 Latest Latest
Warning

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

Go to latest
Published: Aug 5, 2024 License: Apache-2.0 Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ADD operation = "add"
	SUB operation = "sub"
	EQ  operation = "eq"
)

Variables

View Source
var ValidatorFactory = new(VFactory)

Functions

func AppendToMap

func AppendToMap(gmap map[string]interface{}, mp map[string]string)

func ConfigAs

func ConfigAs[T any](mapping map[string]any, key string) T

func Contains

func Contains[K comparable, V any](mp map[K]V, keys ...K) bool

func ContainsString

func ContainsString(s []string, v string) bool

ContainsString returns true if a string is present in string slice

func ConvertToStringMap

func ConvertToStringMap(inputs map[string]interface{}) (map[string]string, error)

func CronIntervalValidator

func CronIntervalValidator(val interface{}, _ string) error

CronIntervalValidator return a nil value when a valid cron string is passed used in gopkg.in/validator.v2

func FromEnumProto

func FromEnumProto(typeProto, enumName string) string

FromEnumProto converts models to Types defined in protobuf, TYPE_TASK -> task

func GetMyersDiff added in v0.13.0

func GetMyersDiff(src, dst []string, maxNeighbouringLines int) string

func IsPathOccupied

func IsPathOccupied(path string) (bool, error)

IsPathOccupied checks whether the targeted path is already occupied

func IsTerminal

func IsTerminal(f *os.File) bool

IsTerminal checks if file descriptor is terminal or not

func MapToList

func MapToList[V any](inputMap map[string]V) []V

func MergeAnyMaps

func MergeAnyMaps(maps ...map[string]interface{}) map[string]interface{}

func MergeMaps

func MergeMaps(maps ...map[string]string) map[string]string

MergeMaps can merge values from multiple maps into one It can also create clone of a map

func ToEnumProto

func ToEnumProto(modelType, enumName string) string

ToEnumProto converts models to Types defined in protobuf, task -> TYPE_TASK

func ValidateCronInterval

func ValidateCronInterval(val interface{}) error

ValidateCronInterval return a nil value when a valid cron string is passed

func WriteStringToFileIndexed

func WriteStringToFileIndexed() func(filePath, data string, writer io.Writer) error

Types

type AttributePath added in v0.13.0

type AttributePath string

func (AttributePath) Add added in v0.13.0

func (a AttributePath) Add(propName string) AttributePath

func (AttributePath) String added in v0.13.0

func (a AttributePath) String() string

type CmpOptions added in v0.13.0

type CmpOptions struct {
	IgnoreOrderList bool
}

type Diff added in v0.13.0

type Diff struct {
	Field string
	Diff  string
}

func GetDiffs added in v0.13.0

func GetDiffs(i1, i2 interface{}, opt *CmpOptions) ([]Diff, error)

GetDiffs compares two interfaces and returns a slice of Diff containing differences. Does not compare unexported attributes

type VFactory

type VFactory struct{}

validatorFactory, name abbreviated so that the global implementation can be called 'validatorFactory'

func (*VFactory) NewFromRegex

func (*VFactory) NewFromRegex(re, message string) survey.Validator

Jump to

Keyboard shortcuts

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