Skip to content
Go package for dealing with randomness.
Branch: master
Clone or download
Latest commit 206df58 Jun 9, 2019
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
.circleci Integrate CircleCI (#5) Jun 8, 2019
.editorconfig Initial commit Jun 8, 2019
LICENSE Initial commit Jun 8, 2019
README.md Integrate CircleCI (#5) Jun 8, 2019
go.mod Add go.mod (#6) Jun 9, 2019
runes.go Initial commit Jun 8, 2019
runes_test.go Initial commit Jun 8, 2019
string.go Initial commit Jun 8, 2019
string_test.go Initial commit Jun 8, 2019

README.md

gorando

CircleCI

A golang package for dealing with randomness.

There are many packages like it, but this one is mine.

Examples

package main

import (
    "fmt"
    "github.com/cariad/gorando"
)

func main() {
    abc, _ := gorando.GetString("abc", 8)
    fmt.Println(abc)
    // bcbbcaab

    japanese, _ := gorando.GetString("こんにちは", 8)
    fmt.Println(japanese)
    // こにこちにんんは

    emoji, _ := gorando.GetString("🌈😎🐄", 8)
    fmt.Println(emoji)
    // 😎🐄😎🐄🐄🐄😎🌈
}

Functions

func GetRunes(pool string, count int) ([]rune, error)

GetRunes returns a slice of runes of length count populated by a random pick of runes out of the pool string.

func GetString(pool string, length int) (string, error)

GetString returns a string of length length populated by a random pick of runes out of the pool string.

Security

This package uses crypto/rand to avoid the predictability of math/random.

Also, this package intentionally does not log any pools or random selections.

You can’t perform that action at this time.