Add IncrementalStep* Generators

This commit is contained in:
Dan Jones 2025-03-14 11:19:20 -05:00
commit 9d8737079f
2 changed files with 89 additions and 3 deletions

View file

@ -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)