Examples for everything

This commit is contained in:
Dan Jones 2025-03-14 21:22:29 -05:00
commit 9402d80704
4 changed files with 124 additions and 51 deletions

View file

@ -25,3 +25,41 @@ func ExampleWithGenerator_customGenerator() {
// 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
}
func ExampleUUID() {
option := nomino.WithGenerator(nomino.UUID())
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)
}