-- import "github.com/garrettsparks/idgen"
Package idgen uses crypt/rand to generate a random string of a given length.
const (
// DefaultIDChars defines the default set of characters as alphanumeric plus uppercase.
DefaultIDChars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"
// DefaultIDLength defines the default ID length as 8.
DefaultIDLength = 8
)type IDBuilder struct {
}IDBuilder is a builder for an ID.
func New() *IDBuilderNew creates a new IDBuilder with a specified length.
func (builder *IDBuilder) BuildID() stringBuildID builds an ID.
func (builder *IDBuilder) WithCharset(chars string) *IDBuilderWithCharset sets the string of available characters for the builder to use when generating an ID. The default is alphanumeric plus uppercase.
func (builder *IDBuilder) WithLength(length int) *IDBuilderWithLength sets the length of the randomly generated ID. The default length is 8.