gostrgen

package module
v0.0.0-...-0c3e00d Latest Latest
Warning

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

Go to latest
Published: Mar 25, 2022 License: MIT Imports: 4 Imported by: 78

README

gostrgen

Random string generator in Golang.

#Installation go get -u github.com/elgs/gostrgen

Sample code

package main

import (
	"fmt"
	"github.com/elgs/gostrgen"
)

func main() {

	// possible character sets are:
	// Lower, Upper, Digit, Punct, LowerUpper, LowerDigit, UpperDigit, LowerUpperDigit, All and None.
	// Any of the above can be combine by "|", e.g. LowerUpper is the same as Lower | Upper

	charsToGenerate := 20
	charSet := gostrgen.Lower | gostrgen.Digit
	includes := "[]{}<>" // optionally include some additional letters
	excludes := "Ol"     //exclude big 'O' and small 'l' to avoid confusion with zero and one.

	str, err := gostrgen.RandGen(charsToGenerate, charSet, includes, excludes)
	if err != nil {
		fmt.Println(err)
	}
	fmt.Println(str) // zxh9[pvoxbaup32b7s0d
}

Documentation

Overview

gostrgen

Index

Constants

View Source
const Digit = 1 << 2
View Source
const Lower = 1 << 0
View Source
const LowerDigit = Lower | Digit
View Source
const LowerUpper = Lower | Upper
View Source
const LowerUpperDigit = LowerUpper | Digit
View Source
const None = 0
View Source
const Punct = 1 << 3
View Source
const Upper = 1 << 1
View Source
const UpperDigit = Upper | Digit

Variables

This section is empty.

Functions

func RandGen

func RandGen(size int, set int, include string, exclude string) (string, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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