{"modulePath":"github.com/volatiletech/sqlboiler","version":"v3.7.1+incompatible","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package randomize\n\nPackage randomize has helpers for randomization of structs and fields\n\n## Functions\n\n```go\nfunc ByteSlice(nextInt func() int64, ln int) []byte\n```\nByteSlice creates a random set of bytes (non-printables included)\n\n```go\nfunc Date(nextInt func() int64) time.Time\n```\nDate generates a random time.Time between 1850 and 2050. Only the Day/Month/Year columns are set so that Dates and DateTimes do not cause mismatches in the test data comparisons.\n\n```go\nfunc EnumValue(nextInt func() int64, enum string) (string, error)\n```\nEnumValue takes an enum field type, parses it's definition to figure out valid values, and selects a random one from within them.\n\n```go\nfunc FormattedString(nextInt func() int64, fieldType string) (string, bool)\n```\nFormattedString checks a field type to see if it's in a range of special values and if so returns a randomized string for it.\n\n```go\nfunc MediumInt(nextInt func() int64, fieldType string) (int32, bool)\n```\nMediumInt is a special case in mysql (thanks for that -\\_-) this function checks if the fieldtype matches and if so returns a random value in the proper range.\n\n```go\nfunc MediumUint(nextInt func() int64, fieldType string) (uint32, bool)\n```\nMediumUint is the unsigned version of MediumInt\n\n```go\nfunc StableDBName(input string) string\n```\nStableDBName takes a database name in, and generates a random string using the database name as the rand Seed. getDBNameHash is used to generate unique test database names.\n\n```go\nfunc Str(nextInt func() int64, ln int) string\n```\nStr creates a randomized string from printable characters in the alphabet\n\n```go\nfunc Struct(s *Seed, str interface{}, colTypes map[string]string, canBeNull bool, blacklist ...string) error\n```\nStruct gets its fields filled with random data based on the seed. It will ignore the fields in the blacklist. It will ignore fields that have the struct tag boil:\"-\"\n\n## Types\n\n```go\ntype Randomizer interface {\n\t// Randomize should panic if there's no ability to randomize with the current parameters.\n\t//\n\t// nextInt can be called to create \"random\" sequential integers. This is done to avoid collisions in unique columns\n\t// for the tests.\n\t//\n\t// fieldType is used in the cases where the actual type (string, null string etc.) can actually be multiple\n\t// types of things that have specific randomization requirements, like a uuid for example is a normal null.String\n\t// but when randomizing that null string it must create a valid uuid or the database will reject it.\n\t//\n\t// shouldBeNull is a suggestion that a field should be null in this instance. The randomize implementation\n\t// can ignore this if the field cannot be null either because the type doesn't support it or there\n\t// is no ability for a field of this type to be null.\n\tRandomize(nextInt func() int64, fieldType string, shouldBeNull bool)\n}\n```\nRandomizer allows a field to be randomized\n\n```go\ntype Seed int64\n```\nSeed is an atomic counter for pseudo-randomization structs. Using full randomization leads to collisions in a domain where uniqueness is an important factor.\n\n```go\nfunc NewSeed() *Seed\n```\nNewSeed creates a new seed for pseudo-randomization.\n\n```go\nfunc (s *Seed) NextInt() int64\n```\nNextInt retrives an integer in order\n\n","path":"github.com/volatiletech/sqlboiler/randomize","name":"randomize","synopsis":"Package randomize has helpers for randomization of structs and fields","isRedistributable":true}
