From 7e819cff646cd70fc90f26f49c98dba2399905db Mon Sep 17 00:00:00 2001 From: shanyujie Date: Tue, 24 Sep 2024 17:11:16 +0800 Subject: [PATCH 01/13] =?UTF-8?q?[shanyujie]=E8=A7=A3=E5=86=B3order?= =?UTF-8?q?=E7=94=9F=E6=88=90sql=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- database/gdb/gdb_model_order_group.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/database/gdb/gdb_model_order_group.go b/database/gdb/gdb_model_order_group.go index 9f09dabea59..4b1e5926de5 100644 --- a/database/gdb/gdb_model_order_group.go +++ b/database/gdb/gdb_model_order_group.go @@ -36,7 +36,7 @@ func (m *Model) Order(orderBy ...interface{}) *Model { return model } } - model.orderBy += model.db.GetCore().QuoteString(gstr.JoinAny(orderBy, " ")) + model.orderBy += model.db.GetCore().QuoteString(gstr.JoinAny(orderBy, ", ")) return model } From 34231b355dfe6ef746e90bf79d77bebffe8005bc Mon Sep 17 00:00:00 2001 From: shanyujie Date: Wed, 25 Sep 2024 13:01:04 +0800 Subject: [PATCH 02/13] [shanyujie]add OrderBy statement generated unit test --- .../drivers/mysql/mysql_z_unit_model_test.go | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/contrib/drivers/mysql/mysql_z_unit_model_test.go b/contrib/drivers/mysql/mysql_z_unit_model_test.go index 02532d42b2c..5ba6f9e2408 100644 --- a/contrib/drivers/mysql/mysql_z_unit_model_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_model_test.go @@ -12,6 +12,7 @@ import ( "database/sql" "fmt" "os" + "strings" "testing" "time" @@ -4786,3 +4787,22 @@ func Test_Model_FixGdbJoin(t *testing.T) { t.Assert(gtest.DataContent(`fix_gdb_join_expect.sql`), sqlSlice[len(sqlSlice)-1]) }) } + +func TestOrderByStatementGenerated(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + array := gstr.SplitAndTrim(gtest.DataContent(`table_with_prefix.sql`), ";") + for _, v := range array { + if _, err := db.Exec(ctx, v); err != nil { + gtest.Error(err) + } + } + defer dropTable(`instance`) + sqlArray, _ := gdb.CatchSQL(ctx, func(ctx context.Context) error { + g.DB("default").Ctx(ctx).Model("instance").Order("f_id asc", "name desc").All() + return nil + }) + rawSql := strings.ReplaceAll(sqlArray[len(sqlArray)-1], " ", "") + expectSql := strings.ReplaceAll("SELECT * FROM `instance` ORDER BY `f_id` asc, `name` desc", " ", "") + t.Assert(rawSql, expectSql) + }) +} From fc90cdd07606f3c3ba4b88ed6850610921989f7b Mon Sep 17 00:00:00 2001 From: shanyujie Date: Wed, 25 Sep 2024 16:52:52 +0800 Subject: [PATCH 03/13] [shanyujie]rename unit test function name, use standalone sql for Test_OrderBy_Statement_Generated --- contrib/drivers/mysql/mysql_z_unit_model_test.go | 10 +++++----- contrib/drivers/mysql/testdata/fix_gdb_order_by.sql | 9 +++++++++ 2 files changed, 14 insertions(+), 5 deletions(-) create mode 100644 contrib/drivers/mysql/testdata/fix_gdb_order_by.sql diff --git a/contrib/drivers/mysql/mysql_z_unit_model_test.go b/contrib/drivers/mysql/mysql_z_unit_model_test.go index 5ba6f9e2408..f1a8b604675 100644 --- a/contrib/drivers/mysql/mysql_z_unit_model_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_model_test.go @@ -4788,21 +4788,21 @@ func Test_Model_FixGdbJoin(t *testing.T) { }) } -func TestOrderByStatementGenerated(t *testing.T) { +func Test_OrderBy_Statement_Generated(t *testing.T) { gtest.C(t, func(t *gtest.T) { - array := gstr.SplitAndTrim(gtest.DataContent(`table_with_prefix.sql`), ";") + array := gstr.SplitAndTrim(gtest.DataContent(`fix_gdb_order_by.sql`), ";") for _, v := range array { if _, err := db.Exec(ctx, v); err != nil { gtest.Error(err) } } - defer dropTable(`instance`) + defer dropTable(`employee`) sqlArray, _ := gdb.CatchSQL(ctx, func(ctx context.Context) error { - g.DB("default").Ctx(ctx).Model("instance").Order("f_id asc", "name desc").All() + g.DB("default").Ctx(ctx).Model("employee").Order("name asc", "age desc").All() return nil }) rawSql := strings.ReplaceAll(sqlArray[len(sqlArray)-1], " ", "") - expectSql := strings.ReplaceAll("SELECT * FROM `instance` ORDER BY `f_id` asc, `name` desc", " ", "") + expectSql := strings.ReplaceAll("SELECT * FROM `employee` ORDER BY `name` asc, `age` desc", " ", "") t.Assert(rawSql, expectSql) }) } diff --git a/contrib/drivers/mysql/testdata/fix_gdb_order_by.sql b/contrib/drivers/mysql/testdata/fix_gdb_order_by.sql new file mode 100644 index 00000000000..2ba712641fa --- /dev/null +++ b/contrib/drivers/mysql/testdata/fix_gdb_order_by.sql @@ -0,0 +1,9 @@ +CREATE TABLE IF NOT EXISTS `employee` +( + id BIGINT AUTO_INCREMENT PRIMARY KEY, + name VARCHAR(255) NOT NULL, + age INT NOT NULL +); + +INSERT INTO employee(name, age) VALUES ('John', 30); +INSERT INTO employee(name, age) VALUES ('Mary', 28); \ No newline at end of file From e8a1f6593e05c121661ebfcdee65769ce2706e5c Mon Sep 17 00:00:00 2001 From: shanyujie Date: Wed, 16 Oct 2024 11:06:23 +0800 Subject: [PATCH 04/13] [shanyujie]Allows custom actions after a remote profile update --- contrib/config/nacos/nacos.go | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/contrib/config/nacos/nacos.go b/contrib/config/nacos/nacos.go index 5327b9d6ea9..1995ae075a0 100644 --- a/contrib/config/nacos/nacos.go +++ b/contrib/config/nacos/nacos.go @@ -9,6 +9,7 @@ package nacos import ( "context" + "sync" "github.com/nacos-group/nacos-sdk-go/v2/clients" "github.com/nacos-group/nacos-sdk-go/v2/clients/config_client" @@ -37,7 +38,7 @@ type Client struct { } // New creates and returns gcfg.Adapter implementing using nacos service. -func New(ctx context.Context, config Config) (adapter gcfg.Adapter, err error) { +func New(ctx context.Context, config Config, actions ...func()) (adapter gcfg.Adapter, err error) { // Data validation. err = g.Validator().Data(config).Run(ctx) if err != nil { @@ -57,7 +58,7 @@ func New(ctx context.Context, config Config) (adapter gcfg.Adapter, err error) { return nil, gerror.Wrapf(err, `create nacos client failed with config: %+v`, config) } - err = client.addWatcher() + err = client.addWatcher(actions...) if err != nil { return nil, err } @@ -121,13 +122,22 @@ func (c *Client) doUpdate(content string) (err error) { return nil } -func (c *Client) addWatcher() error { +func (c *Client) addWatcher(actions ...func()) error { if !c.config.Watch { return nil } c.config.ConfigParam.OnChange = func(namespace, group, dataId, data string) { c.doUpdate(data) + var wg sync.WaitGroup + for _, action := range actions { + wg.Add(1) + go func(f func()) { + defer wg.Done() + f() + }(action) + } + wg.Wait() } if err := c.client.ListenConfig(c.config.ConfigParam); err != nil { From 043f39f0739321072b63bd971649a5c79c196714 Mon Sep 17 00:00:00 2001 From: shanyujie Date: Wed, 16 Oct 2024 16:12:06 +0800 Subject: [PATCH 05/13] [shanyujie]Fix unreasonable implementations and add unit tests --- contrib/config/nacos/nacos.go | 28 +++++++------------- contrib/config/nacos/nacos_test.go | 42 +++++++++++++++++++++++++----- 2 files changed, 46 insertions(+), 24 deletions(-) diff --git a/contrib/config/nacos/nacos.go b/contrib/config/nacos/nacos.go index 1995ae075a0..b11145747d2 100644 --- a/contrib/config/nacos/nacos.go +++ b/contrib/config/nacos/nacos.go @@ -9,8 +9,6 @@ package nacos import ( "context" - "sync" - "github.com/nacos-group/nacos-sdk-go/v2/clients" "github.com/nacos-group/nacos-sdk-go/v2/clients/config_client" "github.com/nacos-group/nacos-sdk-go/v2/common/constant" @@ -24,10 +22,11 @@ import ( // Config is the configuration object for nacos client. type Config struct { - ServerConfigs []constant.ServerConfig `v:"required"` // See constant.ServerConfig - ClientConfig constant.ClientConfig `v:"required"` // See constant.ClientConfig - ConfigParam vo.ConfigParam `v:"required"` // See vo.ConfigParam - Watch bool // Watch watches remote configuration updates, which updates local configuration in memory immediately when remote configuration changes. + ServerConfigs []constant.ServerConfig `v:"required"` // See constant.ServerConfig + ClientConfig constant.ClientConfig `v:"required"` // See constant.ClientConfig + ConfigParam vo.ConfigParam `v:"required"` // See vo.ConfigParam + Watch bool // Watch watches remote configuration updates, which updates local configuration in memory immediately when remote configuration changes. + OnConfigChange func() // Configure change callback function } // Client implements gcfg.Adapter implementing using nacos service. @@ -38,7 +37,7 @@ type Client struct { } // New creates and returns gcfg.Adapter implementing using nacos service. -func New(ctx context.Context, config Config, actions ...func()) (adapter gcfg.Adapter, err error) { +func New(ctx context.Context, config Config) (adapter gcfg.Adapter, err error) { // Data validation. err = g.Validator().Data(config).Run(ctx) if err != nil { @@ -58,7 +57,7 @@ func New(ctx context.Context, config Config, actions ...func()) (adapter gcfg.Ad return nil, gerror.Wrapf(err, `create nacos client failed with config: %+v`, config) } - err = client.addWatcher(actions...) + err = client.addWatcher() if err != nil { return nil, err } @@ -122,22 +121,15 @@ func (c *Client) doUpdate(content string) (err error) { return nil } -func (c *Client) addWatcher(actions ...func()) error { +func (c *Client) addWatcher() error { if !c.config.Watch { return nil } - c.config.ConfigParam.OnChange = func(namespace, group, dataId, data string) { c.doUpdate(data) - var wg sync.WaitGroup - for _, action := range actions { - wg.Add(1) - go func(f func()) { - defer wg.Done() - f() - }(action) + if c.config.OnConfigChange != nil { + go c.config.OnConfigChange() } - wg.Wait() } if err := c.client.ListenConfig(c.config.ConfigParam); err != nil { diff --git a/contrib/config/nacos/nacos_test.go b/contrib/config/nacos/nacos_test.go index 30b65a3d6d7..a71fef64134 100644 --- a/contrib/config/nacos/nacos_test.go +++ b/contrib/config/nacos/nacos_test.go @@ -7,16 +7,17 @@ package nacos_test import ( - "testing" - - "github.com/nacos-group/nacos-sdk-go/v2/common/constant" - "github.com/nacos-group/nacos-sdk-go/v2/vo" - "github.com/gogf/gf/contrib/config/nacos/v2" + "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/guid" + "github.com/nacos-group/nacos-sdk-go/v2/common/constant" + "github.com/nacos-group/nacos-sdk-go/v2/vo" + "net/url" + "testing" + "time" ) var ( @@ -33,6 +34,7 @@ var ( DataId: "config.toml", Group: "test", } + configPublishUrl = "http://localhost:8848/nacos/v2/cs/config?type=toml&namespaceId=public&group=test&dataId=config.toml" ) func TestNacos(t *testing.T) { @@ -47,7 +49,6 @@ func TestNacos(t *testing.T) { config.SetAdapter(adapter) t.Assert(config.Available(ctx), true) - v, err := config.Get(ctx, `server.address`) t.AssertNil(err) t.Assert(v.String(), ":8000") @@ -57,3 +58,32 @@ func TestNacos(t *testing.T) { t.AssertGT(len(m), 0) }) } + +func TestNacosOnConfigChangeFunc(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + adapter, _ := nacos.New(ctx, nacos.Config{ + ServerConfigs: []constant.ServerConfig{serverConfig}, + ClientConfig: clientConfig, + ConfigParam: configParam, + Watch: true, + OnConfigChange: func() { + gtest.Assert("gf", g.Cfg().MustGet(gctx.GetInitCtx(), "app.name").String()) + }, + }) + g.Cfg().SetAdapter(adapter) + t.Assert(g.Cfg().Available(ctx), true) + appName, err := g.Cfg().Get(ctx, "app.name") + t.AssertNil(err) + t.Assert(appName.String(), "") + c, _ := g.Cfg().Data(ctx) + j := gjson.New(c) + j.Set("app.name", "gf") + res, _ := j.ToTomlString() + _, err = g.Client().Post(ctx, configPublishUrl+"&content="+url.QueryEscape(res)) + t.AssertNil(err) + time.Sleep(5 * time.Second) + j.Remove("app") + res2, _ := j.ToTomlString() + _, err = g.Client().Post(ctx, configPublishUrl+"&content="+url.QueryEscape(res2)) + }) +} From a7730d43f81f7a25e1b86181b2232ab3793819b8 Mon Sep 17 00:00:00 2001 From: shanyujie <1196661499@qq.com> Date: Thu, 24 Oct 2024 15:36:27 +0800 Subject: [PATCH 06/13] Enter the configuration string and Nacos-related configuration information in the configuration callback function, and leave it up to the developer to decide whether to use it --- contrib/config/nacos/nacos.go | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/contrib/config/nacos/nacos.go b/contrib/config/nacos/nacos.go index b11145747d2..65a237df181 100644 --- a/contrib/config/nacos/nacos.go +++ b/contrib/config/nacos/nacos.go @@ -22,11 +22,11 @@ import ( // Config is the configuration object for nacos client. type Config struct { - ServerConfigs []constant.ServerConfig `v:"required"` // See constant.ServerConfig - ClientConfig constant.ClientConfig `v:"required"` // See constant.ClientConfig - ConfigParam vo.ConfigParam `v:"required"` // See vo.ConfigParam - Watch bool // Watch watches remote configuration updates, which updates local configuration in memory immediately when remote configuration changes. - OnConfigChange func() // Configure change callback function + ServerConfigs []constant.ServerConfig `v:"required"` // See constant.ServerConfig + ClientConfig constant.ClientConfig `v:"required"` // See constant.ClientConfig + ConfigParam vo.ConfigParam `v:"required"` // See vo.ConfigParam + Watch bool // Watch watches remote configuration updates, which updates local configuration in memory immediately when remote configuration changes. + OnConfigChange func(namespace, group, dataId, data string) // Configure change callback function } // Client implements gcfg.Adapter implementing using nacos service. @@ -128,7 +128,7 @@ func (c *Client) addWatcher() error { c.config.ConfigParam.OnChange = func(namespace, group, dataId, data string) { c.doUpdate(data) if c.config.OnConfigChange != nil { - go c.config.OnConfigChange() + go c.config.OnConfigChange(namespace, group, dataId, data) } } From d19ef6a80be6ce8ae64e2fbec4606b5cb2ad835c Mon Sep 17 00:00:00 2001 From: shanyujie <1196661499@qq.com> Date: Thu, 24 Oct 2024 15:47:36 +0800 Subject: [PATCH 07/13] Fixed the unit test of the nacos configuration change callback function --- contrib/config/nacos/nacos_test.go | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/contrib/config/nacos/nacos_test.go b/contrib/config/nacos/nacos_test.go index a71fef64134..84492eaa82f 100644 --- a/contrib/config/nacos/nacos_test.go +++ b/contrib/config/nacos/nacos_test.go @@ -66,7 +66,10 @@ func TestNacosOnConfigChangeFunc(t *testing.T) { ClientConfig: clientConfig, ConfigParam: configParam, Watch: true, - OnConfigChange: func() { + OnConfigChange: func(namespace, group, dataId, data string) { + gtest.Assert("public", namespace) + gtest.Assert("test", group) + gtest.Assert("config.toml", dataId) gtest.Assert("gf", g.Cfg().MustGet(gctx.GetInitCtx(), "app.name").String()) }, }) From 3df70edce2d7217962fa547fdc6851322b68fba5 Mon Sep 17 00:00:00 2001 From: shanyujie <1196661499@qq.com> Date: Tue, 10 Dec 2024 10:47:00 +0800 Subject: [PATCH 08/13] =?UTF-8?q?[lanceadd]=E8=BF=98=E5=8E=9F=E5=BC=95?= =?UTF-8?q?=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- contrib/config/nacos/nacos_test.go | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/contrib/config/nacos/nacos_test.go b/contrib/config/nacos/nacos_test.go index 15a335a7655..a497cff9349 100644 --- a/contrib/config/nacos/nacos_test.go +++ b/contrib/config/nacos/nacos_test.go @@ -9,14 +9,14 @@ package nacos_test import ( "github.com/gogf/gf/contrib/config/nacos/v2" "github.com/gogf/gf/v2/encoding/gjson" - "testing" - "github.com/nacos-group/nacos-sdk-go/v2/common/constant" - "github.com/nacos-group/nacos-sdk-go/v2/vo" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/guid" + "github.com/nacos-group/nacos-sdk-go/v2/common/constant" + "github.com/nacos-group/nacos-sdk-go/v2/vo" "net/url" + "testing" "time" ) @@ -80,12 +80,14 @@ func TestNacosOnConfigChangeFunc(t *testing.T) { t.Assert(appName.String(), "") c, _ := g.Cfg().Data(ctx) j := gjson.New(c) - j.Set("app.name", "gf") + err = j.Set("app.name", "gf") + t.AssertNil(err) res, _ := j.ToTomlString() _, err = g.Client().Post(ctx, configPublishUrl+"&content="+url.QueryEscape(res)) t.AssertNil(err) time.Sleep(5 * time.Second) - j.Remove("app") + err = j.Remove("app") + t.AssertNil(err) res2, _ := j.ToTomlString() _, err = g.Client().Post(ctx, configPublishUrl+"&content="+url.QueryEscape(res2)) }) From 53918f640eacefc549d4ae1e52b4044e58a1adfb Mon Sep 17 00:00:00 2001 From: shanyujie <1196661499@qq.com> Date: Wed, 11 Dec 2024 11:07:51 +0800 Subject: [PATCH 09/13] [lanceadd]The two PRs #4025 and #4029 made 'v.17.0'->'v.18.0'->'v1.17.0' to the version number of 'github.com/fatih/color', it seems that 'v.18.0' should be used --- contrib/registry/consul/go.mod | 8 ++++---- contrib/registry/consul/go.sum | 4 ++++ 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/contrib/registry/consul/go.mod b/contrib/registry/consul/go.mod index 2a782e4a70e..1eea460728f 100644 --- a/contrib/registry/consul/go.mod +++ b/contrib/registry/consul/go.mod @@ -12,7 +12,7 @@ require ( github.com/armon/go-metrics v0.4.1 // indirect github.com/clbanning/mxj/v2 v2.7.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect - github.com/fatih/color v1.17.0 // indirect + github.com/fatih/color v1.18.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect @@ -24,7 +24,7 @@ require ( github.com/hashicorp/go-rootcerts v1.0.2 // indirect github.com/hashicorp/golang-lru v0.5.4 // indirect github.com/hashicorp/serf v0.10.1 // indirect - github.com/magiconair/properties v1.8.7 // indirect + github.com/magiconair/properties v1.8.9 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect @@ -34,8 +34,8 @@ require ( go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/contrib/registry/consul/go.sum b/contrib/registry/consul/go.sum index 69618933a45..7daa6367c21 100644 --- a/contrib/registry/consul/go.sum +++ b/contrib/registry/consul/go.sum @@ -30,6 +30,7 @@ github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= github.com/fatih/color v1.17.0 h1:GlRw1BRJxkpqUCBKzKOw098ed57fEsKeNjpTe3cSjK4= github.com/fatih/color v1.17.0/go.mod h1:YZ7TlrGPkiz6ku9fK3TLD/pl3CpsiFyu8N92HLgmosI= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= @@ -105,6 +106,7 @@ github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= github.com/magiconair/properties v1.8.7 h1:IeQXZAiQcpL9mgcAe1Nu6cX9LLw6ExEHKjN0VQdvPDY= github.com/magiconair/properties v1.8.7/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= github.com/mattn/go-colorable v0.1.4/go.mod h1:U0ppj6V5qS13XJ6of8GYAs25YV2eR4EVcfRqFIhoBtE= github.com/mattn/go-colorable v0.1.6/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= @@ -222,6 +224,7 @@ golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= golang.org/x/sys v0.22.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= @@ -229,6 +232,7 @@ golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From 6603d6859c002a7d26ef23d53d036f76c6cd1c6a Mon Sep 17 00:00:00 2001 From: shanyujie <1196661499@qq.com> Date: Thu, 12 Dec 2024 09:48:04 +0800 Subject: [PATCH 10/13] [lanceadd]Supplemental false assertions --- contrib/config/nacos/nacos_test.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/contrib/config/nacos/nacos_test.go b/contrib/config/nacos/nacos_test.go index a497cff9349..f877adc489e 100644 --- a/contrib/config/nacos/nacos_test.go +++ b/contrib/config/nacos/nacos_test.go @@ -78,17 +78,21 @@ func TestNacosOnConfigChangeFunc(t *testing.T) { appName, err := g.Cfg().Get(ctx, "app.name") t.AssertNil(err) t.Assert(appName.String(), "") - c, _ := g.Cfg().Data(ctx) + c, err := g.Cfg().Data(ctx) + t.AssertNil(err) j := gjson.New(c) err = j.Set("app.name", "gf") t.AssertNil(err) - res, _ := j.ToTomlString() + res, err := j.ToTomlString() + t.AssertNil(err) _, err = g.Client().Post(ctx, configPublishUrl+"&content="+url.QueryEscape(res)) t.AssertNil(err) time.Sleep(5 * time.Second) err = j.Remove("app") t.AssertNil(err) - res2, _ := j.ToTomlString() + res2, err := j.ToTomlString() + t.AssertNil(err) _, err = g.Client().Post(ctx, configPublishUrl+"&content="+url.QueryEscape(res2)) + t.AssertNil(err) }) } From 7a91cce4148aeda99716e705d5bc28a9f8f4af1f Mon Sep 17 00:00:00 2001 From: shanyujie <1196661499@qq.com> Date: Thu, 12 Dec 2024 10:26:25 +0800 Subject: [PATCH 11/13] [lanceadd]reRange imports --- contrib/config/nacos/nacos.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/contrib/config/nacos/nacos.go b/contrib/config/nacos/nacos.go index 65a237df181..c219c37e45a 100644 --- a/contrib/config/nacos/nacos.go +++ b/contrib/config/nacos/nacos.go @@ -9,15 +9,14 @@ package nacos import ( "context" - "github.com/nacos-group/nacos-sdk-go/v2/clients" - "github.com/nacos-group/nacos-sdk-go/v2/clients/config_client" - "github.com/nacos-group/nacos-sdk-go/v2/common/constant" - "github.com/nacos-group/nacos-sdk-go/v2/vo" - "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gcfg" + "github.com/nacos-group/nacos-sdk-go/v2/clients" + "github.com/nacos-group/nacos-sdk-go/v2/clients/config_client" + "github.com/nacos-group/nacos-sdk-go/v2/common/constant" + "github.com/nacos-group/nacos-sdk-go/v2/vo" ) // Config is the configuration object for nacos client. From fdc0445e086b9c12b36453c2b9fc78ed84606628 Mon Sep 17 00:00:00 2001 From: shanyujie <1196661499@qq.com> Date: Thu, 12 Dec 2024 10:32:00 +0800 Subject: [PATCH 12/13] [lanceadd]ix golangcl-lint git push --- .github/workflows/golangci-lint.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 9be6b9564d8..556b211c206 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -79,4 +79,4 @@ jobs: git config --global user.email "github-actions[bot]@users.noreply.github.com" git add . git commit -m "Apply gci import order changes" - git push origin HEAD:$(git rev-parse --abbrev-ref HEAD) \ No newline at end of file + git push origin/$(git rev-parse --abbrev-ref HEAD) \ No newline at end of file From a6da1ca8952611d4d2fde57ad3a5dcc52efffa17 Mon Sep 17 00:00:00 2001 From: houseme Date: Thu, 12 Dec 2024 10:49:07 +0800 Subject: [PATCH 13/13] Update go.mod --- contrib/config/nacos/go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/config/nacos/go.mod b/contrib/config/nacos/go.mod index 8ed4a55e91c..5d1d905bf4d 100644 --- a/contrib/config/nacos/go.mod +++ b/contrib/config/nacos/go.mod @@ -52,7 +52,7 @@ require ( go.uber.org/atomic v1.10.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.21.0 // indirect - golang.org/x/crypto v0.30.0 // indirect + golang.org/x/crypto v0.31.0 // indirect golang.org/x/net v0.32.0 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect