From fc3cfb9997470ecaf9d3f68ffd6caa0e8cef0e2d Mon Sep 17 00:00:00 2001 From: yangyile Date: Mon, 9 Dec 2024 10:53:17 +0700 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E8=A7=A3=E5=86=B3=E9=81=87=E5=88=B0?= =?UTF-8?q?=E5=8F=98=E9=95=BF=E5=8F=82=E6=95=B0=E6=97=B6=E6=B2=A1=E6=9C=89?= =?UTF-8?q?=E8=A1=A5=E5=8C=85=E5=90=8D=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- cls_stub_gen/stub_gen_test.go | 8 +++++++- go.mod | 8 ++++---- go.sum | 18 ++++++++++-------- .../example_cls_stub_gen/example0/example0.go | 6 ++++++ .../example0/example0x1gen/gen.go | 6 ++++++ .../example0/example0x2gen/gen.go | 6 ++++++ 6 files changed, 39 insertions(+), 13 deletions(-) diff --git a/cls_stub_gen/stub_gen_test.go b/cls_stub_gen/stub_gen_test.go index 42046e1..e9b9d06 100644 --- a/cls_stub_gen/stub_gen_test.go +++ b/cls_stub_gen/stub_gen_test.go @@ -1,9 +1,9 @@ package cls_stub_gen import ( - "github.com/pkg/errors" "testing" + "github.com/pkg/errors" "github.com/yyle88/runpath" "github.com/yyle88/syntaxgo/syntaxgo_ast" ) @@ -26,6 +26,12 @@ func (a *A) Sub(x int, y int) (int, error) { return x - y, nil } +type Param struct{} + +func (a *A) Who(param ...Param) {} + +func (a *A) How(param ...Param) {} + func TestGenerateMethodsStub(t *testing.T) { res := GenerateStubMethods( &StubGenConfig{ diff --git a/go.mod b/go.mod index 38dbc53..7dcbd37 100644 --- a/go.mod +++ b/go.mod @@ -13,7 +13,7 @@ require ( github.com/yyle88/printgo v1.0.1 github.com/yyle88/rese v0.0.1 github.com/yyle88/runpath v1.0.22 - github.com/yyle88/syntaxgo v0.0.35 + github.com/yyle88/syntaxgo v0.0.39 github.com/yyle88/tern v0.0.3 github.com/yyle88/zaplog v0.0.16 go.uber.org/zap v1.27.0 @@ -26,10 +26,10 @@ require ( github.com/rogpeppe/go-internal v1.13.1 // indirect github.com/yyle88/mutexmap v1.0.8 // indirect go.uber.org/multierr v1.11.0 // indirect - golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f // indirect + golang.org/x/exp v0.0.0-20241204233417-43b7b7cde48d // indirect golang.org/x/mod v0.22.0 // indirect - golang.org/x/sync v0.9.0 // indirect - golang.org/x/tools v0.27.0 // indirect + golang.org/x/sync v0.10.0 // indirect + golang.org/x/tools v0.28.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/go.sum b/go.sum index 08f7ca2..146dc7a 100644 --- a/go.sum +++ b/go.sum @@ -1,6 +1,8 @@ github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= @@ -31,8 +33,8 @@ github.com/yyle88/rese v0.0.1 h1:Eu2I+7BpbkX1n7SOu11AHVqecTuOVdg4becgt2ThGIo= github.com/yyle88/rese v0.0.1/go.mod h1:GoPiHJPEWyeBL0DxOHT5hLnibFbav+jck/NZxLqNVI8= github.com/yyle88/runpath v1.0.22 h1:gcyaNMNZq7yjL2Xlwvs0W7BOkzn4VJTJqA8ko7CKhKg= github.com/yyle88/runpath v1.0.22/go.mod h1:JRGxn/0Ytg6CvGoE2VrO74oX8Lu4jbOPZDKxr8tzPEg= -github.com/yyle88/syntaxgo v0.0.35 h1:jcDpBTkVehgaQq3LGOQD/jBFu7eauVn2rqc7qKCqzts= -github.com/yyle88/syntaxgo v0.0.35/go.mod h1:blSLJ3XoI8KWT5FISdBTISi1cHElQxtBzZ2UaeDja9w= +github.com/yyle88/syntaxgo v0.0.39 h1:947UHHAqGsHAmS7nJ5Y/Br+yhJjTZtq1543XIizfevI= +github.com/yyle88/syntaxgo v0.0.39/go.mod h1:vR/bU2RVwvkfkQyMy30OWpdmn5jc3wrm8vcMbHQGCbc= github.com/yyle88/tern v0.0.3 h1:Ut5p1wPAVcreEkmzDp+IiteA3K2vnTeAYE1PyBLNgjU= github.com/yyle88/tern v0.0.3/go.mod h1:g9weyOMLtXYyt37EAshZPUTTHdH7WFauuxDi4oPr7/8= github.com/yyle88/zaplog v0.0.16 h1:ZCxQhq3+nWeWMAXIzeA1EA4exRq5Pn8pXTpEw1GjyD4= @@ -43,14 +45,14 @@ go.uber.org/multierr v1.11.0 h1:blXXJkSxSSfBVBlC76pxqeO+LN3aDfLQo+309xJstO0= go.uber.org/multierr v1.11.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= go.uber.org/zap v1.27.0 h1:aJMhYGrd5QSmlpLMr2MftRKl7t8J8PTZPA732ud/XR8= go.uber.org/zap v1.27.0/go.mod h1:GB2qFLM7cTU87MWRP2mPIjqfIDnGu+VIO4V/SdhGo2E= -golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f h1:XdNn9LlyWAhLVp6P/i8QYBW+hlyhrhei9uErw2B5GJo= -golang.org/x/exp v0.0.0-20241108190413-2d47ceb2692f/go.mod h1:D5SMRVC3C2/4+F/DB1wZsLRnSNimn2Sp/NPsCrsv8ak= +golang.org/x/exp v0.0.0-20241204233417-43b7b7cde48d h1:0olWaB5pg3+oychR51GUVCEsGkeCU/2JxjBgIo4f3M0= +golang.org/x/exp v0.0.0-20241204233417-43b7b7cde48d/go.mod h1:qj5a5QZpwLU2NLQudwIN5koi3beDhSAlJwa67PuM98c= golang.org/x/mod v0.22.0 h1:D4nJWe9zXqHOmWqj4VMOJhvzj7bEZg4wEYa759z1pH4= golang.org/x/mod v0.22.0/go.mod h1:6SkKJ3Xj0I0BrPOZoBy3bdMptDDU9oJrpohJ3eWZ1fY= -golang.org/x/sync v0.9.0 h1:fEo0HyrW1GIgZdpbhCRO0PkJajUS5H9IFUztCgEo2jQ= -golang.org/x/sync v0.9.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/tools v0.27.0 h1:qEKojBykQkQ4EynWy4S8Weg69NumxKdn40Fce3uc/8o= -golang.org/x/tools v0.27.0/go.mod h1:sUi0ZgbwW9ZPAq26Ekut+weQPR5eIM6GQLQ1Yjm1H0Q= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/tools v0.28.0 h1:WuB6qZ4RPCQo5aP3WdKZS7i595EdWqWR8vqJTlwTVK8= +golang.org/x/tools v0.28.0/go.mod h1:dcIOrVd3mfQKTgrDVQHqCPMWy6lnhfhtX3hLXYVLfRw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= diff --git a/internal/examples/example_cls_stub_gen/example0/example0.go b/internal/examples/example_cls_stub_gen/example0/example0.go index c447b75..bcebc93 100644 --- a/internal/examples/example_cls_stub_gen/example0/example0.go +++ b/internal/examples/example_cls_stub_gen/example0/example0.go @@ -19,3 +19,9 @@ func (a *A) Add(x int, y int) int { func (a *A) Sub(x int, y int) (int, error) { return x - y, nil } + +type Param struct{} + +func (a *A) Who(param ...Param) {} + +func (a *A) How(param ...Param) {} diff --git a/internal/examples/example_cls_stub_gen/example0/example0x1gen/gen.go b/internal/examples/example_cls_stub_gen/example0/example0x1gen/gen.go index 19bb2db..ca08286 100644 --- a/internal/examples/example_cls_stub_gen/example0/example0x1gen/gen.go +++ b/internal/examples/example_cls_stub_gen/example0/example0x1gen/gen.go @@ -14,3 +14,9 @@ func Add(x int, y int) int { func Sub(x int, y int) (int, error) { return example0.STUB1.Sub(x, y) } +func Who(param ...example0.Param) { + example0.STUB1.Who(param...) +} +func How(param ...example0.Param) { + example0.STUB1.How(param...) +} diff --git a/internal/examples/example_cls_stub_gen/example0/example0x2gen/gen.go b/internal/examples/example_cls_stub_gen/example0/example0x2gen/gen.go index f3bf341..576cb46 100644 --- a/internal/examples/example_cls_stub_gen/example0/example0x2gen/gen.go +++ b/internal/examples/example_cls_stub_gen/example0/example0x2gen/gen.go @@ -14,3 +14,9 @@ func Add(x int, y int) int { func Sub(x int, y int) (int, error) { return example0.STUB2.Sub(x, y) } +func Who(param ...example0.Param) { + example0.STUB2.Who(param...) +} +func How(param ...example0.Param) { + example0.STUB2.How(param...) +}