diff --git a/cmd/gf/internal/cmd/cmd_z_unit_gen_ctrl_test.go b/cmd/gf/internal/cmd/cmd_z_unit_gen_ctrl_test.go index db2d8874b..cf77bc8df 100644 --- a/cmd/gf/internal/cmd/cmd_z_unit_gen_ctrl_test.go +++ b/cmd/gf/internal/cmd/cmd_z_unit_gen_ctrl_test.go @@ -307,3 +307,41 @@ func expectFilesContent(t *gtest.T, paths []string, expectPaths []string) { t.Assert(val, expect) } } + +// https://github.com/gogf/gf/issues/3569 +func Test_Gen_Ctrl_Comments_Issue3569(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + ctrlPath = gfile.Temp(guid.S()) + apiFolder = gtest.DataPath("issue", "3569", "api") + in = genctrl.CGenCtrlInput{ + SrcFolder: apiFolder, + DstFolder: ctrlPath, + WatchFile: "", + SdkPath: "", + SdkStdVersion: false, + SdkNoV1: false, + Clear: false, + Merge: true, + } + ) + + err := gutil.FillStructWithDefault(&in) + t.AssertNil(err) + + err = gfile.Mkdir(ctrlPath) + t.AssertNil(err) + defer gfile.Remove(ctrlPath) + + _, err = genctrl.CGenCtrl{}.Ctrl(ctx, in) + t.AssertNil(err) + + //apiInterface file + var ( + genApi = apiFolder + filepath.FromSlash("/hello/hello.go") + genApiExpect = apiFolder + filepath.FromSlash("/hello/hello_expect.go") + ) + defer gfile.Remove(genApi) + t.Assert(gfile.GetContents(genApi), gfile.GetContents(genApiExpect)) + }) +} diff --git a/cmd/gf/internal/cmd/testdata/issue/3569/api/hello/hello_expect.go b/cmd/gf/internal/cmd/testdata/issue/3569/api/hello/hello_expect.go new file mode 100644 index 000000000..745910243 --- /dev/null +++ b/cmd/gf/internal/cmd/testdata/issue/3569/api/hello/hello_expect.go @@ -0,0 +1,15 @@ +// ================================================================================= +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ================================================================================= + +package hello + +import ( + "context" + + "github.com/gogf/gf/cmd/gf/v2/internal/cmd/testdata/issue/3569/api/hello/v1" +) + +type IHelloV1 interface { + Hello(ctx context.Context, req *v1.HelloReq) (res *v1.HelloRes, err error) +} diff --git a/cmd/gf/internal/cmd/testdata/issue/3569/api/hello/v1/req.go b/cmd/gf/internal/cmd/testdata/issue/3569/api/hello/v1/req.go new file mode 100644 index 000000000..97d74123f --- /dev/null +++ b/cmd/gf/internal/cmd/testdata/issue/3569/api/hello/v1/req.go @@ -0,0 +1,24 @@ +package v1 + +import "github.com/gogf/gf/v2/frame/g" + +type HelloReq struct { + g.Meta `path:"/hello" tags:"Hello" method:"get" summary:"api-Hello"` +} +type HelloRes struct { + g.Meta `mime:"text/html" example:"string"` +} + +// type Hello2Req struct { +// g.Meta `path:"/hello2" tags:"Hello" method:"get" summary:"api-Hello2"` +// } +// type Hello2Res struct { +// g.Meta `mime:"text/html" example:"string"` +// } + +//type Hello3Req struct { +// g.Meta `path:"/hello3" tags:"Hello" method:"get" summary:"api-Hello3"` +// PodState consts.PodPhase +//} +//type Hello3Res struct { +//}