Skip to content

Commit

Permalink
已解决遇到变长参数时没有补包名的问题
Browse files Browse the repository at this point in the history
  • Loading branch information
yangyile committed Dec 9, 2024
1 parent 1c20c98 commit fc3cfb9
Show file tree
Hide file tree
Showing 6 changed files with 39 additions and 13 deletions.
8 changes: 7 additions & 1 deletion cls_stub_gen/stub_gen_test.go
Original file line number Diff line number Diff line change
@@ -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"
)
Expand All @@ -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{
Expand Down
8 changes: 4 additions & 4 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
)
18 changes: 10 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
@@ -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=
Expand Down Expand Up @@ -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=
Expand All @@ -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=
Expand Down
6 changes: 6 additions & 0 deletions internal/examples/example_cls_stub_gen/example0/example0.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {}
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}
Original file line number Diff line number Diff line change
Expand Up @@ -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...)
}

0 comments on commit fc3cfb9

Please sign in to comment.