This is an automated email from the ASF dual-hosted git repository.
alexstocks pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go-pixiu.git
The following commit(s) were added to refs/heads/develop by this push:
new b30eb3f7 optimize: replace interface to any & update corresponding ci
(#670)
b30eb3f7 is described below
commit b30eb3f7cb938d742f725e3b4ccb93276cc70c02
Author: Alan <[email protected]>
AuthorDate: Mon May 5 20:40:09 2025 +0800
optimize: replace interface to any & update corresponding ci (#670)
* gofmt -r 'interface{} -> any' -w .
* update ci
* typo
* add license
* add license
* rename ci file
* update ci
* fix ci error
---
.github/workflows/github-actions.yml | 2 +-
.golangci.yaml | 56 ++++++++++++++++++++++
configcenter/configclient.go | 4 +-
configcenter/load.go | 6 +--
configcenter/nacos_load.go | 4 +-
.../zookeeper/application_service_listener.go | 4 +-
pkg/adapter/dubboregistry/registrycenter.go | 2 +-
pkg/adapter/springcloud/cloud.go | 4 +-
.../servicediscovery/zookeeper/zk_discovery.go | 10 ++--
pkg/client/client.go | 6 +--
pkg/client/dubbo/dubbo.go | 6 +--
pkg/client/dubbo/mapper.go | 30 ++++++------
pkg/client/dubbo/mapper_test.go | 8 ++--
pkg/client/dubbo/option.go | 22 ++++-----
pkg/client/dubbo/option_test.go | 16 +++----
pkg/client/http/http.go | 4 +-
pkg/client/http/mapper.go | 24 +++++-----
pkg/client/http/mapper_test.go | 10 ++--
pkg/client/mapper.go | 6 +--
pkg/client/mapper_test.go | 8 ++--
pkg/client/mq/mq.go | 4 +-
pkg/client/triple/triple.go | 4 +-
pkg/cluster/healthcheck/healthcheck.go | 2 +-
pkg/common/constant/jtypes.go | 2 +-
pkg/common/extension/adapter/adapter.go | 2 +-
pkg/common/extension/adapter/adapter_test.go | 2 +-
pkg/common/extension/filter/filter.go | 26 +++++-----
pkg/common/extension/filter/filter_manager.go | 2 +-
pkg/common/extension/filter/filter_manager_test.go | 6 +--
pkg/common/http/manager.go | 4 +-
pkg/common/http/manager_test.go | 2 +-
pkg/common/mock/routerfilter.go | 2 +-
pkg/common/router/trie/trie.go | 20 ++++----
pkg/common/util/response.go | 36 +++++++-------
pkg/common/util/response_test.go | 26 +++++-----
pkg/common/yaml/yaml.go | 8 ++--
pkg/config/config_load.go | 2 +-
pkg/config/config_load_test.go | 2 +-
pkg/config/xds/apiclient/grpc.go | 2 +-
pkg/config/xds/lds.go | 2 +-
pkg/config/xds/lds_test.go | 38 +++++++--------
pkg/context/base_context.go | 2 +-
pkg/context/http/context.go | 4 +-
pkg/filter/accesslog/access_log.go | 4 +-
pkg/filter/auth/jwt/jwt.go | 2 +-
pkg/filter/authority/authority.go | 2 +-
pkg/filter/cors/cors.go | 2 +-
pkg/filter/csrf/csrf.go | 2 +-
pkg/filter/event/event.go | 2 +-
pkg/filter/failinject/filter.go | 2 +-
pkg/filter/header/header.go | 2 +-
pkg/filter/host/host.go | 2 +-
pkg/filter/http/apiconfig/api_config.go | 2 +-
pkg/filter/http/dubboproxy/dubbo.go | 12 ++---
pkg/filter/http/grpcproxy/grpc.go | 2 +-
pkg/filter/http/httpproxy/routerfilter.go | 2 +-
pkg/filter/http/loadbalancer/loadbalancer.go | 2 +-
pkg/filter/http/proxyrewrite/rewrite.go | 2 +-
pkg/filter/http/proxywasm/filter.go | 2 +-
pkg/filter/http/proxywasm/filter_windows.go | 2 +-
pkg/filter/http/remote/call.go | 2 +-
pkg/filter/metric/metric.go | 2 +-
.../network/dubboproxy/filter/http/httpfilter.go | 4 +-
.../network/dubboproxy/filter/proxy/proxyfilter.go | 8 ++--
pkg/filter/network/dubboproxy/manager.go | 10 ++--
pkg/filter/network/dubboproxy/plugin.go | 4 +-
pkg/filter/network/grpcconnectionmanager/plugin.go | 4 +-
pkg/filter/network/httpconnectionmanager/plugin.go | 4 +-
pkg/filter/prometheus/metric.go | 2 +-
.../sentinel/circuitbreaker/circuit_breaker.go | 2 +-
pkg/filter/sentinel/logger_warpper.go | 8 ++--
pkg/filter/sentinel/ratelimit/rate_limit.go | 2 +-
pkg/filter/tracing/tracing.go | 2 +-
pkg/filter/traffic/traffic.go | 2 +-
pkg/filterchain/network_filter_chain.go | 8 ++--
pkg/listener/http/http_listener.go | 2 +-
pkg/listener/http2/http2_listener.go | 2 +-
pkg/listener/listener.go | 2 +-
pkg/listener/tcp/pkg_handler.go | 4 +-
pkg/listener/tcp/server_handler.go | 2 +-
pkg/listener/tcp/tcp_listener.go | 2 +-
pkg/listener/triple/triple_listener.go | 8 ++--
pkg/logger/controller.go | 16 +++----
pkg/logger/output.go | 16 +++----
pkg/logger/triple.go | 16 +++----
pkg/model/adapter.go | 8 ++--
pkg/model/base.go | 2 +-
pkg/model/filter.go | 4 +-
pkg/model/health.go | 20 ++++----
pkg/model/http.go | 10 ++--
pkg/model/listener.go | 2 +-
pkg/model/log.go | 20 ++++----
pkg/model/trace.go | 8 ++--
pkg/model/tracing.go | 4 +-
pkg/model/wasm.go | 4 +-
pkg/pool/pool.go | 4 +-
pkg/remote/nacos/client.go | 2 +-
pkg/router/route.go | 4 +-
pkg/server/adapter_manager_test.go | 8 ++--
pkg/server/controls/mocks/mocks.go | 14 +++---
pkg/wasm/service.go | 2 +-
101 files changed, 392 insertions(+), 336 deletions(-)
diff --git a/.github/workflows/github-actions.yml
b/.github/workflows/github-actions.yml
index 3d689e0e..69a97c94 100644
--- a/.github/workflows/github-actions.yml
+++ b/.github/workflows/github-actions.yml
@@ -94,7 +94,7 @@ jobs:
fi
- name: Go Fmt
run: |
- go fmt ./... && git status && [[ -z `git status -s` ]]
+ go fmt ./... && gofmt -s && git status && [[ -z `git status -s` ]]
# diff -u <(echo -n) <(gofmt -d -s .)
lint:
diff --git a/.golangci.yaml b/.golangci.yaml
new file mode 100644
index 00000000..e176e876
--- /dev/null
+++ b/.golangci.yaml
@@ -0,0 +1,56 @@
+linters-settings:
+ gocyclo:
+ min-complexity: 10
+ dupl:
+ threshold: 100
+ goconst:
+ min-len: 2
+ min-occurrences: 2
+ depguard:
+ rules:
+ main:
+ deny:
+ - pkg: "github.com/sirupsen/logrus"
+ desc: logging is allowed only by logutils.Log, logrus is allowed
to use only in logutils package
+ misspell:
+ locale: US
+ ignore-words:
+ - nto
+ lll:
+ line-length: 140
+ gofmt:
+ # simplify code: gofmt with `-s` option, true by default
+ simplify: true
+ rewrite-rules:
+ - pattern: interface{}
+ replacement: any
+ goimports:
+ local-prefixes: github.com/golangci/golangci-lint
+ gocritic:
+ enabled-tags:
+ - performance
+ - style
+ - experimental
+ disabled-checks:
+ - wrapperFunc
+
+linters:
+ disable-all: true
+ enable:
+ - govet
+ - staticcheck
+ - ineffassign
+ - gofmt
+ - misspell
+
+issues:
+ exclude-rules:
+ - text: "weak cryptographic primitive"
+ linters:
+ - gosec
+ - linters:
+ - staticcheck
+ text: "SA1019:"
+ exclude-dirs:
+ - test/testdata_etc
+ - pkg/golinters/goanalysis/(checker|passes)
diff --git a/configcenter/configclient.go b/configcenter/configclient.go
index e74f5710..3c847754 100644
--- a/configcenter/configclient.go
+++ b/configcenter/configclient.go
@@ -23,9 +23,9 @@ import (
type (
ConfigClient interface {
- LoadConfig(properties map[string]interface{}) (string, error)
+ LoadConfig(properties map[string]any) (string, error)
- ListenConfig(properties map[string]interface{}) (err error)
+ ListenConfig(properties map[string]any) (err error)
// ViewConfig returns the current remote configuration.
ViewConfig() *model.Bootstrap
diff --git a/configcenter/load.go b/configcenter/load.go
index 215cff32..a2c8eed9 100644
--- a/configcenter/load.go
+++ b/configcenter/load.go
@@ -34,7 +34,7 @@ const (
KEY_CONFIG_TYPE_NACOS = "nacos"
)
-var Parsers = map[string]func(data []byte, v interface{}) error{
+var Parsers = map[string]func(data []byte, v any) error{
".yaml": ParseYamlBytes,
".yml": ParseYamlBytes,
}
@@ -93,7 +93,7 @@ func (d *DefaultConfigLoad) LoadConfigs(boot
*model.Bootstrap, opts ...Option) (
return nil, nil
}
- m := map[string]interface{}{}
+ m := map[string]any{}
if strings.EqualFold(boot.Config.Type, KEY_CONFIG_TYPE_NACOS) {
m["dataId"] = getOrDefault(opt.DataId, DataId)
@@ -133,6 +133,6 @@ func (d *DefaultConfigLoad) ViewRemoteConfig()
*model.Bootstrap {
return d.configClient.ViewConfig()
}
-func ParseYamlBytes(content []byte, v interface{}) error {
+func ParseYamlBytes(content []byte, v any) error {
return yaml.Unmarshal(content, v)
}
diff --git a/configcenter/nacos_load.go b/configcenter/nacos_load.go
index 5f17857c..3fa8013a 100644
--- a/configcenter/nacos_load.go
+++ b/configcenter/nacos_load.go
@@ -108,7 +108,7 @@ func getNacosConfigClient(boot *model.Bootstrap)
(config_client.IConfigClient, e
}
// LoadConfig retrieves the configuration from Nacos based on the provided
parameters.
-func (n *NacosConfig) LoadConfig(param map[string]interface{}) (string, error)
{
+func (n *NacosConfig) LoadConfig(param map[string]any) (string, error) {
return n.client.GetConfig(vo.ConfigParam{
DataId: getOrDefault(param[KeyDataId].(string), DataId),
Group: getOrDefault(param[KeyGroup].(string), Group),
@@ -124,7 +124,7 @@ func getOrDefault(target, fallback string) string {
}
// ListenConfig listens for configuration changes in Nacos.
-func (n *NacosConfig) ListenConfig(param map[string]interface{}) error {
+func (n *NacosConfig) ListenConfig(param map[string]any) error {
return n.client.ListenConfig(vo.ConfigParam{
DataId: getOrDefault(param[KeyDataId].(string), DataId),
Group: getOrDefault(param[KeyGroup].(string), Group),
diff --git
a/pkg/adapter/dubboregistry/registry/zookeeper/application_service_listener.go
b/pkg/adapter/dubboregistry/registry/zookeeper/application_service_listener.go
index 87024d3c..b47acb5b 100644
---
a/pkg/adapter/dubboregistry/registry/zookeeper/application_service_listener.go
+++
b/pkg/adapter/dubboregistry/registry/zookeeper/application_service_listener.go
@@ -222,12 +222,12 @@ func (asl *applicationServiceListener) getUrls(path
string) []*dubboCommon.URL {
// toZookeeperInstance convert to registry's service instance
func toZookeeperInstance(cris *curator_discovery.ServiceInstance)
dr.ServiceInstance {
- pl, ok := cris.Payload.(map[string]interface{})
+ pl, ok := cris.Payload.(map[string]any)
if !ok {
logger.Errorf("toZookeeperInstance{%s} payload is not
map[string]interface{}", cris.ID)
return nil
}
- mdi, ok := pl["metadata"].(map[string]interface{})
+ mdi, ok := pl["metadata"].(map[string]any)
if !ok {
logger.Errorf("toZookeeperInstance{%s} metadata is not
map[string]interface{}", cris.ID)
return nil
diff --git a/pkg/adapter/dubboregistry/registrycenter.go
b/pkg/adapter/dubboregistry/registrycenter.go
index ff5c9356..ebcd3b35 100644
--- a/pkg/adapter/dubboregistry/registrycenter.go
+++ b/pkg/adapter/dubboregistry/registrycenter.go
@@ -113,7 +113,7 @@ func (a *Adapter) Apply() error {
}
// Config returns the config of the adaptor
-func (a *Adapter) Config() interface{} {
+func (a *Adapter) Config() any {
return a.cfg
}
diff --git a/pkg/adapter/springcloud/cloud.go b/pkg/adapter/springcloud/cloud.go
index 467a9cdd..9a310a93 100644
--- a/pkg/adapter/springcloud/cloud.go
+++ b/pkg/adapter/springcloud/cloud.go
@@ -149,7 +149,7 @@ func (a *CloudAdapter) Apply() error {
case Zookeeper:
sd, err = zookeeper.NewZKServiceDiscovery(a.cfg.Services,
a.cfg.Registry, a)
default:
- return errors.New("adapter init error registry not recognise")
+ return errors.New("adapter init error registry not recognize")
}
if err != nil {
logger.Errorf("Apply NewServiceDiscovery %s ",
a.cfg.Registry.Protocol, err.Error())
@@ -209,7 +209,7 @@ func (a *CloudAdapter) GetServiceNames() []string {
}
// Config get config for Adapter
-func (a *CloudAdapter) Config() interface{} {
+func (a *CloudAdapter) Config() any {
return a.cfg
}
diff --git a/pkg/adapter/springcloud/servicediscovery/zookeeper/zk_discovery.go
b/pkg/adapter/springcloud/servicediscovery/zookeeper/zk_discovery.go
index 844fac0f..3a9b2ffe 100644
--- a/pkg/adapter/springcloud/servicediscovery/zookeeper/zk_discovery.go
+++ b/pkg/adapter/springcloud/servicediscovery/zookeeper/zk_discovery.go
@@ -283,11 +283,11 @@ func (sd *zookeeperDiscovery) pathForName(name string)
string {
}
type SpringCloudZKInstance struct {
- Name string `json:"name"`
- ID string `json:"id"`
- Address string `json:"address"`
- Port int `json:"port"`
- SslPort interface{} `json:"sslPort"`
+ Name string `json:"name"`
+ ID string `json:"id"`
+ Address string `json:"address"`
+ Port int `json:"port"`
+ SslPort any `json:"sslPort"`
Payload struct {
Class string `json:"@class"`
ID string `json:"id"`
diff --git a/pkg/client/client.go b/pkg/client/client.go
index 500c4190..d891b895 100644
--- a/pkg/client/client.go
+++ b/pkg/client/client.go
@@ -26,10 +26,10 @@ type Client interface {
Close() error
// Call invoke the downstream service.
- Call(req *Request) (res interface{}, err error)
+ Call(req *Request) (res any, err error)
// MapParams mapping param, uri, query, body ...
- MapParams(req *Request) (reqData interface{}, err error)
+ MapParams(req *Request) (reqData any, err error)
}
/**
@@ -42,5 +42,5 @@ type MapOption map[string]RequestOption
// RequestOption option interface.
type RequestOption interface {
- Action(target, val interface{}) error
+ Action(target, val any) error
}
diff --git a/pkg/client/dubbo/dubbo.go b/pkg/client/dubbo/dubbo.go
index f1aa506c..25f113b2 100644
--- a/pkg/client/dubbo/dubbo.go
+++ b/pkg/client/dubbo/dubbo.go
@@ -161,7 +161,7 @@ func (dc *Client) Close() error {
}
// Call invoke service
-func (dc *Client) Call(req *client.Request) (res interface{}, err error) {
+func (dc *Client) Call(req *client.Request) (res any, err error) {
// if GET with no args, values would be nil
values, err := dc.genericArgs(req)
if err != nil {
@@ -220,7 +220,7 @@ func (dc *Client) Call(req *client.Request) (res
interface{}, err error) {
return rst, nil
}
-func (dc *Client) genericArgs(req *client.Request) (interface{}, error) {
+func (dc *Client) genericArgs(req *client.Request) (any, error) {
values, err := dc.MapParams(req)
if err != nil {
return nil, err
@@ -230,7 +230,7 @@ func (dc *Client) genericArgs(req *client.Request)
(interface{}, error) {
}
// MapParams params mapping to api.
-func (dc *Client) MapParams(req *client.Request) (interface{}, error) {
+func (dc *Client) MapParams(req *client.Request) (any, error) {
r := req.API.Method.IntegrationRequest
values := newDubboTarget(r.MappingParams)
if dc.dubboProxyConfig != nil && dc.dubboProxyConfig.IsDefaultMap {
diff --git a/pkg/client/dubbo/mapper.go b/pkg/client/dubbo/mapper.go
index d6ed7fc3..081c4e3d 100644
--- a/pkg/client/dubbo/mapper.go
+++ b/pkg/client/dubbo/mapper.go
@@ -48,8 +48,8 @@ var mappers = map[string]client.ParamMapper{
}
type dubboTarget struct {
- Values []interface{} // the slice contains the parameters.
- Types []string // the slice contains the parameters' types. It
should match the values one by one.
+ Values []any // the slice contains the parameters.
+ Types []string // the slice contains the parameters' types. It should
match the values one by one.
}
// pre-allocate proper memory according to the params' usability.
@@ -65,7 +65,7 @@ func newDubboTarget(mps []config.MappingParam) *dubboTarget {
}
if length > 0 {
- val := make([]interface{}, length)
+ val := make([]any, length)
target := &dubboTarget{
Values: val,
Types: make([]string, length),
@@ -78,7 +78,7 @@ func newDubboTarget(mps []config.MappingParam) *dubboTarget {
type queryStringsMapper struct{}
// nolint
-func (qm queryStringsMapper) Map(mp config.MappingParam, c *client.Request,
target interface{}, option client.RequestOption) error {
+func (qm queryStringsMapper) Map(mp config.MappingParam, c *client.Request,
target any, option client.RequestOption) error {
t, err := validateTarget(target)
if err != nil {
return err
@@ -106,7 +106,7 @@ func (qm queryStringsMapper) Map(mp config.MappingParam, c
*client.Request, targ
type headerMapper struct{}
// nolint
-func (hm headerMapper) Map(mp config.MappingParam, c *client.Request, target
interface{}, option client.RequestOption) error {
+func (hm headerMapper) Map(mp config.MappingParam, c *client.Request, target
any, option client.RequestOption) error {
rv, err := validateTarget(target)
if err != nil {
return err
@@ -127,7 +127,7 @@ func (hm headerMapper) Map(mp config.MappingParam, c
*client.Request, target int
type bodyMapper struct{}
// nolint
-func (bm bodyMapper) Map(mp config.MappingParam, c *client.Request, target
interface{}, option client.RequestOption) error {
+func (bm bodyMapper) Map(mp config.MappingParam, c *client.Request, target
any, option client.RequestOption) error {
// TO-DO: add support for content-type other than application/json
rv, err := validateTarget(target)
if err != nil {
@@ -149,7 +149,7 @@ func (bm bodyMapper) Map(mp config.MappingParam, c
*client.Request, target inter
if err != nil {
return err
}
- mapBody := map[string]interface{}{}
+ mapBody := map[string]any{}
json.Unmarshal(rawBody, &mapBody)
val, err := client.GetMapValue(mapBody, keys)
@@ -164,7 +164,7 @@ func (bm bodyMapper) Map(mp config.MappingParam, c
*client.Request, target inter
type uriMapper struct{}
// nolint
-func (um uriMapper) Map(mp config.MappingParam, c *client.Request, target
interface{}, option client.RequestOption) error {
+func (um uriMapper) Map(mp config.MappingParam, c *client.Request, target any,
option client.RequestOption) error {
rv, err := validateTarget(target)
if err != nil {
return err
@@ -184,7 +184,7 @@ func (um uriMapper) Map(mp config.MappingParam, c
*client.Request, target interf
// validateTarget verify if the incoming target for the Map function
// can be processed as expected.
-func validateTarget(target interface{}) (*dubboTarget, error) {
+func validateTarget(target any) (*dubboTarget, error) {
val, ok := target.(*dubboTarget)
if !ok {
return nil, errors.New("Target params for dubbo backend must be
*dubbogoTarget")
@@ -193,7 +193,7 @@ func validateTarget(target interface{}) (*dubboTarget,
error) {
}
func setTargetWithOpt(req *client.Request, option client.RequestOption,
- target *dubboTarget, pos int, value interface{}, targetType string)
error {
+ target *dubboTarget, pos int, value any, targetType string) error {
if option != nil {
return setGenericTarget(req, option, target, value, targetType)
}
@@ -206,24 +206,24 @@ func setTargetWithOpt(req *client.Request, option
client.RequestOption,
}
func setGenericTarget(req *client.Request, option client.RequestOption,
- target *dubboTarget, value interface{}, targetType string) error {
+ target *dubboTarget, value any, targetType string) error {
var err error
switch option.(type) {
case *groupOpt, *versionOpt, *interfaceOpt, *applicationOpt, *methodOpt:
err = option.Action(req, value)
case *valuesOpt:
- err = option.Action(target, [2]interface{}{value, targetType})
+ err = option.Action(target, [2]any{value, targetType})
case *paramTypesOpt:
err = option.Action(target, value)
}
return err
}
-func setCommonTarget(target *dubboTarget, pos int, value interface{},
targetType string) {
+func setCommonTarget(target *dubboTarget, pos int, value any, targetType
string) {
// if the mapTo position is greater than the numbers of usable
parameters,
// extend the values and types slices. It changes the address of the
the target.
if cap(target.Values) <= pos {
- list := make([]interface{}, pos+1-len(target.Values))
+ list := make([]any, pos+1-len(target.Values))
typeList := make([]string, pos+1-len(target.Types))
target.Values = append(target.Values, list...)
target.Types = append(target.Types, typeList...)
@@ -232,7 +232,7 @@ func setCommonTarget(target *dubboTarget, pos int, value
interface{}, targetType
target.Types[pos] = targetType
}
-func mapTypes(jType string, originVal interface{}) (interface{}, error) {
+func mapTypes(jType string, originVal any) (any, error) {
targetType, ok := constant.JTypeMapper[jType]
if !ok {
return nil, errors.Errorf("Invalid parameter type: %s", jType)
diff --git a/pkg/client/dubbo/mapper_test.go b/pkg/client/dubbo/mapper_test.go
index baa61ae3..479a65d0 100644
--- a/pkg/client/dubbo/mapper_test.go
+++ b/pkg/client/dubbo/mapper_test.go
@@ -165,7 +165,7 @@ func TestBodyMapper(t *testing.T) {
err = bm.Map(api.IntegrationRequest.MappingParams[2], req, target, nil)
assert.Nil(t, err)
assert.Equal(t, target.Types[2], "object")
- assert.Equal(t, target.Values[2],
map[string]interface{}(map[string]interface{}{
+ assert.Equal(t, target.Values[2], map[string]any(map[string]any{
"firstName": "Joe", "lastName": "Biden",
}))
}
@@ -285,7 +285,7 @@ func TestNewDubboTarget(t *testing.T) {
}
func TestSetCommonTarget(t *testing.T) {
- vals := make([]interface{}, 10)
+ vals := make([]any, 10)
types := make([]string, 10)
target := &dubboTarget{
Values: vals,
@@ -307,12 +307,12 @@ func TestSetGenericTarget(t *testing.T) {
req := client.NewReq(context.TODO(), r, api)
target := &dubboTarget{
- Values: make([]interface{}, 3),
+ Values: make([]any, 3),
Types: make([]string, 3),
}
opt := DefaultMapOption[optionKeyValues]
- err := setGenericTarget(req, opt, target, []interface{}{1, "abc",
struct{ Name string }{"joe"}}, "int, string, object")
+ err := setGenericTarget(req, opt, target, []any{1, "abc", struct{ Name
string }{"joe"}}, "int, string, object")
assert.Nil(t, err)
assert.Equal(t, target.Values[0], 1)
assert.Equal(t, target.Values[1], "abc")
diff --git a/pkg/client/dubbo/option.go b/pkg/client/dubbo/option.go
index db7040b3..c8538661 100644
--- a/pkg/client/dubbo/option.go
+++ b/pkg/client/dubbo/option.go
@@ -55,7 +55,7 @@ var DefaultMapOption = client.MapOption{
type groupOpt struct{}
// nolint
-func (opt *groupOpt) Action(target, val interface{}) error {
+func (opt *groupOpt) Action(target, val any) error {
v, ok := val.(string)
if !ok {
return errors.New("Group value is not string")
@@ -71,7 +71,7 @@ func (opt *groupOpt) Action(target, val interface{}) error {
type versionOpt struct{}
// nolint
-func (opt *versionOpt) Action(target, val interface{}) error {
+func (opt *versionOpt) Action(target, val any) error {
v, ok := val.(string)
if !ok {
return errors.New("Version value is not string")
@@ -87,7 +87,7 @@ func (opt *versionOpt) Action(target, val interface{}) error {
type methodOpt struct{}
// nolint
-func (opt *methodOpt) Action(target, val interface{}) error {
+func (opt *methodOpt) Action(target, val any) error {
v, ok := val.(string)
if !ok {
return errors.New("Method value is not string")
@@ -103,7 +103,7 @@ func (opt *methodOpt) Action(target, val interface{}) error
{
type applicationOpt struct{}
// nolint
-func (opt *applicationOpt) Action(target, val interface{}) error {
+func (opt *applicationOpt) Action(target, val any) error {
v, ok := val.(string)
if !ok {
return errors.New("Application value is not string")
@@ -119,7 +119,7 @@ func (opt *applicationOpt) Action(target, val interface{})
error {
type interfaceOpt struct{}
// nolint
-func (opt *interfaceOpt) Action(target, val interface{}) error {
+func (opt *interfaceOpt) Action(target, val any) error {
v, ok := val.(string)
if !ok {
return errors.New("Interface value is not string")
@@ -138,25 +138,25 @@ type valuesOpt struct{}
// parameter values to dubbo generic call. the second element is string, which
is the types
// for the generic call, it could be empty or types sep from ','. If empty, it
should retrieve types from
// another generic option - types.
-func (opt *valuesOpt) Action(target, val interface{}) error {
+func (opt *valuesOpt) Action(target, val any) error {
dubboTarget, ok := target.(*dubboTarget)
if !ok {
return errors.New("Target is not dubboTarget in value options")
}
- v, ok := val.([2]interface{})
+ v, ok := val.([2]any)
if !ok {
return errors.New("The value must be [2]interface{}")
}
- var toVals []interface{}
+ var toVals []any
toTypes := []string{}
if t, tok := v[1].(string); tok && len(t) != 0 {
toTypes = strings.Split(t, ",")
}
- if val, vok := v[0].([]interface{}); vok {
+ if val, vok := v[0].([]any); vok {
toVals = val
} else if val, ok := v[0].(string); !ok || val != "" {
- toVals = []interface{}{v[0]}
+ toVals = []any{v[0]}
}
if !(len(toTypes) != 0 && len(toTypes) == len(toVals)) {
dubboTarget.Types = toTypes
@@ -185,7 +185,7 @@ type paramTypesOpt struct{}
// Action for paramTypesOpt override the other param types mapping/config.
// The val must be string(e.g. "int, object"), and will then assign to the
target.(dubboTarget).Types
-func (opt *paramTypesOpt) Action(target, val interface{}) error {
+func (opt *paramTypesOpt) Action(target, val any) error {
dubboTarget, ok := target.(*dubboTarget)
if !ok {
return errors.New("Target is not dubboTarget in target
parameter")
diff --git a/pkg/client/dubbo/option_test.go b/pkg/client/dubbo/option_test.go
index 179ef1b5..562526ed 100644
--- a/pkg/client/dubbo/option_test.go
+++ b/pkg/client/dubbo/option_test.go
@@ -28,15 +28,15 @@ import (
func TestValuesOpt(t *testing.T) {
opt := &valuesOpt{}
target := &dubboTarget{
- Values: make([]interface{}, 3),
+ Values: make([]any, 3),
Types: make([]string, 3),
}
- vals := []interface{}{
+ vals := []any{
struct{ Name string }{"joe"},
"abc",
123,
}
- err := opt.Action(target, [2]interface{}{
+ err := opt.Action(target, [2]any{
vals,
"object, string, int",
})
@@ -47,22 +47,22 @@ func TestValuesOpt(t *testing.T) {
assert.Equal(t, target.Types[1], "string")
assert.Equal(t, target.Types[2], "int")
- err = opt.Action(target, []interface{}{
+ err = opt.Action(target, []any{
vals,
"object, string, int",
})
assert.NotNil(t, err)
target = &dubboTarget{
- Values: make([]interface{}, 3),
+ Values: make([]any, 3),
Types: make([]string, 3),
}
- vals = []interface{}{
+ vals = []any{
struct{ Name string }{"joe"},
"abc",
123,
}
- err = opt.Action(target, [2]interface{}{
+ err = opt.Action(target, [2]any{
vals,
"",
})
@@ -75,7 +75,7 @@ func TestValuesOpt(t *testing.T) {
func TestParamTypesOptAction(t *testing.T) {
opt := ¶mTypesOpt{}
target := &dubboTarget{
- Values: make([]interface{}, 3),
+ Values: make([]any, 3),
Types: make([]string, 3),
}
err := opt.Action(target, "object,string")
diff --git a/pkg/client/http/http.go b/pkg/client/http/http.go
index 8cd0c4aa..c5e2dd12 100644
--- a/pkg/client/http/http.go
+++ b/pkg/client/http/http.go
@@ -91,7 +91,7 @@ func (dc *Client) Close() error {
}
// Call invoke service
-func (dc *Client) Call(req *client.Request) (resp interface{}, err error) {
+func (dc *Client) Call(req *client.Request) (resp any, err error) {
// Map the origin parameters to backend parameters according to the API
configure
transformedParams, err := dc.MapParams(req)
if err != nil {
@@ -135,7 +135,7 @@ func (dc *Client) Call(req *client.Request) (resp
interface{}, err error) {
}
// MapParams param mapping to api.
-func (dc *Client) MapParams(req *client.Request) (reqData interface{}, err
error) {
+func (dc *Client) MapParams(req *client.Request) (reqData any, err error) {
mp := req.API.IntegrationRequest.MappingParams
r := newRequestParams()
if len(mp) == 0 {
diff --git a/pkg/client/http/mapper.go b/pkg/client/http/mapper.go
index 3e90ad77..84ef39aa 100644
--- a/pkg/client/http/mapper.go
+++ b/pkg/client/http/mapper.go
@@ -64,7 +64,7 @@ func newRequestParams() *requestParams {
type queryStringsMapper struct{}
// nolint
-func (qs queryStringsMapper) Map(mp config.MappingParam, c *client.Request,
rawTarget interface{}, option client.RequestOption) error {
+func (qs queryStringsMapper) Map(mp config.MappingParam, c *client.Request,
rawTarget any, option client.RequestOption) error {
target, fromKey, to, toKey, err := mapPrepare(mp, rawTarget)
if err != nil {
return err
@@ -84,7 +84,7 @@ func (qs queryStringsMapper) Map(mp config.MappingParam, c
*client.Request, rawT
type headerMapper struct{}
// nolint
-func (hm headerMapper) Map(mp config.MappingParam, c *client.Request,
rawTarget interface{}, option client.RequestOption) error {
+func (hm headerMapper) Map(mp config.MappingParam, c *client.Request,
rawTarget any, option client.RequestOption) error {
target, fromKey, to, toKey, err := mapPrepare(mp, rawTarget)
if err != nil {
return err
@@ -101,7 +101,7 @@ func (hm headerMapper) Map(mp config.MappingParam, c
*client.Request, rawTarget
type bodyMapper struct{}
// nolint
-func (bm bodyMapper) Map(mp config.MappingParam, c *client.Request, rawTarget
interface{}, option client.RequestOption) error {
+func (bm bodyMapper) Map(mp config.MappingParam, c *client.Request, rawTarget
any, option client.RequestOption) error {
// TO-DO: add support for content-type other than application/json
target, fromKey, to, toKey, err := mapPrepare(mp, rawTarget)
if err != nil {
@@ -115,7 +115,7 @@ func (bm bodyMapper) Map(mp config.MappingParam, c
*client.Request, rawTarget in
if err != nil {
return err
}
- mapBody := map[string]interface{}{}
+ mapBody := map[string]any{}
json.Unmarshal(rawBody, &mapBody)
val, err := client.GetMapValue(mapBody, fromKey)
if err != nil {
@@ -128,7 +128,7 @@ func (bm bodyMapper) Map(mp config.MappingParam, c
*client.Request, rawTarget in
type uriMapper struct{}
// nolint
-func (um uriMapper) Map(mp config.MappingParam, c *client.Request, rawTarget
interface{}, option client.RequestOption) error {
+func (um uriMapper) Map(mp config.MappingParam, c *client.Request, rawTarget
any, option client.RequestOption) error {
target, fromKey, to, toKey, err := mapPrepare(mp, rawTarget)
if err != nil {
return err
@@ -143,7 +143,7 @@ func (um uriMapper) Map(mp config.MappingParam, c
*client.Request, rawTarget int
return nil
}
-func validateTarget(target interface{}) (*requestParams, error) {
+func validateTarget(target any) (*requestParams, error) {
val, ok := target.(*requestParams)
if !ok || val == nil {
return nil, errors.New("Target params must be a requestParams
pointer")
@@ -151,7 +151,7 @@ func validateTarget(target interface{}) (*requestParams,
error) {
return val, nil
}
-func setTarget(target *requestParams, to string, key string, val interface{})
error {
+func setTarget(target *requestParams, to string, key string, val any) error {
valType := reflect.TypeOf(val)
if (to == constant.Headers || to == constant.QueryStrings) &&
valType.Kind() != reflect.String {
return errors.Errorf("%s only accepts string", to)
@@ -171,7 +171,7 @@ func setTarget(target *requestParams, to string, key
string, val interface{}) er
if err != nil {
return errors.New("Raw body read failed")
}
- mapBody := map[string]interface{}{}
+ mapBody := map[string]any{}
if len(rawBody) != 0 {
err = json.Unmarshal(rawBody, &mapBody)
if err != nil {
@@ -192,7 +192,7 @@ func setTarget(target *requestParams, to string, key
string, val interface{}) er
// setMapWithPath set the value to the target map. If the origin targetMap has
// {"abc": "cde": {"f":1, "g":2}} and the path is abc, value is "123", then the
// targetMap will be updated to {"abc", "123"}
-func setMapWithPath(targetMap map[string]interface{}, path string, val
interface{}) map[string]interface{} {
+func setMapWithPath(targetMap map[string]any, path string, val any)
map[string]any {
keys := strings.Split(path, constant.Dot)
_, ok := targetMap[keys[0]]
@@ -201,13 +201,13 @@ func setMapWithPath(targetMap map[string]interface{},
path string, val interface
return targetMap
}
if !ok && len(keys) != 1 {
- targetMap[keys[0]] = make(map[string]interface{})
- targetMap[keys[0]] =
setMapWithPath(targetMap[keys[0]].(map[string]interface{}),
strings.Join(keys[1:], constant.Dot), val)
+ targetMap[keys[0]] = make(map[string]any)
+ targetMap[keys[0]] =
setMapWithPath(targetMap[keys[0]].(map[string]any), strings.Join(keys[1:],
constant.Dot), val)
}
return targetMap
}
-func mapPrepare(mp config.MappingParam, rawTarget interface{}) (target
*requestParams, fromKey []string, to string, toKey []string, err error) {
+func mapPrepare(mp config.MappingParam, rawTarget any) (target *requestParams,
fromKey []string, to string, toKey []string, err error) {
// ensure the target is a pointer and type is requestParams
target, err = validateTarget(rawTarget)
if err != nil {
diff --git a/pkg/client/http/mapper_test.go b/pkg/client/http/mapper_test.go
index c1311683..24b84cb9 100644
--- a/pkg/client/http/mapper_test.go
+++ b/pkg/client/http/mapper_test.go
@@ -213,19 +213,19 @@ func TestSetTarget(t *testing.T) {
err = setTarget(emptyRequestParams, constant.QueryStrings, "id", 123)
assert.EqualError(t, err, "queryStrings only accepts string")
- err = setTarget(emptyRequestParams, constant.RequestBody, "testStruct",
map[string]interface{}{"test": "happy", "name": "mock"})
+ err = setTarget(emptyRequestParams, constant.RequestBody, "testStruct",
map[string]any{"test": "happy", "name": "mock"})
assert.Nil(t, err)
rawBody, err := io.ReadAll(emptyRequestParams.Body)
assert.Nil(t, err)
assert.Equal(t, string(rawBody),
"{\"testStruct\":{\"name\":\"mock\",\"test\":\"happy\"}}")
- err = setTarget(emptyRequestParams, constant.RequestBody,
"testStruct.secondLayer", map[string]interface{}{"test": "happy", "name":
"mock"})
+ err = setTarget(emptyRequestParams, constant.RequestBody,
"testStruct.secondLayer", map[string]any{"test": "happy", "name": "mock"})
assert.Nil(t, err)
rawBody, err = io.ReadAll(emptyRequestParams.Body)
assert.Nil(t, err)
assert.Equal(t, string(rawBody),
"{\"testStruct\":{\"secondLayer\":{\"name\":\"mock\",\"test\":\"happy\"}}}")
- err = setTarget(emptyRequestParams, constant.RequestBody,
"testStruct.secondLayer.thirdLayer", map[string]interface{}{"test": "happy",
"name": "mock"})
+ err = setTarget(emptyRequestParams, constant.RequestBody,
"testStruct.secondLayer.thirdLayer", map[string]any{"test": "happy", "name":
"mock"})
assert.Nil(t, err)
rawBody, err = io.ReadAll(emptyRequestParams.Body)
assert.Nil(t, err)
@@ -237,7 +237,7 @@ func TestSetTarget(t *testing.T) {
nonEmptyRequestParams := newRequestParams()
nonEmptyRequestParams.Body =
io.NopCloser(bytes.NewReader([]byte("{\"testStruct\":\"abcde\"}")))
- err = setTarget(nonEmptyRequestParams, constant.RequestBody,
"testStruct", map[string]interface{}{"test": "happy", "name": "mock"})
+ err = setTarget(nonEmptyRequestParams, constant.RequestBody,
"testStruct", map[string]any{"test": "happy", "name": "mock"})
assert.Nil(t, err)
rawBody, err = io.ReadAll(nonEmptyRequestParams.Body)
assert.Nil(t, err)
@@ -245,7 +245,7 @@ func TestSetTarget(t *testing.T) {
nonEmptyRequestParams = newRequestParams()
nonEmptyRequestParams.Body =
io.NopCloser(bytes.NewReader([]byte("{\"otherStructure\":\"abcde\"}")))
- err = setTarget(nonEmptyRequestParams, constant.RequestBody,
"testStruct", map[string]interface{}{"test": "happy", "name": "mock"})
+ err = setTarget(nonEmptyRequestParams, constant.RequestBody,
"testStruct", map[string]any{"test": "happy", "name": "mock"})
assert.Nil(t, err)
rawBody, err = io.ReadAll(nonEmptyRequestParams.Body)
assert.Nil(t, err)
diff --git a/pkg/client/mapper.go b/pkg/client/mapper.go
index df745f9a..26b5ba3f 100644
--- a/pkg/client/mapper.go
+++ b/pkg/client/mapper.go
@@ -35,7 +35,7 @@ import (
// ParamMapper defines the interface about how to map the params in the
inbound request.
type ParamMapper interface {
// Map implements how the request parameters map to the target
parameters described by config.MappingParam
- Map(config.MappingParam, *Request, interface{}, RequestOption) error
+ Map(config.MappingParam, *Request, any, RequestOption) error
}
// ParseMapSource parses the source parameter config in the mappingParams
@@ -50,7 +50,7 @@ func ParseMapSource(source string) (from string, params
[]string, err error) {
}
// GetMapValue return the value from map base on the path
-func GetMapValue(sourceMap map[string]interface{}, keys []string)
(interface{}, error) {
+func GetMapValue(sourceMap map[string]any, keys []string) (any, error) {
if len(keys) > 0 && keys[0] == constant.DefaultBodyAll {
return sourceMap, nil
}
@@ -65,7 +65,7 @@ func GetMapValue(sourceMap map[string]interface{}, keys
[]string) (interface{},
if rvalue.Type().Kind() != reflect.Map && len(keys) == 1 {
return rvalue.Interface(), nil
}
- deeperStruct, ok := sourceMap[keys[0]].(map[string]interface{})
+ deeperStruct, ok := sourceMap[keys[0]].(map[string]any)
if !ok {
return nil, errors.Errorf("%s is not a map structure. It
contains %v", keys[0], sourceMap[keys[0]])
}
diff --git a/pkg/client/mapper_test.go b/pkg/client/mapper_test.go
index a128ab8d..b6e20918 100644
--- a/pkg/client/mapper_test.go
+++ b/pkg/client/mapper_test.go
@@ -49,9 +49,9 @@ func TestParseMapSource(t *testing.T) {
}
func TestGetMapValue(t *testing.T) {
- testMap := map[string]interface{}{
+ testMap := map[string]any{
"Test": "test",
- "structure": map[string]interface{}{
+ "structure": map[string]any{
"name": "joe",
"age": 77,
},
@@ -68,11 +68,11 @@ func TestGetMapValue(t *testing.T) {
val, err = GetMapValue(testMap, []string{"structure", "name"})
assert.Nil(t, err)
assert.Equal(t, val, "joe")
- val, err = GetMapValue(map[string]interface{}{}, []string{"structure"})
+ val, err = GetMapValue(map[string]any{}, []string{"structure"})
assert.Nil(t, val)
assert.EqualError(t, err, "structure does not exist in request body")
- val, err = GetMapValue(map[string]interface{}{"structure": "test"},
[]string{"structure", "name"})
+ val, err = GetMapValue(map[string]any{"structure": "test"},
[]string{"structure", "name"})
assert.Nil(t, val)
assert.EqualError(t, err, "structure is not a map structure. It
contains test")
}
diff --git a/pkg/client/mq/mq.go b/pkg/client/mq/mq.go
index 5a98ba10..96334cb2 100644
--- a/pkg/client/mq/mq.go
+++ b/pkg/client/mq/mq.go
@@ -90,7 +90,7 @@ func (c Client) Close() error {
return nil
}
-func (c Client) Call(req *client.Request) (res interface{}, err error) {
+func (c Client) Call(req *client.Request) (res any, err error) {
body, err := io.ReadAll(req.IngressRequest.Body)
if err != nil {
return nil, err
@@ -154,6 +154,6 @@ func (c Client) Call(req *client.Request) (res interface{},
err error) {
return nil, nil
}
-func (c Client) MapParams(req *client.Request) (reqData interface{}, err
error) {
+func (c Client) MapParams(req *client.Request) (reqData any, err error) {
return nil, perrors.New("map params does not support on mq mqClient")
}
diff --git a/pkg/client/triple/triple.go b/pkg/client/triple/triple.go
index 70710bfd..cb6031e9 100644
--- a/pkg/client/triple/triple.go
+++ b/pkg/client/triple/triple.go
@@ -63,7 +63,7 @@ func (tc *Client) Apply() error {
panic("implement me")
}
-func (tc *Client) MapParams(req *client.Request) (reqData interface{}, err
error) {
+func (tc *Client) MapParams(req *client.Request) (reqData any, err error) {
panic("implement me")
}
@@ -78,7 +78,7 @@ func SingletonTripleClient(protoset []string) *Client {
}
// Call invoke service
-func (tc *Client) Call(req *client.Request) (res interface{}, err error) {
+func (tc *Client) Call(req *client.Request) (res any, err error) {
address :=
strings.Split(req.API.IntegrationRequest.HTTPBackendConfig.URL, ":")
p := proxy.NewProxy()
targetURL := &url.URL{
diff --git a/pkg/cluster/healthcheck/healthcheck.go
b/pkg/cluster/healthcheck/healthcheck.go
index 4f6a7cb1..d3046833 100644
--- a/pkg/cluster/healthcheck/healthcheck.go
+++ b/pkg/cluster/healthcheck/healthcheck.go
@@ -43,7 +43,7 @@ const (
type HealthChecker struct {
checkers map[string]*EndpointChecker
- sessionConfig map[string]interface{}
+ sessionConfig map[string]any
// check config
timeout time.Duration
intervalBase time.Duration
diff --git a/pkg/common/constant/jtypes.go b/pkg/common/constant/jtypes.go
index 2184642d..0f3d4370 100644
--- a/pkg/common/constant/jtypes.go
+++ b/pkg/common/constant/jtypes.go
@@ -23,7 +23,7 @@ import (
)
// Object represents the java.lang.Object type
-type Object interface{}
+type Object any
// JTypeMapper maps the java basic types to golang types
var JTypeMapper = map[string]reflect.Type{
diff --git a/pkg/common/extension/adapter/adapter.go
b/pkg/common/extension/adapter/adapter.go
index 365dd36b..cf09f7b4 100644
--- a/pkg/common/extension/adapter/adapter.go
+++ b/pkg/common/extension/adapter/adapter.go
@@ -48,7 +48,7 @@ type (
// Apply init
Apply() error
// Config get config for Adapter
- Config() interface{}
+ Config() any
}
)
diff --git a/pkg/common/extension/adapter/adapter_test.go
b/pkg/common/extension/adapter/adapter_test.go
index c0f16977..0a73179e 100644
--- a/pkg/common/extension/adapter/adapter_test.go
+++ b/pkg/common/extension/adapter/adapter_test.go
@@ -53,7 +53,7 @@ func (a *DemoAdapter) Apply() error {
}
// Config get config for Adapter
-func (a *DemoAdapter) Config() interface{} {
+func (a *DemoAdapter) Config() any {
return a.cfg
}
diff --git a/pkg/common/extension/filter/filter.go
b/pkg/common/extension/filter/filter.go
index de19ab23..8828fabf 100644
--- a/pkg/common/extension/filter/filter.go
+++ b/pkg/common/extension/filter/filter.go
@@ -45,7 +45,7 @@ type (
// HttpFilterFactory describe http filter
HttpFilterFactory interface {
// Config Expose the config so that Filter Manger can inject
it, so it must be a pointer
- Config() interface{}
+ Config() any
// Apply After the config is injected, check it or make it to
default
Apply() error
@@ -80,9 +80,9 @@ type (
// Kind returns the unique kind name to represent itself.
Kind() string
// CreateFilterFactory return the filter callback
- CreateFilter(config interface{}) (NetworkFilter, error)
+ CreateFilter(config any) (NetworkFilter, error)
// Config Expose the config so that Filter Manger can inject
it, so it must be a pointer
- Config() interface{}
+ Config() any
}
// NetworkFilter describe network filter
@@ -90,13 +90,13 @@ type (
// ServeHTTP handle http request and response
ServeHTTP(w stdHttp.ResponseWriter, r *stdHttp.Request)
// OnDecode decode bytes received from getty server
- OnDecode(data []byte) (interface{}, int, error)
+ OnDecode(data []byte) (any, int, error)
// OnEncode encode interface sent to getty server
- OnEncode(p interface{}) ([]byte, error)
+ OnEncode(p any) ([]byte, error)
// OnData dubbo rpc invocation from getty server
- OnData(data interface{}) (interface{}, error)
+ OnData(data any) (any, error)
// OnTripleData triple rpc invocation from triple-server
- OnTripleData(ctx context.Context, methodName string, arguments
[]interface{}) (interface{}, error)
+ OnTripleData(ctx context.Context, methodName string, arguments
[]any) (any, error)
}
// EmptyNetworkFilter default empty network filter adapter which offers
empty function implements
@@ -113,9 +113,9 @@ type (
// Kind returns the unique kind name to represent itself.
Kind() string
// CreateFilter return the filter callback
- CreateFilter(config interface{}) (DubboFilter, error)
+ CreateFilter(config any) (DubboFilter, error)
// Config Expose the config so that Filter Manger can inject
it, so it must be a pointer
- Config() interface{}
+ Config() any
}
)
@@ -126,22 +126,22 @@ var (
)
// OnDecode empty implement
-func (enf *EmptyNetworkFilter) OnDecode(data []byte) (interface{}, int, error)
{
+func (enf *EmptyNetworkFilter) OnDecode(data []byte) (any, int, error) {
panic("OnDecode is not implemented")
}
// OnEncode empty implement
-func (enf *EmptyNetworkFilter) OnEncode(p interface{}) ([]byte, error) {
+func (enf *EmptyNetworkFilter) OnEncode(p any) ([]byte, error) {
panic("OnEncode is not implemented")
}
// OnData receive data from listener
-func (enf *EmptyNetworkFilter) OnData(data interface{}) (interface{}, error) {
+func (enf *EmptyNetworkFilter) OnData(data any) (any, error) {
panic("OnData is not implemented")
}
// OnTripleData empty implement
-func (enf *EmptyNetworkFilter) OnTripleData(ctx context.Context, methodName
string, arguments []interface{}) (interface{}, error) {
+func (enf *EmptyNetworkFilter) OnTripleData(ctx context.Context, methodName
string, arguments []any) (any, error) {
panic("OnTripleData is not implemented")
}
diff --git a/pkg/common/extension/filter/filter_manager.go
b/pkg/common/extension/filter/filter_manager.go
index 01b0fe03..7e08baf7 100644
--- a/pkg/common/extension/filter/filter_manager.go
+++ b/pkg/common/extension/filter/filter_manager.go
@@ -96,7 +96,7 @@ func (fm *FilterManager) ReLoad(filters []*model.HTTPFilter) {
}
// Apply return a new filter factory by name & conf
-func (fm *FilterManager) Apply(name string, conf map[string]interface{})
(HttpFilterFactory, error) {
+func (fm *FilterManager) Apply(name string, conf map[string]any)
(HttpFilterFactory, error) {
plugin, err := GetHttpFilterPlugin(name)
if err != nil {
return nil, errors.New("filter not found")
diff --git a/pkg/common/extension/filter/filter_manager_test.go
b/pkg/common/extension/filter/filter_manager_test.go
index 63f33384..e0bce702 100644
--- a/pkg/common/extension/filter/filter_manager_test.go
+++ b/pkg/common/extension/filter/filter_manager_test.go
@@ -95,7 +95,7 @@ func (f *DemoFilterFactory) PrepareFilterChain(ctx
*contexthttp.HttpContext, cha
return nil
}
-func (f *DemoFilterFactory) Config() interface{} {
+func (f *DemoFilterFactory) Config() any {
return f.conf
}
@@ -106,7 +106,7 @@ func (f *DemoFilterFactory) Apply() error {
func TestApply(t *testing.T) {
fm := NewEmptyFilterManager()
- conf := map[string]interface{}{}
+ conf := map[string]any{}
conf["foo"] = "Cat"
conf["bar"] = "The Walnut"
f, err := fm.Apply(DEMO, conf)
@@ -120,7 +120,7 @@ func TestApply(t *testing.T) {
func TestLoad(t *testing.T) {
fm := NewEmptyFilterManager()
- conf := map[string]interface{}{}
+ conf := map[string]any{}
conf["foo"] = "Cat"
conf["bar"] = "The Walnut"
diff --git a/pkg/common/http/manager.go b/pkg/common/http/manager.go
index f2b3d809..cd37a6d4 100644
--- a/pkg/common/http/manager.go
+++ b/pkg/common/http/manager.go
@@ -54,7 +54,7 @@ type HttpConnectionManager struct {
// CreateHttpConnectionManager create http connection manager
func CreateHttpConnectionManager(hcmc *model.HttpConnectionManagerConfig)
*HttpConnectionManager {
hcm := &HttpConnectionManager{config: hcmc}
- hcm.pool.New = func() interface{} {
+ hcm.pool.New = func() any {
return hcm.allocateContext()
}
hcm.routerCoordinator =
router2.CreateRouterCoordinator(&hcmc.RouteConfig)
@@ -65,7 +65,7 @@ func CreateHttpConnectionManager(hcmc
*model.HttpConnectionManagerConfig) *HttpC
func (hcm *HttpConnectionManager) allocateContext() *pch.HttpContext {
return &pch.HttpContext{
- Params: make(map[string]interface{}),
+ Params: make(map[string]any),
}
}
diff --git a/pkg/common/http/manager_test.go b/pkg/common/http/manager_test.go
index 450546a5..480272ef 100644
--- a/pkg/common/http/manager_test.go
+++ b/pkg/common/http/manager_test.go
@@ -106,7 +106,7 @@ func (f *DemoFilterFactory) PrepareFilterChain(ctx
*contexthttp.HttpContext, cha
return nil
}
-func (f *DemoFilterFactory) Config() interface{} {
+func (f *DemoFilterFactory) Config() any {
return f.conf
}
diff --git a/pkg/common/mock/routerfilter.go b/pkg/common/mock/routerfilter.go
index 046ccd13..f429ca30 100644
--- a/pkg/common/mock/routerfilter.go
+++ b/pkg/common/mock/routerfilter.go
@@ -69,7 +69,7 @@ func (p *Plugin) CreateFilterFactory()
(filter.HttpFilterFactory, error) {
return &FilterFactory{cfg: &Config{}}, nil
}
-func (ff *FilterFactory) Config() interface{} {
+func (ff *FilterFactory) Config() any {
return ff.cfg
}
diff --git a/pkg/common/router/trie/trie.go b/pkg/common/router/trie/trie.go
index 5060fa87..4423cf8f 100644
--- a/pkg/common/router/trie/trie.go
+++ b/pkg/common/router/trie/trie.go
@@ -41,7 +41,7 @@ func NewTrie() Trie {
}
// NewTrieWithDefault
-func NewTrieWithDefault(path string, defVal interface{}) Trie {
+func NewTrieWithDefault(path string, defVal any) Trie {
ret := Trie{root: Node{endOfPath: false, matchStr: ""}}
_, _ = ret.Put(path, defVal)
return ret
@@ -55,7 +55,7 @@ type Node struct {
PathVariableNode *Node // in path /:a/b/c/:d , /b/c/:d is a
child tree of pathVariable node :a ,and some special logic for match
pathVariable it better not store in children.
MatchAllNode *Node // /a/b/** /** is a match all Node.
endOfPath bool // if true means a real path exists ,
/a/b/c/d only node of d is true, a,b,c is false.
- bizInfo interface{} // route info and any other info
store here.
+ bizInfo any // route info and any other info
store here.
}
func (trie *Trie) Clear() bool {
@@ -68,7 +68,7 @@ func (trie *Trie) IsEmpty() bool {
}
// Put put key and values into trie as map.
-func (trie *Trie) Put(withOutHost string, bizInfo interface{}) (bool, error) {
+func (trie *Trie) Put(withOutHost string, bizInfo any) (bool, error) {
if bizInfo == nil {
return false, errors.Errorf("data to put should not be nil.")
}
@@ -77,7 +77,7 @@ func (trie *Trie) Put(withOutHost string, bizInfo
interface{}) (bool, error) {
}
// Put put key and values into trie as map.
-func (trie *Trie) PutOrUpdate(withOutHost string, bizInfo interface{}) (bool,
error) {
+func (trie *Trie) PutOrUpdate(withOutHost string, bizInfo any) (bool, error) {
if bizInfo == nil {
return false, errors.Errorf("data to put should not be nil.")
}
@@ -146,7 +146,7 @@ func (trie Trie) Contains(withOutHost string) (bool, error)
{
}
// Put node put
-func (node *Node) internalPut(keys []string, bizInfo interface{}) (bool,
error) {
+func (node *Node) internalPut(keys []string, bizInfo any) (bool, error) {
// empty node initialization
if node.children == nil {
node.children = map[string]*Node{}
@@ -189,7 +189,7 @@ func (node *Node) IsEmpty() bool {
}
// GetBizInfo get info
-func (node *Node) GetBizInfo() interface{} {
+func (node *Node) GetBizInfo() any {
return node.bizInfo
}
@@ -283,7 +283,7 @@ func (node *Node) Get(keys []string) (*Node, []string,
bool, error) {
}
-func (node *Node) put(key string, isReal bool, bizInfo interface{}) bool {
+func (node *Node) put(key string, isReal bool, bizInfo any) bool {
if !stringutil.IsPathVariableOrWildcard(key) {
if stringutil.IsMatchAll(key) {
@@ -296,7 +296,7 @@ func (node *Node) put(key string, isReal bool, bizInfo
interface{}) bool {
return node.putPathVariable(pathVariable, isReal, bizInfo)
}
-func (node *Node) putPathVariable(pathVariable string, isReal bool, bizInfo
interface{}) bool {
+func (node *Node) putPathVariable(pathVariable string, isReal bool, bizInfo
any) bool {
//path variable put
if node.PathVariableNode == nil {
node.PathVariableNode = &Node{endOfPath: false}
@@ -317,7 +317,7 @@ func (node *Node) putPathVariable(pathVariable string,
isReal bool, bizInfo inte
return true
}
-func (node *Node) putNode(matchStr string, isReal bool, bizInfo interface{})
bool {
+func (node *Node) putNode(matchStr string, isReal bool, bizInfo any) bool {
selfNode := &Node{endOfPath: isReal, matchStr: matchStr}
old := node.children[matchStr]
@@ -339,7 +339,7 @@ func (node *Node) putNode(matchStr string, isReal bool,
bizInfo interface{}) boo
return true
}
-func (node *Node) putMatchAllNode(matchStr string, isReal bool, bizInfo
interface{}) bool {
+func (node *Node) putMatchAllNode(matchStr string, isReal bool, bizInfo any)
bool {
selfNode := &Node{endOfPath: isReal, matchStr: matchStr}
old := node.MatchAllNode
diff --git a/pkg/common/util/response.go b/pkg/common/util/response.go
index 5d4403a3..347632e6 100644
--- a/pkg/common/util/response.go
+++ b/pkg/common/util/response.go
@@ -28,25 +28,25 @@ import (
"github.com/apache/dubbo-go-pixiu/pkg/client"
)
-func NewDubboResponse(data interface{}, hump bool) *client.UnaryResponse {
+func NewDubboResponse(data any, hump bool) *client.UnaryResponse {
r, _ := dealResp(data, hump)
bytes, _ := json.Marshal(r)
return &client.UnaryResponse{Data: bytes}
}
-func dealResp(in interface{}, HumpToLine bool) (interface{}, error) {
+func dealResp(in any, HumpToLine bool) (any, error) {
if in == nil {
return in, nil
}
switch reflect.TypeOf(in).Kind() {
case reflect.Map:
- if _, ok := in.(map[interface{}]interface{}); ok {
+ if _, ok := in.(map[any]any); ok {
m := mapIItoMapSI(in)
if HumpToLine {
m = humpToLine(m)
}
return m, nil
- } else if inm, ok := in.(map[string]interface{}); ok {
+ } else if inm, ok := in.(map[string]any); ok {
if HumpToLine {
m := humpToLine(in)
return m, nil
@@ -59,7 +59,7 @@ func dealResp(in interface{}, HumpToLine bool) (interface{},
error) {
return data, nil
}
value := reflect.ValueOf(in)
- newTemps := make([]interface{}, 0, value.Len())
+ newTemps := make([]any, 0, value.Len())
for i := 0; i < value.Len(); i++ {
if value.Index(i).CanInterface() {
newTemp, e :=
dealResp(value.Index(i).Interface(), HumpToLine)
@@ -78,14 +78,14 @@ func dealResp(in interface{}, HumpToLine bool)
(interface{}, error) {
return in, nil
}
-func mapIItoMapSI(in interface{}) interface{} {
- var inMap map[interface{}]interface{}
- if v, ok := in.(map[interface{}]interface{}); !ok {
+func mapIItoMapSI(in any) any {
+ var inMap map[any]any
+ if v, ok := in.(map[any]any); !ok {
return in
} else {
inMap = v
}
- outMap := make(map[string]interface{}, len(inMap))
+ outMap := make(map[string]any, len(inMap))
for k, v := range inMap {
if v == nil {
@@ -99,12 +99,12 @@ func mapIItoMapSI(in interface{}) interface{} {
vt := reflect.TypeOf(v)
switch vt.Kind() {
case reflect.Map:
- if _, ok := v.(map[interface{}]interface{}); ok {
+ if _, ok := v.(map[any]any); ok {
v = mapIItoMapSI(v)
}
case reflect.Slice:
vl := reflect.ValueOf(v)
- os := make([]interface{}, 0, vl.Len())
+ os := make([]any, 0, vl.Len())
for i := 0; i < vl.Len(); i++ {
if vl.Index(i).CanInterface() {
osv :=
mapIItoMapSI(vl.Index(i).Interface())
@@ -120,15 +120,15 @@ func mapIItoMapSI(in interface{}) interface{} {
}
// traverse all the keys in the map and change the hump to underline
-func humpToLine(in interface{}) interface{} {
- var m map[string]interface{}
- if v, ok := in.(map[string]interface{}); ok {
+func humpToLine(in any) any {
+ var m map[string]any
+ if v, ok := in.(map[string]any); ok {
m = v
} else {
return in
}
- out := make(map[string]interface{}, len(m))
+ out := make(map[string]any, len(m))
for k1, v1 := range m {
x := humpToUnderline(k1)
@@ -138,7 +138,7 @@ func humpToLine(in interface{}) interface{} {
out[x] = humpToLine(struct2Map(v1))
} else if reflect.TypeOf(v1).Kind() == reflect.Slice {
value := reflect.ValueOf(v1)
- newTemps := make([]interface{}, 0, value.Len())
+ newTemps := make([]any, 0, value.Len())
for i := 0; i < value.Len(); i++ {
newTemp :=
humpToLine(value.Index(i).Interface())
newTemps = append(newTemps, newTemp)
@@ -170,11 +170,11 @@ func humpToUnderline(s string) string {
return strings.ToLower(string(data[:]))
}
-func struct2Map(obj interface{}) map[string]interface{} {
+func struct2Map(obj any) map[string]any {
t := reflect.TypeOf(obj)
v := reflect.ValueOf(obj)
- data := make(map[string]interface{})
+ data := make(map[string]any)
for i := 0; i < t.NumField(); i++ {
data[t.Field(i).Name] = v.Field(i).Interface()
}
diff --git a/pkg/common/util/response_test.go b/pkg/common/util/response_test.go
index 9e24aa0c..74bb3827 100644
--- a/pkg/common/util/response_test.go
+++ b/pkg/common/util/response_test.go
@@ -27,13 +27,13 @@ import (
func TestNewDubboMapResponse(t *testing.T) {
slice := append(make([]string, 0), "read")
- resp := map[string]interface{}{
+ resp := map[string]any{
"age": 18,
"iD": 0o001,
"name": "tc",
"time": nil,
"hobby": slice,
- "father": map[string]interface{}{
+ "father": map[string]any{
"name": "bob",
},
}
@@ -41,23 +41,23 @@ func TestNewDubboMapResponse(t *testing.T) {
if err != nil {
t.Error("failed to deal resp")
}
- r := result.(map[string]interface{})
+ r := result.(map[string]any)
assert.Equal(t, 18, r["age"])
assert.Equal(t, 1, r["iD"])
assert.Equal(t, "tc", r["name"])
assert.Equal(t, "read", r["hobby"].([]string)[0])
- assert.Equal(t, "bob", r["father"].(map[string]interface{})["name"])
+ assert.Equal(t, "bob", r["father"].(map[string]any)["name"])
}
func TestNewDubboMapHumpResponse(t *testing.T) {
slice := append(make([]string, 0), "readBook")
- resp := map[string]interface{}{
+ resp := map[string]any{
"age": 18,
"iD": 0o001,
"name": "tc",
"time": nil,
"simpleHobby": slice,
- "father": map[string]interface{}{
+ "father": map[string]any{
"name": "bob",
},
}
@@ -65,21 +65,21 @@ func TestNewDubboMapHumpResponse(t *testing.T) {
if err != nil {
t.Error("failed to deal resp")
}
- r := result.(map[string]interface{})
+ r := result.(map[string]any)
assert.Equal(t, 18, r["age"])
assert.Equal(t, 1, r["i_d"])
assert.Equal(t, "tc", r["name"])
- assert.Equal(t, "readBook", r["simple_hobby"].([]interface{})[0])
- assert.Equal(t, "bob", r["father"].(map[string]interface{})["name"])
+ assert.Equal(t, "readBook", r["simple_hobby"].([]any)[0])
+ assert.Equal(t, "bob", r["father"].(map[string]any)["name"])
}
func TestNewDubboSliceResponse(t *testing.T) {
- resp := append(make([]map[string]interface{}, 0),
map[string]interface{}{
+ resp := append(make([]map[string]any, 0), map[string]any{
"age": 18,
"iD": 0o001,
"name": "tc",
"time": nil,
- "father": map[string]interface{}{
+ "father": map[string]any{
"name": "bob",
},
})
@@ -87,9 +87,9 @@ func TestNewDubboSliceResponse(t *testing.T) {
if err != nil {
t.Error("failed to deal resp")
}
- r := result.([]interface{})[0].(map[string]interface{})
+ r := result.([]any)[0].(map[string]any)
assert.Equal(t, 18, r["age"])
assert.Equal(t, 1, r["iD"])
assert.Equal(t, "tc", r["name"])
- assert.Equal(t, "bob", r["father"].(map[string]interface{})["name"])
+ assert.Equal(t, "bob", r["father"].(map[string]any)["name"])
}
diff --git a/pkg/common/yaml/yaml.go b/pkg/common/yaml/yaml.go
index 2f6281d5..c7bae3b1 100644
--- a/pkg/common/yaml/yaml.go
+++ b/pkg/common/yaml/yaml.go
@@ -41,7 +41,7 @@ func LoadYMLConfig(confProFile string) ([]byte, error) {
}
// UnmarshalYMLConfig Load yml config byte from file, then unmarshal to object
-func UnmarshalYMLConfig(confProFile string, out interface{}) error {
+func UnmarshalYMLConfig(confProFile string, out any) error {
confFileStream, err := LoadYMLConfig(confProFile)
if err != nil {
return perrors.Errorf("os.ReadFile(file:%s) = error:%v",
confProFile, perrors.WithStack(err))
@@ -50,17 +50,17 @@ func UnmarshalYMLConfig(confProFile string, out
interface{}) error {
}
// UnmarshalYML unmarshals decodes the first document found within the in byte
slice and assigns decoded values into the out value.
-func UnmarshalYML(data []byte, out interface{}) error {
+func UnmarshalYML(data []byte, out any) error {
return yaml.Unmarshal(data, out)
}
// MarshalYML serializes the value provided into a YAML document.
-func MarshalYML(in interface{}) ([]byte, error) {
+func MarshalYML(in any) ([]byte, error) {
return yaml.Marshal(in)
}
// ParseConfig get config struct from map[string]interface{}
-func ParseConfig(factoryConfStruct interface{}, conf map[string]interface{})
error {
+func ParseConfig(factoryConfStruct any, conf map[string]any) error {
// conf will be map, convert to yaml
yamlBytes, err := yaml.Marshal(conf)
if err != nil {
diff --git a/pkg/config/config_load.go b/pkg/config/config_load.go
index cef11034..6c5c3033 100644
--- a/pkg/config/config_load.go
+++ b/pkg/config/config_load.go
@@ -133,7 +133,7 @@ func GetHttpConfig(cfg *model.Bootstrap) (err error) {
for i, l := range cfg.StaticResources.Listeners {
hc := &model.HttpConfig{}
if l.Config != nil {
- if v, ok := l.Config.(map[string]interface{}); ok {
+ if v, ok := l.Config.(map[string]any); ok {
logger.Info("http config:", v, ok)
switch l.Name {
case constant.DefaultHTTPType:
diff --git a/pkg/config/config_load_test.go b/pkg/config/config_load_test.go
index e3ce5ec8..0f033b76 100644
--- a/pkg/config/config_load_test.go
+++ b/pkg/config/config_load_test.go
@@ -77,7 +77,7 @@ func TestMain(m *testing.M) {
TimeoutStr: "10s",
}
- var inInterface map[string]interface{}
+ var inInterface map[string]any
inrec, _ := json.Marshal(hcmc)
_ = json.Unmarshal(inrec, &inInterface)
b = model.Bootstrap{
diff --git a/pkg/config/xds/apiclient/grpc.go b/pkg/config/xds/apiclient/grpc.go
index 3de81cfb..10a43840 100644
--- a/pkg/config/xds/apiclient/grpc.go
+++ b/pkg/config/xds/apiclient/grpc.go
@@ -328,7 +328,7 @@ func (g *GRPCClusterManager) GetGrpcCluster(name string)
(*GRPCCluster, error) {
func (g *GRPCClusterManager) Close() (err error) {
//todo enhance the close process when concurrent
- g.clusters.Range(func(_, value interface{}) bool {
+ g.clusters.Range(func(_, value any) bool {
if conn := value.(*grpc.ClientConn); conn != nil {
if err = conn.Close(); err != nil {
logger.Errorf("can not close grpc connection.",
err)
diff --git a/pkg/config/xds/lds.go b/pkg/config/xds/lds.go
index cc455d12..028754a1 100644
--- a/pkg/config/xds/lds.go
+++ b/pkg/config/xds/lds.go
@@ -188,7 +188,7 @@ func (l *LdsManager) makeFilters(filters
[]*xdsModel.NetworkFilter) []model.Netw
return result
}
-func (l *LdsManager) makeConfig(filter *xdsModel.NetworkFilter) (m
map[string]interface{}) {
+func (l *LdsManager) makeConfig(filter *xdsModel.NetworkFilter) (m
map[string]any) {
switch cfg := filter.Config.(type) {
case *xdsModel.NetworkFilter_Yaml:
if err := yaml.Unmarshal([]byte(cfg.Yaml.Content), &m); err !=
nil {
diff --git a/pkg/config/xds/lds_test.go b/pkg/config/xds/lds_test.go
index 9f71ab12..9c22f54a 100644
--- a/pkg/config/xds/lds_test.go
+++ b/pkg/config/xds/lds_test.go
@@ -48,26 +48,26 @@ http_filters:
- name: dgp.filter.http.response
config:
`
- configMap := map[string]interface{}{
- "route_config": map[string]interface{}{
- "routes": []interface{}{
- map[string]interface{}{
- "match": map[string]interface{}{
+ configMap := map[string]any{
+ "route_config": map[string]any{
+ "routes": []any{
+ map[string]any{
+ "match": map[string]any{
"prefix": "/",
},
- "route": map[string]interface{}{
+ "route": map[string]any{
"cluster":
"http_bin",
"cluster_not_found_response_code": "505",
},
},
},
},
- "http_filters": []interface{}{
- map[string]interface{}{
+ "http_filters": []any{
+ map[string]any{
"name": "dgp.filter.http.httpproxy",
"config": nil,
},
- map[string]interface{}{
+ map[string]any{
"name": "dgp.filter.http.response",
"config": nil,
},
@@ -75,26 +75,26 @@ http_filters:
}
httpManagerConfigStruct, _ := structpb2.NewStruct(configMap)
- oneConfigMap := map[string]interface{}{
- "route_config": map[interface{}]interface{}{
- "routes": []interface{}{
- map[interface{}]interface{}{
- "match": map[interface{}]interface{}{
+ oneConfigMap := map[string]any{
+ "route_config": map[any]any{
+ "routes": []any{
+ map[any]any{
+ "match": map[any]any{
"prefix": "/",
},
- "route": map[interface{}]interface{}{
+ "route": map[any]any{
"cluster":
"http_bin",
"cluster_not_found_response_code": "505",
},
},
},
},
- "http_filters": []interface{}{
- map[interface{}]interface{}{
+ "http_filters": []any{
+ map[any]any{
"name": "dgp.filter.http.httpproxy",
"config": nil,
},
- map[interface{}]interface{}{
+ map[any]any{
"name": "dgp.filter.http.response",
"config": nil,
},
@@ -107,7 +107,7 @@ http_filters:
tests := []struct {
name string
args args
- wantM map[string]interface{}
+ wantM map[string]any
}{
{
name: "yaml",
diff --git a/pkg/context/base_context.go b/pkg/context/base_context.go
index a34e4758..114abaa6 100644
--- a/pkg/context/base_context.go
+++ b/pkg/context/base_context.go
@@ -46,7 +46,7 @@ type (
GetClientIP() string
GetApplicationName() string
- WriteErr(p interface{})
+ WriteErr(p any)
Request()
Response()
diff --git a/pkg/context/http/context.go b/pkg/context/http/context.go
index ec6d1378..9674f1a0 100644
--- a/pkg/context/http/context.go
+++ b/pkg/context/http/context.go
@@ -49,7 +49,7 @@ type HttpContext struct {
Filters FilterChain
Timeout time.Duration
Ctx context.Context
- Params map[string]interface{}
+ Params map[string]any
// localReply Means that the request was interrupted,
// which may occur in the Decode or Encode stage
@@ -61,7 +61,7 @@ type HttpContext struct {
// the response context will return.
TargetResp client.Response
// client call response.
- SourceResp interface{}
+ SourceResp any
HttpConnectionManager model.HttpConnectionManagerConfig
Route *model.RouteAction
diff --git a/pkg/filter/accesslog/access_log.go
b/pkg/filter/accesslog/access_log.go
index 938dca2a..58a5baf5 100644
--- a/pkg/filter/accesslog/access_log.go
+++ b/pkg/filter/accesslog/access_log.go
@@ -99,7 +99,7 @@ func (f *Filter) Encode(c *http.HttpContext)
filter.FilterStatus {
}
// Config return config of filter
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.conf
}
@@ -152,7 +152,7 @@ func buildAccessLogMsg(c *http.HttpContext, cost
time.Duration) string {
// nolint
// converter interface to byte array
-func getBytes(key interface{}) ([]byte, error) {
+func getBytes(key any) ([]byte, error) {
var buf bytes.Buffer
enc := gob.NewEncoder(&buf)
err := enc.Encode(key)
diff --git a/pkg/filter/auth/jwt/jwt.go b/pkg/filter/auth/jwt/jwt.go
index 9179a313..f46d8572 100644
--- a/pkg/filter/auth/jwt/jwt.go
+++ b/pkg/filter/auth/jwt/jwt.go
@@ -220,6 +220,6 @@ func checkToken(value, prefix, providerName string,
provider Provider) bool {
return token.Valid
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.cfg
}
diff --git a/pkg/filter/authority/authority.go
b/pkg/filter/authority/authority.go
index dbb97727..5f0aa130 100644
--- a/pkg/filter/authority/authority.go
+++ b/pkg/filter/authority/authority.go
@@ -56,7 +56,7 @@ func (p *Plugin) CreateFilterFactory()
(filter.HttpFilterFactory, error) {
return &FilterFactory{cfg: &AuthorityConfiguration{}}, nil
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.cfg
}
diff --git a/pkg/filter/cors/cors.go b/pkg/filter/cors/cors.go
index 5191e8e4..780960f4 100644
--- a/pkg/filter/cors/cors.go
+++ b/pkg/filter/cors/cors.go
@@ -129,6 +129,6 @@ func (factory *FilterFactory) Apply() error {
return nil
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.cfg
}
diff --git a/pkg/filter/csrf/csrf.go b/pkg/filter/csrf/csrf.go
index c4b615b5..f660c3f5 100644
--- a/pkg/filter/csrf/csrf.go
+++ b/pkg/filter/csrf/csrf.go
@@ -135,6 +135,6 @@ func (factory *FilterFactory) Apply() error {
return nil
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.cfg
}
diff --git a/pkg/filter/event/event.go b/pkg/filter/event/event.go
index c6516e77..ca89eff6 100644
--- a/pkg/filter/event/event.go
+++ b/pkg/filter/event/event.go
@@ -90,6 +90,6 @@ func (factory *FilterFactory) Apply() error {
return nil
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.cfg
}
diff --git a/pkg/filter/failinject/filter.go b/pkg/filter/failinject/filter.go
index 865bd413..460affe7 100644
--- a/pkg/filter/failinject/filter.go
+++ b/pkg/filter/failinject/filter.go
@@ -52,7 +52,7 @@ func (factory *FilterFactory) Apply() error {
return nil
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.cfg
}
diff --git a/pkg/filter/header/header.go b/pkg/filter/header/header.go
index ffbe38ed..4b078eda 100644
--- a/pkg/filter/header/header.go
+++ b/pkg/filter/header/header.go
@@ -59,7 +59,7 @@ func (p *Plugin) CreateFilterFactory()
(filter.HttpFilterFactory, error) {
return &FilterFactory{}, nil
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.cfg
}
diff --git a/pkg/filter/host/host.go b/pkg/filter/host/host.go
index 463ccfb9..233cf43c 100644
--- a/pkg/filter/host/host.go
+++ b/pkg/filter/host/host.go
@@ -68,7 +68,7 @@ func (f *Filter) Decode(c *contexthttp.HttpContext)
filter.FilterStatus {
c.Request.Host = f.cfg.Host
return filter.Continue
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.cfg
}
diff --git a/pkg/filter/http/apiconfig/api_config.go
b/pkg/filter/http/apiconfig/api_config.go
index 1d13e21d..a8e5d0fd 100644
--- a/pkg/filter/http/apiconfig/api_config.go
+++ b/pkg/filter/http/apiconfig/api_config.go
@@ -67,7 +67,7 @@ func (p *Plugin) CreateFilterFactory()
(filter.HttpFilterFactory, error) {
return &FilterFactory{cfg: &ApiConfigConfig{}}, nil
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.cfg
}
diff --git a/pkg/filter/http/dubboproxy/dubbo.go
b/pkg/filter/http/dubboproxy/dubbo.go
index 78840d04..41548729 100644
--- a/pkg/filter/http/dubboproxy/dubbo.go
+++ b/pkg/filter/http/dubboproxy/dubbo.go
@@ -80,7 +80,7 @@ func (p *Plugin) CreateFilterFactory()
(filter.HttpFilterFactory, error) {
}
// Config return filter facotry config, now is empty
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.cfg
}
@@ -145,7 +145,7 @@ func (f *Filter) Decode(hc *pixiuHttp.HttpContext)
filter.FilterStatus {
return filter.Stop
}
- var body interface{}
+ var body any
if err := json.Unmarshal(rawBody, &body); err != nil {
logger.Infof("[dubbo-go-pixiu] unmarshal request body error
%v", err)
bt, _ := json.Marshal(pixiuHttp.ErrResponse{Message:
fmt.Sprintf("unmarshal request body error %v", err)})
@@ -153,7 +153,7 @@ func (f *Filter) Decode(hc *pixiuHttp.HttpContext)
filter.FilterStatus {
return filter.Stop
}
- inIArr := make([]interface{}, 3)
+ inIArr := make([]any, 3)
inVArr := make([]reflect.Value, 3)
inIArr[0] = method
@@ -167,8 +167,8 @@ func (f *Filter) Decode(hc *pixiuHttp.HttpContext)
filter.FilterStatus {
}
values := body
- if _, ok := values.([]interface{}); ok {
- for _, v := range values.([]interface{}) {
+ if _, ok := values.([]any); ok {
+ for _, v := range values.([]any) {
valuesList = append(valuesList, v)
}
} else {
@@ -214,7 +214,7 @@ func (f *Filter) Decode(hc *pixiuHttp.HttpContext)
filter.FilterStatus {
return filter.Stop
}
- var resp interface{}
+ var resp any
invoc.SetReply(&resp)
invCtx, cancel := context.WithTimeout(context.Background(), hc.Timeout)
diff --git a/pkg/filter/http/grpcproxy/grpc.go
b/pkg/filter/http/grpcproxy/grpc.go
index 9549cdc0..ddcbdc2b 100644
--- a/pkg/filter/http/grpcproxy/grpc.go
+++ b/pkg/filter/http/grpcproxy/grpc.go
@@ -380,7 +380,7 @@ func isServerTimeout(st *status.Status) bool {
return st.Code() == codes.DeadlineExceeded || st.Code() ==
codes.Canceled
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.cfg
}
diff --git a/pkg/filter/http/httpproxy/routerfilter.go
b/pkg/filter/http/httpproxy/routerfilter.go
index cb98da47..f1ba58f2 100644
--- a/pkg/filter/http/httpproxy/routerfilter.go
+++ b/pkg/filter/http/httpproxy/routerfilter.go
@@ -75,7 +75,7 @@ func (p *Plugin) CreateFilterFactory()
(filter.HttpFilterFactory, error) {
return &FilterFactory{cfg: &Config{}}, nil
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.cfg
}
diff --git a/pkg/filter/http/loadbalancer/loadbalancer.go
b/pkg/filter/http/loadbalancer/loadbalancer.go
index e037ec00..fe057746 100644
--- a/pkg/filter/http/loadbalancer/loadbalancer.go
+++ b/pkg/filter/http/loadbalancer/loadbalancer.go
@@ -60,7 +60,7 @@ func (p *Plugin) CreateFilterFactory()
(filter.HttpFilterFactory, error) {
return &FilterFactory{cfg: &Config{}}, nil
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.cfg
}
diff --git a/pkg/filter/http/proxyrewrite/rewrite.go
b/pkg/filter/http/proxyrewrite/rewrite.go
index f8ab7620..f04510a2 100644
--- a/pkg/filter/http/proxyrewrite/rewrite.go
+++ b/pkg/filter/http/proxyrewrite/rewrite.go
@@ -71,7 +71,7 @@ func (p *Plugin) CreateFilterFactory()
(filter.HttpFilterFactory, error) {
return &FilterFactory{cfg: &Config{}}, nil
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.cfg
}
diff --git a/pkg/filter/http/proxywasm/filter.go
b/pkg/filter/http/proxywasm/filter.go
index 255247c1..9979eff7 100644
--- a/pkg/filter/http/proxywasm/filter.go
+++ b/pkg/filter/http/proxywasm/filter.go
@@ -93,7 +93,7 @@ func (w *WasmFilter) Encode(ctx *http.HttpContext)
filter.FilterStatus {
return filter.Continue
}
-func (factory *WasmFilterFactory) Config() interface{} {
+func (factory *WasmFilterFactory) Config() any {
return factory.cfg
}
diff --git a/pkg/filter/http/proxywasm/filter_windows.go
b/pkg/filter/http/proxywasm/filter_windows.go
index 0dc4039a..d1421882 100644
--- a/pkg/filter/http/proxywasm/filter_windows.go
+++ b/pkg/filter/http/proxywasm/filter_windows.go
@@ -53,7 +53,7 @@ func (w *WasmFilter) Encode(ctx *http.HttpContext)
filter.FilterStatus {
return filter.Continue
}
-func (factory *WasmFilterFactory) Config() interface{} {
+func (factory *WasmFilterFactory) Config() any {
return factory.cfg
}
diff --git a/pkg/filter/http/remote/call.go b/pkg/filter/http/remote/call.go
index 83054e98..6c5c087e 100644
--- a/pkg/filter/http/remote/call.go
+++ b/pkg/filter/http/remote/call.go
@@ -84,7 +84,7 @@ func (p *Plugin) CreateFilterFactory()
(filter.HttpFilterFactory, error) {
return &FilterFactory{conf: &config{}}, nil
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.conf
}
diff --git a/pkg/filter/metric/metric.go b/pkg/filter/metric/metric.go
index fc4bba0a..6aaf600b 100644
--- a/pkg/filter/metric/metric.go
+++ b/pkg/filter/metric/metric.go
@@ -81,7 +81,7 @@ func (p *Plugin) CreateFilterFactory()
(filter.HttpFilterFactory, error) {
return &FilterFactory{}, nil
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return &struct{}{}
}
diff --git a/pkg/filter/network/dubboproxy/filter/http/httpfilter.go
b/pkg/filter/network/dubboproxy/filter/http/httpfilter.go
index 1593fe15..a8f0b626 100644
--- a/pkg/filter/network/dubboproxy/filter/http/httpfilter.go
+++ b/pkg/filter/network/dubboproxy/filter/http/httpfilter.go
@@ -69,13 +69,13 @@ func (p Plugin) Kind() string {
}
// CreateFilter return the filter
-func (p Plugin) CreateFilter(config interface{}) (filter.DubboFilter, error) {
+func (p Plugin) CreateFilter(config any) (filter.DubboFilter, error) {
cfg := config.(*Config)
return Filter{Config: cfg}, nil
}
// Config Expose the config so that Filter Manger can inject it, so it must be
a pointer
-func (p Plugin) Config() interface{} {
+func (p Plugin) Config() any {
return &Config{}
}
diff --git a/pkg/filter/network/dubboproxy/filter/proxy/proxyfilter.go
b/pkg/filter/network/dubboproxy/filter/proxy/proxyfilter.go
index 8f35b87b..19087aa2 100644
--- a/pkg/filter/network/dubboproxy/filter/proxy/proxyfilter.go
+++ b/pkg/filter/network/dubboproxy/filter/proxy/proxyfilter.go
@@ -68,13 +68,13 @@ func (p Plugin) Kind() string {
}
// CreateFilter return the filter callback
-func (p Plugin) CreateFilter(config interface{}) (filter.DubboFilter, error) {
+func (p Plugin) CreateFilter(config any) (filter.DubboFilter, error) {
cfg := config.(*Config)
return Filter{Config: cfg}, nil
}
// Config Expose the config so that Filter Manger can inject it, so it must be
a pointer
-func (p Plugin) Config() interface{} {
+func (p Plugin) Config() any {
return &Config{}
}
@@ -129,7 +129,7 @@ func (f Filter) sendDubboRequest(ctx *dubbo2.RpcContext)
filter.FilterStatus {
ctx.SetError(errors.Errorf("can't connect to upstream server %s
with address %s", endpoint.Name, endpoint.Address.GetAddress()))
return filter.Stop
}
- var resp interface{}
+ var resp any
invoc.SetReply(&resp)
invCtx := context.Background()
@@ -178,7 +178,7 @@ func (f Filter) sendTripleRequest(ctx *dubbo2.RpcContext)
filter.FilterStatus {
return filter.Stop
}
- var resp interface{}
+ var resp any
invoc.SetReply(&resp)
invCtx := context.Background()
result := invoker.Invoke(invCtx, invoc)
diff --git a/pkg/filter/network/dubboproxy/manager.go
b/pkg/filter/network/dubboproxy/manager.go
index 92e7b1b7..67aa2603 100644
--- a/pkg/filter/network/dubboproxy/manager.go
+++ b/pkg/filter/network/dubboproxy/manager.go
@@ -60,7 +60,7 @@ func CreateDubboProxyConnectionManager(config
*model.DubboProxyConnectionManager
}
// OnDecode decode bytes to DecodeResult
-func (dcm *DubboProxyConnectionManager) OnDecode(data []byte) (interface{},
int, error) {
+func (dcm *DubboProxyConnectionManager) OnDecode(data []byte) (any, int,
error) {
resp, length, err := dcm.codec.Decode(data)
// err := pkg.Unmarshal(buf, p.client)
@@ -75,7 +75,7 @@ func (dcm *DubboProxyConnectionManager) OnDecode(data []byte)
(interface{}, int,
}
// OnEncode encode Response to bytes
-func (dcm *DubboProxyConnectionManager) OnEncode(pkg interface{}) ([]byte,
error) {
+func (dcm *DubboProxyConnectionManager) OnEncode(pkg any) ([]byte, error) {
res, ok := pkg.(*remoting.Response)
if ok {
buf, err := (dcm.codec).EncodeResponse(res)
@@ -101,8 +101,8 @@ func (dcm *DubboProxyConnectionManager) OnEncode(pkg
interface{}) ([]byte, error
}
// OnTripleData handle triple rpc invocation
-func (dcm *DubboProxyConnectionManager) OnTripleData(ctx context.Context,
methodName string, arguments []interface{}) (interface{}, error) {
- dubboAttachment := make(map[string]interface{})
+func (dcm *DubboProxyConnectionManager) OnTripleData(ctx context.Context,
methodName string, arguments []any) (any, error) {
+ dubboAttachment := make(map[string]any)
md, ok := metadata.FromIncomingContext(ctx)
if ok {
for k := range md {
@@ -137,7 +137,7 @@ func (dcm *DubboProxyConnectionManager) OnTripleData(ctx
context.Context, method
}
// OnData handle dubbo rpc invocation
-func (dcm *DubboProxyConnectionManager) OnData(data interface{}) (interface{},
error) {
+func (dcm *DubboProxyConnectionManager) OnData(data any) (any, error) {
old_invoc, ok := data.(*invocation.RPCInvocation)
if !ok {
panic("create invocation occur some exception for the type is
not suitable one.")
diff --git a/pkg/filter/network/dubboproxy/plugin.go
b/pkg/filter/network/dubboproxy/plugin.go
index 35e6a0a7..3e8d99f4 100644
--- a/pkg/filter/network/dubboproxy/plugin.go
+++ b/pkg/filter/network/dubboproxy/plugin.go
@@ -43,7 +43,7 @@ func (p *Plugin) Kind() string {
}
// CreateFilter create dubbo networkfilter
-func (p *Plugin) CreateFilter(config interface{}) (filter.NetworkFilter,
error) {
+func (p *Plugin) CreateFilter(config any) (filter.NetworkFilter, error) {
hcmc, ok := config.(*model.DubboProxyConnectionManagerConfig)
hcmc.Timeout = stringutil.ResolveTimeStr2Time(hcmc.TimeoutStr,
constant.DefaultReqTimeout)
if !ok {
@@ -53,6 +53,6 @@ func (p *Plugin) CreateFilter(config interface{})
(filter.NetworkFilter, error)
}
// Config return DubboProxyConnectionManagerConfig
-func (p *Plugin) Config() interface{} {
+func (p *Plugin) Config() any {
return &model.DubboProxyConnectionManagerConfig{}
}
diff --git a/pkg/filter/network/grpcconnectionmanager/plugin.go
b/pkg/filter/network/grpcconnectionmanager/plugin.go
index 34c4c49f..9b3dc821 100644
--- a/pkg/filter/network/grpcconnectionmanager/plugin.go
+++ b/pkg/filter/network/grpcconnectionmanager/plugin.go
@@ -43,13 +43,13 @@ func (p *Plugin) Kind() string {
}
// CreateFilter create grpc network filter
-func (p *Plugin) CreateFilter(config interface{}) (filter.NetworkFilter,
error) {
+func (p *Plugin) CreateFilter(config any) (filter.NetworkFilter, error) {
hcmc := config.(*model.GRPCConnectionManagerConfig)
hcmc.Timeout = stringutil.ResolveTimeStr2Time(hcmc.TimeoutStr,
constant.DefaultReqTimeout)
return grpc.CreateGrpcConnectionManager(hcmc), nil
}
// Config return GRPCConnectionManagerConfig
-func (p *Plugin) Config() interface{} {
+func (p *Plugin) Config() any {
return &model.GRPCConnectionManagerConfig{}
}
diff --git a/pkg/filter/network/httpconnectionmanager/plugin.go
b/pkg/filter/network/httpconnectionmanager/plugin.go
index 58612aea..c3c56bf7 100644
--- a/pkg/filter/network/httpconnectionmanager/plugin.go
+++ b/pkg/filter/network/httpconnectionmanager/plugin.go
@@ -43,13 +43,13 @@ func (p *Plugin) Kind() string {
}
// CreateFilter create http network filter
-func (p *Plugin) CreateFilter(config interface{}) (filter.NetworkFilter,
error) {
+func (p *Plugin) CreateFilter(config any) (filter.NetworkFilter, error) {
hcmc := config.(*model.HttpConnectionManagerConfig)
hcmc.Timeout = stringutil.ResolveTimeStr2Time(hcmc.TimeoutStr,
constant.DefaultReqTimeout)
return http.CreateHttpConnectionManager(hcmc), nil
}
// Config return HttpConnectionManagerConfig
-func (p *Plugin) Config() interface{} {
+func (p *Plugin) Config() any {
return &model.HttpConnectionManagerConfig{}
}
diff --git a/pkg/filter/prometheus/metric.go b/pkg/filter/prometheus/metric.go
index d2579c12..c37bf5fe 100644
--- a/pkg/filter/prometheus/metric.go
+++ b/pkg/filter/prometheus/metric.go
@@ -64,7 +64,7 @@ func (p *Plugin) CreateFilterFactory()
(filter.HttpFilterFactory, error) {
}, nil
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.Cfg
}
diff --git a/pkg/filter/sentinel/circuitbreaker/circuit_breaker.go
b/pkg/filter/sentinel/circuitbreaker/circuit_breaker.go
index c9535f8a..ce972dd7 100644
--- a/pkg/filter/sentinel/circuitbreaker/circuit_breaker.go
+++ b/pkg/filter/sentinel/circuitbreaker/circuit_breaker.go
@@ -104,7 +104,7 @@ func (f *Filter) Decode(ctx *http.HttpContext)
filter.FilterStatus {
return filter.Continue
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.cfg
}
diff --git a/pkg/filter/sentinel/logger_warpper.go
b/pkg/filter/sentinel/logger_warpper.go
index b5c0d427..5f6fa1cb 100644
--- a/pkg/filter/sentinel/logger_warpper.go
+++ b/pkg/filter/sentinel/logger_warpper.go
@@ -30,19 +30,19 @@ func GetWrappedLogger() loggerWrapper {
return loggerWrapper{}
}
-func (l loggerWrapper) Debug(msg string, keysAndValues ...interface{}) {
+func (l loggerWrapper) Debug(msg string, keysAndValues ...any) {
logger.Debugf(msg, keysAndValues...)
}
-func (l loggerWrapper) Info(msg string, keysAndValues ...interface{}) {
+func (l loggerWrapper) Info(msg string, keysAndValues ...any) {
logger.Infof(msg, keysAndValues...)
}
-func (l loggerWrapper) Warn(msg string, keysAndValues ...interface{}) {
+func (l loggerWrapper) Warn(msg string, keysAndValues ...any) {
logger.Warnf(msg, keysAndValues...)
}
-func (l loggerWrapper) Error(err error, msg string, keysAndValues
...interface{}) {
+func (l loggerWrapper) Error(err error, msg string, keysAndValues ...any) {
logger.Warnf(msg, err, keysAndValues)
}
diff --git a/pkg/filter/sentinel/ratelimit/rate_limit.go
b/pkg/filter/sentinel/ratelimit/rate_limit.go
index c7d3f7a3..6dfa59d1 100644
--- a/pkg/filter/sentinel/ratelimit/rate_limit.go
+++ b/pkg/filter/sentinel/ratelimit/rate_limit.go
@@ -99,7 +99,7 @@ func (f *Filter) Decode(hc *contexthttp.HttpContext)
filter.FilterStatus {
return filter.Continue
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.conf
}
diff --git a/pkg/filter/tracing/tracing.go b/pkg/filter/tracing/tracing.go
index 650ae85b..67ba5023 100644
--- a/pkg/filter/tracing/tracing.go
+++ b/pkg/filter/tracing/tracing.go
@@ -58,7 +58,7 @@ func (ap *Plugin) CreateFilterFactory()
(filter.HttpFilterFactory, error) {
return &TraceFilterFactory{}, nil
}
-func (m *TraceFilterFactory) Config() interface{} {
+func (m *TraceFilterFactory) Config() any {
return &Config{}
}
diff --git a/pkg/filter/traffic/traffic.go b/pkg/filter/traffic/traffic.go
index 9c363306..b1837b72 100644
--- a/pkg/filter/traffic/traffic.go
+++ b/pkg/filter/traffic/traffic.go
@@ -89,7 +89,7 @@ func (p *Plugin) CreateFilterFactory()
(filter.HttpFilterFactory, error) {
}, nil
}
-func (factory *FilterFactory) Config() interface{} {
+func (factory *FilterFactory) Config() any {
return factory.cfg
}
diff --git a/pkg/filterchain/network_filter_chain.go
b/pkg/filterchain/network_filter_chain.go
index cc6787ff..f9f8cbd2 100644
--- a/pkg/filterchain/network_filter_chain.go
+++ b/pkg/filterchain/network_filter_chain.go
@@ -47,7 +47,7 @@ func (fc NetworkFilterChain) ServeHTTP(w http.ResponseWriter,
r *http.Request) {
}
// OnDecode decode bytes received from getty listener
-func (fc NetworkFilterChain) OnDecode(data []byte) (interface{}, int, error) {
+func (fc NetworkFilterChain) OnDecode(data []byte) (any, int, error) {
// todo: only one filter will exist for now, needs change when more
than one
for _, filter := range fc.filtersArray {
return filter.OnDecode(data)
@@ -56,7 +56,7 @@ func (fc NetworkFilterChain) OnDecode(data []byte)
(interface{}, int, error) {
}
// OnEncode encode struct to bytes sent to getty listener
-func (fc NetworkFilterChain) OnEncode(p interface{}) ([]byte, error) {
+func (fc NetworkFilterChain) OnEncode(p any) ([]byte, error) {
// todo: only one filter will exist for now, needs change when more
than one
for _, filter := range fc.filtersArray {
return filter.OnEncode(p)
@@ -65,7 +65,7 @@ func (fc NetworkFilterChain) OnEncode(p interface{}) ([]byte,
error) {
}
// OnData handle dubbo rpc invocation
-func (fc NetworkFilterChain) OnData(data interface{}) (interface{}, error) {
+func (fc NetworkFilterChain) OnData(data any) (any, error) {
// todo: only one filter will exist for now, needs change when more
than one
for _, filter := range fc.filtersArray {
return filter.OnData(data)
@@ -74,7 +74,7 @@ func (fc NetworkFilterChain) OnData(data interface{})
(interface{}, error) {
}
// OnTripleData handle triple rpc invocation
-func (fc *NetworkFilterChain) OnTripleData(ctx context.Context, methodName
string, arguments []interface{}) (interface{}, error) {
+func (fc *NetworkFilterChain) OnTripleData(ctx context.Context, methodName
string, arguments []any) (any, error) {
// todo: only one filter will exist for now, needs change when more
than one
for _, filter := range fc.filtersArray {
return filter.OnTripleData(ctx, methodName, arguments)
diff --git a/pkg/listener/http/http_listener.go
b/pkg/listener/http/http_listener.go
index 1cc75ae2..d18c4157 100644
--- a/pkg/listener/http/http_listener.go
+++ b/pkg/listener/http/http_listener.go
@@ -86,7 +86,7 @@ func (ls *HttpListenerService) Close() error {
return ls.srv.Close()
}
-func (ls *HttpListenerService) ShutDown(wg interface{}) error {
+func (ls *HttpListenerService) ShutDown(wg any) error {
timeout := config.GetBootstrap().GetShutdownConfig().GetTimeout()
if timeout <= 0 {
return nil
diff --git a/pkg/listener/http2/http2_listener.go
b/pkg/listener/http2/http2_listener.go
index 3d7bc91e..1686d438 100644
--- a/pkg/listener/http2/http2_listener.go
+++ b/pkg/listener/http2/http2_listener.go
@@ -134,7 +134,7 @@ func (ls *Http2ListenerService) Close() error {
return ls.server.Close()
}
-func (ls *Http2ListenerService) ShutDown(wg interface{}) error {
+func (ls *Http2ListenerService) ShutDown(wg any) error {
timeout := config.GetBootstrap().GetShutdownConfig().GetTimeout()
if timeout <= 0 {
return nil
diff --git a/pkg/listener/listener.go b/pkg/listener/listener.go
index 63685881..6f9606e0 100644
--- a/pkg/listener/listener.go
+++ b/pkg/listener/listener.go
@@ -39,7 +39,7 @@ type (
// Close the listener service forcefully
Close() error
// ShutDown gracefully shuts down the listener.
- ShutDown(interface{}) error
+ ShutDown(any) error
// Refresh config
Refresh(model.Listener) error
}
diff --git a/pkg/listener/tcp/pkg_handler.go b/pkg/listener/tcp/pkg_handler.go
index 74958c37..d8154b43 100644
--- a/pkg/listener/tcp/pkg_handler.go
+++ b/pkg/listener/tcp/pkg_handler.go
@@ -29,10 +29,10 @@ func NewPackageHandler(ls *TcpListenerService)
*PackageHandler {
return &PackageHandler{ls}
}
-func (h *PackageHandler) Read(ss getty.Session, data []byte) (interface{},
int, error) {
+func (h *PackageHandler) Read(ss getty.Session, data []byte) (any, int, error)
{
return h.ls.FilterChain.OnDecode(data)
}
-func (h *PackageHandler) Write(ss getty.Session, p interface{}) ([]byte,
error) {
+func (h *PackageHandler) Write(ss getty.Session, p any) ([]byte, error) {
return h.ls.FilterChain.OnEncode(p)
}
diff --git a/pkg/listener/tcp/server_handler.go
b/pkg/listener/tcp/server_handler.go
index 4f6f6e01..4a861d04 100644
--- a/pkg/listener/tcp/server_handler.go
+++ b/pkg/listener/tcp/server_handler.go
@@ -118,7 +118,7 @@ func (h *ServerHandler) OnClose(session getty.Session) {
}
// OnMessage called when session receive new pkg
-func (h *ServerHandler) OnMessage(session getty.Session, pkg interface{}) {
+func (h *ServerHandler) OnMessage(session getty.Session, pkg any) {
h.ls.gShutdownConfig.AddActiveCount(1)
defer h.ls.gShutdownConfig.AddActiveCount(-1)
diff --git a/pkg/listener/tcp/tcp_listener.go b/pkg/listener/tcp/tcp_listener.go
index 9cfab57e..266abd1c 100644
--- a/pkg/listener/tcp/tcp_listener.go
+++ b/pkg/listener/tcp/tcp_listener.go
@@ -77,7 +77,7 @@ func (ls *TcpListenerService) Close() error {
return nil
}
-func (ls *TcpListenerService) ShutDown(wg interface{}) error {
+func (ls *TcpListenerService) ShutDown(wg any) error {
timeout := config.GetBootstrap().GetShutdownConfig().GetTimeout()
if timeout <= 0 {
return nil
diff --git a/pkg/listener/triple/triple_listener.go
b/pkg/listener/triple/triple_listener.go
index a8dc6eba..cf3348cf 100644
--- a/pkg/listener/triple/triple_listener.go
+++ b/pkg/listener/triple/triple_listener.go
@@ -98,7 +98,7 @@ func (ls *TripleListenerService) Close() error {
return nil
}
-func (ls *TripleListenerService) ShutDown(wg interface{}) error {
+func (ls *TripleListenerService) ShutDown(wg any) error {
timeout := config.GetBootstrap().GetShutdownConfig().GetTimeout()
if timeout <= 0 {
return nil
@@ -124,13 +124,13 @@ func (ls *TripleListenerService) Refresh(c
model.Listener) error {
}
// GetReqParamsInterfaces get params
-func (d *ProxyService) GetReqParamsInterfaces(methodName string)
([]interface{}, bool) {
+func (d *ProxyService) GetReqParamsInterfaces(methodName string) ([]any, bool)
{
val, ok := d.reqTypeMap.Load(methodName)
if !ok {
return nil, false
}
typs := val.([]reflect.Type)
- reqParamsInterfaces := make([]interface{}, 0, len(typs))
+ reqParamsInterfaces := make([]any, 0, len(typs))
for _, typ := range typs {
reqParamsInterfaces = append(reqParamsInterfaces,
reflect.New(typ).Interface())
}
@@ -138,7 +138,7 @@ func (d *ProxyService) GetReqParamsInterfaces(methodName
string) ([]interface{},
}
// InvokeWithArgs called when rpc invocation comes
-func (d *ProxyService) InvokeWithArgs(ctx context.Context, methodName string,
arguments []interface{}) (interface{}, error) {
+func (d *ProxyService) InvokeWithArgs(ctx context.Context, methodName string,
arguments []any) (any, error) {
d.ls.gShutdownConfig.AddActiveCount(1)
defer d.ls.gShutdownConfig.AddActiveCount(-1)
if d.ls.gShutdownConfig.RejectRequest {
diff --git a/pkg/logger/controller.go b/pkg/logger/controller.go
index 91449361..8914cf5d 100644
--- a/pkg/logger/controller.go
+++ b/pkg/logger/controller.go
@@ -56,49 +56,49 @@ func (c *logController) updateLogger(l *logger) {
c.logger = l
}
-func (c *logController) debug(args ...interface{}) {
+func (c *logController) debug(args ...any) {
c.mu.RLock()
defer c.mu.RUnlock()
c.logger.Debug(args...)
}
-func (c *logController) info(args ...interface{}) {
+func (c *logController) info(args ...any) {
c.mu.RLock()
defer c.mu.RUnlock()
c.logger.Info(args...)
}
-func (c *logController) warn(args ...interface{}) {
+func (c *logController) warn(args ...any) {
c.mu.RLock()
defer c.mu.RUnlock()
c.logger.Warn(args...)
}
-func (c *logController) error(args ...interface{}) {
+func (c *logController) error(args ...any) {
c.mu.RLock()
defer c.mu.RUnlock()
c.logger.Error(args...)
}
-func (c *logController) debugf(fmt string, args ...interface{}) {
+func (c *logController) debugf(fmt string, args ...any) {
c.mu.RLock()
defer c.mu.RUnlock()
c.logger.Debugf(fmt, args...)
}
-func (c *logController) infof(fmt string, args ...interface{}) {
+func (c *logController) infof(fmt string, args ...any) {
c.mu.RLock()
defer c.mu.RUnlock()
c.logger.Infof(fmt, args...)
}
-func (c *logController) warnf(fmt string, args ...interface{}) {
+func (c *logController) warnf(fmt string, args ...any) {
c.mu.RLock()
defer c.mu.RUnlock()
c.logger.Warnf(fmt, args...)
}
-func (c *logController) errorf(fmt string, args ...interface{}) {
+func (c *logController) errorf(fmt string, args ...any) {
c.mu.RLock()
defer c.mu.RUnlock()
c.logger.Errorf(fmt, args...)
diff --git a/pkg/logger/output.go b/pkg/logger/output.go
index 10b2f96c..51c299a9 100644
--- a/pkg/logger/output.go
+++ b/pkg/logger/output.go
@@ -17,34 +17,34 @@
package logger
-func Info(args ...interface{}) {
+func Info(args ...any) {
control.info(args...)
}
-func Warn(args ...interface{}) {
+func Warn(args ...any) {
control.warn(args...)
}
-func Error(args ...interface{}) {
+func Error(args ...any) {
control.error(args...)
}
-func Debug(args ...interface{}) {
+func Debug(args ...any) {
control.debug(args...)
}
-func Infof(fmt string, args ...interface{}) {
+func Infof(fmt string, args ...any) {
control.infof(fmt, args...)
}
-func Warnf(fmt string, args ...interface{}) {
+func Warnf(fmt string, args ...any) {
control.warnf(fmt, args...)
}
-func Errorf(fmt string, args ...interface{}) {
+func Errorf(fmt string, args ...any) {
control.errorf(fmt, args...)
}
-func Debugf(fmt string, args ...interface{}) {
+func Debugf(fmt string, args ...any) {
control.debugf(fmt, args...)
}
diff --git a/pkg/logger/triple.go b/pkg/logger/triple.go
index fb893fc6..b37cbce9 100644
--- a/pkg/logger/triple.go
+++ b/pkg/logger/triple.go
@@ -26,34 +26,34 @@ func GetTripleLogger() *TripleLogger {
return &TripleLogger{}
}
-func (l *TripleLogger) Info(args ...interface{}) {
+func (l *TripleLogger) Info(args ...any) {
control.info(args...)
}
-func (l *TripleLogger) Warn(args ...interface{}) {
+func (l *TripleLogger) Warn(args ...any) {
control.warn(args...)
}
-func (l *TripleLogger) Error(args ...interface{}) {
+func (l *TripleLogger) Error(args ...any) {
control.error(args...)
}
-func (l *TripleLogger) Debug(args ...interface{}) {
+func (l *TripleLogger) Debug(args ...any) {
control.debug(args...)
}
-func (l *TripleLogger) Infof(fmt string, args ...interface{}) {
+func (l *TripleLogger) Infof(fmt string, args ...any) {
control.infof(fmt, args...)
}
-func (l *TripleLogger) Warnf(fmt string, args ...interface{}) {
+func (l *TripleLogger) Warnf(fmt string, args ...any) {
control.warnf(fmt, args...)
}
-func (l *TripleLogger) Errorf(fmt string, args ...interface{}) {
+func (l *TripleLogger) Errorf(fmt string, args ...any) {
control.errorf(fmt, args...)
}
-func (l *TripleLogger) Debugf(fmt string, args ...interface{}) {
+func (l *TripleLogger) Debugf(fmt string, args ...any) {
control.debugf(fmt, args...)
}
diff --git a/pkg/model/adapter.go b/pkg/model/adapter.go
index 709a0bd5..5d6f1aa7 100644
--- a/pkg/model/adapter.go
+++ b/pkg/model/adapter.go
@@ -19,8 +19,8 @@ package model
// Adapter the adapter plugin for manage cluster or router
type Adapter struct {
- ID string `yaml:"id" json:"id"`
- Name string `yaml:"name" json:"name"` // Name the
adapter unique name
- Enabled string `yaml:"enabled" json:"enabled"
default:"true"`
- Config map[string]interface{} `yaml:"config" json:"config"
mapstructure:"config"` // Config adapter config
+ ID string `yaml:"id" json:"id"`
+ Name string `yaml:"name" json:"name"` // Name the adapter
unique name
+ Enabled string `yaml:"enabled" json:"enabled" default:"true"`
+ Config map[string]any `yaml:"config" json:"config"
mapstructure:"config"` // Config adapter config
}
diff --git a/pkg/model/base.go b/pkg/model/base.go
index 2612fb37..f36cf4be 100644
--- a/pkg/model/base.go
+++ b/pkg/model/base.go
@@ -29,7 +29,7 @@ type Metadata struct {
Info map[string]MetadataValue
}
-type MetadataValue interface{}
+type MetadataValue any
// Status is the components status
diff --git a/pkg/model/filter.go b/pkg/model/filter.go
index a03abe41..c52d5d7c 100644
--- a/pkg/model/filter.go
+++ b/pkg/model/filter.go
@@ -24,8 +24,8 @@ type FilterChain struct {
// NetworkFilter core struct, filter is extend by user
type NetworkFilter struct {
- Name string `yaml:"name" json:"name"
mapstructure:"name"` // Name filter name unique
- Config map[string]interface{} `yaml:"config" json:"config"
mapstructure:"config"` // Config filter config
+ Name string `yaml:"name" json:"name" mapstructure:"name"`
// Name filter name unique
+ Config map[string]any `yaml:"config" json:"config"
mapstructure:"config"` // Config filter config
}
// FilterChainMatch
diff --git a/pkg/model/health.go b/pkg/model/health.go
index 7f260b94..8e72c805 100644
--- a/pkg/model/health.go
+++ b/pkg/model/health.go
@@ -19,15 +19,15 @@ package model
// HealthCheck
type HealthCheckConfig struct {
- Protocol string `yaml:"protocol"
json:"protocol,omitempty" mapstructure:"protocol"`
- TimeoutConfig string `yaml:"timeout"
json:"timeout,omitempty" mapstructure:"timeout"`
- IntervalConfig string `yaml:"interval"
json:"interval,omitempty" mapstructure:"interval"`
- InitialDelaySeconds string
`yaml:"initial_delay_seconds" json:"initial_delay_seconds,omitempty"
mapstructure:"initial_delay_seconds"`
- HealthyThreshold uint32 `yaml:"healthy_threshold"
json:"healthy_threshold,omitempty" mapstructure:"healthy_threshold"`
- UnhealthyThreshold uint32 `yaml:"unhealthy_threshold"
json:"unhealthy_threshold,omitempty" mapstructure:"unhealthy_threshold"`
- ServiceName string `yaml:"service_name"
json:"service_name,omitempty" mapstructure:"service_name"`
- SessionConfig map[string]interface{} `yaml:"check_config"
json:"check_config,omitempty" mapstructure:"check_config"`
- CommonCallbacks []string `yaml:"common_callbacks"
json:"common_callbacks,omitempty" mapstructure:"common_callbacks"`
+ Protocol string `yaml:"protocol"
json:"protocol,omitempty" mapstructure:"protocol"`
+ TimeoutConfig string `yaml:"timeout"
json:"timeout,omitempty" mapstructure:"timeout"`
+ IntervalConfig string `yaml:"interval"
json:"interval,omitempty" mapstructure:"interval"`
+ InitialDelaySeconds string `yaml:"initial_delay_seconds"
json:"initial_delay_seconds,omitempty" mapstructure:"initial_delay_seconds"`
+ HealthyThreshold uint32 `yaml:"healthy_threshold"
json:"healthy_threshold,omitempty" mapstructure:"healthy_threshold"`
+ UnhealthyThreshold uint32 `yaml:"unhealthy_threshold"
json:"unhealthy_threshold,omitempty" mapstructure:"unhealthy_threshold"`
+ ServiceName string `yaml:"service_name"
json:"service_name,omitempty" mapstructure:"service_name"`
+ SessionConfig map[string]any `yaml:"check_config"
json:"check_config,omitempty" mapstructure:"check_config"`
+ CommonCallbacks []string `yaml:"common_callbacks"
json:"common_callbacks,omitempty" mapstructure:"common_callbacks"`
}
// HttpHealthCheck
@@ -50,5 +50,5 @@ type GrpcHealthCheck struct {
type CustomHealthCheck struct {
HealthCheckConfig
Name string
- Config interface{}
+ Config any
}
diff --git a/pkg/model/http.go b/pkg/model/http.go
index 1cf0ac7e..e9bbfc47 100644
--- a/pkg/model/http.go
+++ b/pkg/model/http.go
@@ -57,14 +57,14 @@ type DubboProxyConnectionManagerConfig struct {
// HTTPFilter http filter
type HTTPFilter struct {
- Name string `yaml:"name" json:"name"
mapstructure:"name"`
- Config map[string]interface{} `yaml:"config" json:"config"
mapstructure:"config"`
+ Name string `yaml:"name" json:"name" mapstructure:"name"`
+ Config map[string]any `yaml:"config" json:"config"
mapstructure:"config"`
}
// DubboFilter dubbo filter
type DubboFilter struct {
- Name string `yaml:"name" json:"name"
mapstructure:"name"`
- Config map[string]interface{} `yaml:"config" json:"config"
mapstructure:"config"`
+ Name string `yaml:"name" json:"name" mapstructure:"name"`
+ Config map[string]any `yaml:"config" json:"config"
mapstructure:"config"`
}
type RequestMethod int32
@@ -113,7 +113,7 @@ type HttpConfig struct {
MaxHeaderBytes int `json:"max_header_bytes,omitempty"
yaml:"max_header_bytes,omitempty" mapstructure:"max_header_bytes"`
}
-func MapInStruct(cfg interface{}) *HttpConfig {
+func MapInStruct(cfg any) *HttpConfig {
var hc *HttpConfig
if cfg != nil {
if ok := mapstructure.Decode(cfg, &hc); ok != nil {
diff --git a/pkg/model/listener.go b/pkg/model/listener.go
index c458859a..e068c80e 100644
--- a/pkg/model/listener.go
+++ b/pkg/model/listener.go
@@ -69,6 +69,6 @@ type (
ProtocolStr string `default:"http" yaml:"protocol_type"
json:"protocol_type" mapstructure:"protocol_type"`
Protocol ProtocolType `default:"http" yaml:"omitempty"
json:"omitempty"`
FilterChain FilterChain `yaml:"filter_chains"
json:"filter_chains" mapstructure:"filter_chains"`
- Config interface{} `yaml:"config" json:"config"
mapstructure:"config"`
+ Config any `yaml:"config" json:"config"
mapstructure:"config"`
}
)
diff --git a/pkg/model/log.go b/pkg/model/log.go
index 16a8c74f..149efb00 100644
--- a/pkg/model/log.go
+++ b/pkg/model/log.go
@@ -27,16 +27,16 @@ import (
)
type Log struct {
- Level string `json:"level" yaml:"level"`
- Development bool `json:"development"
yaml:"development"`
- DisableCaller bool `json:"disableCaller"
yaml:"disableCaller"`
- DisableStacktrace bool `json:"disableStacktrace"
yaml:"disableStacktrace"`
- Sampling SamplingConfig `json:"sampling"
yaml:"sampling"`
- Encoding string `json:"encoding"
yaml:"encoding"`
- EncoderConfig EncoderConfig `json:"encoderConfig"
yaml:"encoderConfig"`
- OutputPaths []string `json:"outputPaths"
yaml:"outputPaths"`
- ErrorOutputPaths []string `json:"errorOutputPaths"
yaml:"errorOutputPaths"`
- InitialFields map[string]interface{} `json:"initialFields"
yaml:"initialFields"`
+ Level string `json:"level" yaml:"level"`
+ Development bool `json:"development" yaml:"development"`
+ DisableCaller bool `json:"disableCaller"
yaml:"disableCaller"`
+ DisableStacktrace bool `json:"disableStacktrace"
yaml:"disableStacktrace"`
+ Sampling SamplingConfig `json:"sampling" yaml:"sampling"`
+ Encoding string `json:"encoding" yaml:"encoding"`
+ EncoderConfig EncoderConfig `json:"encoderConfig"
yaml:"encoderConfig"`
+ OutputPaths []string `json:"outputPaths" yaml:"outputPaths"`
+ ErrorOutputPaths []string `json:"errorOutputPaths"
yaml:"errorOutputPaths"`
+ InitialFields map[string]any `json:"initialFields"
yaml:"initialFields"`
}
func (l *Log) Build() *zap.Config {
diff --git a/pkg/model/trace.go b/pkg/model/trace.go
index 8524a7b3..1f7f4a01 100644
--- a/pkg/model/trace.go
+++ b/pkg/model/trace.go
@@ -19,10 +19,10 @@ package model
// TracerConfig inclueds detail information about the exporter
type TracerConfig struct {
- Name string `yaml:"name" json:"name"
mapstructure:"name"`
- ServiceName string `yaml:"serviceName"
json:"serviceName" mapstructure:"serviceName"`
- Sampler Sampler `yaml:"sampler" json:"sampler"
mapstructure:"sampler"`
- Config map[string]interface{} `yaml:"config" json:"config"
mapstructure:"config"`
+ Name string `yaml:"name" json:"name" mapstructure:"name"`
+ ServiceName string `yaml:"serviceName" json:"serviceName"
mapstructure:"serviceName"`
+ Sampler Sampler `yaml:"sampler" json:"sampler"
mapstructure:"sampler"`
+ Config map[string]any `yaml:"config" json:"config"
mapstructure:"config"`
}
// Sampler policy
diff --git a/pkg/model/tracing.go b/pkg/model/tracing.go
index 65710dcb..ac3a00c5 100644
--- a/pkg/model/tracing.go
+++ b/pkg/model/tracing.go
@@ -26,6 +26,6 @@ type Tracing struct {
// Tracing
type Http struct {
- Name string `yaml:"name"`
- Config interface{} `yaml:"config"`
+ Name string `yaml:"name"`
+ Config any `yaml:"config"`
}
diff --git a/pkg/model/wasm.go b/pkg/model/wasm.go
index 97b2fd08..e9c1a10c 100644
--- a/pkg/model/wasm.go
+++ b/pkg/model/wasm.go
@@ -24,6 +24,6 @@ type WasmConfig struct {
// WasmService includes all information about the specific application.
type WasmService struct {
- Name string `yaml:"name" json:"name"
mapstructure:"name"`
- Config map[string]interface{} `yaml:"config" json:"config"
mapstructure:"config"`
+ Name string `yaml:"name" json:"name" mapstructure:"name"`
+ Config map[string]any `yaml:"config" json:"config"
mapstructure:"config"`
}
diff --git a/pkg/pool/pool.go b/pkg/pool/pool.go
index 92728751..d3cf3b63 100644
--- a/pkg/pool/pool.go
+++ b/pkg/pool/pool.go
@@ -48,12 +48,12 @@ func newClientPool() *ClientPool {
}
// init default support request type
clientPool.poolMap[config.DubboRequest] = &sync.Pool{
- New: func() interface{} {
+ New: func() any {
return dubbo.NewDubboClient()
},
}
clientPool.poolMap[config.HTTPRequest] = &sync.Pool{
- New: func() interface{} {
+ New: func() any {
return http.NewHTTPClient()
},
}
diff --git a/pkg/remote/nacos/client.go b/pkg/remote/nacos/client.go
index eb43b2b6..1f80a7d9 100644
--- a/pkg/remote/nacos/client.go
+++ b/pkg/remote/nacos/client.go
@@ -58,7 +58,7 @@ func (client *NacosClient) Unsubscribe(param
*vo.SubscribeParam) error {
}
func NewNacosClient(config *model.RemoteConfig) (*NacosClient, error) {
- configMap := make(map[string]interface{}, 2)
+ configMap := make(map[string]any, 2)
addresses := strings.Split(config.Address, ",")
serverConfigs := make([]constant.ServerConfig, 0, len(addresses))
for _, addr := range addresses {
diff --git a/pkg/router/route.go b/pkg/router/route.go
index 6112bff8..c471fadf 100644
--- a/pkg/router/route.go
+++ b/pkg/router/route.go
@@ -237,7 +237,7 @@ func (rt *Route) DeleteAPI(fullPath string, httpverb
config.HTTPVerb) bool {
}
func (rt *Route) getNode(fullPath string) (*Node, bool) {
- var n interface{}
+ var n any
var found bool
rt.lock.RLock()
defer rt.lock.RUnlock()
@@ -254,7 +254,7 @@ func (rt *Route) getNode(fullPath string) (*Node, bool) {
}
func (rt *Route) matchNode(fullPath string) (*Node, bool) {
- var n interface{}
+ var n any
var found bool
rt.lock.RLock()
defer rt.lock.RUnlock()
diff --git a/pkg/server/adapter_manager_test.go
b/pkg/server/adapter_manager_test.go
index e136bf97..d0bdb7eb 100644
--- a/pkg/server/adapter_manager_test.go
+++ b/pkg/server/adapter_manager_test.go
@@ -46,7 +46,7 @@ func (d *DemoAdapterPlugin) Kind() string {
return "test"
}
-func (p *DemoAdapterPlugin) CreateAdapter(ad *model.Adapter) (adapter.Adapter,
error) {
+func (d *DemoAdapterPlugin) CreateAdapter(ad *model.Adapter) (adapter.Adapter,
error) {
return &DemoAdapter{cfg: &Config{}}, nil
}
@@ -60,7 +60,7 @@ func (a *DemoAdapter) Apply() error {
}
// Config get config for Adapter
-func (a *DemoAdapter) Config() interface{} {
+func (a *DemoAdapter) Config() any {
return a.cfg
}
@@ -74,9 +74,9 @@ func TestAdapterManager(t *testing.T) {
bs := &model.Bootstrap{
StaticResources: model.StaticResources{
Adapters: []*model.Adapter{
- &model.Adapter{
+ {
Name: "test",
- Config: make(map[string]interface{}),
+ Config: make(map[string]any),
},
},
},
diff --git a/pkg/server/controls/mocks/mocks.go
b/pkg/server/controls/mocks/mocks.go
index 90a2334a..cec692e0 100644
--- a/pkg/server/controls/mocks/mocks.go
+++ b/pkg/server/controls/mocks/mocks.go
@@ -60,7 +60,7 @@ func (m *MockClusterManager) AddCluster(cluster
*model.ClusterConfig) {
}
// AddCluster indicates an expected call of AddCluster.
-func (mr *MockClusterManagerMockRecorder) AddCluster(cluster interface{})
*gomock.Call {
+func (mr *MockClusterManagerMockRecorder) AddCluster(cluster any) *gomock.Call
{
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddCluster",
reflect.TypeOf((*MockClusterManager)(nil).AddCluster), cluster)
}
@@ -89,7 +89,7 @@ func (m *MockClusterManager) HasCluster(name string) bool {
}
// HasCluster indicates an expected call of HasCluster.
-func (mr *MockClusterManagerMockRecorder) HasCluster(name interface{})
*gomock.Call {
+func (mr *MockClusterManagerMockRecorder) HasCluster(name any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasCluster",
reflect.TypeOf((*MockClusterManager)(nil).HasCluster), name)
}
@@ -101,7 +101,7 @@ func (m *MockClusterManager) RemoveCluster(names []string) {
}
// RemoveCluster indicates an expected call of RemoveCluster.
-func (mr *MockClusterManagerMockRecorder) RemoveCluster(names interface{})
*gomock.Call {
+func (mr *MockClusterManagerMockRecorder) RemoveCluster(names any)
*gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveCluster",
reflect.TypeOf((*MockClusterManager)(nil).RemoveCluster), names)
}
@@ -113,7 +113,7 @@ func (m *MockClusterManager) UpdateCluster(cluster
*model.ClusterConfig) {
}
// UpdateCluster indicates an expected call of UpdateCluster.
-func (mr *MockClusterManagerMockRecorder) UpdateCluster(cluster interface{})
*gomock.Call {
+func (mr *MockClusterManagerMockRecorder) UpdateCluster(cluster any)
*gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "UpdateCluster",
reflect.TypeOf((*MockClusterManager)(nil).UpdateCluster), cluster)
}
@@ -150,7 +150,7 @@ func (m_2 *MockListenerManager) AddListener(m
*model.Listener) error {
}
// AddOrUpdateListener indicates an expected call of AddOrUpdateListener.
-func (mr *MockListenerManagerMockRecorder) AddOrUpdateListener(m interface{})
*gomock.Call {
+func (mr *MockListenerManagerMockRecorder) AddOrUpdateListener(m any)
*gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "AddListener",
reflect.TypeOf((*MockListenerManager)(nil).AddListener), m)
}
@@ -162,7 +162,7 @@ func (m *MockListenerManager) RemoveListener(names
[]string) {
}
// RemoveListener indicates an expected call of RemoveListener.
-func (mr *MockListenerManagerMockRecorder) RemoveListener(names interface{})
*gomock.Call {
+func (mr *MockListenerManagerMockRecorder) RemoveListener(names any)
*gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "RemoveListener",
reflect.TypeOf((*MockListenerManager)(nil).RemoveListener), names)
}
@@ -278,7 +278,7 @@ func (m *MockClusterStore) HasCluster(name string) bool {
}
// HasCluster indicates an expected call of HasCluster.
-func (mr *MockClusterStoreMockRecorder) HasCluster(name interface{})
*gomock.Call {
+func (mr *MockClusterStoreMockRecorder) HasCluster(name any) *gomock.Call {
mr.mock.ctrl.T.Helper()
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "HasCluster",
reflect.TypeOf((*MockClusterStore)(nil).HasCluster), name)
}
diff --git a/pkg/wasm/service.go b/pkg/wasm/service.go
index 1590cf45..f7d16b80 100644
--- a/pkg/wasm/service.go
+++ b/pkg/wasm/service.go
@@ -77,7 +77,7 @@ func createWasmService(service model.WasmService)
(*WasmService, error) {
wasmService.rootContextID =
atomic.AddInt32(&wasmService.contextIDGenerator, 1)
wasmService.instancePool = sync.Pool{
- New: func() interface{} {
+ New: func() any {
pwd, _ := os.Getwd()
path := filepath.Join(pwd, cfg.Path)
if _, err := os.Stat(path); err != nil {