This is an automated email from the ASF dual-hosted git repository.

Alanxtl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/develop by this push:
     new 56fe55baa refactor: remove legacy config handling from 
variadicrpccheck (#3413)
56fe55baa is described below

commit 56fe55baa6a8db2d17a0149567a27235171dba84
Author: ヴァニラシ <[email protected]>
AuthorDate: Sun Jun 14 13:12:47 2026 +0800

    refactor: remove legacy config handling from variadicrpccheck (#3413)
---
 tools/variadicrpccheck/helpers_test.go | 35 ++++++-----------------
 tools/variadicrpccheck/scan.go         | 13 +++------
 tools/variadicrpccheck/scan_test.go    | 52 ++++------------------------------
 3 files changed, 19 insertions(+), 81 deletions(-)

diff --git a/tools/variadicrpccheck/helpers_test.go 
b/tools/variadicrpccheck/helpers_test.go
index c99dcce21..10e47cce1 100644
--- a/tools/variadicrpccheck/helpers_test.go
+++ b/tools/variadicrpccheck/helpers_test.go
@@ -363,12 +363,12 @@ func TestAstAndTypeHelpers(t *testing.T) {
 
                _, ok = analyzer.wrapperParamIndexFromCall(ref.pkg, params, 
&ast.CallExpr{Fun: &ast.BasicLit{}})
                assert.False(t, ok)
-               configPkg := 
types.NewPackage("dubbo.apache.org/dubbo-go/v3/config", "config")
-               helperSel := &ast.SelectorExpr{X: &ast.Ident{Name: "config"}, 
Sel: &ast.Ident{Name: "SetProviderService"}}
+               dubboPkg := types.NewPackage("dubbo.apache.org/dubbo-go/v3", 
"dubbo")
+               helperSel := &ast.SelectorExpr{X: &ast.Ident{Name: "dubbo"}, 
Sel: &ast.Ident{Name: "SetProviderService"}}
                helperPkg := &packages.Package{
                        TypesInfo: &types.Info{
                                Uses: map[*ast.Ident]types.Object{
-                                       helperSel.Sel: 
types.NewFunc(token.NoPos, configPkg, "SetProviderService", 
testSignature(false, nil, nil)),
+                                       helperSel.Sel: 
types.NewFunc(token.NoPos, dubboPkg, "SetProviderService", testSignature(false, 
nil, nil)),
                                },
                        },
                }
@@ -389,10 +389,6 @@ func TestAstAndTypeHelpers(t *testing.T) {
                proxyType := types.NewNamed(types.NewTypeName(token.NoPos, 
serverPkg, "Proxy", nil), types.NewStruct(nil, nil), nil)
                proxyType.AddMethod(types.NewFunc(token.NoPos, serverPkg, 
"Implement", testSignature(false, []types.Type{types.NewInterfaceType(nil, 
nil)}, nil)))
 
-               configPkg := 
types.NewPackage("dubbo.apache.org/dubbo-go/v3/config", "config")
-               serviceConfigType := 
types.NewNamed(types.NewTypeName(token.NoPos, configPkg, "ServiceConfig", nil), 
types.NewStruct(nil, nil), nil)
-               serviceConfigType.AddMethod(types.NewFunc(token.NoPos, 
configPkg, "Implement", testSignature(false, 
[]types.Type{types.NewInterfaceType(nil, nil)}, nil)))
-
                commonPkg := 
types.NewPackage("dubbo.apache.org/dubbo-go/v3/common", "common")
                serviceMapType := types.NewNamed(types.NewTypeName(token.NoPos, 
commonPkg, "serviceMap", nil), types.NewStruct(nil, nil), nil)
                serviceMapType.AddMethod(types.NewFunc(token.NoPos, commonPkg, 
"Register", testSignature(false, []types.Type{types.NewInterfaceType(nil, nil), 
types.NewInterfaceType(nil, nil), types.NewInterfaceType(nil, nil), 
types.NewInterfaceType(nil, nil), types.NewInterfaceType(nil, nil)}, 
[]types.Type{types.Universe.Lookup("error").Type()})))
@@ -409,10 +405,6 @@ func TestAstAndTypeHelpers(t *testing.T) {
                require.True(t, ok)
                assert.Equal(t, 0, idx)
 
-               idx, ok = 
selectedMethodHandlerArgumentIndex(types.NewMethodSet(types.NewPointer(serviceConfigType)).Lookup(configPkg,
 "Implement"))
-               require.True(t, ok)
-               assert.Equal(t, 0, idx)
-
                idx, ok = 
selectedMethodHandlerArgumentIndex(types.NewMethodSet(types.NewPointer(serviceMapType)).Lookup(commonPkg,
 "Register"))
                require.True(t, ok)
                assert.Equal(t, 4, idx)
@@ -427,21 +419,12 @@ func TestAstAndTypeHelpers(t *testing.T) {
                assert.False(t, ok)
        })
 
-       // Package-level helpers cover config registration, root dubbo helpers, 
and generated Register* entry points.
-       t.Run("calledObjectHandlerArgumentIndex matches config helpers and 
generated handlers", func(t *testing.T) {
+       // Package-level helpers cover root dubbo helpers and generated 
Register* entry points.
+       t.Run("calledObjectHandlerArgumentIndex matches root helpers and 
generated handlers", func(t *testing.T) {
                analyzer := newRegistrationAnalyzer(nil)
-               configPkg := 
types.NewPackage("dubbo.apache.org/dubbo-go/v3/config", "config")
                dubboPkg := types.NewPackage("dubbo.apache.org/dubbo-go/v3", 
"dubbo")
 
-               idx, ok := 
analyzer.calledObjectHandlerArgumentIndex(types.NewFunc(token.NoPos, configPkg, 
"SetProviderService", testSignature(false, 
[]types.Type{types.NewInterfaceType(nil, nil)}, nil)))
-               require.True(t, ok)
-               assert.Equal(t, 0, idx)
-
-               idx, ok = 
analyzer.calledObjectHandlerArgumentIndex(types.NewFunc(token.NoPos, configPkg, 
"SetProviderServiceWithInfo", testSignature(false, 
[]types.Type{types.NewInterfaceType(nil, nil), types.NewInterfaceType(nil, 
nil)}, nil)))
-               require.True(t, ok)
-               assert.Equal(t, 0, idx)
-
-               idx, ok = 
analyzer.calledObjectHandlerArgumentIndex(types.NewFunc(token.NoPos, dubboPkg, 
"SetProviderService", testSignature(false, 
[]types.Type{types.NewInterfaceType(nil, nil)}, nil)))
+               idx, ok := 
analyzer.calledObjectHandlerArgumentIndex(types.NewFunc(token.NoPos, dubboPkg, 
"SetProviderService", testSignature(false, 
[]types.Type{types.NewInterfaceType(nil, nil)}, nil)))
                require.True(t, ok)
                assert.Equal(t, 0, idx)
 
@@ -466,16 +449,16 @@ func TestAstAndTypeHelpers(t *testing.T) {
                serverType := types.NewNamed(types.NewTypeName(token.NoPos, 
serverPkg, "Server", nil), types.NewStruct(nil, nil), nil)
                serverType.AddMethod(types.NewFunc(token.NoPos, serverPkg, 
"RegisterService", testSignature(false, 
[]types.Type{types.NewInterfaceType(nil, nil)}, 
[]types.Type{types.Universe.Lookup("error").Type()})))
                selection := 
types.NewMethodSet(types.NewPointer(serverType)).Lookup(serverPkg, 
"RegisterService")
-               configPkg := 
types.NewPackage("dubbo.apache.org/dubbo-go/v3/config", "config")
+               dubboPkg := types.NewPackage("dubbo.apache.org/dubbo-go/v3", 
"dubbo")
 
                selector := &ast.SelectorExpr{X: &ast.Ident{Name: "srv"}, Sel: 
&ast.Ident{Name: "RegisterService"}}
-               packageSelector := &ast.SelectorExpr{X: &ast.Ident{Name: 
"config"}, Sel: &ast.Ident{Name: "SetProviderService"}}
+               packageSelector := &ast.SelectorExpr{X: &ast.Ident{Name: 
"dubbo"}, Sel: &ast.Ident{Name: "SetProviderService"}}
                ident := &ast.Ident{Name: "RegisterGreeterHandler"}
                pkg := &packages.Package{
                        TypesInfo: &types.Info{
                                Selections: 
map[*ast.SelectorExpr]*types.Selection{selector: selection},
                                Uses: map[*ast.Ident]types.Object{
-                                       packageSelector.Sel: 
types.NewFunc(token.NoPos, configPkg, "SetProviderService", 
testSignature(false, nil, nil)),
+                                       packageSelector.Sel: 
types.NewFunc(token.NoPos, dubboPkg, "SetProviderService", testSignature(false, 
nil, nil)),
                                        ident:               
types.NewFunc(token.NoPos, types.NewPackage("example.com/test", "test"), 
"RegisterGreeterHandler", testSignature(false, nil, nil)),
                                },
                        },
diff --git a/tools/variadicrpccheck/scan.go b/tools/variadicrpccheck/scan.go
index a186a5ef0..65c995a59 100644
--- a/tools/variadicrpccheck/scan.go
+++ b/tools/variadicrpccheck/scan.go
@@ -35,13 +35,10 @@ import (
 var packagesLoad = packages.Load
 
 const (
-       dubboRootPkgPath   = "dubbo.apache.org/dubbo-go/v3"
-       dubboCommonPkgPath = dubboRootPkgPath + "/common"
-       dubboConfigPkgPath = dubboRootPkgPath + "/config"
-       dubboServerPkgPath = dubboRootPkgPath + "/server"
-
+       dubboRootPkgPath         = "dubbo.apache.org/dubbo-go/v3"
+       dubboCommonPkgPath       = dubboRootPkgPath + "/common"
+       dubboServerPkgPath       = dubboRootPkgPath + "/server"
        serverServiceOptionsType = "*" + dubboServerPkgPath + ".ServiceOptions"
-       configServiceConfigType  = "*" + dubboConfigPkgPath + ".ServiceConfig"
 )
 
 type registeredTypeKey struct {
@@ -454,8 +451,6 @@ func selectedMethodHandlerArgumentIndex(selection 
*types.Selection) (int, bool)
                return 0, true
        case path == dubboServerPkgPath && name == "Implement":
                return 0, types.TypeString(selection.Recv(), nil) == 
serverServiceOptionsType
-       case path == dubboConfigPkgPath && name == "Implement":
-               return 0, types.TypeString(selection.Recv(), nil) == 
configServiceConfigType
        case path == dubboCommonPkgPath && name == "Register":
                return 4, strings.HasSuffix(types.TypeString(selection.Recv(), 
nil), ".serviceMap")
        default:
@@ -471,7 +466,7 @@ func (a *registrationAnalyzer) 
calledObjectHandlerArgumentIndex(obj types.Object
        }
        if obj.Pkg() != nil {
                switch obj.Pkg().Path() {
-               case dubboConfigPkgPath, dubboRootPkgPath:
+               case dubboRootPkgPath:
                        switch obj.Name() {
                        case "SetProviderService":
                                return 0, true
diff --git a/tools/variadicrpccheck/scan_test.go 
b/tools/variadicrpccheck/scan_test.go
index 79e679bd6..a8dbee58c 100644
--- a/tools/variadicrpccheck/scan_test.go
+++ b/tools/variadicrpccheck/scan_test.go
@@ -220,46 +220,6 @@ func register() {
        assert.Equal(t, filepath.Join(dir, "service", "service.go"), 
findings[0].Position.Filename)
 }
 
-func 
TestScanFindsVariadicImplementationRegisteredViaSetProviderServiceWithInfo(t 
*testing.T) {
-       dir := t.TempDir()
-       writeTempFile(t, dir, goModFileName, 
goModuleContentWithDubboGoReplace("example.com/providerinfo", repoRoot(t)))
-       writeTempFile(t, filepath.Join(dir, "service"), serviceFileName, 
`package service
-
-import "context"
-
-type VariadicService struct{}
-
-func (s *VariadicService) MultiArgs(ctx context.Context, args ...string) error 
{
-       return nil
-}
-
-type Helper struct{}
-
-func (h *Helper) Merge(ctx context.Context, values ...string) error {
-       return nil
-}
-`)
-       writeTempFile(t, filepath.Join(dir, "provider"), "provider.go", 
`package provider
-
-import (
-       "dubbo.apache.org/dubbo-go/v3/config"
-       "example.com/providerinfo/service"
-)
-
-func init() {
-       config.SetProviderServiceWithInfo(&service.VariadicService{}, nil)
-}
-`)
-
-       findings, err := Scan(dir, []string{"./..."})
-       require.NoError(t, err)
-       require.Len(t, findings, 1)
-       assert.Equal(t, "implementation", findings[0].Kind)
-       assert.Equal(t, "VariadicService", findings[0].TypeName)
-       assert.Equal(t, "MultiArgs", findings[0].MethodName)
-       assert.Equal(t, filepath.Join(dir, "service", "service.go"), 
findings[0].Position.Filename)
-}
-
 func TestScanFindsVariadicImplementationRegisteredViaRootSetProviderService(t 
*testing.T) {
        dir := t.TempDir()
        writeTempFile(t, dir, goModFileName, 
goModuleContentWithDubboGoReplace("example.com/rootprovider", repoRoot(t)))
@@ -310,12 +270,12 @@ func (s *VariadicService) MultiArgs(ctx context.Context, 
args ...string) error {
        writeTempFile(t, filepath.Join(dir, "generated"), "generated.go", 
`package generated
 
 import (
+       dubbo "dubbo.apache.org/dubbo-go/v3"
        "dubbo.apache.org/dubbo-go/v3/common"
-       "dubbo.apache.org/dubbo-go/v3/config"
 )
 
 func SetProviderService(srv common.RPCService) {
-       config.SetProviderServiceWithInfo(srv, nil)
+       dubbo.SetProviderServiceWithInfo(srv, nil)
 }
 `)
        writeTempFile(t, filepath.Join(dir, "provider"), "provider.go", 
`package provider
@@ -400,14 +360,14 @@ func (s *VariadicService) MultiArgs(ctx context.Context, 
args ...string) error {
        writeTempFile(t, filepath.Join(dir, "provider"), "provider.go", 
`package provider
 
 import (
+       dubbo "dubbo.apache.org/dubbo-go/v3"
        "dubbo.apache.org/dubbo-go/v3/common"
-       "dubbo.apache.org/dubbo-go/v3/config"
        "example.com/interfacevar/service"
 )
 
 func init() {
        var svc common.RPCService = &service.VariadicService{}
-       config.SetProviderServiceWithInfo(svc, nil)
+       dubbo.SetProviderServiceWithInfo(svc, nil)
 }
 `)
 
@@ -442,14 +402,14 @@ func (s *SecondService) MultiArgs(ctx context.Context, 
args ...string) error {
        writeTempFile(t, filepath.Join(dir, "provider"), "provider.go", 
`package provider
 
 import (
+       dubbo "dubbo.apache.org/dubbo-go/v3"
        "dubbo.apache.org/dubbo-go/v3/common"
-       "dubbo.apache.org/dubbo-go/v3/config"
        "example.com/interfacevarreassign/service"
 )
 
 func init() {
        var svc common.RPCService = &service.FirstService{}
-       config.SetProviderServiceWithInfo(svc, nil)
+       dubbo.SetProviderServiceWithInfo(svc, nil)
        svc = &service.SecondService{}
 }
 `)

Reply via email to