✅ Add a couple testable examples
This commit is contained in:
parent
4b509d31bb
commit
1f9fb28645
2 changed files with 29 additions and 0 deletions
20
generators_examples_test.go
Normal file
20
generators_examples_test.go
Normal file
|
|
@ -0,0 +1,20 @@
|
||||||
|
package nomino
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func ExampleWithGenerator_custom_generator() {
|
||||||
|
gen := func() (string, error) {
|
||||||
|
return "hello", nil
|
||||||
|
}
|
||||||
|
option := WithGenerator(gen)
|
||||||
|
|
||||||
|
str, _ := Make(NewConfig(option))
|
||||||
|
fmt.Println(str)
|
||||||
|
|
||||||
|
str, _ = Make(NewConfig(option, WithoutExtension()))
|
||||||
|
fmt.Println(str)
|
||||||
|
|
||||||
|
// Output:
|
||||||
|
// hello.txt
|
||||||
|
// hello
|
||||||
|
}
|
||||||
9
make_examples_test.go
Normal file
9
make_examples_test.go
Normal file
|
|
@ -0,0 +1,9 @@
|
||||||
|
package nomino
|
||||||
|
|
||||||
|
import "fmt"
|
||||||
|
|
||||||
|
func ExampleMake_basic() {
|
||||||
|
// Use default config
|
||||||
|
out, _ := Make(NewConfig())
|
||||||
|
fmt.Println(out)
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue