Documentation ¶
Index ¶
- func IfElse[T comparable](cond bool, valTrue, valFalse T) T
- func MustReadFile(filePath string) []byte
- func MustTime(in string) time.Time
- func MustTimeFn(in string) func() time.Time
- func MustTimePtr(in string) *time.Time
- func MustUUID(in string) uuid.UUID
- func MustUUIDFn(in string) func() uuid.UUID
- func Neg[T NumberPosNeg](n T) T
- func NilOrBool(nilPercent int) *bool
- func NilOrDecimalBig(nilPercent int, allowNegative bool, beforeCommaDigits int, ...) *decimal.Big
- func NilOrFloat32(nilPercent int, maxValBeforeComma uint) *float32
- func NilOrInt8(allowNegative bool, nilPercent int, maxValue int) *int8
- func NilOrInt8Flag(nilPercent int) *int8
- func NilOrIntn(nilPercent int, maxValue int) *int
- func NilOrRandStrItem(nilPercent int, items ...string) *string
- func NilOrStr(nilPercent int, str string) *string
- func NilOrTime(nilPercent int, isPast bool) *time.Time
- func NilOrUInt8(allowNegative bool, nilPercent int, maxValue int) *uint8
- func NonEmptyNaturalIntSlice(nums []int) []int
- func NonNeg[T NumberPosNeg](n T) T
- func NonPos[T NumberPosNeg](n T) T
- func NotNilRnd(rnd *rand.Rand) *rand.Rand
- func Pos[T NumberPosNeg](n T) T
- func Ptr[T any](in T) *T
- func RandDecimalBig(allowNegative bool, beforeCommaDigits int, afterCommaDigits int) decimal.Big
- func RandInt8Flag() int8
- func RandItemInt(items ...int) int
- func RandItemStr(items ...string) string
- type NumberPosNeg
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IfElse ¶
func IfElse[T comparable](cond bool, valTrue, valFalse T) T
IfElse returns the value of the valTrue if the condition is true and returns valFalse otherwise.
func MustReadFile ¶
MustReadFile reads the file and returns the content byte slice. nolint:gosec
func MustTime ¶
MustTime parses a time string of format RFC3339 and returns a time. Panics if fails.
func MustTimeFn ¶
MustTimeFn creates a time function with mocked (time.RFC3339 formatted string)time value to be returned. Panics if fails.
func MustTimePtr ¶
MustTimePtr parses a time string of format RFC3339 and returns a pointer to a time. Panics if fails.
func MustUUID ¶
MustUUID parses uuid's string representation and returns a uuid.UUID. Panics if fails.
func MustUUIDFn ¶
MustUUIDFn create uuid function with mocked uuid. Panics if fails.
func NilOrDecimalBig ¶
func NilOrFloat32 ¶
func NilOrInt8Flag ¶
func NilOrRandStrItem ¶
func NilOrStr ¶
NilOrStr returns a nil or pointer to a given string value. Used to construct nilPercent of invalid null.String values using FromStringPtr() method. e.g.: null.StringFromPtr(testvalue.NilOrStr(10, randomstring.UTF8Printable(20, rnd))) will return 10% of NULL DB values and 90% of random UTF strings of length 1-20
null.StringFromPtr(testvalue.NilOrStr(10, testvalue.RandItemStr("ABC", "DEF"))) will fill out a NULLABLE DB field of enum: ["ABC", "DEF"]
func NonEmptyNaturalIntSlice ¶
func RandDecimalBig ¶
func RandInt8Flag ¶
func RandInt8Flag() int8