From 1f9fb28645fbf97016d25c9c7f0beb273e02c70b Mon Sep 17 00:00:00 2001 From: Dan Jones Date: Tue, 11 Mar 2025 16:54:03 -0500 Subject: [PATCH] =?UTF-8?q?=E2=9C=85=20Add=20a=20couple=20testable=20examp?= =?UTF-8?q?les?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- generators_examples_test.go | 20 ++++++++++++++++++++ make_examples_test.go | 9 +++++++++ 2 files changed, 29 insertions(+) create mode 100644 generators_examples_test.go create mode 100644 make_examples_test.go diff --git a/generators_examples_test.go b/generators_examples_test.go new file mode 100644 index 0000000..67d5995 --- /dev/null +++ b/generators_examples_test.go @@ -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 +} diff --git a/make_examples_test.go b/make_examples_test.go new file mode 100644 index 0000000..07c85ba --- /dev/null +++ b/make_examples_test.go @@ -0,0 +1,9 @@ +package nomino + +import "fmt" + +func ExampleMake_basic() { + // Use default config + out, _ := Make(NewConfig()) + fmt.Println(out) +}