Documentation ¶
Index ¶
- Variables
- func GenerateToken(n uint, letterRunes []rune) string
- type Bucket
- func (bucket *Bucket) Count() uint64
- func (bucket *Bucket) EstimatedFillPercentage() float64
- func (bucket *Bucket) EstimatedTokenSpace() uint64
- func (bucket *Bucket) LoadTokens(tokens []string)
- func (bucket *Bucket) NewToken(distance int) (string, error)
- func (bucket *Bucket) Resolve(code string) (string, int)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( // ErrTokenLengthTooSmall gets returned when the token length is too small ErrTokenLengthTooSmall = errors.New("Token length is too small") // ErrTooFewRunes gets returned when the set of runes is too small ErrTooFewRunes = errors.New("Not enough runes") // ErrDupeRunes gets returned when the set of runes contains a dupe ErrDupeRunes = errors.New("Dupe in runes") // ErrDistanceTooSmall gets returned when the required distance is too small ErrDistanceTooSmall = errors.New("Distance must be at least 1") // ErrTokenSpaceExhausted gets returned when the token space has been exhausted ErrTokenSpaceExhausted = errors.New("Token space exhausted. Use longer tokens, more runes or a smaller distance") )
Functions ¶
func GenerateToken ¶
GenerateToken generates a new token of length n with the defined rune-set letterRunes.
Types ¶
type Bucket ¶
Bucket tracks all the generated tokens and lets you create new, unique tokens.
func NewBucketWithRunes ¶
NewBucketWithRunes returns a new bucket and lets you define which runes will be used for token generation.
func (*Bucket) EstimatedFillPercentage ¶
EstimatedFillPercentage returns how full the Bucket approximately is.
func (*Bucket) EstimatedTokenSpace ¶
EstimatedTokenSpace returns the total estimated token space available in this Bucket.
func (*Bucket) LoadTokens ¶
LoadTokens adds previously generated tokens to the Bucket.
Click to show internal directories.
Click to hide internal directories.