srand

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Sep 25, 2017 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AlphaNumeric

func AlphaNumeric(n int) string

AlphaNumeric returns a new alphanumeric string

func RandomNOfSet

func RandomNOfSet(set interface{}, n int) []interface{}

RandomOfSet returns a slice of random values from a set. If the input is a map, the return value is a slice of random keys from the map. If the input is not a container type, it is returned as a single element []interface{} containing only the input.

This function operates on generics, and uses reflection in the background. The return value must be copy-casted back into the original container type by the caller, eg.:

n := 20
arr := []int{1,2,3,4,5}
result := make([]int, n)
for i, d := range RandomNOfSet(arr, n).([]interface{}) {
    result[i] := d.(int)
}

func RandomOfSet

func RandomOfSet(set interface{}) interface{}

RandomOfSet returns a random value from a set. If the input is a map, the return value is a random key from the map. If the input is not a container type, the input is returned.

This function operates on generics, and uses reflection in the background. The return value must be casted back into the original type by the caller, eg.:

arr := []int{1,2,3,4,5}
x := RandomOfSet(arr).(int)

Types

This section is empty.

Jump to

Keyboard shortcuts

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