randgen

package module
v0.0.0-...-efe7529 Latest Latest
Warning

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

Go to latest
Published: Oct 17, 2021 License: MIT Imports: 4 Imported by: 0

README

randgen

A Golang package to generate random strings and numbers.

Installation


go get github.com/wisdommatt/randgen

Features


  • Generate random strings.
  • Generate random numbers.

Requirements


go 1.5

Documentation


https://pkg.go.dev/github.com/wisdommatt/randgen

How to use (examples)


  • Generating 10 random strings.
stringGenerator := randgen.NewStringGenerator()
randomString := stringGenerator.GenerateFromSource(randgen.StringAlphaNumericSource, 10) // source, length
  • Generating 8 random numbers.
numberGenerator := randgen.NewNumberGenerator()
randomNumbers := numberGenerator.GenerateFromSource(randgen.NumberSource, 8) // source, 

Documentation

Overview

Package randgen is a package that helps generate random strings and numbers.

Index

Constants

This section is empty.

Variables

View Source
var NumberSource int = 1234567890

NumberSource is the source for number generator that contains all the numbers.

StringAlphaNumericSource is a string generator source that contains all cases alph-numeric characters.

StringAlphaNumericSymbolsSource is a string generator source that contains all cases alph-numeric characters and symbols.

StringAlphabetsSource is a string generator source that contains both uppercase and lowercase alphabets only.

View Source
var StringLowercaseAlphaNumericSource string = StringLowercaseAlphabetsSource + StringNumbericSoure

StringLowercaseAlphaNumericSource is a string generator source that contains lowercase alph-numeric characters only.

View Source
var StringLowercaseAlphabetsSource string = "qwertyuiopasdfghjklzxcvbnm"

StringLowercaseAlphabetsSource is a string generator source string that contains only lowercase alphabets.

View Source
var StringNumbericSoure string = "0123456789"

StringNumbericSoure is a string generator source that contains numberic characters only.

View Source
var StringSymbolsSource string = "~`!@#$%^&*()_+-={}[]|\\;:'\",.<>/?"

StringSymbolsSource is a string generator source that contains symbols only.

View Source
var StringUppercaseAlphaNumericSource string = StringUppercaseAlphabetsSource + StringNumbericSoure

StringUppercaseAlphaNumericSource is a string generator source that contains uppercase alph-numeric characters only.

View Source
var StringUppercaseAlphabetsSource string = "QWERTYUIOPASDFGHJKLZXCVBNM"

StringUppercaseAlphabetsSource is a string generator source string that contains only uppercase alphabets.

Functions

This section is empty.

Types

type NumberGenerator

type NumberGenerator interface {
	GenerateFromSource(source, length int) int
}

NumberGenerator is the interface that describes a number generator object.

func NewNumberGenerator

func NewNumberGenerator() NumberGenerator

NewNumberGenerator returns a new number generator object that implements the NumberGenerator interface.

type StringGenerator

type StringGenerator interface {
	GenerateFromSource(source string, length int) string
}

StringGenerator is the interface that describes a string generator object.

func NewStringGenerator

func NewStringGenerator() StringGenerator

NewStringGenerator returns a new string generator object that implements the StringGenerator interface.

Jump to

Keyboard shortcuts

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