utils

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2019 License: ISC Imports: 11 Imported by: 5

Documentation

Index

Constants

View Source
const (
	// DefaultAlphabet default alphabet for string generation
	DefaultAlphabet = "asdfghjklqwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM1234567890"
)

Variables

This section is empty.

Functions

func AskPassword

func AskPassword(question string) (password string, err error)

AskPassword ask a password

func AskYes

func AskYes(question string, defaultYes bool) (isYes bool)

AskYes prompt a yes/no question to the prompt

func DefaultIfEmptyInt

func DefaultIfEmptyInt(v *int, defaultV int)

DefaultIfEmptyInt set the value of an int to a default if it is nulled (0)

func DefaultIfEmptyInt64

func DefaultIfEmptyInt64(v *int64, defaultV int64)

DefaultIfEmptyInt64 set the value of an int to a default if it is nulled (0)

func DefaultIfEmptyStr

func DefaultIfEmptyStr(s *string, defaultS string)

DefaultIfEmptyStr set a default for a string if it is nulled

func DefaultIfEmptyUint32

func DefaultIfEmptyUint32(v *uint32, defaultV uint32)

DefaultIfEmptyUint32 set the value of an int to a default if it is nulled (0)

func DefaultIfEmptyUint64

func DefaultIfEmptyUint64(v *uint64, defaultV uint64)

DefaultIfEmptyUint64 set the value of an int to a default if it is nulled (0)

func DefaultIfEmptyUint8

func DefaultIfEmptyUint8(v *uint8, defaultV uint8)

DefaultIfEmptyUint8 set the value of an int to a default if it is nulled (0)

func IsEmptyStr

func IsEmptyStr(s string) bool

IsEmptyStr tells if a string is empty or not

func IsEqStr

func IsEqStr(a, b string) bool

IsEqStr tells if two strings a and b are equals after trimming spaces and lowercasing

func IsInt64

func IsInt64(str string) (isInt bool, val int64)

IsInt64 check if a string is a int64

func IsPositiveInt64

func IsPositiveInt64(str string) (isInt bool, val int64)

IsPositiveInt64 check if a string is a positive integer

func RandomString

func RandomString(alphabet string, length int) (s string, err error)

RandomString generate a random string of required lenght an with requested alphabet

func RandomStringL

func RandomStringL(l int) string

RandomStringL generate a string that can be used as secrete api key

Types

type BigInt

type BigInt struct {
	big.Int
}

BigInt is composed of a big.Int, but includes a Validate() method for swagger and other convenience functions. Once created, it can be used just like a big.Int.

func NewBigInt

func NewBigInt() (i *BigInt)

NewBigInt returns a new BigInt with its Int struct field initialized

func NewBigIntFromString

func NewBigIntFromString(number string) (i *BigInt, err error)

NewBigIntFromString returns a new BigInt from a string representation

func NewBigIntFromUint64

func NewBigIntFromUint64(number uint64) (i *BigInt)

NewBigIntFromUint64 returns a new BigInt from a uint64 representation

func RequireBigIntFromString

func RequireBigIntFromString(number string) *BigInt

RequireBigIntFromString returns a new BigInt from a string representation or panics if NewBigIntFromString would have returned an error.

func (BigInt) LargerOrEqualToZero

func (b BigInt) LargerOrEqualToZero() error

LargerOrEqualToZero checks that the number is >=0

func (BigInt) LargerThanZero

func (b BigInt) LargerThanZero() error

LargerThanZero checks that the number is >=0

func (BigInt) Validate

func (b BigInt) Validate(formats strfmt.Registry) error

Validate ensures that the BigInt's value is >= 0. The actual check does not need 'formats' from swagger, which is why Validate() wraps that function.

Jump to

Keyboard shortcuts

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