random

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2022 License: BSD-3-Clause Imports: 6 Imported by: 13

Documentation

Overview

pcakage random provides methods for generating random strings.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func String

func String(opts *Options) (string, error)

String returns a randomly-generated string configured by 'opts'.

Types

type Options

type Options struct {
	// The length in bytes of the final string.
	Length int
	// The number of characters in the final string.
	Chars int
	// A boolean flag indicating that only ASCII characters be included in the final string.
	ASCII bool
	// A boolean flag indicating that only alphanumeric (a-zA-Z0-9) characters be included in the final string.
	AlphaNumeric bool
	// A boolean flag indicating the random string should be returned as a base32 encoded string.
	Base32 bool
}

Options is a struct containing configuration options for the `String` method.

func DefaultOptions

func DefaultOptions() *Options

DefaultOptions returns an `Options` instance with no limits or restrictions save a minimum length of 32 bytes.

Jump to

Keyboard shortcuts

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