diff --git a/README.md b/README.md index a95edd2..584bbfb 100644 --- a/README.md +++ b/README.md @@ -27,17 +27,17 @@ Generates Go classes from predefined objects, embedding assertion logic to preve Extracts functions from existing code and generates Go packages, integrating assertion and crash handling. -### `cls_stub_gen`: **Generates Go Method Stubs with Assertions** +### `cls_stub_gen`: **Generates Package-Level Function Wrappers** -Generates method stubs for Go objects, embedding assertions for proper error handling. +Creates package-level functions that wrap methods of a singleton struct, simplifying access usage. ## Usage ### Examples: -- [sure_cls_gen](internal/examples/example_sure_cls_gen) -- [sure_pkg_gen](internal/examples/example_sure_pkg_gen) -- [cls_stub_gen](internal/examples/example_cls_stub_gen) +- [Generating Classes with `sure_cls_gen`](internal/examples/example_sure_cls_gen) +- [Generating Packages with `sure_pkg_gen`](internal/examples/example_sure_pkg_gen) +- [Generating Singleton with `cls_stub_gen`](internal/examples/example_cls_stub_gen) --- diff --git a/README.zh.md b/README.zh.md index 0d4eff1..906c631 100644 --- a/README.zh.md +++ b/README.zh.md @@ -22,15 +22,15 @@ ### `cls_stub_gen`: **生成带有断言的 Go 方法存根** -给 Go 对象生成方法存根,再嵌入断言以确保适当的错误处理。 +给 Go 类型创建封装单例结构体方法的包级函数,简化访问使用。。 ## 使用示例 ### 示例: -- [sure_cls_gen](internal/examples/example_sure_cls_gen) -- [sure_pkg_gen](internal/examples/example_sure_pkg_gen) -- [cls_stub_gen](internal/examples/example_cls_stub_gen) +- [使用 `sure_cls_gen` 生成类](internal/examples/example_sure_cls_gen) +- [使用 `sure_pkg_gen` 生成包](internal/examples/example_sure_pkg_gen) +- [使用 `cls_stub_gen` 生成单例](internal/examples/example_cls_stub_gen) --- diff --git a/cls_stub_gen/stub_gen_test.go b/cls_stub_gen/stub_gen_test.go index 081b774..42046e1 100644 --- a/cls_stub_gen/stub_gen_test.go +++ b/cls_stub_gen/stub_gen_test.go @@ -1,6 +1,7 @@ package cls_stub_gen import ( + "github.com/pkg/errors" "testing" "github.com/yyle88/runpath" @@ -13,7 +14,8 @@ func (a *A) Get() *A { return a } -func (a *A) Set(string) { +func (a *A) Set(string) error { + return errors.New("not implement") } func (a *A) Add(x int, y int) int { @@ -33,7 +35,7 @@ func TestGenerateMethodsStub(t *testing.T) { OutputPath: "", AllowFileCreation: false, }, - NewStubParam(A{}, "a_a_a"), + NewStubParam(A{}, "singletonInstance"), ) t.Log(res) }