52 lines
974 B
Go
52 lines
974 B
Go
package nomino_test
|
|
|
|
import (
|
|
"fmt"
|
|
|
|
"codeberg.org/danjones000/nomino"
|
|
)
|
|
|
|
func ExampleWithGenerator_customGenerator() {
|
|
gen := func(*nomino.Config) (string, error) {
|
|
return "hello", nil
|
|
}
|
|
option := nomino.WithGenerator(gen)
|
|
|
|
str, _ := nomino.Make(nomino.NewConfig(option))
|
|
fmt.Println(str)
|
|
|
|
str, _ = nomino.Make(nomino.NewConfig(
|
|
option,
|
|
nomino.WithoutExtension(),
|
|
))
|
|
fmt.Println(str)
|
|
|
|
// Output:
|
|
// hello.txt
|
|
// hello
|
|
}
|
|
|
|
func ExampleMultiGeneratorInOrder() {
|
|
gen1 := func(*nomino.Config) (string, error) {
|
|
return "hello", nil
|
|
}
|
|
gen2 := func(*nomino.Config) (string, error) {
|
|
return "goodbye", nil
|
|
}
|
|
gen := nomino.MultiGeneratorInOrder(gen1, gen2)
|
|
option := nomino.WithGenerator(gen)
|
|
|
|
str, _ := nomino.Make(nomino.NewConfig(option))
|
|
fmt.Println(str)
|
|
|
|
str, _ = nomino.Make(nomino.NewConfig(option))
|
|
fmt.Println(str)
|
|
|
|
str, _ = nomino.Make(nomino.NewConfig(option))
|
|
fmt.Println(str)
|
|
|
|
// Output:
|
|
// hello.txt
|
|
// goodbye.txt
|
|
// hello.txt
|
|
}
|