Documentation
¶
Overview ¶
Package rowkey provides a simple way to build row keys. It's mostly useful when there's a need to reverse digits numeric identifiers.
Index ¶
Examples ¶
Constants ¶
View Source
const DefaultSeparator = "#"
Variables ¶
This section is empty.
Functions ¶
func Reverse ¶
Reverse reverses all characters in a string so the first becomes the last and so on.
Example ¶
processOpt := NewProcessOption(Reverse) // we explicitly tell the builder to use the `Reverse` function to process each part of the key b := NewBuilder(processOpt) key := b.ToRowKey("1234", "john") fmt.Println(key)
Output: 4321#nhoj
func ReverseIfInteger ¶
ReverseIfInteger reverses the digits of a string if it's a numeric form. "Plain strings" won't be impacted.
Example ¶
processOpt := NewProcessOption(ReverseIfInteger) // we explicitly tell the builder to use the `ReverseIfInteger` function to process each part of the key b := NewBuilder(processOpt) key := b.ToRowKey("1234", "john") fmt.Println(key)
Output: 4321#john
Types ¶
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func NewBuilder ¶
func NewBuilder(opts ...BuilderOption) *Builder
Example ¶
sepOpt := NewSeparatorOption(":") processOpt := NewProcessOption(func(s string) string { return s }) b := NewBuilder(sepOpt, processOpt) key := b.ToRowKey("1234", "john") fmt.Println(key)
Output: 1234:john
type BuilderOption ¶
type BuilderOption interface {
// contains filtered or unexported methods
}
BuilderOption is a function that can be used to configure a Builder.
type ProcessOption ¶
type ProcessOption struct {
// contains filtered or unexported fields
}
func NewProcessOption ¶
func NewProcessOption(process func(string) string) ProcessOption
type SeparatorOption ¶
type SeparatorOption struct {
// contains filtered or unexported fields
}
func NewSeparatorOption ¶
func NewSeparatorOption(separator string) SeparatorOption
Click to show internal directories.
Click to hide internal directories.