Documentation
¶
Index ¶
- Constants
- Variables
- func AlphaString(n int) (string, error)
- func AlphaStringRange(min, max int) (string, error)
- func ChoiceInt(choices []int) (int, error)
- func ChoiceString(choices []string) (string, error)
- func Convert(src interface{}, dest interface{}) error
- func Exist(path string) bool
- func FolderSize(folder string, excludes_suffixes []string) int64
- func HasSuffix(fn, suffix string) bool
- func IntRange(min, max int) (int, error)
- func Namespace(uri string) (string, error)
- func NamespaceKey(uri string) (string, string)
- func NumberInt(v interface{}) (int, error)
- func PathFolders(path string) []string
- func QrcodeKey(uri string, size int) string
- func ResizeKey(uri string, resize string) string
- func SignString(secret, message string) string
- func String(n int, charset string) (string, error)
- func StringRange(min, max int, charset string) (string, error)
- type AtomicInt64
- type Background
- type Choice
- type Email
- type Length
- type Match
- type Max
- type MaxSize
- type Min
- type MinSize
- type Rect
- type Required
- type Signature
- type Validator
Constants ¶
const ( // Set of characters to use for generating random strings Alphabet = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz" Numerals = "1234567890" Alphanumeric = Alphabet + Numerals Ascii = Alphanumeric + "~!@#$%^&*()-_+={}[]\\|<,>.?/\"';:`" )
Variables ¶
var MinMaxError = errors.New("Min cannot be greater than max.")
Functions ¶
func AlphaString ¶
AlphaString returns a random alphanumeric string n characters long.
func AlphaStringRange ¶
AlphaRange returns a random alphanumeric string at least min and no more than max characters long.
func ChoiceString ¶
ChoiceString returns a random selection from an array of strings.
func FolderSize ¶
func NamespaceKey ¶
func PathFolders ¶
func SignString ¶
Types ¶
type AtomicInt64 ¶
type AtomicInt64 struct {
// contains filtered or unexported fields
}
func NewAtomicInt64 ¶
func NewAtomicInt64(init int64) *AtomicInt64
func (*AtomicInt64) Caculate ¶
func (ai *AtomicInt64) Caculate(delta int64) int64
func (*AtomicInt64) Value ¶
func (ai *AtomicInt64) Value() int64
type Background ¶
func (*Background) Work ¶
func (b *Background) Work(fn func())
type Choice ¶
type Choice struct { Weight int Item interface{} }
A Choice contains a generic item and a weight controlling the frequency with which it will be selected.
func WeightedChoice ¶
WeightedChoice used weighted random selection to return one of the supplied choices. Weights of 0 are never selected. All other weight values are relative. E.g. if you have two choices both weighted 3, they will be returned equally often; and each will be returned 3 times as often as a choice weighted 1.
type Email ¶
type Email struct {
*Match
}
func ValidEmail ¶
func ValidEmail() Email
func (Email) DefaultMessage ¶
type Length ¶
type Length struct {
N int
}
Requires an array or string to be exactly a given length.
func ValidLength ¶
func (*Length) DefaultMessage ¶
func (*Length) IsSatisfied ¶
type Match ¶
Requires a string to match a given regex.
func ValidMatch ¶
func (*Match) DefaultMessage ¶
func (*Match) IsSatisfied ¶
type MaxSize ¶
type MaxSize struct {
Max int
}
Requires an array or string to be at most a given length.
func ValidMaxSize ¶
func (*MaxSize) DefaultMessage ¶
func (*MaxSize) IsSatisfied ¶
type MinSize ¶
type MinSize struct {
Min int
}
Requires an array or string to be at least a given length.
func ValidMinSize ¶
func (*MinSize) DefaultMessage ¶
func (*MinSize) IsSatisfied ¶
type Required ¶
type Required struct{}
func ValidRequired ¶
func ValidRequired() *Required