vcgen

package
v0.0.8 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2023 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNotFeasible       = errors.New("Not feasible to generate requested number of codes")
	ErrPatternIsNotMatch = errors.New("Pattern is not match with the length value")
)
View Source
var (
	ErrInvalidCount   = errors.New("invalid count, It should be greater than 0")
	ErrInvalidCharset = errors.New("invalid charset, charset length should be greater than 0")
	ErrInvalidPattern = errors.New("invalid pattern, pattern cannot be empty")
)

Functions

This section is empty.

Types

type Generator

type Generator struct {
	// Length of the code
	Length uint16 `json:"length"`

	// Count of the codes
	Count uint16 `json:"count"`

	// Charset to use
	Charset string `json:"charset"`

	// Prefix of the code
	Prefix string `json:"prefix"`

	// Suffix of the code
	Suffix string `json:"suffix"`

	// Pattern of the code
	Pattern string `json:"pattern"`

	// Suffix of the code
	//
	// Deprecated: use Suffix instead
	Postfix string `json:"postfix"`
}

func Default

func Default() *Generator

Creates a new generator with default values

func New deprecated

func New(i *Generator) *Generator

New generator config

Deprecated: use NewWithOptions or Default instead

func NewWithOptions

func NewWithOptions(opts ...Option) (*Generator, error)

Creates a new generator with options

func (*Generator) Run

func (g *Generator) Run() ([]string, error)

Generates a list of codes

type Option

type Option func(*Generator) error

func SetCharset

func SetCharset(charset string) Option

SetCharset sets the charset of the code

func SetCount

func SetCount(count uint16) Option

SetCount sets the count of the code

func SetLength

func SetLength(length uint16) Option

SetLength sets the length of the code

func SetPattern

func SetPattern(pattern string) Option

SetPattern sets the pattern of the code

func SetPrefix

func SetPrefix(prefix string) Option

SetPrefix sets the prefix of the code

func SetSuffix

func SetSuffix(suffix string) Option

SetSuffix sets the suffix of the code

Jump to

Keyboard shortcuts

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