Skip to content

Commit

Permalink
修改说明文档
Browse files Browse the repository at this point in the history
  • Loading branch information
yangyile1990 committed Dec 3, 2024
1 parent 7b02ffc commit 4597f46
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

---

Expand Down
8 changes: 4 additions & 4 deletions README.zh.md
Original file line number Diff line number Diff line change
Expand Up @@ -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)

---

Expand Down
6 changes: 4 additions & 2 deletions cls_stub_gen/stub_gen_test.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package cls_stub_gen

import (
"github.com/pkg/errors"
"testing"

"github.com/yyle88/runpath"
Expand All @@ -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 {
Expand All @@ -33,7 +35,7 @@ func TestGenerateMethodsStub(t *testing.T) {
OutputPath: "",
AllowFileCreation: false,
},
NewStubParam(A{}, "a_a_a"),
NewStubParam(A{}, "singletonInstance"),
)
t.Log(res)
}

0 comments on commit 4597f46

Please sign in to comment.