random

package module
v1.0.6 Latest Latest
Warning

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

Go to latest
Published: May 28, 2022 License: Apache-2.0 Imports: 3 Imported by: 9

README

random

Small and simple helper to generate "random" string.

Usage

Installation:

go get -u github.com/dmitrymomot/random

Use

import "github.com/dmitrymomot/random"

str := random.String(16)
log.Println(str)

Output:

Cb0ajMig6N7l9Fzf

Licensed under Apache License 2.0

Documentation

Index

Constants

View Source
const (
	Uppercase    = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
	Lowercase    = "abcdefghijklmnopqrstuvwxyz"
	Alphabetic   = Uppercase + Lowercase
	Numeric      = "0123456789"
	Alphanumeric = Alphabetic + Numeric
	Symbols      = "`" + `~!@#$%^&*()-_+={}[]|\;:"<>,./?`
	Hex          = Numeric + "abcdef"
)

Charsets

Variables

This section is empty.

Functions

func GetRandomMapItemWithPrecent added in v1.0.6

func GetRandomMapItemWithPrecent(items map[string]float64) string

GetRandomMapItemWithPrecent returns random item from a map where values are drop percentages

func GetRandomMapItemWithProbabilities added in v1.0.1

func GetRandomMapItemWithProbabilities(items map[string]float64) string

GetRandomMapItemWithProbabilities returns random item from a map where values are probabilities

func GetRandomStructWithProbabilities

func GetRandomStructWithProbabilities(items []interface{ GetProbability() float64 }) interface{}

GetRandomStructWithProbabilities returns random item from slice of structures with given probabilities

func GetRandomWithProbabilities

func GetRandomWithProbabilities(items []interface{}, probabilities []float64) interface{}

GetRandomWithProbabilities returns random item from slice of any data type with given probalities

func String

func String(length uint8, charsets ...string) string

String is a helper to get random string

Types

type Random

type Random struct{}

Random structure

func New

func New() *Random

New Random structure

func (*Random) String

func (r *Random) String(length uint8, charsets ...string) string

String function

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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