✨ Add Incremental* Generators
This commit is contained in:
parent
28803e6a28
commit
67f472a2c6
2 changed files with 99 additions and 1 deletions
|
|
@ -18,3 +18,75 @@ func ExampleWithGenerator_custom_generator() {
|
|||
// hello.txt
|
||||
// hello
|
||||
}
|
||||
|
||||
func ExampleIncremental() {
|
||||
conf := NewConfig(WithPrefix("foo"), WithGenerator(Incremental()))
|
||||
|
||||
str, _ := Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
str, _ = Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
str, _ = Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
// Output:
|
||||
// foo_0.txt
|
||||
// foo_1.txt
|
||||
// foo_2.txt
|
||||
}
|
||||
|
||||
func ExampleIncrementalWithStart() {
|
||||
conf := NewConfig(WithPrefix("foo"), WithGenerator(IncrementalWithStart(42)))
|
||||
|
||||
str, _ := Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
str, _ = Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
str, _ = Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
// Output:
|
||||
// foo_42.txt
|
||||
// foo_43.txt
|
||||
// foo_44.txt
|
||||
}
|
||||
|
||||
func ExampleIncrementalWithStep() {
|
||||
conf := NewConfig(WithPrefix("foo"), WithGenerator(IncrementalWithStep(2)))
|
||||
|
||||
str, _ := Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
str, _ = Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
str, _ = Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
// Output:
|
||||
// foo_0.txt
|
||||
// foo_2.txt
|
||||
// foo_4.txt
|
||||
}
|
||||
|
||||
func ExampleIncrementalWithStartAndStep() {
|
||||
conf := NewConfig(WithPrefix("foo"), WithGenerator(IncrementalWithStartAndStep(42, 2)))
|
||||
|
||||
str, _ := Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
str, _ = Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
str, _ = Make(conf)
|
||||
fmt.Println(str)
|
||||
|
||||
// Output:
|
||||
// foo_42.txt
|
||||
// foo_44.txt
|
||||
// foo_46.txt
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue