✨ Add IncrementalStep* Generators
This commit is contained in:
parent
1d235af876
commit
9d8737079f
2 changed files with 89 additions and 3 deletions
|
|
@ -91,6 +91,61 @@ func ExampleIncrementalWithStartAndStep() {
|
|||
// foo_46.txt
|
||||
}
|
||||
|
||||
func ExampleIncrementalFormat() {
|
||||
conf := NewConfig(
|
||||
WithPrefix("foo"),
|
||||
WithGenerator(IncrementalFormat("%03d")),
|
||||
)
|
||||
|
||||
str, _ := Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
str, _ = Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
str, _ = Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
// Output:
|
||||
// foo_000.txt
|
||||
// foo_001.txt
|
||||
// foo_002.txt
|
||||
}
|
||||
|
||||
func ExampleIncrementalFormatWithStart() {
|
||||
conf := NewConfig(
|
||||
WithPrefix("foo"),
|
||||
WithGenerator(IncrementalFormatWithStart(9, "%02d")),
|
||||
)
|
||||
|
||||
str, _ := Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
str, _ = Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
// Output:
|
||||
// foo_09.txt
|
||||
// foo_10.txt
|
||||
}
|
||||
|
||||
func ExampleIncrementalFormatWithStep() {
|
||||
conf := NewConfig(
|
||||
WithPrefix("foo"),
|
||||
WithGenerator(IncrementalFormatWithStep(10, "%02d")),
|
||||
)
|
||||
|
||||
str, _ := Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
str, _ = Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
// Output:
|
||||
// foo_00.txt
|
||||
// foo_10.txt
|
||||
}
|
||||
|
||||
func ExampleSlug() {
|
||||
conf := NewConfig(WithGenerator(Slug()), WithOriginal("My name is Jimmy"))
|
||||
str, _ := Make(conf)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue