mirror of
https://github.com/mickael-menu/zk
synced 2024-11-19 03:25:40 +00:00
50855154e2
* Move everything under the internal package. * Better separation between core and adapter packages, for easier unit testing. * Simplify data models. * Support multiple opened notebooks during runtime (useful for the LSP server). * Proper surface API which might be exposed later as a public Go package.
38 lines
1.0 KiB
Go
38 lines
1.0 KiB
Go
package core
|
|
|
|
// IDOptions holds the options used to generate an ID.
|
|
type IDOptions struct {
|
|
Length int
|
|
Charset Charset
|
|
Case Case
|
|
}
|
|
|
|
// Charset is a set of characters.
|
|
type Charset []rune
|
|
|
|
var (
|
|
// CharsetAlphanum is a charset containing letters and numbers.
|
|
CharsetAlphanum = Charset("0123456789abcdefghijklmnopqrstuvwxyz")
|
|
// CharsetAlphanum is a charset containing hexadecimal characters.
|
|
CharsetHex = Charset("0123456789abcdef")
|
|
// CharsetLetters is a charset containing only letters.
|
|
CharsetLetters = Charset("abcdefghijklmnopqrstuvwxyz")
|
|
// CharsetNumbers is a charset containing only numbers.
|
|
CharsetNumbers = Charset("0123456789")
|
|
)
|
|
|
|
// Case represents the letter case to use when generating an ID.
|
|
type Case int
|
|
|
|
const (
|
|
CaseLower Case = iota + 1
|
|
CaseUpper
|
|
CaseMixed
|
|
)
|
|
|
|
// IDGenerator is a function returning a new ID with each invocation.
|
|
type IDGenerator func() string
|
|
|
|
// IDGeneratorFactory creates a new IDGenerator function using the given IDOptions.
|
|
type IDGeneratorFactory func(opts IDOptions) func() string
|