Skip to content

elgs/gostrgen

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 

Repository files navigation

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
}

About

Random string generator in Golang.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages