randx

package
v0.0.0-...-45da7de Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2024 License: MIT Imports: 20 Imported by: 9

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Bool

func Bool() bool

func Bytes

func Bytes(n int) []byte

Bytes generates n random bytes.

func Color

func Color() color.Color

Color generate a random color

func CopySlice

func CopySlice(s interface{}) interface{}

func Int

func Int() int

func Int32

func Int32() int32

func Int32N

func Int32N(n int) int32

func Int64

func Int64() int64

func Int64Between

func Int64Between(min, max int64) (v int64)

func Int64N

func Int64N(n int64) int64

func IntBetween

func IntBetween(min, max int) int

func IntN

func IntN(n int) int

func Shuffle

func Shuffle(slice interface{})

Shuffle pseudo-randomizes the order of elements using the default Source. https://stackoverflow.com/questions/12264789/shuffle-array-in-go

func ShuffleSs

func ShuffleSs(a []string) []string

func String

func String(n int, letters ...string) string

String generates a random string using only letters provided in the letters parameter if user ommit letters parameters, this function will use defLetters instead

func Time

func Time() time.Time

func TimeBetween

func TimeBetween(min, max time.Time) time.Time

func Uint64

func Uint64() (v uint64)

func Uint64N

func Uint64N(n int64) uint64

Types

type ImgConfig

type ImgConfig struct {
	Width      int
	Height     int
	RandomText string
	FastMode   bool
	PixelSize  int
}

func (*ImgConfig) Gen

func (c *ImgConfig) Gen(imageFormat string) ([]byte, int)

Gen generate a random image with imageFormat (jpg/png) . refer: https://onlinejpgtools.com/generate-random-jpg

func (*ImgConfig) GenFile

func (c *ImgConfig) GenFile(filename string, fileSize int) int

type RandomImageResult

type RandomImageResult struct {
	Size     int
	Filename string
}

func RandomImage

func RandomImage(prefix string) (*RandomImageResult, error)

RandomImage creates a random image. Environment variables supported: GG_IMG_FAST=Y/N to enable fast mode or not GG_IMG_FORMAT=jpg/png to choose the format GG_IMG_FILE_SIZE=10M to set image file size GG_IMG_SIZE=640x320 to set the {width}x{height} of image

Jump to

Keyboard shortcuts

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