random

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: BSD-3-Clause Imports: 7 Imported by: 15 modules, 19 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

package 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'. If 'opts' is nil the result of DefaultOptions is used. It is safe for concurrent use.

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