From 910703ec3aa8d6a57ec4f5727c1c6ac7f7eed494 Mon Sep 17 00:00:00 2001 From: wingfeng Date: Mon, 18 Nov 2024 18:33:59 +0800 Subject: [PATCH 001/102] chore(database/gdb): comment update for function `Model.Order` (#3933) --- database/gdb/gdb_model_order_group.go | 1 - 1 file changed, 1 deletion(-) diff --git a/database/gdb/gdb_model_order_group.go b/database/gdb/gdb_model_order_group.go index 4b1e5926de5..ec69818b6be 100644 --- a/database/gdb/gdb_model_order_group.go +++ b/database/gdb/gdb_model_order_group.go @@ -17,7 +17,6 @@ import ( // // Eg: // Order("id desc") -// Order("id", "desc"). // Order("id desc,name asc") // Order("id desc").Order("name asc") // Order(gdb.Raw("field(id, 3,1,2)")). From 0d1aed0741a3e2a3dd11eb6514218f991a2e90f9 Mon Sep 17 00:00:00 2001 From: yijiong <59520517+yzy613@users.noreply.github.com> Date: Tue, 19 Nov 2024 23:30:29 +0800 Subject: [PATCH 002/102] fix(os/gcache): function `Remove` returns value not `*gvar.Var` as previous version (#3936) --- os/gcache/gcache_adapter_memory.go | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/os/gcache/gcache_adapter_memory.go b/os/gcache/gcache_adapter_memory.go index 4653c2df0ba..aceb0dc39c7 100644 --- a/os/gcache/gcache_adapter_memory.go +++ b/os/gcache/gcache_adapter_memory.go @@ -288,11 +288,7 @@ func (c *AdapterMemory) GetExpire(ctx context.Context, key interface{}) (time.Du // If multiple keys are given, it returns the value of the last deleted item. func (c *AdapterMemory) Remove(ctx context.Context, keys ...interface{}) (*gvar.Var, error) { defer c.lru.Remove(keys...) - value, err := c.doRemove(ctx, keys...) - if err != nil { - return nil, err - } - return gvar.New(value), nil + return c.doRemove(ctx, keys...) } func (c *AdapterMemory) doRemove(_ context.Context, keys ...interface{}) (*gvar.Var, error) { From 3090fe7f4e6b97ae2590075126d090aeb0b93b9c Mon Sep 17 00:00:00 2001 From: John Guo Date: Wed, 20 Nov 2024 20:21:33 +0800 Subject: [PATCH 003/102] fix(database/gdb): recognize `tinyint(1)/int(1)` as bool (#3943) --- database/gdb/gdb_core_structure.go | 4 ---- 1 file changed, 4 deletions(-) diff --git a/database/gdb/gdb_core_structure.go b/database/gdb/gdb_core_structure.go index 8a4c1192740..bbb9df7574c 100644 --- a/database/gdb/gdb_core_structure.go +++ b/database/gdb/gdb_core_structure.go @@ -259,10 +259,6 @@ func (c *Core) CheckLocalTypeForField(ctx context.Context, fieldType string, fie if gstr.ContainsI(fieldType, "unsigned") { return LocalTypeUint, nil } - // field length is 1 means boolean. - if typePattern == "1" { - return LocalTypeBool, nil - } return LocalTypeInt, nil case From 90851881cc7e7eb863942b01249b32611e12557c Mon Sep 17 00:00:00 2001 From: cruel Date: Wed, 20 Nov 2024 20:39:05 +0800 Subject: [PATCH 004/102] fix(registry/zookeeper): watch service name path error with extra suffix `-` (#3948) --- contrib/registry/zookeeper/zookeeper_registrar.go | 2 +- contrib/registry/zookeeper/zookeeper_watcher.go | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/registry/zookeeper/zookeeper_registrar.go b/contrib/registry/zookeeper/zookeeper_registrar.go index 5b8a018178b..26273a5b2a7 100644 --- a/contrib/registry/zookeeper/zookeeper_registrar.go +++ b/contrib/registry/zookeeper/zookeeper_registrar.go @@ -65,7 +65,7 @@ func (r *Registry) Register(_ context.Context, service gsvc.Service) (gsvc.Servi // Deregister off-lines and removes `service` from the Registry. func (r *Registry) Deregister(ctx context.Context, service gsvc.Service) error { ch := make(chan error, 1) - prefix := strings.TrimPrefix(strings.ReplaceAll(service.GetPrefix(), "/", "-"), "-") + prefix := strings.Trim(strings.ReplaceAll(service.GetPrefix(), "/", "-"), "-") servicePath := path.Join(r.opts.namespace, prefix, service.GetName()) go func() { err := r.conn.Delete(servicePath, -1) diff --git a/contrib/registry/zookeeper/zookeeper_watcher.go b/contrib/registry/zookeeper/zookeeper_watcher.go index def4fa818a3..1ee710a17e0 100644 --- a/contrib/registry/zookeeper/zookeeper_watcher.go +++ b/contrib/registry/zookeeper/zookeeper_watcher.go @@ -66,7 +66,7 @@ func (w *watcher) Proceed() ([]gsvc.Service, error) { } func (w *watcher) getServicesByPrefix() ([]gsvc.Service, error) { - prefix := strings.TrimPrefix(strings.ReplaceAll(w.prefix, "/", "-"), "-") + prefix := strings.Trim(strings.ReplaceAll(w.prefix, "/", "-"), "-") serviceNamePath := path.Join(w.nameSpace, prefix) instances, err, _ := w.group.Do(serviceNamePath, func() (interface{}, error) { servicesID, _, err := w.conn.Children(serviceNamePath) @@ -122,7 +122,7 @@ func (w *watcher) Close() error { } func (w *watcher) watch(ctx context.Context) { - prefix := strings.TrimPrefix(strings.ReplaceAll(w.prefix, "/", "-"), "-") + prefix := strings.Trim(strings.ReplaceAll(w.prefix, "/", "-"), "-") serviceNamePath := path.Join(w.nameSpace, prefix) for { From 9c8b21af7b9df0c1f7ac894ba8cbe62d0dff7c55 Mon Sep 17 00:00:00 2001 From: John Guo Date: Wed, 20 Nov 2024 21:47:32 +0800 Subject: [PATCH 005/102] fix(cmd/gf): incorrect make command in project template (#3946) --- cmd/gf/internal/packed/template-mono-app.go | 2 +- cmd/gf/internal/packed/template-mono.go | 2 +- cmd/gf/internal/packed/template-single.go | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/cmd/gf/internal/packed/template-mono-app.go b/cmd/gf/internal/packed/template-mono-app.go index aa9dc1c812c..46fb81ca96a 100644 --- a/cmd/gf/internal/packed/template-mono-app.go +++ b/cmd/gf/internal/packed/template-mono-app.go @@ -3,7 +3,7 @@ package packed import "github.com/gogf/gf/v2/os/gres" func init() { - if err := gres.Add("H4sIAAAAAAAC/7RaCTiUaxv+ENn3JVmyjexDCZUlpRr7EkKowRjDmJlmEIcokVBIZCnaZE2IiqRIkkK20kbZFUKK7P/Vf07OfGLMjI7rauZSV/d9P8/zfu/3vO9zmxnSreEFGAFGQMQMZwsQ/awHmAAvhCcODfdCKHpiMVhFOA4HNYZ7IFxRaISVJT1Ac8BTA8n8dYIj/Mgoq4WZmVm+lVmjTD2srsZcRsa0sfsr4Zs3GzvOy4feUPZ6WjrkfG+czOGSYoYfP/Y+OZGm2wnJKqHfGg7Julcy6Td5L5ye3sBeaa6+/abuD0scohfSF5eeJtf/CSkljTzBVPYevQMAgPl5M8O1jErM53NwAABEAQCwfABCSwZgsVtXz3i3krHeQgQW1rgXR+QNao2tGPXrFJ/qK+hb4Z5DLRjraw1f6LMZKD7t62RWqDOqt2ZU0leQK7D42GT1VEZWVuZOU6vpC1M6VMtzqEErdE0WzZpf+nRjxUJNAAAwItIH/KaPb0l9cBxqQdlPLOL/sTyW0HJYUDcEGo1dEfH37EmRRvz7Uwn5L3RRVJ175Q7WkBeN+1i1qyCjnWv7az5FX1E12zkckathWJZTt4eN6fqwY+d4w1o3eqePzomCfbjp1r31VxodlWFxtdJaGuOMg9cKopuc/StOtCPZg3uzQrOi+Kw9NPPUiw/cvhAxhxCAfGn35RxECMc/DUt7o5xh24hS3XpAV1WeATs94fkShTvBvh3J3fRU+vll84SLsV3dbXEdJt66kLMOsZeP3r/aul47uVvkSDBHsjGu/Y2gjojVWC6Ly9aPvZb7z/XsZof02kY9bDxMUzM5lWw4lZa3sN4sJgPbWwEAyKMhVQPRFTLmo0JFGTauCPp7JdB1BSYnVFjXfCwJZH7Oo3DmUC2PFxzunDN5+OKpxJDHWXbi7SLm0mlRG9vaWv38kXyaWgDvgKdGe0VUka9j3nSubUO6rBtzRnUMw4U1kOK1I4YCmrDcIVvtw1M2F7oEBr3mpep9Bwe3Wjx9yLYTmXKWPajiMcE/Mq0zhJA0Wqz3F4pln2Dz6D3dL6FRI7Mcyepi8tJn7etFbx2AxG0+kMeNmpLZ8JfWJNOv5HLbCaOzAQDoI7nA+ZfMgxvc2YOKpEosCwZ1xmJcUUglP7gnegFYL6rMRF6FN2T6aIR503v5Ap85WIy8lJwUM7NjeYHpab531a+Ru8aHzHmlsieTk7AnIY7tjuK1n2jsm07bfPy0M9wjXeIyPvzM8zMv8x9nwIb2DJRnuG6Wxej6+ziU8obh8LLJNIyWGBrf50eAPWk29QyRmhN5LusLE7+7lvq/35CaWvUyaKBON7fFILfOp/TtfOtOB/6HiPJ9RxStw+210coxao3KQGpb0lsH/EWnrwyRjY9cH36AD6p/8qqyEY+T3zP1wDSCbfiMyajB7PChVKtatZjsZvM+v6Lbcwsblt3uz3ztAACI0VCZtp8fis5olJLnv/VAxxzM4VHhrLqkfqkzf8JC4V741OudVsx36A/vHtV9K3F4c81J13O3ku4wz47cmpW8OuHZW3t8bLukaH5Ekjfj54F2N2kc7d2Qy0mbnOfg9CayMHEdxYHoD9JuwQLGIzzm9+seZ7pFnJExwSR6aGxHK45pm8bhU99VcrxJMynpvoG3/s4LQz77vP6y0baqmCLz+sCggPMHmGmUjndyRd6b2zR3MGDC74Gws+r64OQ7hgwvgthL9u+WQ3bkxZvN3ss6GtYhFuJbfv+661qRug3vzkF6huTmkudlhxSyJV3NTkbJie4sH3jTz1eP9I38vr6n6wK3lVQc1BB9t7mjgEuIhpd+i+fOEtiw914B4BIXz4ekp/d3uLZtHj/qfup0NPtU+SdMw+C+OIvzArFXm7evz4Re+N78geZXLc7dcqnYTAMAr0nWQpR0LYjrEGL1IbpTjTPQcZ6vWTj+1F/iFhtshz71PyrIwAgU6cilGIRedKFVihp6y863e2Y43vMWzb03XRWntS49xGqKmjJ01SQ0Pp8dw28TaqscYbiVPBrMKY13FGD0SMbGXizUvS3eTXc/M9guJGvmKip0x26a2vXFZfPM1rQZ/GfonVFPuO5ksp1z2sEwVvqm8q54S0SLO2PUGSZn2b7uz2PZIXa6O0WmoSZCm6Qz23U9E210lXbXWN9OP69Pc/18PIcs28AJkVxfeU6niS6hTYEi3DPV+nVZaoyWKkEn+Zhbvhwq4bU2rDfPSH9dVFvy8mJxB1s7X8THjRsOveU0hsSdvnbcwn1dtOsn3/MmIQif1lh+y9jgZ+wGfUfZVPNu74HroiYFevmt2WZtv8l8fqb6wLoayqPj40avh5wxzbyroANXhR8Xnt9uI2Tpfzu0Vj3zuJWX96PejMfRAkZl2hjZsJ4xN2YcXdkDW8m+fCd+VQxPD+GclKvi7dDSGjfh6pB42vmTc9WbiwpaXjHE6umnSGYYlb+41ER7Nytza3SXetpFPg7m9CElaRlm6wc0TpBv4y+ufeqQvL++OjcjbSwho5R/2JW9dR37J7xPrQl2eHQt7MYxxyDN0lnvr8UB62bVwsPKyrq07Y90tyTQ5ebeyERs7QlYm63mMaEWrXzGwNEl8KNY2hYotvCqkGZTaTGGm6+7OrP4fQpjaXV/WrJTW4tg73m6CMVmC0uZQf3R6TapmTLCkIOtEi7SPltDuvtzoS4Lk2NlsL3VhWAUjPfbVHThmzH8zHcVE0VrubaWJ88iZiNbWfDxAshjEczWVwtQpzKq0vGRyc0p+v7TPd0dEyfezXzWGo8zHT41yc+nFooGzK7/YI/9Wlr63s+GKahYLrF2GPlhJ185hzrn7pG+La+3MK/9C7K/pdcDZt+m0d8c4LU9PLrEZ9IUmshN3xjIJRg6KbH+i8BZlsrbo8o5DU3BdutdL7o+Nc6PPGarVyc/9iH0UqDqqMS24oPd16C2mXytVfbb99vZJb3smS9NGFNzyM3ljueK9y4SiE/xvsHi3nrXvl9wC+PcCa89kQ8Ezj3pj2P8Mk/76wl8NpAuokgHANJrSb2Rlu6PURgvBB4DR1PRw4mSBIQ6e7pQ8aqDrAj68w9x9+AVo+vxXpkz9EVT3jqvWyecG0XZSqQaxmPN7hRNZGm9ijCQVIlVP35rvsymtEH41kYVbGp7wP3TYxu81hDsi8ZVNmY1oBC9j+PbsxvtBPsGDk9r1cvaJbx3b3M3vTQkt65mG6G53DJ3+6tk7AGLAkzU87D9clXC+U1HjS5+UUEOlMQqM5RW6jMffywqG+LilfedCbExaM+LEcB/8Eeck57jnPt1R+WmNYck/lI7Yf0Zqbu3eXuHuWYuT6KFudzgezOYiZTnNKLLL9i7q+TCgJD9gOAlpWFA8HpMuUPpdBmblpcUrVRsWpjITr5E0fIzOnaYVnXUjBzqeUqBa3F36dGTpdZtvrADENR5j5Pu06NvoIaX9/N+Vqqff6TeDYkRzux+HDp15KGoFtThgpUHJuBK68FL9wLd7AipeTZhZ6AhO715GMZ15b1Fi7YNOM6z/FpOW6L8h4xpAECDllT1xVcoFBZD8CJQsQDkycH954t4GcjBjOpNjEytYPUv5JVke2kXeoVyAdZaPgAAOEguZsiKtF54LBqNwFPxoMiTi0314UeVMoYlDkP1FUy0KpyhHf7ZvmzFWeXn8iV8i44fFlE/4ZyKlobdE/BvmJ+rTNg8/lCp57RhAYNHjOj7XDvvcw1CN+n21l/Q5AsbY9LdZnP0mHcjU2GJ5IOBNntxthMiWA+EQdDZ9AQFDlu+3W1J2gtNQ5YZ7CQaAAB2kk2DBjVhHcQgjoBDK3Ov3MG55uPbad4TkYcEXl1ZC4P07eUcfJJ50NBj8mnb0GFbrtMNpWFSxqJiqa7Z0YJ9Iz8+iPc19Iutg+jDz9FcZNAbr3m9URD3oGP3JZa9umOvHlnuCp3lCutiMp0etzz+BX9608SwJvNN7mDuycTb69SK7KLbbzaXfN5yz7w6cnP41vwaJfcmkb5BDf+JrldFkFsH+FWTb7gxWtxbv8E6vb03tH/TddG1k4Of68aPZLsffJiTo9KcfcoY0tGRlypgd+rBwj4/kgzb9AQAgCiSSdOiKmk+Kgd/P5dFlWEGlFlDkWOyvltsdSXEJ/hoeVM2qxZmN0WY61u6vVU2+9bGUiqyzUuMUTigLyP0hyh3Rwre9ViBKn+V6DaeErlc98ubUS3TM58lBC5psGmzBU4Or2UKDdg0svaKpR27QcajeNMrWza87Z/gfniRzeYY/CbX9Kkwlv189UndPehRP+epTPk5VlzCcJDelbWi5wvfnZXXUhjf2YxFbZMIR1c7jdLd6775LRHVtLED3+jNcueLwb6ubWdLazLjPLA+Ou02X9/pOF/habKVC3i0f+FwLPGIq7pp0dmB4pebCxz7xw7HxKBQJSTKywOBwC2gLzwyPwHoV9xrxEhToLFIlDMVymXJgP2vtXtiXRDoP6/9/7Cr1i5JDokLNYtGgTzkVUewkRweBMYL5eVHRRTK5KOvOpIVWhMc3NkD4fLnW5O/cf/5Wqo1ARqzZO2PLWxEYwzuL3lWbEwkSJMSEHgflDPiz0fzDzCFxfidRnBJGk84CkOcooB63exHypxPRr37eK/kuDSy3pe/H1qM66J3MWpeN2i0MwWme7+0JbdzbjpwRj5U/rpb4i3A5SbC3PnK9iRtRFlRIUeoSrzqlT03N6OEi2GCmda1Vw9zJR/e1/mazmtDnmrHLMdztn0N3wc6w4R8BytojIwfbW/cNnZMaaSfI65qw4XXdd9LM/1rpvJyvNlTR5h/RSjJmfopFgCAVoDyg5UnHINyRRC8qOgXxUkC/nPlR0XFFcnBXfJG8XR0hUmlMuvJ4bNf2c2Ly+HGdyrUeh5LjjBjulzp77KHl4bf3Tt08jHT2X2DpnOzkxUXd+PZ6iFfWE6/xukr4fe38R3YX2Cfj96WOiXuOXUcJ6nhSqubi1F2Q7A+tsl/deg8srLGH5ugjbwoxoEV6zt044Sm6nB8RvxL+bSQnrA2w5x46yAbb/sGSKdXQlOEb9KBLYxQmPQ6Fr27Itx+5w+l1f7I+/h6Tts6h5FW0dK+S3Jc+dyNIGe3RO3ggq79s2lmiRD0kem+hMrRb3IOge+/RJ3BBhSyTZfpaG6tkBvf/qvamcHKUx0AAGBpVlEcFwQOjfX7Y4eERbhQD2+CF9YT9ReCCgZlyhigTnACNfvKDipo/vlbTwTGC7zwAmLKTNaosIZMa1bdL2d2uMAeHtsp99e5wvJHPjfO0Ay9uzZCeHuumLB1qrdZivfr44GYL3y8Kl+02XuMZyxHy68c3Tyu8ER/o0E2PW7TTdgdMwPHG/4HZa4CBi9uOG9KzJ6/zPVeOh+fqbqeL4yW1RrzpvVStvmd1uqUgWy2vsG7JRe2mkKl1FXLP+T75frHauSVfv46i7FcF35p347TjjcDqunxAfu1fOLvWL0f2Oh5Le7fAQxro7xaIQAA/iQ79V3UZOrXr3AvFBYDTpbCswK2R8qc9A1z6SO0KgZh92m1yg5r9z8fdegmSIR+koVNpiWoazempMu2tIVtCeSK/HThks2wKOqucyC821bOW7/jcK6mm5wIxh86IrXPJj/XR63/FBKTY1TRyME/IyvxcCG+KsaaJ64/HxWA8pPICvH9894BR4au02WmU2EM7SjLGKE9/ulm8RA9g929hNNxDVIRZ7cG6ffjfXSmKpzlsaPmRTyp6j/OB3JqV72IpU9es0HY6NjrEiY4rPCZeBaq9bGrstHXmQt/nRZEQTqO0unpEdjq7JgORh91CJ6VLJhvVHsTI7e1BUWjVmoXfHAh3MKrh2r9AQC4QfL5UqUwXKwPAo+G+xGoeJQ1qaSCuiB8EGgsjorH2nCVlP+8VzzhOHBpNc+UmVQps+6Z0KzKGCyLY/ND7HFymtczYuquNsBHxvj66qG+9HYRFJo7I++IenANTnzZfF7M90aPIsZUNcFbGWcmbJZopax6oLMB0mohkKyYtzcFhTk/f+G5OoF7RgPof+vjia8Fdrm9LRX+2AN32B+U7W7nNprU5fBx2G30a6NH0r2gw++KjI9ePRJm8p2j91xaqTSj5r57KdFmebuU31q1YRdWQfisxct0AABmSObJaLV5Wm4rRJ/Ryq7cwRoyrVVlX67pmLMNCYOiufSsdXxDxe9yCL22THL/oZ3Y0VJ6cVcl08Wtczfnxy11GNVrRKE8ea4WATiVLeVvQsyc3pS4FI681ig8E3d0CuG6lj/lTWXkyx7hSOAdkmON83cofcuP0YGT7CVpex/Q/YocSSfpfAQAgLskIzddbeSktrZaY/eQHZx7R4+mXIUeCi9t2M9oS38L+u5hesPc5RxhnIkOa9fcRKrq7C71XMjJWdU820sfLZ9nCw0ffGJXXa1aibjq8Jy7ciL38W3+q+w5SNN82K5DoknVtqyqIS+kDLsMv+q2PG7WGWwt1VAz1ukXan8Z7NMif+2HYqSLzbmQdfw38KImet8W+sKZ609nIgAAyFlNG+eCdfYg4zqR3APhIlyo3v+/QNYXPMvXCaunNaZGsq9Ma2Wf1hre3vSq8GOnRbrSRwtrMUBzNniX8NEA4V2as7OZmO0JOQcTdxYHxdyNRHKerJsKp6e3j1JSYt6dVTV5fXdNVj+z5eVt3yuyv30ztCCwfCNsGjOQ7+Qh7Ks1+kbg2TzGmb1D8+ZlM53Q7tPvZ3jph5hVZbOnow69lpORWROmwRBq1uZqE/NI82nPIAuzWL46zcKp4iomuvcKAAC2tJQfXhbn4O8vJYIbkXemxfRZbbOpgUL9x04La8aapwrWfzuAnipYw3JhxkqK+sbmMAPj51ADK1iNab2JogVMrq5Wv7GLlu5fQ8/ZQovRXf/vdUgtgA2kRaJUNDBUlF9mZdT/6DZjgQOHx3phnbxdqVCvRh4yVOmnfEWUqyIG4YwgEOB4P2pjWfp4hkcQsN54Z8QfO579AoTivJ3QZNyx/Y4rTQ4u1M3Lk5pLMCjZ4KtePDJkUeHQ3kgUNetfhQL4VcciRxbZKhaTEkUEUGcCNTM1dYpJVp04ZcooUZ5wJDWHza1U0Kw6NkXKSN0Jf2yfJMHxH+35Cwy//umPNSy/Ia86gqWvGr29UGjq7qwlSOGtWi3XUugkVNLQ8tL9q5PYUvzzDffrJ+34z08yfNCLAYk9wEIgwIolAX/3Jf+LuLR3+O8fTmBIF04DrOgkXh5LCISVuxzWb8N0cLzEHlkpULzzpBF/H56TEisKEqtCB5BvuQXrJbadbgTpPbkiKGWS+UGSo9YAKxtZwVKJ3ZkSIKnvlgVb8tp5MTCx1RAMzM0AUGL1XAxM7KASBQGnrgXI9S2Syul6UE7FWADyrFjkrqvDJAEXWbHAoRO7fSCg0J+sCLrYikVKsDhIMJYNoMg9BNZMbOmRB2muJgd3CfcQKeUQkHJtdoBio9Dy2PIg7GRysVfY24jdNaqg/MxQxkBq4/ibitiTogGiauYAVm/eWUxHbN7QAtExcgF/yPZC/mNnwg2QbxIBB0LcI4C382srgv7eepCSLAaSzMADUOIPWV60LEi0Axmwq5H9iDT+YmsIubIFeQEqrCGkZEuCZAeSg+9C3ipRACl/TR4yZeI3gsTv4AOoMIQsH4Ay+MVKPjplQYBfNMz8AEVeELB8YosG+EXjRA7uEl4QUsolQMpbSTP8bvxYPvNg6coCAFXGj8UMxO4IQRBDwpIMiz0f5PdLfusA8hwW5K6KZyQBf3dYgAMnNgooggKXEASodFiQrx25HqDIgEBu8/GQHNwlDQjLMyiDGMSFgNUYEMBFIB6x7wAV4RQVNMtO3RbTEk++d4FobwkDf3Sav5iZeAgNbn1iRYA/NGcnVUtVUC2PiwKrHXYvT6UJohqkkmqJYTc4o8QDXUNQRg9uAP6TYfdiBcSDVSOQgjAx4L8ZIy+WQDzLNAVJOC4O/GfzXPK3u7MSAEVTVHB0xNNEcAP1iRzcpaaoiymIZ4HEL9qh40OSAFVDSlLJ2QBKTqwUQMGEcfkGQQaUmv6VUVfTFBtBAAqHi8sLVwMJTycPmdRwkfymZJ00QN5ckdyVjiIJ+PtccXlcaRBuBTm4i+eKy6ccCkq56EaA6rkiqRBkQCGEk8Xy20hx+SBUwAueAnjKwpADhWElA1A3TVyeQAlEcIcigkXTxOWzpQ7KlpAssOppIvlNYxRlbIsHicsHtRUU1HcqaCgLSxEUlrscQPUMkdztsJ5SjtXs6jvkAQrHh+RedSSTh0yZeEGQeFoFgKzJ4fKSweMIC1J4lAnlIhI6r5u/FDARDj3D315NQwAiDAA/FH7+9r8AAAD//5kQIMMzSQAA"); err != nil { + if err := gres.Add("H4sIAAAAAAAC/7RaCTjU2xs+FNmXkMouY2co11IoUo19F0JNjDGMmcEQIS0kyVIppCylBQlpQ0pFkSVLpQXZKYQWa/g//e/NnZ8YM6PreZp51NP7vt/3nd/5fed8r5nhsuW8gAkwgRgE0Q6Q/KwFzICI8iRgkUSUgiceh1dAEghwY6QHyhWDRVlbMQA64StaaJYvo5wR+4bZLMzMzHKtzeqkaxDVFebS0qZ1nV98vvmycxCIfgyGMpfTr8DOdsdJexXcYxwb2/H0SLpOOyyjgEEjApZRWDAeMF4YwcBg4KA4XdNyQ2fMioDqhvXEXUmX7f2IlpBEH2Fu7jxvVNyExVrsL3h7EAAwM2NmuIKpUUtrLAAAkAEAWDgSgXkjsdimo2e8TdFYbzYUCxvCi31yBlXG1kz61Qrl+vL61oRKuAVTTZXhC312A4XynnYW+WqjGhsmRX152TyL1nrrcmkZGek79Y2mL0yXYV5Wwg0a4csz6Jb/0qdzSjTMBABgRKIP/KaPb159SAJmVtlPLNL/sTCWwEJYcDcUFotfFPH37EmQR/z7UxH9L/St6Gr3J1vYQl/UWbJpl8GG21f0VnyMSVMx0x08nq1uWJxVvZ2d+fKgU/tI7Qo3hr2tzglregiTjTtq0uqclBBxVZJa6iNM/ZfyYuqdAx8daUFzHO7OCMuI5rPx0MxRu7frdtLxaRQ/7HOLP1c/SvBMeXj6W6WrdnUYFY1dOipyjPjJUc9XGMIRjk3olfXlkpWp5vHnT3V0Nse1mfjqwE46nkoNvn+xca32uU6hfYc5zxkTWt6u2Sxk/TWb1UWjtdtq5+mubRywbrvoh3VedBXjE+cMJ9JzZtebxfiBlkYAQA4duRoIL5IxP2UayiC1KOjvlcBW55kcUWZb3lpwgKWSRz5qTxUPEYl0zhr3On8sIbQ0w16sRchcMj1aqrm5MSAQzaepBXj7PNVbHkXf8nfKmcy2q70i48Zy9VksY9Jy2L0VQ4b8mojsATttrwnbpA7+fuKMRI1/f7+GRflDdl30hZMcIY9KfQIj09tDfRKH7+ntx7BarmkYLtT5HBY9NMV5Tk1UTvKkQ43wzV2wuA27clZiJqRF9muNM/9K7kp7QWwmAKCH7AJfNW8e3JDOHjQkVXxBMLgzHueKQSsGID2xs8B60cUmcsq8oZPBx83rm+Ty/KYRsXISshIsLE4leaYn+N4/e4PeOjJgziuROX4uEX8U5tTiJFb1kc6h/oRt60fdCI8r4qneEVGVUa9yS68iBrb3lVx13SCD0wn0cyziDSd4y5yjY7LC0flX7gPb021rGCM1R3Nc1uYnfHctCmwSSU4uexXSV62T/dIgu9qv6N1Mo67jqoeoEst9CjYRDtpYpVjVOiWQ3Jz4ztH7/N4vjJF1j10ffkD2q30kltmKxcltn3hgepx9MMpk2GBqcE+ydZVqbGaDeU/ArdvTsxuW/bZPfC0AAFE6GtP280PBGYtR9Py3HtjY3Vk8ylxlKWop7bmjFvKFERNvdK1Z7jB4bRvWeSfutaHiqOvpm4l3WKaGbk6tuzjq2V116OumdcK5xxN9mT71tbhJEujvhqYmrneeRjKYyCDENiv0xXyQdDvMbzzEY36/uvSa2/EoaRNcgof6JqzCV23TOO/k908436abFHRe97b5zotAP/+0NtVoY1nsLfOaAyFBZ3ex0CkeaueOLJxeP707aDTggaCzytrD5+4YMr4I4SjYuU0W3ZZzxmyqMCM4vE001L/k/mXXFULVIu9Pw7oGZKfPzcgMyGeuczU7Gi0rrFvS97aXrwbtH/l9bVdH0kpriTi4IfZuQ1setwAdL8NfnroFiEHfHfwghZvnQ2L5/S2uzRtGgt2PnYjhmCj5iKvtt4yzOMt/6mLDprXX4EnfGz7Q/arF6ZsujzbQAfCGbC2EydeCtA6h1h9i2lW5DjjN8FlGG+gVc2XEXB8hEtveWN5lfSdyxuSyrsl6Ov5nfgPMfNt+DJ5xvklX2D+852nyiw9qwjFSU3VjlUNd0wHKiRyDSMIyDMyl5s0Kf2UNqdCI6b0BESXWHIcFm1pCGOpFNdLWEUotI3J1+kJtgl+nNBuLPGBPXX99/bLy9F7WrmOGFTe04azX2Eqb8mfaUaJ8x98rWJlcg7nY8+21szPRlZO+rogsy/dd+Xpyl9NzG9FQuxh8+cs+ro7NTu5Ps7e2bn+Jtr2o28d5FrPNxjBC1Wu8EFVTbtAdruYff+1wSvBB/a0qdWZMERwsnkiV85KXMOttJNzen+p2yD/fxxrXMrnWzcYu8niJ7RS/6/LKo9MS+62sP67dnWUJz99/P5WPi78jRLeI+y33JVbW/qGQQ7d1bu9M6sNGrdKriN+B/R73qmON5d1wAUXksOZ50LTlbo+NNEye4VCZMfZTU2neLowhQU04+uKxCN22D7WT/of9SjO8uZ5tf88G42c5MB3XeU/fCobiLRbryr6Wwmr4/lja823DjAje2mYtTqnJmCF3wTvCp2uckj/b308JcHD2T3/xVmxTs2PUh61GLIXFdd9GGoc72pFj79XXEvclB4YEi1311Rg6TqzQd3F4rpDwPPvHe80S+bXBZ8cfhOe+1nxYfSpneMtgR2GEcaxI2sn9gRL9Ipfi3Y/7Ol5OOLncSgB5W9a8zny4schuLLDnHRyl8YzdwPPisbysFxzMe+8f1SiSbSzI5RLoHRG+2tBT1tvnHMd1VtJuZzRRZrqsT6Po+ReeLRVnpGvNV7Zj8iJaUs8E9Z36jFM+MBY8qPZwP6dWV8Omvb6RLEm6quCesjer13Cz47TmxYObg/hOoEcb8GksreECvcTWFx6pfLKc+2Fq52/ylT7AaX7DqN4X2hHuMPlDCm2Ud6gG1+LFmB+Azk3aF7T6QVS4XUSpj4lmlYSpeeGeHroNgyo516cVf3y7FNl9oXjG91MvK7d72T7lDzVRr9IbMsdCRr+0XMm6bb3XwrWedaAsXUqo78S7UQWR/c+FdKd0NqaVFfLnP70nzd00w/DrqZspCskSWwYA9wpyb6H5m2MMjojyxiGxNPRtwmQB4c6eLjS83mCLgv78Q9oxEGN1PJqUuMJe1OesJt484lwnzF4gUTtyyuzOrdEMrdfHDdYpn1I7dHOm2LaoVvCmlDI+uSXo/omvIsTlPg63RpSlMmoxqO7SMy2ZdfZrevq8JrVqZOzjm9yb3U1TBmRXV2z0aSixyt70+hx+l0UeLroyfKdsmWBufbDR+c/K6L6CU0qMRU/0WQ6VCsuEuhBzvjOjpEK2vxgCgf1jcXv1nKbdLzsp1S/fI75f9YjNJ7TOjoZNbeaa2TwJFuay/U1mCBMJz0lUR8Bh346CpD4Bh741KYqDYM3l2BLHoslidi2iBL3EqfRwIV2+BOGSqM32uEY1zA9ZTOWFPNd7nUXBR4tsmv0Ru2CYsx5H3SeH38INU3fyflKsmXms1gmLFbzWWRo2se+hsBbcMcnaAxeU1rg7pfCAm71Pco5teBQ8VNeXh3FER85X+NbGPqcZ1l/L6a/owAFjOgDU6clVX2yRQuFxPkQfGhaAHCW4/3yRLgNZhFGNiZGpNaLmhZyiTDf9bH9Qws9WxQcA4CS7mGGL0hK98VgsypuGB0WOUmyaDzwq1DHMcwCqecRMr8wV1haY6c9+L6PkdK64/61DXkJqR5yTsZKIQv7A2pnpJ/EbRh4qdp0wzGP0iBVuyrb3PV0rcGPZjpokTb7wr8w6G22DD/rWMecXrHvQ1+wgxn5ECO+BMgg5eSVentOOb1tzovZso5BhhjiKBQBwkG0U1GkJazcOtQ8aWrH7ky1cy1vfTfIeidzD/zptBQLWs4Or/+m13YYe4+XNA1523Cdqi8IljIVFk10zY9b0DI19EOup7RVdDdNHnqY7z6g3UvFGag3hQdu2FNYdOl9fP7baGjbFHd7BbDo5YnXos/eJ9aODmiw3Vh5eOZ5we7XqLfuYlhsNBZ/+KjR/FrkhQiO3QtG9XqinXz1wtOP1LdjNXatUzl13Y7IoXCtic6WlO6x3/WXhFeP9n6pH9mW6736YlaXckHnMGNbWlpPMb3/sAf2vpA2dQ6x/CgCIJps0LZqS5qe8+/ezWHQxrk+JLQz9Vcb/LzsdcbFRPnreCxtU8jPrj5vrW7m9UzL71sxaJLSRKMokGNRzNWxMeGXbBW/Xg3kqq8qEN/IUyGa7p27AvJz88UmcP0WdXZv9wPjgCuawoPVDK9Ks7DkMrj4+Y5r2l8i73tGVD8+z2x5E3uCePBbOupOvJrGzCzsc4DxxTW6ajRA/GKKXtkL4bP77k3Ja8iO6DXjMRvEI7LO9w8sKO298S8DUS7V51/my3vlsYNmx8WRRxbU4D7zf5hbbL+83O6fx1NvJBj3eOXsgFn/M/ax+znmB6pebCxL/xw7EpKBwRTSG6IFCEWbRZx+ZnwAMi+41ouQpsHg0xpkG5TIUwP7X2j3xLijsn9f+f9gla19HCYkLLYtGnjLkJUcgRQkPCkfEEANoiEKJcvQlR7JIa0JAOnugXP58a/I37j9f87UmoC5DxuHfm+CvjO6veBZtTMTJk/qgvP0wzqg/H80/wFQW43eaNfPSeCIxONIUBdXoZD5W4no67NvDm5blUsd2X+5+2D1CB4OLUcPqfiPdCwid+0Uvs9unJw/8kAuTu+yWcBO43ECZO6dtStRGFd/K5wxTPqOStv3GBozgPcSaazZVF724z3lZtr9ZRhTJUWmb4qxkt6z93tceLuDf/4jOyPjxprqNXw8qDvVyxpWJJL2p/l50LbBiIifLlyN5iOVXhOu4kj+eAgA0AuoPVp5IHMYV5UOkoV8UIwv4zzUfDRVXoAR33lvEEzGPTJ4osR0dPPmFw/xeCdL4ziPVrtJ1Qyy4DleGuxwRRRF3dwwcLWU+adlvOj01/uj8Nm/2Gthn1hNvCPqK3jub+XbtzHPIxW5MnhDznDhEWKfuSq+TjVNyQ7GV2ua+3nMW/aQiEB+vjT4vyokX7dlz/YimyuCZq2deyaWHdoU3G2adsQmx9XWohbUT4+uP+yfu+osJjpBczap3V2hlwNk96VVjOa1vprVtspjoFawcOtaNKJ2+HuLslqB9OK9j51S6WQIMu2+yJ/7J8DdZxwNNn6Oj8EH57JPFmzU1HsmObPpV7WuHlSbaAAB4uiUUxwVFwOID/tghYQ4u3MPXh4j3xOxH0cCgRB0DfC/Sh5Z9ZQsNNP/8rScKR4QuvKDYYpPlymyhk5pl90tYHJM4Ik61y+4/nV/y2O96FN3A+0tDPu9O3/PRmOhukOD9UtoX+5mPV/mzNkeX8Q+r4ZK04A0j8k/1pQwyGQjrbyDumBk4XQ/cLX0RGLy47rw+IXMmlbtJMtf7mspavnB6Nhvc28aUTPM7jc8u9GWy9/TfLUjSMIVLqKmUfMgNyA48pZ5T9OnLFM5qdUSK5ZYTTjeCnjF4B+3U8jtzx7qpT8rzUty/Qxe2OjnVfABAINlOfSstmfr1K5KIweOgyZJ/nsf+WImLoXb6yhC9skH4fXqtYi/t3sphx04f8bCPMojx9Hg17boLV2ReNof/dYA78mNSiu2gMOau8wFkp52sr36bV7amm6wQLhA+JGFpm5vtp9p7DI3LMnpUx7nqh4z4w9n4ypgqnrr+fFQA9SeRReL7570DjQxbrcOyTJkprK346hD9oY837g0wMNoXxp+Iq5U4flIjRL/X22/zxCNnOfyw+S2eZLWxswe4tMtenGI4t1xE0OjgmwJmJCL/uVgGprHUVcnoy4+k/SfWYGBtwcv09HzYq+2Zd8cEOx6eWpc3U6f6NlZW4yWGTrXI/vDu2XDzL+6pCgQAXCf7fKlQGS7eD+WNRQb40PAoa9JIBXdB+aGweAINj7XhEin/ea94IgnQ0mpGFZuUKbFtH9Usu9pfHMcegNq+d++MnhFz5zMD78hYf389zOfuDh/5hvbIO8Ie3P2jnzecFfW/3qWAM1WJ91UimAmaJVgrqexqr4U1WvCfU8jZcQGDOzuTVKnms/KHOuh95+fpXQW2ur0rEmztQjruDMl0t3cbTuxwbB10G/5S55FYGOL1/pZx8MV94SbfObtPpxdJMmlaFl6IMcvZqvTOuhk/uwoipixeXQEA/CCbJ6Ol5mmhrRAbpZX5ZAtb6KRWmUOJplPWRjQCjuXWs9nsHyZ2l1PgjVWi+5h2QtvLovNbnzCf15i+MTNitZlJrUIYzpPjahFEUP6r5G2o2d63BS75Q2/U86PigidQritWXXj7JPJVl2AkeI/mXO78Hc7wcmy47yhHQfqOB8t+RY5ets55HwDgLtnITZcaObmtrcrYPXQL147h4AsX4Xsiimp3Mtkx3IS/f3ildjo1S5BgspmtY3o0WWVqq1o27OiUSo5dSqtVZabA4O6n9s+eqTxBXXSsXPlkNLv09qqLHFlo01zE1j3Cic/s2FRCX0gYdhh+0XlZ2rC5v7FIXdV4c69Ay6vDfi/lLo0pRLrYng5dveq6t7CJ3rfZvvDH5fIfxwEAWUtp41zwzh4UXCdSeiCcgwvX+/8XxPfizfpl1Lq8wtRI5rVplUx5leHt9a/zW9strii2WtiIAs2pw1sFg4MEt2pOTV3DbYrP2p2gey8k9m4kmuto9UQEA4NDtKIiy7aMsvHL2yoyelmsUjd+f5T57ZuhhQ/rN5/1Xw3k2nl8LKuMvvnwbPjKlblF80aq2eawzhNNP3gZBlhUZDIno/e8kZWWXh6uzhhm1uxqG/tYs7yrn5VFNFeNbvZUcREX050GALCjp/7wMjcHf38p+riR+GVemj6vajA1kK9pbbewYaool7f52/5TLm+DyEYYKyroG5sjDIwr4QbWiArTGhMFC4RsdZV+XQf9si2zW8HJfIvhrf/vdcgtABHyIjHK6jgayi+9OOp/dJsxy0HwxhPxe31daVCvShkyXPGnfAWMqwIO5Yzy8UF6B9Aay/zHM2+UD97X2xn1x45nvwDhBN+9WAru2H7HlaQEF+5G9KTlEgxOMfiSF480RVQErC8aQ8v6V6YCfsmxyFJEtoTFpEgVAdzZh5aZmhrVJEtOnBJ1lBhPJJqWw6YGDTRLjk2BOlJ3nz+2T5Lh+I/2/FmGX//0xxqW35CXHMH8V42+RAyWtjtrcXJ4S1bLPR86GZV09LzL/tVJaiP++Yb79ZN+6OcnBSbouYCkvl8BCODzeQF/9yL/izi/X/jvHy4woONOBxZ1Dy+MJQDBurMQ1m/DdGi8pL5YCUi8TPSAOvcwObHCELEblwHKbbZQvaRWUymI3phFQamTvAoiOX45WNy8CpVK6sgUh0jtXBBs3mvnucCk9kIosAAjoMbeOReY1EElDAG+ugJQ6lUkl9O1kJwKsQLKrFiUriscWcA5Vixo6KRuHxgk9CeLgs61YpETLAYRjGUHVLmHoJpJLT1yEM2llODO4x4ipxwGUb6JA1BtFFoYWw76rFGKvcjeRuquUYHkZ5w6BnIbx99UpJ4UdQhVLSdYunlnLh2peUMLQsfADf6Q7YXyx85wJaDcJAINhLRHgG7nqYuC/t56kJMsCpG8jAdQ4w9ZWLQMRLQ9BbBLkf2QPP5cawilslfxAhqsIeRkr4PIDqQE34WyVSIPUf6KMmTqxEtBxGvxARoMIQsHoAQJIIlydOqCgL5oVqwCVHlBoPJJLRrQF81uSnDn8YKQUy4OUf6SPMPvxo+FMw+VrsAPaDJ+zGUgdUesgTDEzcsw1/NBeb/ktxpQ5rCgdFU8Iwv4u8MCGjipUUABErjIGkCjw4Jy7S5rAVUGBEqbj/uU4M5rQFiYQQnCICwAlmJAgBaBdMS+BVKEMBpoFpy6zaUlnXxvhdDmCII/Os2fy0w6hIa2PjFC4A/N2cnVUgVSywPCYKnD7oWpNCFUH2mkmmfYDc0o6UDXEJJRBxHwnwy75yogHawaQRSEioL/Zow8VwLpLNMUIuGAGPjP5rmUb3fR4oCqKSo0OtJpIrSB6qYEd74p6lwK0lkg6Yt24NCndYCmISW55IhAkhMjAaiYMC7cIEhDUtO1OOpSmmJ9GKByuLiwcFWI8EuUIZMbLlLelPBJAsrmipSudFeygL/PFRfGlYTgPqAEd+5cceGUw6EXb1KA5rkiuRCkISEcpYjlt5HiwkEoQxc8FfDUhSELCcNCGtA2TVyYQBFCkE8VwZxp4sLZUoNka7UMWPI0kfKmMZI6trmDxIWD0oAE9YUGGurCUoCEhZYFNM8QKd0OK6nlWMquriUHqBwfUnrVEU8ZMnXi10DEz8xL8fvkcGHJ0HGEqTygZnJITig3idAZnez5gElwGBj/9moaApggAN/lf/72vwAAAP//E9IPLjBJAAA="); err != nil { panic("add binary content to resource manager failed: " + err.Error()) } } diff --git a/cmd/gf/internal/packed/template-mono.go b/cmd/gf/internal/packed/template-mono.go index 5ce3d248aa6..97f98f20c26 100644 --- a/cmd/gf/internal/packed/template-mono.go +++ b/cmd/gf/internal/packed/template-mono.go @@ -3,7 +3,7 @@ package packed import "github.com/gogf/gf/v2/os/gres" func init() { - if err := gres.Add("H4sIAAAAAAAC/+y9BVRW2ds+fEjpFlRKEJAuSemUTkFQUOnuBhEkRLpFQulUQFQUCRHpBsEAJKQlpLu+NfObcXhUHp9yvv/7vr9Za2Dpct3Xvu69zzn73Pd19qWmiIJKAmAAGACFmr0ucOg/CgATcDaxsbc2cDZhs7GzteNgN7NwNnB2drQwdHE2cdK6iAYg6doImL3VaGpuU+RoZ2XvbpdvU+RQVlItddk4hgoABwdqiscwetS4zlMAAEAKAMDRcCd+CmdhZmvnaPINiidMEc+fE0d6w4mEdJ3eEwVPDY2z5nhwZt2XqfXjXbZDcnZZFzQ/eDPV8HeR8po+lJzXEs/ulzI9pvvuTusX2lsSyp94GxvSzJJtCBuyErlwlF4siZZrSehF+00S09ndcuEYPMlkrJ8teBCoyEz2hfjtzWcRvdYe7zaTV7bQ/2Yzqzj7xgcAgEKwbEh/YKNsYGViamH9D5eWNsUOJmV5rSY5pY73xwjLmwUTPV/2+QJ/A3XHTFym+DMx4IDIfgDSkJGQVpZhV5b+huTcKkKETINzYemBpnHDqZ4FpPctbyKxOa2lL242Eiws2PsWDu9QTge80yAuV+xRdUw/LmvmrCdD+Gbi0kqy7YM2MqzoB1/Pk076NRpf0Pm8cMO1/7awe6y6ohlvJZ2X9fQdhhCfb4O+qC7JYgYAwM1DgwZ+GDThD4M2sLf/Ntw/4hz+10fHofpZHA4Dewu2v//2l0F/zOjZXwb9cS6xljfwg92WcDTU1NQea6l1M3bItTerMzKqdo8vO6264OLZO7uiKTJlZ+XQ352MY3R4WYa+uXmhwT9LYjQYLbGcPv8lmmAwfb6CHvt+x1CRhADdS+6VGCcFTY3jq6ura6ur54hin9YEXLXlO/13ost7eodtAQC4A5YL46+5/LhcNLTtO91YFNqUtTAYWzoVlNnVMeTb2ZrkWeW17Fs5NOxxFi9iqLAxtyqpTIyOjiJ/u84faR3f4gEAgB3snNH+ekgG9hYwLAZGiAJzmJtYW9vBsCy4oAj/n5/sZv/gPOvQt6zlxDm2ODVN4rMcF8bHcOyjZnnkax2DuKqK4KSk+ruzltkmc1/P9KELvWYmkBQLoDOy3xmWaEiLfsBlP2Ic7/Wxq/YKWW/5a5HnZMJN3k8edAuXqkWXvLEMn1pDd3voqnmraPmEzEBV362SKQcS2qlMOhkJ3SF5NVErlZMmWyPOB68Kzy+ZRhmYxXlTFC6/VSQwMuLhK58oVglP5E/SvK8pn5XQZE591rPws59jf1/EkkRfmEyu2a7eo6SFcvFRFFsVF97IysV06ejNzYQIbHsFTQXmL7F3XiH/PflCW71DgwAAvEYCN0cs0CTRlQuGaeKBDuHHmbJuL1Hx58JBHXl5E6uVmDX8ehuxs4GB0cMth5Q79wLq8i/TDFGqM2RFnB0c/ODhZXZcWAQgmbURGKqJeOZ+tXinULcrh8kcK7cxCj0Zlb7s2KIimbBc4byuqMO2TvIY2ZzzAV2H+9ycoEZTNa6k2f1oPJ+aOiev0KzRAKfEpTJpTwtszZM9S+USXwMjFveuJfHTsTBE63VQPblCH3fuSjGRxTYjtaf3Fubfad/uevm1AACAabCXxplfJ8XcwMgKhnRzQBaZw8jO1tTCjN3DwMb6G4p0RJUKCxdJwI53iPrbTywlrvtyUSx0zHRYWFdfl6iGHR9o/GgmtT6vTkJXsJWUaHeb/urQVZq2L0h6b8N0Rr5IBlvl0KY5Boe3hr97XJcrNy87+zrX9ByTrYSXq34FSZC9I1MSEsZFWyT3VjdANkunAz1UeKPY+NTTe2umFV6fqB88qH/nM9suUdirUNjuWtF/8EFSn7Ta5LWmG5t2sJ6oNWcUXzcn8GAwsV/fMcVwGT20+41p9bDBHP8X53odmjgW2e1XqiG4C+EqSwp7C9cfaLXxRRX0qE95PCvd/3ZHvCwzc3wIAIDTYC8KCB44FrbOJo62BtYw3BZZII/OYWRjDMMa4IYO4Y//D19wzmo1lp84CUQUr3FNGx9rzBA55SifNk+fbm2xoOn16Hi8rCGdHbLJQZVORbags6rhkHDVxqRJik/6mXtjGaWRgvKBKiznzhataoe/bxG4FjnQ6aDSXT6uPavttW1+qUbufWIyao7lYMn7G8kxIS5OevuzGkyTvvFfjUaNucxC+4YPZAqnFN6cmHtwUQODbl2Ohi7Tq1CVcedk5/RJqusbJ1I1wppa7Qp7sWWTACXpTtMuBW+OaXPPY8IhuS7ImswKgXsYjHRnY57vPVsSrilf+tS+hlukH66a4OYbpiE3UrR100YKnzIYCKb7YoCfjqWEP9Jgp/xilpzn5t1nEx065/RWB0Vr9WcdhLMKY3hatKRK9zbnEui7WLBcyCbFRrCXieTwLjqOSu5VXIt8kFDUXsDL/6prNhJfX4znEVfnB52gcA7MwBkGnDl/7Rlhc5f3VfvEfy89bNHgJA0kAJBBBrc42KGZOjtbJ2cnGNaHANQgf/06vEqY5ZQ6VJRUteQ6OlnYmSb/2XW8JsNpOw4AAD7Yq4AbujE4O9pZW5s4wnC5CcAEBPOuRAIOuJ/tUmowkbkIAj97FbjjluW/jn1M6/7slgMlv7/RA2sGuXIyr66D/dqEc+vV7BNhiiXoVlFUnwovu8R2kRehXOhIFj4etIIpcV7H29elG/PpyzOvZgf1aHD9Ke2sTBR8onMSWPF1j8sMJooi/T13+Wpyt60BAMBDAsdRBm6O12xN3EB4qihazooT6FWoqrsvPSZ7n4ZSGZ8Sefojeab3FctWKdOcIPnQ6wFfqVIImpBi+km01KinFg9eSHSkd0twKsS8YUARwL0zF1uiyj1yozZWlDTCbzI7MP821s4ZvEZiqvX5fOS9Zq6WT9XLjGUKGArjRu8NP3ZZinhWqEwVfJiWpeTooJt8zVCRJ085NSewM/jCi+zrU2PlK7QVJhKZzSG3T2c/XDI1mbG5eoddc8YhaqNoyLra9eH6lop+eKK2jDUz5sHNnKlA0ozIby9daGLneFoBAEgGm0YF+NPoynXtx/1SRIlKHSfO7alWzXtK7V/Y1T0CFe68ROEPGplkjhFwGSwgGh1Ux5bDwbk7cS1VrGJ78euZN5SatNkNesFop1ze3goZYbicHxuR+SnhEjljhZyDvYP9bCb5RzNn9QMUjMmkyhFeTZopK5dXER+Gnak/OXQXFmrL5hswISUBUxEhnNkBu29PuQ8lMjShiw1//FpxzdfBb6W/H+WLA3cXZ4dP5hZyUyVZyS18NIDAJrLH76kw14TK80Eb60inbO7MqiXGewqZ+Gif7vQM+PM1Mmey6vXmbmP9nVYPfq+R9wAAnENC1PPV2MDu92xpDyP8WTexMjH554X62/X2RzS0X97C2KDAs7YzszCCgRMftBj/KisbO2MT69/M6k8MuFlxQo1oDMsSFIQBBm5uPFCDmtg6Wzh7wMBPBEYouDlCswGzNzCyMjH+zRuw/4D89etnGzCgO59J758q5Qq65TviX26/OKAYgZOJo6uFkclv5vkXCpQT+CMmw68xbQwsbA9nMiyiBOsNJ8HtqSHNAJXmLopNLLzRkVHspsQcro8VAZ7xfptfNWrkj31ITV3YYQ5kyTa/9wQwLjLRMEoXTOQzqWozo8YyYrYQD9e78PajQ7TfRRaN9kGzetZTZ9MJLxnPXfGdxI5Gr7R7/IkTTf+m6H486tcr9kAt62dKu/se4sRlG8daRiOfftQadVPfiHF5GOqC92Dx2yMP41wZeQIAAEsAnC+sNga2FqYmTs4w7KDZIY/+V1kBhqVyHmqQn5YwwiJrVGo5ccQXtrBY9EYeMwxcT3YcJd5Ee+Hw1O9KUN1g3XDm6ygBGseQtfHcKSGBh5OnUhS5SVPyY2P04tLLWdaKNF6q9eE8CdPsDyPukbXoCFOYTEZD8eUiLeAV9+JLqdx4D8jloK2s+nniXaeczPcqfMJzsfgeUTy1M3khl88qjkYT/V3nVi5Wm3w0Tv07NL4ykxxVsrq8vnfj9z+H7S1gK0vXU7HwOmURXnq/jjZi4YF9fSpyuyP9jvnHr+uRqkFjX3SDblQPUgoNb9mSr3v5uNsraBVypX67BPjn8ZcHAAAwQkLUhBmb2Fvbefye96rvQDisXJyc7WwsPE1ggBOBA47D0MAJltuXMryYf/2tjYmtM+gydY6sUmnkxKnbEK6vEg8sN5UyNJ6us9XAZk3Br0fvfXEBKeRy74GyesdGDyWvx6ithiJqqakbtZN77BNZYfuechN2Km6hwnESFDVGJ9QNy1gnW4UOJDVP09LPRtf3qXXGeNo6lOmjZdqQOLVVru6ossbmfmhEmYpBnesc7k3vj3oA8BO8vmrO+G6ULnCHhs97QVqagcmn2tfY8+U9nycJbu+yC7LYRq+KWTwl+KeebK+S/LAYAAAzsO80anCn7O8/Gjhb2NmCZo21pQT3DScBWtd+ziIyl0JQJbJIlYPodOuS/rgTbeAXJrmtrAR+0e77OUy9g0G8NwlDvySn6ixQWbwwumkwrsvsIv/ZoVDYnJnS1otjkU5T53GhK9/0HTPbh0o13fiku0y01d8eovUYzQ2mAADYAXC+wP2C7F8PPVCaeuFcWMgSODI7KbRkOl0qbz1vodWLtt00tjcj4jbo5BAKv76xuVCrWcxRl/c+MJLF23I4gPpOJqma1ExOvmSbPnkAId9d6RV9Yh6KCWfb6LEAk4zFecm2Nqq72tZkN4c+vMxqIH+5r4IipHC5qXdmfzjN7hvt++YpUa4AAGSAvRQl4KFt52riaG3g4QTDLUAeEbgcxiauJtZ29jDcDnQQif/X08vGwB508q0jlRVrxQluL2wdlwrMCGrI6dZGD/GjmlWuVH0a+9h5vXZQPn0kMqHhIq57yoa/G1XI+n3N5zVnKB6OXq+ScMd7VTrIUv+mJIaGnhUQFpQdIVmW7JOhmZA5R0dZPxqzrd1CLCixyQoARSOBcetxHs470pb+HMc+hFHhkfkGFI05vwQCIlkxOM9E90UmvQu4SsizJhxy+8qMzAFPoVhK6Nc4MVRNjJB3Ba8qrtlRTar2181aljIlTDx59LgoYTZ5oMg7rsvaLZ0m8YJC4vCjsXmPMbe+xVcLDZ8J7fgrd6k/kZiKI6WkKYn/c1fh2BP1mAUAIALsXeU6QjP/z02Z7Y/rz8Txu8uvnaugVhwHteumKhcZZ+pwQcfJt9heGLR3td0DaV7g41mH5BHZXZft+Sp8e43AfHJT6GCgx5D40z0vH8HMpKfOPRoW4nmarzMjs6dfWpWEj3uaEBdR3/Mc7M/s9Wu8h8yayo6hx/YK697smJsk34NPXq9Q/s6FZ3USswsAAMVgV6EeQnMB7m7bpmwZIE5wYcn7fgbH9eCKrksYumhPOAaqc7r20x5S2KuI4Yztbzzg2ZPiL6S/vcdTrJs6crG1gHzhWsPlxkaeWpMM/Vai2o3CulLSDLyHZqqP5aSuUyU26uLwBHTSKY4pLkv01vWIzX2oEOBTFpsmH3rn59rLkrnJFmqsExtwgvSRI5WK9Oq3jfBudtNuCAAADxG2VTW2M7KCoKIM07v3dyAc0n/+AlEoOGIvb2g1NasqMb1XbWNqalMs5X7/dGRUI4d9REP7NCC85ydF4X2DQkp4by/PVijh4bV7kmU+US9CzQhut28Ho6HpRbCzY8nk129lyzTnT2NdTDu/VlOwuqqo4YS96sS9osAySuyk2aa06kR8boWgQFy4KE1NLHA87NMuCdo8Fg9TwU7E9Y/MjIyoQQLogWqDpjpRb4SbJuawsU4/5kf6tt/MsI2cTAcAQBcZzte87xPyn1/sTuaHRA69qi1tPaoKrB0joxraGM1NrNr/UW00sWrLFcops7PJK6vLKSi3cihoyTWrdqiwacgxt7fJd48ho4h/e4RFP9VYkgIAQBzsOmGFYsQWXAK2MKwSXigh4K5cQPAS6GjiZOfiaGTye14C/47OYe9iaA1BEfJHkHNQg3CYO9vAUhgUhg0J7knihR7X3trFzAKWFSgKKxbcLPmhR4ZjaQrBjsZh5ARLA1UaPkS48ysCB76FjYEZLC/DsvBiws36PBwjsIRlmqXgAvw3Wgnf4OCQVwrCAAM3t58LRS3tDBEvFD0cFKFCUd0teViEomV6pi9gFYqCcIFeKCrf3t6pudiiOoqM9M+OaVHjoibXn/046BVrIONBqGLth8j/VaxBvfcDySHCFWs/jY5QxdqRCN8r1gKiu0N7OQkaUmOrDds0veJQb+iVHVuQJrlYV2/GkZzT597exi3fidJ3oB9zd0VALzvq7Rf+lZ1Xzc3lXuTCZTwKJ3uCy8TPBjoG1IuR0gdmPMoiYa5z1MPrV+e+9cb4jTHV1eRgm2WGvFDkFoYynv0LrwMOtFPupcRUxeHffVijykerJ0VZaMdEHzrGwVRnlryLJ05Pro6rcceuD73aS7vs83QuZZ4eK1neiCH+oj/e/EIF2iBeDpr+VMsZ6ytdL2a9fGMn5k4WndpQ3JlOX2kbSQz2ymOQ7qJmcq7a9yV+J4jySUstW3xsaE1r3TtPnw2NeIZ/rCzk3XFhEcuyaVN/ke6h7Vqiq6PuEmEntEde3new/Hjpg6/DkOljDmyjQn59kbBbxaJ1esJSouwmWakYF0LH5nRfxK2pFMx64yx82L7Z49LuFIHEOOuNYz6VYHtQnly49/KK0Ygpgxu+U6nGU3HBbbEIx+SiF6X8yh9OfZDTuLNyul53fdnt2w2ERCxc2hMJAGZhULYdMcWIVbaBA0G8sg2aqwWR+pMjEX6TUuPneIjVn4DB+FdZIVZ/AgbjN20awSEiUH8CHuY36U/AgSJYf/JrqN+kP/k5MIL1J+BA/h39yc9HgGj9CViU36Q/AcH8UX/CFfGGk0Bmto3p0UVXwshnlz4alqLhkolHjJ2QMm3AIibBdHAjoWNmNK9+NeTFW+fU1KzGiKOW1/KoQdKJ04bdU8+TOpBTkUqd+B2T+YycDmdvyNkvFR9CAnnbKRg+RVmYIyXxS1Mtbfs71lC47G1uahNZmNcghWE3mlW6TKIrZ9UsSBpUX/toS3SQsJoauj9jed9fSPhbi+ZC3SB9EowSlO9oI1iC8tPoiJaggAP56TtJQJuISgMnDtAlkvv4DbJU7L54qLBDPI+DZOCVhDqZ0fU8op0XVV9EanJn+rp2aF/evp/SOxpbN5l5cTkw21k9ovJ4rQaWFg+gJFbnex3lKS+gHKsXkrZGa0T1wGKPo6KSK5GE51F6t8jZls+GVZivB5YCr28Mr7fryJAEOXh6Jyds4IdPrXCyF7lVkdsnbW/Vs/CW+nxbwuMYWL73AADoRli2EawfAQfyG/QjkMEhVj8CBeZ/9SPQp+x/vH4EGrL/i/QjENJGuH4ESlyE60dgxP+vfgRu/Qismf/fqB+BNRf/J/QjRyQHsfoRcCD/J/UjYBPy/7N+5OftKydXI8S3rw4HRWj7qt6kGZb2Ve96SxWs7SsQLtC3rxSUOlTaFdW/nXXyT2W2ptF8he/P6hf0J52ADAq2k07OQhSYw8TI3A5hDbKfRv/zB8iHtRE1ltwSBAGdA6rqc/I+zseoR8TyMSXvENBvuD7XDxLoGbM2c8D02Dgt34RNhyZT45bHPLV48EKmwyC/MC2WLlD5sr0loSDdWFRWvUFd1dDxCL+JWvQcT9vH/aMOFY2epX38aWKCsol72G7IS2fpsbisuJTyCqoYYh++u6iu5VajUhzUYOV83/WCGdFKovKkeuz5jr41/1QfzUbBsivp5KS8ysHWbX7t/amrHreilFqiq0bCCygjie0u3Sjkbe1MSW9CO7gt83RsSZ5dUylkVSwtVULhpW5r3FDw9Jm/p15FxPdgCACAF2AbZMxQ5BCmY064oQL4YZ70/vxolwBtdpNF+8qtgA6/t7hoGWlpLy8666a0NyA3inpRNkvuCmHxnJ3JTeRP3D2GWXvTTumO4PFA8nNpqPoDO8255vTNhiYlO/76WDLP/Sbfn5hPNMi6OYl9ka2d5UaihErxI1ROk7fv0k2qGa7kn2GUd9mc+4B6JkHEXfbOI6skSiwWSRsujS94wxr+Cnt4V0deO3DXavbH8YtEvGHgnMfDvnaZUfhM29BnOUrL8zcMYi+ktG24GFQx7xafnz431Ym3b7cV6PNtV0Yv1/amBQAAMiToW8ogKUNoS/mHyP9tKcN3T0N4S/mn0RHaUj4SAZpDUDweHS/96SEoztVdxGUCVpSGKhrpPS1ldfFDBd2XT1LPOOwIlpMUqt4suVmSG+lKGGZc9VL+esF7aqv2F0z5Oguju9cSFLiKdb6IMqiQOj2fGP96kMFnT2+gN//g4tvyGB3HRmPn4jVMk+rRkyi1KHOkY5ohhB77hfGeNXLEvsEnPuJczl9AE1Fe8L2A+UzpuoJM/uNhIHBc+u3zVD5XYlbyio53/GXavKL6Q0jcCjS3KiZ3SnFFnOmQ6WKygkQCmDlFfKmreQeL7Lo2dd/eFTJqt+/e2MFxK2xYinqu8JbxEu679TGne1PxV9XzKjgPkK5FTcWPi9OfZe+t3lk74f61/9H6aAOZ595S+mwQOu/oVtLM4yX6NLXBgFu1BfHn8S/fdyk++Lb0PgdgoGogAYAUDK3iI6YOsa1icCC/bhWPIvdgndJLiUBDe8CE9RwLs95E5tsWC1Mv6VCXZEzIR5b3z1UK/SEpR44R9kNS+GECgnVDIwY72o8bnJ+ekMIVkVzDpcr39PsTUkrxZqPYyq48+8Kczq93LCLlkgcz3hSxn/PjLeDKPyekUPqTD72fjdunVeZgwtcluczcc/bvedPdXNCxAgAAFwl64SDkBH84HiWixLJWnEDaauESDrufvk6Q6On4OVSJx+SZN70vK9KWD4xVKnBKHlARYYyjjDIdMx1ywus8oHTEi3/up5JhzGdRUyIzQnMKX/2y3lf3dwltEmpV7zjflbzeDxj7Elb7SpQsLeiOuuFBx33xG8XSUnJJuOSXCytqtr9ouOMW9XydUZI81WdMxlMwFvdpvnbh5pVGC/thaqt+oj4RTObwuy4U9Pz0tnfP2q1IOt/PaFQXTXZ8updOulaz0R93zyK+PodiadVNiOMZgTfa30lMUCEdbgUAIAEJesEpFEl05brmZOBxOI/S4TWWtZw4tzu7Ne9QyGq8vafnNk/+6HHF2Ysf2p7ryWCyZS+IPnEZkLhzMDa18zBXlfpEYgcygdNx3rk0C/mQpXeXfXNwuztaG+Vi9KPsHRteMthVdmrUbV0erHy7n3D+WubADdv7l6eRVBRp5jDcjjHlxBDN7vSOdQ+ff8IimtBQ20mttuVX4XIqcn+9IYFKaGKLug3lyYxrhshQuvpzGexXu8e/DucYFidb3Ljd6EvP4P760rf7BW19b/dzAACWEfZURaT05EiE3yTS+DkeYqUnYDD+VVaIlZ6AwfhN0hNwiAiUnoCH+U3SE3CgCJae/BrqN0lPfg6MYOkJOJB/R3ry8xEgWnoCFuU3SU9AMH8iPQmp5SSQsepkCmDJf4y+jnWF9UpWM5of993jhJ1yH42MMF562Z/W0sjauzHkxdvFm2UuYIzUpNea1SDpxG3T4qnb8eCvw08a00rGaNGkCgWKe6u02zIcYjhHI8K8sbsqad76zuLfPUn8ZX1pqTCgzK4GCSe069zQeSf/22UbQVH11GQlFXUHMnsJj6rLdadG8P45R+3Ni2oHWKUn39FGsPTkp9ERLT0BB3LE6SftKrWcOL4LHn+efmKqbyAmuIRR6TdQpltTKDVqOzqvfl0uhUCwfntcNXVh5FFSiBt7yz2HHFlHZ4nbo0W9FZJbkh7nmrhVHM6pKJFnC3IxJ9pN4gK3o/JJ8Nd0faxVz1oBdN1+Fp4SIl6P8Xp6K0l1mZkvhUUv45eHv78n5onePE6rWDlx4m75RZR77HUjNbQrCVf9H81IrCgc2N/e3whkSDOMDCwQ7LrDYrWHvPis0uPxygUPs1SZ3hcVX5csfAREZ6O+Dgym9/EN5KzpvxgUE8jOWD/392pYVVnm7AcAwAAJUfOFYPEKOJDfIF6BDA6x4hUoMP8rXoE+Zf/jxSvQkP1fJF6BkDbCxStQ4iJcvAIj/n/FK3CLV2DN/P9G8Qqsufg/IV45IjmIFa+AA/k/KV4Bm5D/Jw8/+fmIEXr4ydEQ/0bt6RugvaOds52hiynCTgQAD8PB/gcxNgtTNlsTIxMnJwNHD1hZskAB7+Rg/Xvqu4cROFyc/ljIh6DCukoUasUpGpeqVJeGk3z9/fxOUxZ9ya8Zp13idp6hbM6X8MRMCO1gf9su86irXn5wjoBteoWu+0XUqcdvmXrstm8EpU4YSXOp9bpxPhYmDrnVjXTdoe703f6P/Tw0Cbo3GGRQ6zLFkRuRSNTsjIlbG9kZSFg79wZtvTc0lEnX0ypKrLOEW99KW6An6AVO6Z0cEJpkfpLzKiR32bUk5lJwSH/z8lrOzUrbrLBa7ObGjPuPqIZmpjzOSNGXkZ4pOimth00ZiYazKIqV4nJFxXRi6gKv98ED0vD2nrzsQlMZF7EDs0jvAZl9gohFgrCJedNGVCU8az+v53HNaQeXnuBF+/hZcHzIrfC6n/rtijzPtUyDjQQAFfD22iE+HwUDlmvj2wEP8JagSH7AMrNjt7H7p1IYFyvxJJkT5/aHCRLWATQ+hubZ2eeXpjEp1MJCbNR1o+x3ImKVds7jGJcb6NxIXR2IQXGJDXqbvtqjW0ry7IxbN7LBqnYaFkk+I0W8bOJGxvVNXppiD7duJ82O8PP5kxxrLzdXkXZFHeKoNWfUsdGudcjyFrCXsnO5NnW1iLnPdvLJhqkEDXSarRUL7dZjrZfTq6YoJvdQJdNiXr0rJtbnPkBIofWAYnbXA1XslXGss+rzPoOTVS+2saak54GYwKrxCIumGi/MVwpvBLQN9Qso4p0KLU342q9TPidhe0KVKHtdQu7lYIXnQLS0oWj33tX5PilbozjBSm1O3eiJk7MDVg9yMS7NZfkw5yoHCuP0iDucZhPsiVf3pe5/Xi8Q+4CWwf6kSJGsXIjsHWQqZAwOLPnY197q7Q68sbiXc203VaU+Pn884U5+n9Z1O8foauTlxLWHW3LZ9IP5nglEZSIhibx8eCoGvaG4V9uDHEUfrc8oLgn9PXn3mvXYHZEAQAAV6slzcrH5NnmP7l1wGmuK8V1YuNR2n6amItz9mLuUHyqG72l7/w1G99pr1RL5Zgkz9x68/5ocKplb/KqtRcmYiyXnBt7wmS7xT8LPYnkjPZCU0/IPdKLcVin3z1zYnz3ffTJkeED/+cajDmly7qKOl1QpxqZ0o85pWRlFX/NTwxerD9au0Mbd2kCvU+WsHhRZE150LiY1ZMFNCMdntDkrIJ+/UDiWpq8jPVoZlLyFRvHOoOu5TLJEu7Yk9naj3yvN1CJ27PvILdFbafFEo5+YiKwN33hYbi2hP+8S6BBy0/40WxQ6LPGqaXLqzbw+aie+lnOXUfBn+SaUD89IeO3rXyupsBn71cakjZE5UrDKx02ooQ81sOum6ooPRZ91YEokSop+bEd2Vam0dWZc09ugeO8O5W2FJWFUFpEPrieYtyWV/POb0jF6r2+mEaamX0oQPSsSmBzh/Lg4OQWnPCxEJCfKFH0b9fSJS+nbyKWfNoU+KX60V9ncE9ESVk8ruyHhzWbuujZKR++U8qiyS3q23NHPKHz20sxHv3y5jYOtqWYGMeUBlM/rT3Fyo7E/RXzC4dcatX/kPISTpc0QHkfuOF42FrLBNhn6VceImHupiOHlyPb1omcPl9J1xxvH+n3TjaVCizNdhZ4sXxrEqXx3mjxtKrVTUuZanom1YwVhR2Y6O+Oq+UydYZlGBb2oroOEKdB9cmdx3Zdgnf/ibnDrdennm6UE2s5Pd5/1qjWZrvrLuGpQ3D/bTF7hH2QUcvZede2ef8wYycHJ7QtVV77m+A516PVKegn6qfI9JKJzXcVcmNZ3Iu/JziwOMonaw9ug7ZsGLjN8lay7em/8EiGdkIdbhFCcjpPm8m4MxqCL3OKA+m5wUrba3f1ppVFNLhMP5SxUZRrsK9rjwiwdVNydr2ZUUQrWTbMJ89x1XrpmHFCt08rNM3W7cW6Y93QPMFrVJ6JbtQWSx9uaKBa+UWqwi3xNmJl67/TDWLNV9Z69ktcLdUIr4/pqQvPBorU7GGbJa9oc2Dgq9eHxgswWgopS/BenlfNf33SlCCnHS+PFvECg1bzaNhGpwh+mVdS1LBEc3I00gUO5eX7VrJ/7eUaxGaq+N8ob2RcWPq67VpOKm0PxRZinbDeYuMi0S8/xbCTusDVK+QncwSOps06kzS8aFxvsBArMzCY1NavDe9Sc7TSjwu1Ouk8i71O421tOvfXE0m/xLVA0cDoTJp9pOnjvYcRMFOaXhLv8LzLxRg7Id+mB3qRmJB5hJJoXO/W9KBsBX2mCu+biM0PJT9N8buFkPal5bWUQVZfwFh8jeh65eAKOZnRY527XwnisIkn6bGzgsdTML6wVvjkqEmy9GapXHeq+1qphJAnH06wgvWr37h4qSX6+uJPDuWLTbX0pTneJzkDi8323sRPEZtQo7z2p6Yj2McWU5y+8E5lyI3jffI6+ScjPm+dO3WhRdX1GgKpbbTXlWg9z12sLjwF0TspOvFJbeZJQ7B3lGatcHZw4VnstsxT7+okvtsMLzr5sBY9czuswR1xta8L0r4jZ46084W/R76P32YqbWbUD+dw8UYaNRuclvPfdJzgIk0bep+UknFJO0y+/0rqW5eO/2307ybIzPfHN9gTJh2WXV+tBjqcCz+cbdjIiNyTIRnTQvOe8GR1c3ESmu2GfGe75xGbvCQUZXzeJwv2pJkN77IlmbhFJ5OMDlbicC8XNtZ8YrAhVt87uxhe+PvHEQplRnJ0jz2xLnZ3BiEULD79BPRoPN0nwPWdQYdHN0HAC1QIn01Ze53tJr21IhUTv7tPZPbzCHP7AoYNtCqtCyVKslXMquZfMhE2lnKiw5ur4h6ChelLZTyzThF7PWjxb7p1BfS8krqI+N3vsRK8876W0QoBHBNuWMoTppCj+5mM+NcE0LqTaD8hIYbLlgm/1pkQbyDH7086Psc4olaRHne3eqCneud8d3bhtGffZtUnfs7iNUJcrCHuvnC5e9x3tBb7lkOyC4o2PvM1nToyaXR2lVZ6lveHKvyuY73DrChqhaGsFpgC9cOKDkssRSO6DVUQpm2osjDKWYsbtxfHCJNi+k89PxM5ZbLvYvG8qrbMzvPlYzsfSzsXKqfyhn0C7wrbxVSXMPL6Pljb9GdX+o6mtGDa5yVKN7BZ1Vb4auvk92/PCZOrP8yfe825G9y8+yWw03MWdl1E/b/See/qYGDvhk0+qFk75q046w2sY0s+i+ls4V24T26x+YBJWkeKW2QKUmzen/C743JzDF7w92DLtfA7VpLzufm3n21stj3QbXHWVc7vFK2WYl+W9aGuEpmNcFWay5HMMfDgA1JzxMVy/kVQ3FPUw7oXVUzkBXQWyD3i43dzvNNjYdBqfT/YSEH+/RhX1ct9rRHEOwJ+aILCKDKcSpxJsLnWgFFuYUrlMZctFyzP/Xvf9A+KpD3rmYQ8v6UqNVKiUY4m0004E6zZlFsWUJIRJ+BBkyS0mOKIuP2nGX/DqIvtsr+Xxhj3oqVIScnHKYH19fCy3IEMRlW0O53OTV3OinQ/2GQi7eFDVlwsqXfOGWOkjlN6UPe2vskd7odg5lq22cSKz5z5D+d4JeZFVm7lQHkrWQo/zVO6JGesrzZhEwphqypzNb0SNR6Jf3HwpVdvSRD2hdsxmHe82Tn/a+suN1wtNkR9s4tCtyim0hFxkg1V5tLpvd/WXG9+WPpW/nDdUwcI6bI28zzstM0czJJzP61Fw627OOfqluAvItOXx14blcxokUnmbxSe/RO8F838dm9LxG1Y7IWNwSoIAS8JhmQ33DPNtlLB0/8XSt2HMCwT65I4FLjERUxkhAjxzZ6o4+wmeDG6loLmyYhfc35tkRM8hJLqgtoubzYjqf5LZGGM5VXhm9ty8WAONGPqjd7MajQLR+Vs16VaViSJ3uZ6uyWEl1NmHoJb6JRMt9C2R9d302ycsYeoTbUXa4hEqmXe+GJQn/yjTfTBUEW94jbwh5StpYUiYk6Sb//ksafVRHylP9adkmUW7+acGQ0VF83iMOxXffS5SsYtqRcHg4clNfdNI4140mfbwyUZGYIZwcMEG2tbwrKzcuO4VHr/0OnKsRsboNJ6wWuprfSJTdn0dY4C87Q1flZvK9KTCFKxIUTiklmtsRVYeRLGZ+wdC42tT1OKkn5WNqNnI87SGu7esi0tNl0XDoujl0hmFx/gTFqkWW3W9unoXsNcb/fa2Hsm9uILSjL9OU74nn5hgrnFy3JzL46btqQ3kTydfDTwwVRfeUewIfU+YuhHiqUbBcWpPKeTYg7oqZwna2AKq3rRtxc88U/73grerD9aGv+3MzxW8exCDCQASxODeMYh+2NzBKK6m+mmgP3+wGVlbsNv8E9Q66tpDYi6C+lT+1NHHGxqs5cHbHyW1sJ6jOcgsSfTTOpxrvm0a+yTxOdbe4pO9MxkbNpNtt1aEzlA9Dkl0wZiZHTJnsEd+EZCWyG20b4CmwiRHI8Y2GznMYO5HprxIrF7ZXpdnHhLOqGJ7z0pAyFqmtbKTODtlan1Rii9fk13wYYqWCNrbxCflDIyxKlx0NnFPh6lTJ+5K+iqmuddlFFWHHZANez/gaDwRfjsrZz6mZiVValErukV30+rsxWpby2EDAQwaKk67/D6JCyuN68aKHhUh1ZM+l4VCZ+6cjEvPDAkiWPTk8wxcOTlkWCW7tZkjfRxzopVoYN5507pOFpCRUE5WY3/rNdiN9tqsrs6NgZsjSncjzDv1FO1Ypr+ofTk5zw5JdtxEYNb0agT6TKvp3uo/Jyo1eEU18iABQB/YwvCpoyfi8CQEaA1HjvIR3Lx6cLyHIv6OJ40Gte78l+k3Jbm2ZM/EmO8rBKYYI7NHzPfjHZfZXYi3eYJU3jdWEyaSWm0nTKWKPtac0N26t+J4nnywdhH9SdKSHwGD41UyDKsku5iUpxKlNOMolXl+lwPydzMsAsVlkNpOlVUdYGkj55KGoxlZNBA+z8ONNRRHX6noq31B0xvSa4kREY5pxDQ1PrNSEHBZQpJyh0OFnJshb0jC5p6OBLtMs3Zpzl15pOy78fhMuLP+lIXuLASGG2Pk3DcpiXYb5dvz+TAucvncPo7V+/X6SxJtxQ713JyPz9pevksp+4w7dDxk5Cz19X4CZfq4sMxbGpYnIk2/uN9VCTBx/RBDejHGrwVPYcobl6e4VNZAwmKLbJJUG3dPd5VxpoXnlXYjB7GYqzmatNmuat4LVjEDHoNbFAdCOuQXvUoD2/jzbmk5u7yZzK2LJFOqErVlCppYMceyR6l6pXtm6rEhKY8t8YRTLJ0pW2lgRbM5RWNAPPLB7f3Gc89Ket+jx0jL3z+Tq/S6M/Ut8ov8PMHIMf6slOP4WDnz7AyMWNqvkAzpV9c7M798PlN5qrEwN2slIbeCdMEU78MJvC+Orm0qdgtLx+Qe+V71Ea7Yc1kuu3Fijy84qKpqTFTPbbw3AaWw8FGeieDEjWMFfFYbfJGc4QpXjW+OnM7i5bB7mkEu/LaizJbo+HhjXtmn+xgVjdNZSYaDvScn76KEsPVoXGSck1/aGaTbrXKa19dltw/VKxBgGJ95KoGNebXWT08r2c9CjmR1O/Jp34rj7hqXCps282BvQ0vIXugHbMd4MjPfECztjBKLO7n1OY6hST335b12JsY/b/gP7M6IrMepLtzZIj3OF2gNqGVv4sUsV1R88tDB9Cljvte2YDYsefw1Pj+BzOIU70derGOe9Jd6J62qY8r6HRZzt6ZdiahX5r+errq+Yo7WfZPwZOAW7amvZNHYjaUrnA+73vpdPmWaYtqk/DjUV1e63WplOCj1Js8S7fmya+Oq6k/UzhUlv3xe9OwZ98PWAzeuKZvyK1fYmM8wz5qfYxaa1SPrLfJ52XXOkmA36EsYqbcqQ3g3E+Gng28CVbm797g4UACA/Ri4O+rxH64/F2cLa9hEX1RHxYK7Mor7fWQwo0NCJkH5Z3w9alznKf60zgcACgDz27/LuvXHT9DR/jFKA2dnRwtDF2eTw/1N0JCHvfpPgIS0+2lICzNbO0eTI8MdduQnBQknggT8yu7/+2CHnfLJQILl/BDsx28X/4n2c3f9//xHAMxLXEEGwHrtHx2HCiRO5s/iHOW1D0r1sFf9WRCqm78M+utEHradZwSJXocCQO9+Dy4jtCAZuYQKQOdkf3RgRpDAjyEK/INnLGhaDhuyc4GkBR8NgMPJHhwNFhAaF9EBGM3eQZkc9jjnAWHyHDoE6MicASHTegyA0kIdlMThr+A4QEjQYwAwW6iDG/9ZkPFbYAIwmIxDOtWNkEf/7vs60Cwddq3mBskSExYAj8k4OCrsIFTGsQHYLbFB2Rw+wFMAhI08DgC/JTY4TtwgnNqhg/vxw66jgQRAgPhwAUS4X4Om8bBLtARIGrPhgAN3M/gP7mFbZRkQ3GA8AMGO1N9jH/YeVgDB7sIHfoeNM+TX+llCAEbDY1CKh/eToLf1YOgQftyzgiPDBkJmCwqo7z/4OZoOHwgdfSIAXq9jyAl1QgH2/bc+kBI6RwzAa3MMjhAnCKFsqMGMIVtzgiCccEgABDgcg6PFA0LrFtR4P3zhczQ1ERBqczBCQUcP9ClqchyA3dcYlNjhz2xAn6ItUIP85OMecJw4QDgpkQJwmBgfPVugpJ5AjwJuov4Dd9jXlwEEjoEMgNa/GPJN56kTAAxGwZCuMXfIo//4qQxofg4b3Z4Hyc8g1CBQb9RBWTGdAmB304V0nxYBNchPPyg5Gk4EBG4PDrjvPygBnbjDX0oog0ycAznwm9x0vx8DyAcMIGPIogB+nz3t98M4/EEB6JYxmhL4Hcax4OZfAmT+71ABCLVwPRpXHgQXoAZ+i4UraOIP6+p1QBLvi0j8o75i+H44h6Xt10GGs30a+Pd8Tb8f1mFRuR7IsNBpgX/HYhTym/CZMwDsxp6gvA/LukG3nHegBvmZtv17vMOi7MM7i/lbiXQA/L6Z4HLICpJDRXoAVtPLo/dKvCAZLIISArodLehehpoBgMHvEtIF5w159B/9Lo8GOQcCMgo1yPd+l0dPjDDIxCidBRDjdwmOHC8IuTroIX+wujyanigIPU5GAFFWl+AI8oMQLIAeFKoFKQSCdoIJQJDL5dFJlQZJagh8iNClFnR/isUMIMzg8mi6siB0b8KLCR3h86AbIxYAMd6WR7OVAt2NwwUIT/1oEQrkX3Yyj64fXWIFEGBrCXk7tu2neEc4WoKSOOwICdqOpWEDoHa0/D76YX9H0Hbs/K+jQ9eOBe3QebMDUFpGQtqh+wBZZDg7dOScAAymipBW7T0gjw62Q3fYfQ+0QzcAHQLsHbpX3ADs1n6QdujOnAPgt/aDfHpyoYCDramCyQPA5+IHeQ/CAwooWJsqg9BiwENIlReA2bsPUkJPocWA56FIzwfAY9sH6UMxDAYYeJoqSPwAvI59kDZVrGGEgqepMgEFJsxNFQUBAH6zPsibKm1QwMHeVOEWBOB35vse7rBTHWhTJefXcLA3Ve6fB2CwvoN0je1AHv1XTZXD7m+gTZXrQgAirO8gZ2UhDMBuMQdpU6UDahC4mioiIgDCLOYgbaqUwIuJgKbKuCjw+zzbIG+qdIsBv8NNDfKmSpM4gFBfM0ibKuISwG/xNYO0qfIakfjwN1XOSwH/ntkX5E0VWWng3/HdgvwmbCQDwO52BWlTpQlqEPiaKn2yAPxmUpCXfUIvAJA7QYFyOOykBFr2Gfll0F+XfQ5bIoGWfR7JAdB7M0GuwpeQB6BzWYJ0n5UEUeDvTQlAs3LYLQi0prQJefQfTAjAcWAG4SCsCMDmQwRK47DBDmjR5z5UAFAxAa3udSkBULr3QFrdY1YGYHbvgXw12aoAMPjbQFo+aoM8Otjq3mHDFNCJZlcF4PG3gfwp8UUNgN2NBZTNYdcT0PdBFXUAfjcWyPX3y9DBQaO/B+0RXtEAEGCsAprFwx4kYiBZbIYdDcyd4D+oh007QFtJBZoAQt1Ovkc+7H0B2rJbuAgg2iIE8kucVhuA0WwD0gpxAHQI8BRUV6GAgrVCrHMJgNdnA3JCLVCAwVohZtcB4LXYgLxCnAY1GEwV4mO6AALcNSCvEN+AGg/mCvEUjFDwVIivXwZg99SAtEJcDzUIXBXiC1cAOAw0IK0QF0KP8usK8WFDCdAKMY0eAK13BuR7zRP6AAwOFZCuMVfIo/+qQnzYYgG0QjwANQicFWKGawDsPg6QVohDoQaBq0K8DQccrBVi2+vAb/JxgLxCnG4A/D5jBMgrxBGGwO+wLIC8QhxoBCDUPADSCvEeInDhqBB7GwO/3zwA8grxhgnw752oD3mFGMUM+HcOt4f8JnzaHID9SHlIK8SBUIPAVyG+awHAf2I75LJ7OUsA1uPWIZXdP4QSAp73EAorAJ6T1iHVp/rDAAPupHXI3+uRrQEYD1kH5Xb46G/Q93pj6BB+PGQd8p1nvw0Aw8niR08SJwgRAVsA9pPFv4c5fEY1CehXez/AfHeo+PehDp+ICBrKwB4Af8Q1uNQSgaRW1BMAf6Ai6JgOn+lHBTKmoJ8G+umBit8HPXxQ2SmQoAQ3AEgOBwRH9zgI3Sgf4JennR29bkAZfzoqFnQ3JtxDAzyQ4PMFjjzoDA39j39VBpQBfUoA4On7x5/+vwAAAP//yQ3yTWnNAAA="); err != nil { + if err := gres.Add("H4sIAAAAAAAC/+y9BVRW2ds+fEgp6VApQUC6JKVTOgVBQEVKulsFCRGkQ1IaFCRERZEQkW4QBAEJQUK6O74185txeFQen3K+//u+v1lrYOly3de+7r3POfvc93X2paaIgkoMYAAYQKicky5w6D8KABNwMrG2szJ0MmGztrWx5WA3M3cydHJyML/u7GTiqHURDUCiyBYxe6/R0NiiyNHKyt7ZKt+iyKGspFrsvHEMFQAODtQUj2F0qXGdpwAAgBQAgKPhTvwUztzMxtbB5BsUT7Airi8njvSGIzHpOr0HCq4aGmcVSWBGzdfJdZIOmyE528wLmr23mKr4O0h5TZ9IzmmJZ/VLmR7T/XCv+SvtHQnlT7z1dalmidYEdZnxXDhKr5ZES7Uk9CN8JojobO84cwyeZDI2yBI88FdkJvtK9P72i9BuK/cPm4krW+h/s5lRnHnnBQBAPlg2pD+wUTa0NDE1t/qHS1OLYhuTsrxWg5xSW88xgtJGwXiP133ewN9AnZHjlyn+TAw4ILIfgDRkJKSVZdiVpb8hOTWLECLT4FxYStY0rjvVtYDU0/QuDJvTSvriZj3+woKdd/7wDuWU3wcNolLFLlWHNBJZMyd9GYJ345dWEm2SW8iwIpLnz5NO+NQbX9D5vHDTpf+usFuUuqIZbzmdp9XUPYYgr2+DvqguyWIGAMDtQ4MGfhg0wQ+DNrSz+zbcP+Ic/tdHx6H6WRwOQztztr//9pdBf8zo2V8G/XEusZY38AJdl3A01NTUnmqpdTK2ybU2qjMyqnZ+WXZcdT6Oa+fkgqbIlJWZTf9gIprR/nUJ+ubmhTrfTInRQLT4Uvqc12iCgfQ5Cvrs+21DBRICdK+5VyIdFTQ1SFZXV9dWV88RRj2v8rNxUMm+YsPHbl7xyUr8W8pn7dN73QAAeASWFeOvWf24cDS07dpdWRRalLUwGJvaFZTZ1THkW9ka5FnlteyaOTTscBYvYqiwMTcrqYyPjo4if7vi87RItngAAGAHO3u0vx6SoZ05DMuCEaLAHDdMrKxsYVggXFCE/89PdrN/cF60GVhUc+IcW5ycIvZajg7mYzj2UbM07K2OYXRFWWBCQu2DGYssk9n5M33oQm+Z8SXF/OiM7HaGJepSI5K57EaMYzw/dlTrkXWXvhV5SSbccOtZcqdwsVpE0TuLkMk1dNcnLpp3CpZPyAxU9N0pmrQnpp3MoJOR0B2SVxO1VDlpsjXidPAm//ySabihWfQtivzl94r4RkY8fKXjhSoh8fwJmg815TNjG25Qn/XI/+zj0N8XuiTRFyzzyGxXPy9hoVR8FMVGxZk3rHwxTTpiczM2FNtOQVOB+WvUvTfIf0++0Fb30CAAAG+RwM0RCzRJdOGCYZp4oEP4caasWotUfLlwUEde38ZqJmINudZC5GRoaPRkyz7pXpxfTc5lmiFKdYbM0LODg73unmYkwiIA8Yy1wFBV6Au3K4U7+bod2Uw3sB7Vh6MnotKXHFtUJBOWy5/TFbXf1kkcI5t1OqBrc5udFdRoqDwuafYwAterqsbR837mqJ9j/FKJtIc5tubJrqVSiXn/0MW9qwn8dCwMEfptVM/06KPP6RUSmm8zUnvc2sL8O+3bHa/ncwEAmAJ7aZz5dVJuGBpZwpBuDsgicxjZ2piam7G7G1pbfUORDq1QYeEi9tu5FaT+/hNLkcu+XDgLHTMdFtaVt0WqwSQD9R/NpNbn1InpcrcS4m3v0l8ZukLT8hVJ/32wzshXyUDLbNpUh8CQ5pAPT2seyc3Jzrx9ZHqOyUbC08WgjDjAzoEpAQnjog2SW7MrIJup04Z+X3ij0PjU87g10zLPT9TJybUfvGZaJfK7FfJbXcr6D3olDUgrTd5qurJpB+qLWnGG83VyAsmD8f0GDknXl9Hvd74zrRw2nOX/6lSrQxPNIrv9RjXo+EKIypLC3sK1ZK0WvvDcLvVJ9xfF+9/uiJdlpkmGAAA4DfaigODRY27jZOJgY2gFw22RBfLoHEbWxjCsAW7oEP74//AF56RWZfGJE19E8SrXlPGx+nSRUw7yqXP0aVbmC5qeeSQxstfpbJFNDip0yrIEnVSvDwlXbEyYJHmlnYkbSy8OE5T3V2E5d7ZgVTukp0ngathAu71KZ+kX7Rltz+0bl6rkeuITUbMtBot6biZGBjk76u/PaDBNeMfMG40ac5nd7xs+kMmfVHh3Yjb5ogYG3bocDV2GZ74q487J9qmTVNc2TqRoBDc02+Z3Y8smAErS7aYdCrc4pm54HBMOeuSMrMms4L+HwUh3NvLl3osl4arSpU+ta8cLDEJUY129gzXkRgq2bltL4VEGAoF0Xw3x0rCU8EbqbJVfzZDz3H7wYrxN55z+6qBotcGMvXBmfiRPk5ZU8d7mbCx9BwuWM9mE2Aj2MqEc7kWHUcm9sqthybEFrbm8/G86ZsLwDMR48rjae3UCQjgw/acZcGZ9taeFbzj3VOwT/b30sEUDEzSQAEAGGdziYIdm6mxtHJ0cYVgfAlCD/PXr8CphllNqU1FS1ZJra2dhZ5r4Z9fxlgynhQQAADywVwE3dGNwcrC1sjJxgOFyE4AJCOZdiQQccD/bpVRhInPh+3/2zHU7XpLzNuoprduLO/aU/L5GyVYMcqVknh0H+9Wx59Yr2ceDFYvQLcOpPuVfdo7qIC9AudCWKEwSsIIpcV7nlrdzJ+bz12fezAzq0xz3pbS1NFHwisiOZcXTJZEZjBdF+nvuctTk7loBAICLBI6jDNwcr9qYuILwVFG0mBHH1y9TVXdbekrWk4pSHpMUdvojecYtPYtmKdPsAPn71/zmqZLwG5Ai+4m11KgnFw9eSbSldUpwKkS+Y0AROH5vNqpIlXvkZnWUKGmoz0SWf85drJ0zuPVEVOtzOch7jVxNnyqXGUsUMBS+GPVc/9hhIeJRpjKZ2zslS8nRRjfxlqHssTzl5KzAzuArT7L558bKerRlJhIZjUF3T2c9WTI1mba+co9dc9o+fKNgyKrS5cn6lopBSLy2jBUz5sHt7El/0vSwb+8CaGLneJoBAEgEm0YF+NPownX1x/1SaJFKDSfO3clmzTil1q/s6u7+Cvdeo/AHjEwwRwo4D+YSjg6qY8vh4DwYv5oiVra9OH/mHaUmbVadfiDaKef3d4JGGC7nRIVmfIq9RM5YJmdvZ283k0H+0cxJ/QAFYyKhfIRXk2bS0vlNaO+wE/Un+878fG3ZHEMmpARgMjSIM8tv9/0pt6F4hgZ0seGP82VXve19Vvr7Ub7ac3dwtnllbCE3lJMV3cFDA/Ctw7p8ngtzjau8HLS2CnPM4s6oWGKMU8jAQ/t0r2vAl6+eOYNVv/vRNtbfaXXn9xzpAQDgHBKinq/Ghra/Z0t7GOHPCoqlick/r9bfrrc/oqH98hbGBgWela2ZuREMnPigxfhXWVnbGptY/WZWf2LAzYoTakRjWJagIAwwcHPjgRrUxMbJ3MkdBn4iMELBzRGaDZidoZGlifFv3oD9B+SvXz/bgAGdOUz6/9QrV9AtPhD9cvvFAcUIHE0cXMyNTH4zz79QoJzAHzEZfo1pbWhucziTwaFFWO848e9ODmn6qTR2UGxi4Y6OjGI3xGdzfSzz84jx2ZzXqJI/1puSsrDD7M+SdSPuGWBcYKJhlCYYz2dS0WJGjWXEbC4eon/h/Uf7CJ+LLBqtg2a1rKfOphFcMp7V857AjkAvt336iRPN4LbofgzqvJ4dUM36mdL2obs4UcnGsabRsOcftUZd1TcinZ/cd8ZNXvz2yMM4V0IeCwDAEgDnC6u1oY25qYmjEww7aHbIo/9VVoBhqZyHGuSnJYzgsCqVak4c8YUtLBb9kacMA9cSHUaJNtFe2T/30QuoGawZzngbLkDjELT25dGkkMCTiVNJitykSTlRkfrRaaUsawUar9X6cJ4Fa/YHE3XJmrcFK0wkoqF4c5Hm8op78iWVb/QActloK6s+HrjXKCdyPPOf8VwsjCOMoXYiz+fyWsXRaKB/4NTMxWqdg8ZpcI/GW2aCo0JWl9f7Qcz+5+C9BWxl6VoqFl7HTIJLPetoI+bu2Ncmw7bb0u7d+Di/HqYaMPZVN+Bm5SCl0PCWDfm6p5ebnYJWPlfKt0uAfw5veQAAACMkRE2YsYmdla3773mv+g6Ew9LZ0cnW2tzDBAY4ETjgOK4bOsJy+1KGF/Ovv7U2sXECXaZOYRUq9Zw4NRvCtRXi/qWmUteNp2psNLBZk/Bq0btfXUAKutx9oKzettFFyes+aqOhiFps6krt6Bb1TFbYrqvUhJ2KWyj/CzGKGqMj6oZFlKONQhuSmodp8Weja/vUOmM8LW3K9BEyLUic2ipXdlRZox711qNMRqLOtg93p/WHJwP8+G+v3GD8MErnv0PDd2tBWpqByavS29jjdZzXs1jXD1m5mWyjV8TMn+P/U0+2U0l8UggAgBnYdxo1uFP29x8NncxtbUCzxtpUdPwdJz5ax372IjKXQkA5skiFvehU85LBF0da/69McluZsfyinQ+zmboHA3hvE9z/mpiis0Bl/srotuEXXWZn+c/2+cI3mCltPDkW6TR1nua78E3dM7N5olTViUe6y0Rb+e0hWovRWGcKAIAtAOcL3C/I/vXQA6WpH8KFhSyBI7OTREum06Hy3uMOWq1oy21jOzNCbsN2DqGQaxubC9WahRw1j3v8w1huWQz7Ud/LIFWTms7OkWwxIPcj4HsgvWJAxEMx7mQTMeZnkr44J9nSQvVA24rs9lDv68w68tf7KihCCpcbuqf3h1Ntv9F+eCMp3AUAgHSwl6IEPLRtXUwcrAzdHWG4BcgjApfD2MTFxMrWDobbgQ4i8f96elkb2oFOvlWYsmK1OP7dhS0SKf/0gLrsTm30IB+qGeVy1edRT53Wqwfl00bCYusuHndL2vB1pQpaf6j5suoMxZPRaxUSbrhvigdZat8VRdLQswLCgrIjxMuSfTI04zLn6ChrRyO3tZuIBCU2WQGgYMQ/ej3a3WlH2sKX41hvMBUumbdfwZjTa8AvjBWD80xEX1jCB78rBDxrwkF39aZlDnjyxZLuz0eLoWpiBH3IfVN21ZZqQrW/ZsaimCl2/Fne04LYmcSBglvRHVauaTTxFxTih/PG5tzHXPsW3yzUfSaw5S/fpf5EbCqOlJSqJP7PXYVjT9R95o+5BntXuYbQzP9zU2b74/ozcfju8mvlyq0Wx0HtuK3KRcaZMpzbdvI9ticG7QNtN3+aV3i4VkGPCW2vyXbNC99dw78xsSl0MNB1nehTnKeXYEbCc6cuDXPxx5pvM8Kypl5bFoV88TAhKqCO8xjsz+j2qY9DZk1hx9Bne4MVNzPmKsmX/MnzDcrfufCoTGB2BgCgEOwq1EdoLsDdbVuULfzE8S8s3XqYznEtsKzjEoYu2jOOgcrsjv3UJxR2KmI4Y/sbyTx7Uvz59Hf3eAp1U0YuNueSL1ytu1xfz1Ntkm7QTFi9kV9TTJqO+8RM9amc1DWq+HpdHB6/djrFMcVlie6aLrHZ3jIBPmWxKfKhDz4u3SwZm2z3jXWi/E6Q5jlQqUivftsI72Y17AYBAPAEYVtVY1sjSwgqyjC9e38HwiH95y8QrYID9vKGVkOjqhJTj2oLU0OLYjF3z/ORUY1s9hEN7dOA8J6PFMWtmxRSwnt7j22EYp9cjZMs8Qp/dd8M/27rdiAamn4oOzuWTE7tVpZMY84U1sXU82tVuaurihqO2KuO3CsKLKNEjpotSquOROdW8HPFhQtS1cT8vwR/2iVGm8PiYcrdCb32kZmRETVAAN1fbdBUJ/ydcMP4LDbW6af8SN/2m+k2YRNpAADoIsP5mvd9Qv7zi93xxiGRQ7dqU0uXqgJr28iohjZGYwOr9n/0Gw2s2nL5csrsbPLK6nIKys0cClpyjaptKmwacsytLfKdY8go/8gwIp5rLEkBACAOdp2wQjFicy4BGxhWCS+UEHBXLiB4CXQwcbR1djAy+T0vgX9H57Bzvm4FQRHyR5BzUINw3HCyhqUwKAwbEtyTxAs9rp2Vs5k5LCtQFFYsuFnyQ48Mx9IUgh2Nw8gRlgaqNHyIcOdXBA58c2tDM1hehmXhxYSb9Xk4RmAByzRLwQX4b7QSvsHBIbQUhAEGbm4/l4xa2F5HvGT0cFCESkZ1t+Thk4zK5ITrwSoZBWEFvWRUvrW1XXOxSXUUGemf8SxqXNTk+rMzB712DWQ8CNWu/RD5v9o1qHeBIDlEuHbtp9ERql07EuF77ZpfROf9bk78upSoyustmp7RqDf1S44tSBNfrKk140jM7nNrbeGWb0fpOzCIfLAioJ8V/v4r/8rOm8bGUk9y4RIehZNdgSXiZ/0d/GrFSOn90/MyiZlrHPRx+9W577wzfmdMdSUx0HqZ4fF95CaGEp79C2/9DrST4pIiK6LxHjypUuWj1ZeizLdlor8/xsFUY5a4iytOT65+XOOebR96pad2yeepR5SP9VnJHo9cx1v0xZ1bKEMbxM1GM5hsOmOl1/FqxtM7anz2ZMGpDcWdqbSVlpH4QM/HDNId1ExOFfveRB8EUT5pqWWJjw2taa3femzAhkY0zT9WEvSBRFjEomTK1Fekc2i7mvDKqJtE8AntkdcP7S0+Xur1th8yfcqBbZTPbyASfKdQtEZfWEqU3SQzBePC/bFZ3VfRayq5M7dwFnq3b3c5tzqGIjHO3MK5MRlrc1CamL/3Ws9oxJTBFc+xWOO5uOC2WKhDYsGrYn7l3lO9chr3Vk7X6q4vu367gRCLhUh7IAHADAwatyOmGLEaN3AgiNe4QXO1IFKJciTCb9Js/BwPsUoUMBj/KivEKlHAYPym7SM4RAQqUcDD/CYlCjhQBCtRfg31m5QoPwdGsBIFHMi/o0T5+QgQrUQBi/KblCggmD8qUbhC33Hiy8y0MOVddCEIe3Hp4/VitONk4qFjJ6RM67CIiDHtXYnpmBlvVL4Z8uStcWxoVGPEUXvclFcn6chpze6h70Htz6lIpU70genGtJwOZ3fQ2a9lvUH+vK0UDJ/CzW8gJfBLUy1t+zpUUTjvbW5qE5rfqEIKxq43K3eeQFfOrFqQNKy8+tGG8CB2NeX+/rTFQ18h4W/Nmgs1g/QJMIpRvqONYDHKT6MjWowCDuSn7yR+LSIqdZw4QIfIo6fvkKWi9sXvC9vH8NhL+uvF1siMrj8m3HlV8VWk6tF0X8cO7eu7D5O6R6NqJjIuLvtnOamHlpNUa2Bp8QBKYjXe11Ce8wLKUfpBqWu0RlTJ5nscZeVc8cQ8eWmdImebPl+vwHw7sOR/bWN4vVVHhjjA3uNWYuwGXsjkCid7gWsFuV3C9lYtC2+x17cl/AUDyzsOAIBOhGUbwUoScCC/QUkCGRxilSRQYP5XSQJ9yv7HK0mgIfu/SEkCIW2EK0mgxEW4kgRG/P8qSeBWksCa+f+NShJYc/F/QklyRHIQqyQBB/J/UkkCNiH/PytJft7IcnQxQnwj63BQhDayak0a4WtkfV0sl4K1kQXCCvpGloJSm0qrovq380/+qdFW1d9Y4fuzDgb96Scgg4Lt9JOzEAXmMDG6YYuwVtlPo//5A+Rj29AqC24JfL/2AVX1WXkvp2PUI2I5mJL38Ok3XF4aBAh0jVmZ2WO6b5yWb8CmQ5Opcn3MPLl48EqmzTAnPzWKzl/5sp0FgSDdWHhmrWFNxRBJqM94NXq2h83T/lH7snqP4j7+VDFB2fg9bFfkpbP0WFyWXEqPcysYop58uKiu5VqlUhhQZ+n00OWCGeFKvPKEetT5tr413xQvzXrBEr00clJe5UCrFp/W/pRV9zvhSk0RFSMhuZRhRLaXbubzNrcnpTWgHdyVeT62JM+uqRS0KpaaIqHwWrc5eihw6szfU68i4n0wBADAK7CtMmYocgjT0SfcUAH8ME/6f37Ii482s8mirXfHr83n/XG09NTU1xeddJNa65DrRT0pGyV3hbB4zk4/iueP3z2GWX3bVumeIIk/+blUVIOBncZHN+gbr5sU7fgaYMm89JnoOTEXb5h5ewL7Ilsry814CZXCPFROk/cf0kwqGfRyzjDKO2/O9qKeiRVxk72XZ5lAicUiac2l8RV3WMNXYQ/3yshbe+5qzf5ofpHQdwycc7jYVy8zCp9pGfosR2lx/qZh1IWklg1nwwrm3cLzU+cm23H3bbf8vb7tz+jlWt41AQBAhgR9cxkkZQhtLv8Q+b/NZfjuaQhvLv80OkKby0ciQHMwinseSfFPD0ZxquwgKhGwpLyuopHW1VRSEzOU23n5JPW0/Y5gKXG+6u2i20WPwlwIgo0rXstfy+2htmx9xZSjszC6ezVWgatQ56sogwqp48vxL/MH6Xx29Ib6c8kX35dG6jjUGzsVrmGaVI6eRKlGmSUd0wwicN/Pj/GokiPyDjzxEedyzgKaiPKC9wXMF0rXFGRyng4D/l+k379M4XMhYiUva/vAX6LNK2owhMStQHOnbGKn+LiIEx0yXWRmgIgfM6eIN3Ul72CBbcem7vsHQkatdp0bOziu+XVL4S8V3jNeOv5hfcwxbjLmivrjMs4DpKvhkzFfxOnPsndX7qydcJvvz1sfrSPz2FtKmwlA5x3dSph+ukSfqjbod6c6N+Y83uWHzoUH35beZz8MVA0kAJCCoWl8xNQhtmkMDuTXTeNR5C6sU/pJoWhoyUxYL7Ewa01kvm22MPUTDvVLxoS8ZHn/XKXQH5xy5BhhPziFHyYgWDc0YrCj/bjB+empKVyhiVVcqnzPvz81pRh3JpytRO/FV+Y0fv1joUmX3JlxJ4l8nJ5uAXr/nJpC6Us+1DMTvU+rzMGEp0t8mbnr7N/zpru5oGMJAMBxJOjFhJAT/OHIlNAii2pxfGnLhUs47D4GOgGip2NmUSWekmfcvnVZkbZ0YKxcgVPygIoQ4wvKKNMx0yFH3PYDSgfcmJc+KunGfOZVRTIjNKfw1C/rz7t9iG2RUKv4wPmh6O2+39jX4Oo3omSpAffUrx+0PRS/WSgtJZdwnPxyflnV9lcNt+MFXfPTSpKn+ozJeHLHoj/NVS/c1qs3txumtuwn7BPBZA554ExBz09v8+Cs7Yqk08P0enXRRIfne2mka1Ub/dFx5jG12RRLq65CHC/wb6H9ncRYFdLhZgAAYpGgF6FCkUQXrquOhu6H8ygdUmVRzYlzt71T8x6FrMb7OH3XOfK8p2VnL/a2vNSXwWTLWhB95jwgce9gbHLnySNV6hPxbcj4jiS8s6nm8kFLHy57Zx/vbGuul4s0CLdzqHvNYFverlGzdXmw/P1+7PmrGQM3bR5enkJSUaSZxXA9xpQdSTiz0z3WOXz+GYtobF11O7Xalk+Z86mw/fW6WCqh8S3qFpRn0y7pIkNp6i9lsN/skswPZ18vTDS/ebfem57B7e2lb/cL2truzpcAACwj7KmKSBHKkQi/Sa7xczzEilDAYPyrrBArQgGD8ZtEKOAQEShCAQ/zm0Qo4EARLEL5NdRvEqH8HBjBIhRwIP+OCOXnI0C0CAUsym8SoYBg/kSEElTNiS9j2c7kx5LzFH0dS49VL7MRzYf7AQlBu9xHIyOM1552p7U0MvduDnnydvBm3hAwRmrQb86sk3Tktm7y0G1L/utAlPrUojFaNKl8gcLuCu2WdPtIztHQ4FvYHeU0771n8B6cJPq6vrSU71diW4WEc7/j3NB5R9+7JRsB4bXUZEVlNQcye7F5laW6kyO4/5yt9u5VpT2sIpTvaCNYhPLT6IgWoYADOeJElFaVak4c7wX3P09EMTUwFBNcwij3GSjRrcqXGrUZnVO/JpeEL1i7/UU1ZWEkLyHIlb0pzj5b1sFJ4u5oQXeZ5Jak+7kGbhX7cypK5FmCXMzxthPHgbvhOcR4a7peVqpnLQG6Th9zDwkRz6e4Xd3lpLrMzJeCI5bxSkN64sQ80Bu/0CqWj594UHoRJY69ZqSKdiX2im/etMSKwoHd3f0Nf4bU62H+uYId91gs95AXX5S7P1254G6WItP9qmx+ydxLQHQmfH5gMK2PbyB7zeDVoJhAVvr6ub9Xw6rKMmc/AACGSIiaLwTLWMCB/AYZC2RwiJWxQIH5XxkL9Cn7Hy9jgYbs/yIZC4S0ES5jgRIX4TIWGPH/K2OBW8YCa+b/N8pYYM3F/wkZyxHJQayMBRzI/0kZC9iE/D95IMrPR4zQA1GOhvg3ak/fAO0cbJ1srzubIuyUAPAwHOx/EGMzN2WzMTEycXQ0dHCHlSULFPCO9la/p757GIHD2fGPhXwIKrijSKFanKJ+qUJ1aTjB29fH5zRlwdecqi+0S9xO05SNORIemLH329jft8rkddTKD87is02t0HW+Cj/19D1Tl+32zYCUcSNpLrVuV86nwkRBdzqRrtnXnH7Q/7GfhyZW9yaDDGpNhjhyPRKxmq0xUXM9OwMxa/veoM2tDQ1l0vXUsiKrTOHm99Lm6LH6/pP6JweEJpifZb8JerTsUhR5KTCov3F5Lft2uU1mcDV2Y336wzyqoelJ9zNS9CWkZwpOSutjU4ah4SyKYiU566mYjk9e4L11kEwa0tr1OCvfVMZZ7MAs7NaAzD5+6CJ+8PicaT2qEq6Vj+fL6MbUg0vPcCO8fMw5eh+VeT5M+XZFnudapsFGAoAyeHvtEJ+ZggHLtfHt0Ad4S1DEP2CZ2bJb2/5TKYyOkniWyIlzt3ecmHUAjY+hcWbm5aUpTAq14CBrdd1wu53QKKWd8zjGpYY6N1NWByJRnKMC3qetdukWE78449qJbLiqnYpFnMNIESMbv5F+bZOXptDdtdNRsy3kfM4Ex9rrzVWkXVH7aGrNaXVstKttsry57MXsXC4NHU1ibjPtfLLBKgED7WZrhUK7tVjrpfSqSYqJXVSJtJhXHoiJ9bkNEFBoJVPM7Lqjir0xjnJSfdlneLLi1TbWpPQcEOlf8SXUvKHKE/ONwjsB7esGuRQxjvkWJnyt1yhfErM9o4qXvSYh93qwzGMgQvq6aOfelbk+KRujaMFybU7diPGTMwOWyY8wLs1mejE/UvYXxukStz/NJtgVo+5N3f+yViAqmZbB7qRIgaxckOw9ZCpkDA4s+ai3t9Rb7Xmjjl9+ZLOpKvXx5dNxN/KHtC7b2UZXwi7Hrz3ZksuiH8zxiCUsEQmK5+XDVTHsvn/8SmuAg2je+rTiktDfkxfXqM/ugAQAAqhQT56js/W3ycuLu+A41hDpvbBwqeUhTVVZiNsxNykfVAzv03a+G4xu1VcrJXLMYqfjknvmE+9LPip809KkZMzFkn0Td/hMh/gn4RdRvGHuSMqpOQc64a6rlPtnLuzPnO88GTQ8YPByI69Nmpy7oO01VZKxKd2oU2pmesF8TkrIYuXBmh5t9J0N9BpVzspBkTXhRadC0ussx2ND8BitzwrI5yzkj6Ua6EiPlgckbqFRfDDseCmTKNGqLYm9Xe/zRjOlgB37IXJTxFZqDOHoJyZCq+vv3C22ltBfdgi0Cblqf5opuD8s8aZhYvLdnAFqO56WU4dR4Gf5BpTeF8S8drVvlVTYjH2qI1PHyBwoWOWjx9XQh+rYdVN0xYciztozxRMmRDy1JbuiVNw8/UXzlmHh3j3KuwpLwqgsIr0uJ5i3JZV8cxrSMLqvbaYSpKRdihU9K+KfGOr0tDAxCac0OEgkO9wUfRv19IlLadvIxZ82hT4pfrRT2dwT0RJWTy25KXGL7YbL2igdvWNSXnmH9Eypg49RyMyl6Y8+OXIbB1uTjQxiygMon9ef4zyKwP4U+gmHX2vULs9pCCdTmyEkmtzhS8lY0AbbxP15HSMi7qUChtcj29cKXjxZStP9Uj/W751mLHW/MMNF6NnypUGc8g+nyVMnU9olZa4+NrFyKCNoy0hjZ1y9MV1zvUSjjF5U117CFOg8ubO47o2/zn9xN7D5mvTLzWJ8bafnuy+61RpMV31lXDQoHp5tJC/zDTAKOhtXWb3nGzlGfHBy+0KF3ny291Cbfrekp6CPKt8TQjqXVcyFKQNH8q6sjMIAk/A93A3avingMsO8ZM2VuC+XCOiE3F1DhaJ1HDWXdyMxBp3lFgfUdwMTstQe7E8pjWpymbgrZ6Iq02DraX8RZmmj4m5/M62KkrtumkXw2E3ntUv6AdU6rdwcU6cr58aNrs4BRsvaeHTLFn/yGBsTxfx3SnW2YW8JMlLiTj+JMltV79orertQI7TyxUBNaC5QtHoHwyxxTZsDG0elNiRGkNlcUFGK/+KUcs7b2y4UQaW4qbyYF/C1GldbxsNU+IO1CjqWJQIDO5HGcSg3z6+a9XO/TC80QzW4hfJO9pW5l8uu5YTi5lBMAeYpmw0mLjLt4nM8G/E7bPVSPgL3cIlrrOJpcwq+iA22A7lmZhOampUhXWpOtprhIbYn3SaQ9ync7Cwm33tgGTR55yoaOp4Jls8wHYx7Ejodjvk19gH/qwzckQPyXXqgO6ERiUcYiebVTm03yobfPE1gx2xMxn3y0zSfmzhZT2peXRlE1SW4w8eI/phcPBZHMyK4fbdj4UuUInHaTJT/sZSMr6xl3tkqEmzd6apX7Gvmq9UwEoRjaFaQ3rTe6hwqSny5uJPNuWLdaXUpWneJzlDi80PXsRNEZtQoPR7UdIT7mGLKcxc+iEy64vc0nqNvEPK5xXOvZrSgsjbdT9W1upJyrYu54625+wA6J2U7brGNPPF97B3lactHOjjRrHZaZkl2teNfbYYXnLzZcvOcz+swh15pacD0LYvc4y0/4Wve76X/2ZKbWbUN+dwcYbq1Rvsl3J7OExwECSM9qdmxp5RTDUr1mtcyvXx3O+8mWLSnxb/bHifuXXZ+sx7gcMr/fM71dkbkuljZ0DaaHs7bEYGFDWS6G3YZIR7PrPeeUZDxdRIrPJxsuG6HPd7ILSKJTDJQfpxzobCx+hODJYHq1tndmPy3J56ZKzOKs3M8NttSZ2cwYtHCxatTj8A9niDYwxmQX3D7fgi+aq6jaTOvU1zCW2tSIdEH+3S2T/SYQ5Lt29gmscqULMSaOScTu8lM2FRKCfOrrnzpDRiqJZX9xDJF4PmiyaMp7gxqj5C4ivrszLET3fK8l1LzAR4RbBvKIKaTonibT/nUBFO5kKp7kZGCZUsF3+tPitaRY/annh9jnVYqSgs/27lRVbjzsDOiftsi+rNLg4FHYQuBLlcA9l4pXYzuB9oLfMtBWbmFGx95G8+cGDW7MkqrPEN704V/VzDH/o4eGoFocxmmAL1wfHLR5VAkt8EKwqRNNRZGGQsx49bCGGFibO+JlyeiZs23na17GoprbK/ffirnZWHrbOlY+sRHoFVh2/iKEuZjvo8W1v3plb6jKc0Y1o8SperZzWsqvDV0c7q254TJ1F/mjPfwbkb0Lz7LqL++e3xORv28UQ/31DExdoJnn1TNHXNWHXWG1zCkX4T3N3Gu3CWyXu1lElaR4pbZApQbNyd9LnjdnsUTvDvYNOV0DtWktOZhdfv7O015unUuusqPOsXLZZiX5T1pq4SmIl0UpjPlsw29OADU7C9jx31GUlxR1IO5F1ZPZft15Mom83C7ut2rs7ZuNz6f6Ckg3rNGFf5633NEcRbAmxzHtwwLoRKnEmwstqcUW5hUuUxlw0XLM9ej25NMNNmrfyP4ySVdqZEylVIskVba8UDdhoyCyKLYYAkv/Ey5xVgH1OVnjXgLnh1kn+203N+xBzxXSkAuTBqsrY2J4hZkKKCyyeZ8afJmVrQ9eZ+BoIMHVX05t9zl8RArfajSu5Ln/RV2aK8U28ey1DZOZHQ9ZCjdOyEvsmo9e5+HkjXf/TyVW3z6+kojJqEwppoyZ+M7UeORiFe3X0tVNzVQj6sds17HvYvTn7r+euPtQkNYr3U0umUphZaQs2ygKo9W592O/lLju9KncpYfD5WxsA5bIe/zTsnM0gwJ5/C65955kH2Ofin6AjJtaczVYfnsOokU3kbxia8Re4H882OTOj7DaidkDE9J4GNJ2C+zHT/DfBclOM13sfh9MPMCvgG5Q65zZOhkepAAz+yZCs5+/GeDW0loLqzYuQ/3JhjRswkIL6jtHs9iRPU9yWyMsZwiPD1zbk6sjkYMPe/DjEa9QETOVlWaZXm8yAOu52tyWLE1dkGoxT6JhAt9S2R9t332CYqY+kSbkbZ4hIrmnC4GPJbPy3AbvK+IO7xGXpc0T5ofFOwo6ep7PlNafdRLykP9OVlGwW7OqcH7oqKPeYzbFT98LlCxDW9GweDheZTyrp7GrWAi9cmzjXT/dOHA3A20reEZWbkvuno8Pmk15Fj1jBGpPMHV1Ff7RCZt+9rGAHmbm94qt5XpSYUpWJHCcUgt1tgKLN0JozL2D4S+rE1Si5N+VjaiZiN/rDXcuWVVWGy6LBocTi+Xxig8xh+7SLXYrOvZ0b2AvV7vs7eVJ/dKD6URb52mdE8+PvaGxskvN7jcb9uc2kD+dPLNQLKpuvCOYtv9HoKUjSAPNQqOU3tKQceSayqcJGijcqm6U7cVP/NM+sYFblcerA1/25mfy/2QHIkJABJE4N4xCH/Y3MEorqb6aaA/f7AZWZmzW/8T1Cr86hMiLvzaFP6U0acbGqylgdsfJbWwXqLZyyxJ9NPan2u8axr1LP4l1t7is70z6RvWEy13VoTOUD0NinfGmJ4ZusFgh/zKLzWe22jfEE2FSY5GjG0mbJjhhg+Z8iKRenlrzeMbQSGMKjZxlgJCVjLN5e1EWUmT64tSfDma7IJPkrRE0N7HPytlYIxS4aKzjn4+TJ0y/kDSWzHVrSa9oDL4gGz4VjJH/YmQu5nZc5FVKylSi1oRTbqblmcvVtpYDBsKYNBQcdrm9ElcWKlfN1Z0LwuqnPC6LHR/+t7J6LSMoAD8RQ8+D/+Vk0PXK2S3NrOlSTDHmwkH5pw2rWpkARkJ5UQ19veeg51ob81qalwZuDnCdTeCb6Wcoh3L8BW1KyXn2SHOih73z5xaDUWfbjbdW/3nbKU6z/B6HiQA6ANbGD519EQcngQ/reGwUT7821cOSLooYu550GhQ6859nXpX9MiG7IUY80MF/yRjZPbQuX5cEpndhRjrZ0ilfWNVwSIplbbCVKroY42xnc17Kw7nyQerF9GfJSz5hOMtpmNZEGQv388mQSZB47QcWd9n0cFMusxDGpx18sLHdD6lIKSTLQumeMN31Vg0ntB8SToex/nAQaVAtFDhMQldd9HBqPFpI59pyu67gSRfNKKttCwt4onVLHSrEiYSefLwXF6M5otjdIXZNmw6yy1Sn+V91H9arXb3pDajWpnvuIYOm+CFhwnXu7gntR1H7/K7XWL0SbnpbS7FE6PGHYqukGMonJA1pnue4EGfgeJlNXksZiHGhxu8HeU9p/zRssavxunp8K6adWY8ZunavExZqbT7MY0E/+GSWNrQs12/Tj80h92Fa9Zqcx9IuYdT0bU7P2AmphCKXeFc2y7JonjQnsH09vjqtmlIUnWQbkeJcnS7cmRccTfpPEOGPQWRNtYu+TZ1e0edhh65HCG9c2gSN5KYlwL2p+z0CeHQ4XAHbWHGuJdlcamMOlvo92I6BsTCsgPCFi0oXiVHtl1Nnr9cniiobySQ2dzHJVRRUU99ugjZY29pdr23cWzZcHWAjmp9PXTHbjBC8yrui5fP0h+MR69QPu7PGxwQfsfD7B6xdcc3vKe8vDXIZlFuYbRU/mI4dcaogyvtLFVGlEWQs6ZZnB4u40slRfW0p2drF1yjFjfail1NXr9lc8gZjQt/0o7ORud2HNtByxorm0a9Y0aszbS9eam3XqBYJ8dJk5yFZZ3jCkeD1pUkJGZmncC6bJpk0sQmNgsVV4a5udiogGE8m5UnGx81RSvOTOhd/Ej8DEk8ZlRIrmlh3mHSkH73c+417sqUW9hagNgnceKqlN5rvYwUUzH66omFewqjFvVVKRMZA/I3W16V+a76tGaQSO/IGBNP3L9RclWanaK3rTpPUhHbwjzOPoGGv4od2ZSAt7DVi/r2dmfN/amR2xFiMo2SrSU2E/2l79835bEfDNcmvfpqY138OPhxXkbr49k8RwO1sv1xyfbHEovU2ecur4rE88g+krY7IPv7miuO7HE+gwIAJ4+Bu4uS/HDNOTuZW8Em9KI6Khbc1dDj30cGMzokZGKUf8bXpcZ1nuJPM30AoAAwv/27zDt//AQd7R+jNHRycjC/7uxkcrinCRrysHv/CZCQtj8NaW5mY+tgcmS4wx79pCDhRJC+D/fDh5PfBzvsnU8GEiz7h2A/fq/4T7Sf++3/5z98YE5CDxkA675/dBwqkDgZP4tzlPs+KNXDnvVnQahu/jLorxN52H6eESR6GwoAvQs+uIzQgmTEEBWAztH+6MCMIIFLIQr8g3csaFoOG7NzgaTlJBoAh6M9OBosIDSuoAMwmr6DMjnsdc4DwuQtdAjQkTkDQubDMQBKK3VQEoe/fOMAIcGBAcBspQ5u/GdBxu+ICcBgNg7pVHdCHv27b+pAs3TYvZobJEvnsAB4zMbBUWEHoTKPDcBujQ3K5vDxnQIgbDRxAPitscFx4gbh1Asd3I8fcx0NJAACJH4cQIQLNmgaD7tFS4CksRAOOHA3g//gHrZXlgHBjcIFEOxM/T32YQ9iBRDsfjzgd9g5Q36tcxEAMBofg1I8vJ8Eva1HQYfw454VHBk2EDIohADMnsdH0+EDoWMGLQY8hPqgAPv++x5ICYkQAfDaHYMjxAlCqBBqMGPI1pwgCCdSYgABTsfgaPGA0LoPNd4PX/UcTU0EhNo6jFDQ0QN9itqSALD7G4MSO/xpDehTtBtqkJ980AOOEwcIJ21SAA4z46NnC5RUOfQo4CbqP3CH/X0ZQOA4yQBofYwh33TSnQBgMAyGdI35QB79x89jQPNz2PD2PEh+JqEGgXqjDsrq3CkAdlddSPdpcVCD/PQjkqPhREDgjpEDCHPVBZ24w19HKINMnCe8mEd+RPL9GEA+WgAZQwEF8Ptsar8fxuGPCEC3jImUwO8wkAU3/xIg8x9JBSDUyvVoXHkQXCxq4LdYuYIm/rCWXgck8UGIxD/qy4Xvh3NYzn4NZDioNMC/52/6/bAOC8n1QYaFTwv8O1ajkN+E2c4AsBt8gvI+LOUG3XJGQg3yMz3793iHhdiHdxZzdzLoAPj9M8HlkBUkh1r0AKzml0fvlXhBMlgCJQR0O1rQvQwTAwCD7yWkCy4A8ug/+l4eDXIOBGQWapDvfS+PnhhhkInRPgsgxvcSHDleEHJt0EP+YHl5ND1REHrnGQFEWV6CI8gPQvAF9KBQLUghEDRaJgBBbpdHJ1UaJKnR8CFCl1rQ/SkxM4Awo8uj6cqC0L0HLyZ0hM+DboxYAMR4XB7NVgp0Nw4XIDz1o20okH/ZyTy6fmTICiDA3hLydmzPT/GOcLYEJXHYDxK0HcvCBkDtbPl99MPujqDtWCR2AHqHScg7dBG/Dg9jh24Gsshwdug4OAEYLBUhrdqHQB4dbIfusPceaIduAToE2Dt077kB2I39IO3Q8Z8D4Df2g3x6yqCAg62pQskDwOfhB3kPIgQKKFibKkvQYsBDyIgXgNm5D1JC9dBiwPNQFOQD4DHtg/ShmAoDDDxNFRJ+AF6/PkibKt4wQsHTVNmCAhPmpsoVAQB+qz7ImyojUMDB3lSRFQTg9+X7Hu6wTx1oU6X013CwN1WKzgMwGN9BusbwhADYje9A83PY+w20qeIENQicTZVbwgDsBnOQNlVGoQaBq6miLgIgzGAO0qZKLbyYCGiqbIoCv8+xDfKmyrgY8Du81CBvqnwSBxDqagZpU+WiBPBbXM0gbap0IxIf/qaKihTw71l9Qd5UuSwN/DuuW5DfhF1lANi9riBtqnyCGgS+psqcLAC/lRTkZZ+UCwDkPlCgHA67J4GWfVZ/GfTXZZ/DNkigZZ8mOQB6PybIVfhX5QHonJUg3WeVQBT4eyMC0KwcdggCrSmRKgAwOyuB48AMwuGyIgCb9xAojcOmOqBFnzKoAKBiAlrdm1cCoHTsgbS6J6cMwOzYA/lqClYBYPC0gbR8NA15dLDVvcMmKaATraQKwONpA/lT4pg6ALsDCyibw04noO+DVlCDwKW/x9cA4DNTgbRH6A4TEPh72GHfETFQbRzsaGDuBP9BPWzUAdpKatAEEOpw8j3yYb8L0JbdcS0A0bYgkF/i4toAjAYbkFaI06FDgKegSngJgNlbA9KCqgu0GPAQmoICDNYKsZIOAK+tBuQV4jdQg8FUIabXBRDgqAF5hTgBajyYK8RolwEEmWlA/vC8DQUmzBXiMahB4KoQm+gBcJhmQFohboYe5dcV4sMmEqAVYjF9AFq/DMj3mnwGAAyuFJCusWjIo/+qQnzYVgG0QrwFNQicFWLpqwDs3g2QVohzoAaBq0J84hqAMO8GSCvEwfBiIqBCXGkI/D4zBMgrxHnXgd9hUwB5hTjDCECoYQCkFWJyY+C3GAZAWiFORCQ+/BViElPg3ztFH/IKMY0Z8O8caA/5TVj0BgD7MfKQVogzoAaBr0L8whyA/5R2yGX3phYArEesQyq7b4QSAp73kPOWADynq0OqT02DAQbc6eqQv9eftgJgPFgdlNvh475B3+t9oEP48WB1yHeem9YADKeJHz1JnKBfFdgAsJ8m/j3M4XOpiUFg3v0A891B4t+HOnwKImgoLzsA/LHW4FJLCJJafQ8A/CGKoGM6fI4fFciYsn4a6KeHKH4f9PBBZadAgrLfBCA5EBAcXRIQuulewC9POzt63YAynj8qFnQ3puOHBnggIecNHHnQGRr6H/+qBCgB+pQAINj7jz/9fwEAAP//W5J0EHvNAAA="); err != nil { panic("add binary content to resource manager failed: " + err.Error()) } } diff --git a/cmd/gf/internal/packed/template-single.go b/cmd/gf/internal/packed/template-single.go index d8a8fee6bf5..c95abb8349e 100644 --- a/cmd/gf/internal/packed/template-single.go +++ b/cmd/gf/internal/packed/template-single.go @@ -3,7 +3,7 @@ package packed import "github.com/gogf/gf/v2/os/gres" func init() { - if err := gres.Add("H4sIAAAAAAAC/7SbBziV//vHH1v2XhnJyDHOQVbIiuyZEaGMY+TYOyEyskVERMnee6skKyOibCXZ2SJZ/6v/71s/Rxyj78915VxKr/t93/fneZ77+dz3R0UeBZUEwAQwgdMqNtrAri9a4BTgALW0gRk4QDnsza1MYVAI2NTcwcDBwc7c0NEBaq+hjgYgaVkKmL5Ta2pulYe0sYM722Rb5SGKCsoljmsYqACws6Mij4HZpcIlSA0AABkAAAcbpDrAoLmplbUd9LcxnmB5vLucOJJr9iRkq0y3UPBU0DhrSQOevZ6aWCXtsBqWsU6WvtLjDqrl7yDjNcmSmNUQS+m/ZIKh/f5ey9RZL3HFQd7GhiemcZaEDcmxXDgKZYsilRriuve9x4kZrb0cIUOUIGO9lAs7vvKs5FPE7zyKQ7thru+/xy2vo//yZ0Z+5pUnAAA5CP2h2McfRQMLqIk57L/eYC2t4Qc4L+Koqaio5GuodLK0y7Q1q7KwKHd+WbJfccTFs3FwQpMHpSSnMkWPP2CxrShH//5duuFusvhnpowKtAsBTBmV9bGuUxcy5HTB2+3DueLlYxXcyxH2clfUSFdWzhNFFtX66Fvxnfml/VYG2zNLAAACEWqn3Ee7mpS4pKIUWFHyt3g1TZu3zmxyrYoamLJtHE2y7LIaNi0QNcz2Vvm3srhyHE0Tn7HY2xTaNTHBsuysBWqf3mk0sYBALKXvepTfKqOYd7dA5HogqBlIv1eKeMQZXyUAABR2qQP+UEe8jzoDG/Pfun6Sdv/+wSTK/UkQMygMZn0o78+4nUXE+893sOl/wcWhijdnxAh8eqavkOjI4oviCopp2nmg0vvdKLSWn10kMNehdQxWbBq6G8Vudyf5Keg7S+abC4Obq/ftzYrJXQIiepMxGmkZ/M2ok1Z69WzynAOkxZd7X6n7Y83gJvBdG8wdsJTyLAxintPvw8bjxpEjaZCNfPqEfZ7nUTzHuTd2dF8XSrMEaR5rvXBmHuXJb965ICl6bxRUzlT7eDpe7myVgvfqSKD+TR+ziNXBU8Ogazc6+yg/4mosp7AxXvj8MSOXrKWIWp5EdjzRTF9crfJ5aoTI5PlfiXS8OP3gw89LBAlR+KkRhsuJ6wQZYDoE+WcSYG0FSne5cFA/VXhgtRCzh9xoJXYwMDDKWreNvxfj8zpDh36YRpU5OfTc0FCPq5spqfBFgGTGUmC4NrTYRT9vI0e7IxVkhpXWGI4eh8pUjrEgTy4skzOrLWL742rcKPlXhx3GdpevXy+oNb3AlTB9fB/Ps/a1vVtQ8mcf+9jFcslb5thXKLsWK8XnfEMXtvAf8Z9hY76v205beI3pwflreUTmP1jobl1cP/UrsEQ61LBMAAAmEEaBbJ8omFqDLa2Nf7v9IEI8Oo4Tx69njIR9AI07XMnUZIBtBRWP5XJ9aTq7TLl7YqSruRBoxbHOaNE9wkPba6PPaErGfx2TBmO093GwYUy1RjaR1EQBC/VDXB6IFP13I2ZXnsFmdsuK4gWcNsi00eII/8IMu+qLNvMzz6hvV/DY3CnlSU3ujbyR5vnpsWg/BUiQGPxx/v2M4rZxFHpXgWlzShzEDRaY7aAzL9rXyzZXvvT19Rdlk2sCm5GK/S8KBuhpsF2t2yjDAqoIebGVO2DYr4xob3d8ykqWuJLyIeWNbUV3x1dJzA+qjZ0RMbIuEqqvHgzUvFwOTaayT5rRn+0czVEsotnJVSnMtBi3MFsbvzUKDXVJ1fePW6o0z2+0pb0QCuMJcyBTexD3baXd8NOpZ0mNd1jZCE5rVtNeX143uHa6WHbre6Jf4KxNyyKf4A3bcUNDjyWqfnfWnKnKtR49uUU7jtWy6K7JO0nalgv51G/GgG9VbBvqmzi/Mpd6VnnKEgkA8FBPkDl7R8vfmcvulY3MlOnBWHD3DKw6Jzdey59EruB9h4X7lNB4rCSzl/KOn8bQ1lVS940P52E4WqLbrktf6HnZGm5jOROa3bCaHuiM96u+I93RLWri4D+fT3fhh+cdkXGdu/F+aBPIeDdt+Z7xXna4aRXVPxdKJDxSUY9qSrW8Yf2CZATnKxWBqIFHhat0zUTsRgHBwCVP/e93NDUjhJq+5ZRYZmMHycR/sOESqVWlQbe8Vkw5yM4kbCRqApOeDz83VZhP1lH6GmOWnv6bksgZdPCkUQs+3tVXQYI58eCqnm+MHv63T8XN+Lo5q571z8QUrPe/qFxLW56akn6HDY/5JswARczeGzfxi0BMJEvLCE41rt6SiybS0FNlW/Aak/DTkZrHrlwa7fhCdDPn3WrwBbq1CieeukxVRNekPVM2pAqWwpN+gr5Vddmd3d2C1THP1EBbgrVQ377lwszlUKd83ZJM0w+VaG0iL3KeCG4Fumk7ZRqYcD4dvh8cDo6W9MfXYOi2oo56bRjwQ3uE8JZq6dxmxZOpDu8CmZ4Xz4VnRfkCVF9v2mHKkNtb9ssTe1ZNrs06PC1ulLGgCIlQQw8nwzm/wbHMBPayQWN/SNggmPHxoxYLy1MNYQkbF73N1eTs6CUB53e6xolB4V5lVMYXNzddMnvTLnMY3b0GGeHRDT2Pbq34OMYtVz3+dRoruAksVuzvNgnjfLMtUZ9IzVz8bDmcDcOhqElIq+hDU9Cp1QBUKRjTwhV18yvpl7Zo1knXRHEuBC8mynvOO3fpGduUcZOfL6gioX9UTyuLpeX+7kqNhdVI2t3pxFfcTR71NT4wJSBBek6hQT/mixYhI5tj0XtSpdYMkKuHks9c/zmfZ4HXu9l9i1byItc97nzNfDYxe/9KaD9ZEQt4QS3+LFYIr7rTptDbFl6cUSJnvSTPBn3kzzei3mhESnehKkDDi/WTPjCVfsOU5eyTvKrg1T2Nrjv5vR5V+7GwFh3vUBhl3/2qrS4hI81b5+YpbcMwS10FvgkziLFRa36eTB5TQLvGOWJFjRW//vmblB7GAsMpDAKN5u/ZTOsFc9l9DWSqOn2Ua4GeibldqRcXgl3uyDrzaVxqlpgZyfHFnb823rJEXi1o8MYcdzpDIr+4JKo9hhaZbJk5A5tovIWKO6CJAu36JK3628jYMMUtvmD3zpoQcb5q6Cdt7JXRQYbyodM6zaVsRZJoDr5zTHRMC80WQlsNYX2aYSWECRVn6LcvbkKRPKqhGexWsMpZ624OemIl+1f9F8Fl3edxkbkMpGf7irrd5wKYmwIxi8U76/TwK5PpgoxdPvj3dSqvxVDwJ3IEp3etKpIVnMpUVncYsOi/S0SuqilPYxvs8hxzuGzoYa8E7TzlkhPlZGFCYIlreUKYjI/yU+i9twUBRhsckIJBlCZyD+qBtVy39vkz2ZFhEU/m7zJfzPeZgRS4nGkYqHfujlwloLhRVg1F8gk4F+fBLksSdB199u37h03FFf6RlBnTwcS5PjzD2QMhpxbWWUBDp1pJG1svG/vXKrZv00L8blD3pAV/VZmWyhUGYQcXyzeVyl687qfwjTuegZ2+dTsmwYLdq6euLT6vf6qHe3X4ljzrGV/OgJts6rzeHwMqzQTMounNO1+r3m0Jv0pd76C3OLO6xbFO9MGXelwtLNpR8O10K3OgAl0aiHvNJ2BRPTYzX6yRzBpp85ydaEnzs3uNmyieiVQ6RR8jQcNp8oP1D6B8kXUtSpin17sVy/pnYr1EX11mlxA198+blL9BWdspZS6B5OQ6ki5/7cJpN/lcu+QX6UtIN/Nb+TZAMOXEc9TpkTczxa4hudwuff0M0pC8s9B87nZt8p1atHgXEpZetgdxz9ocKxsl7e+Ql7cLRH4w5yNZYvwhsnkLpcrhgc51CLRcrKIlO4rrCf7guMQLMMhVkPU+h95SYErW26i5R8bYP75rR5fLdFViJk7gr8fI+ry8iErYmfIeiKe+6efsGrOKtnBuTc7us1P2J5KcrXBekbV+ztVmirGLwsx1iVqE46Ntp8YE5h7cH9dFdRVufNymjHGvvVX2ldZUTGgd2rfxS/fD3th/uUszGeGkMJ0s2+AxRAqgGy15XLscEBbMWfMwLcrVBwQqbpRP4CHCsPxc71osGKXUQLWa71qDpu7xg/e7moqYTxdO/ZtSzotNDEIVfLmzE2sZQq1x13BY6sodo0tuGe4M+vqX38J1I/yeK6TrK1SXlFKaCPrmkGwIofQWYqQ+W5vYgiSzfNZyeK3j4cuR0aZIzb4ZIihmdXZVkXzTI+F+dFsf6ksU/dyJWommJZ4sqMKr4g+qL3s49GbEyiPT+BpAo66NYFk9nK6rEMjlak9mu+SURUUzt1DW97BDgbPML1WiWrIrK7dPXIIRKRUTXeOqCnpp9bcW0jk6t6kamuknbU5P3n5Cs0q0NjP23yIkrpGsVaOhiBBQEFB/O2hLr5g3JJrLW2apyrZhQkiNB7sn7IFXg1qHc0tFuLBvuo3jfWdRfZy2PZguTxzpw4DTWP6M2flMBg9cvuy6xkXJYU7UOgJ0KVWqesxpDlwGwcvIt9+ijlik6WVWX1KWS+zKeewgTK7B2J1/7dYwm3uTU2UCmib7KWm2jQ1p923Vpev2k9vPkp25pfK4NclivROAGaeYm44uH8JPs9HA2CZxE4tt/bwxF+wnmSi+9rq+I/Wy4/4aekcM6PIIw6IYRn1gZC6dJ5yYc9ezgGE1iJ+5ZYN2qy/SxIGBzswQrdy2jEJFpUNTd7LXToX47tW2y68YfGD87zmCPcP1k54Ge/KF3pzgqvw8WHNTZawzEJs6qtlQWFc+1Gc+M8Utbt2jt4p1gJSDekxWfdZk5fpAiNqkfR0lSWMTP04AF3cthY/Y8HUki3ahvjfEgCK1yMvLL1KJiaforwDdtPhR/QEzOlT1khe3TPFdt9YAFalJlq8fCmsLKp0VRLTDdLhc6MQziJJtSKZ9RiOG/aqFLXAf3eIfFTXZdJ1xecHIoYQif7oqYE4vMu0CVZibOu+aay5/iBv6nM8guzKXecJWxjKRPFNqSRL/o9H6FvckyXtpmJDHnU1PskLmwrZ1e0PwAmJdfmyV7eD/qqZAbj7LSKcA4A4hohcMkn2qKTMDI4sTvFicOQAFMbK2MjE3BbsaWMJ+YyVDa5TYuEh8NtwDVd8NshU4bcuEszGyMmJh6b8sUA4mHWjsNb20OqtKwpi5/ijW2o9Jf1ifvnUKSfdd8NVPUxIBFqlnn9gFhLSEvM9/nSYze3nmZZrJeZCVuJuTXhWJv40d6BESproVkkuLM3A5+Wo7epDwWp4xVVHMN5Mqt0G6hIT6954zbeI53XI5bU5V/Ts9EnpkL6AvrzhzaAboisA4w/k6OYGEodh+Pbt4wyX0oM5XJi8+Gnzln3Kov0r/gO3yj+fKgbjzIUqLclvzNxI0WvnCM7tUJ1yLS7Z/v6nrSE2TDv8MC9KJgvbzG4cRzBxs+d9cwMKvZxFzEdQn8id+zl9TY68M+NEroYFVimYrtSjef9b2fLOfSWRhbCnW1kLhFkPSmuV4q9eyEANtfmCsI+b0zLAZsw1ymc+TWG6jbQM0JZAMvSjHTNhHZjNvcsUFYtXqttfpZoEhLEpWMRYCQjCOZRHlB3YJA3X4fclKFV+y7TS/kciYvpmmeqIgWB9erNru4Xk7+hoWEtjrM2FQ5Tb39vXba67PqY14qLwflcqjv/XEq9CSYjUdyYtS2arMcPcfOePj8rI6xQSDpo1uIJJpbJZ1+9EOaJY9k8FExS+UlVbi5UzfJGm7qUvQN6qx0TgiDcYHEHlYWddIAeFpJBI0XkuJCpl5R2lyIJGQ+GNsU7WYydD5Vfeb94LD8H68nLLq+HrlgVo0eURSlxBVOiTuW9dHpF+ZiCw0rj2PBAC9CDNBjSgTu7Pgo/Ex7DMfgYf+DmkXddS9W/RqdNqzU5OvCtKsyItFWR/L+cYbI4NDZ/vxSKU256MsC5Eq+0Zrgy8mvrAWplVGH21+2NmytWwneHqobgG98NGiNwGznT45psUj64j4IvES+i8o1eneOj4Zm0nmvmJSSK1U5TU7WJrIaWQhaEbmDYSl6biRhmLoy1V9dWX03YHdNzFDQ04ZgSa+TC9n+uiIS9BsQJROczOnD4tbxlwVB0s1a5akRssipURH4YNwZ+7S5LiwERiujZ7m9qAh2myUbcvgw1Tn8vQjxeqeu1FBoinfrpqW2lvcWvE+vnwEd5g08NM5uhv9BIpMD4KfeandpAgzmXKJVvKBOvVEkKlHeL/Bk5twx+XJK7lsIG6+Tj5Opom7pb3CMv2G57lmI4RY1MkMTdJ0Uzm9jF3UgMfAi3pH6OppdbcS31b+dC8NB8dX42mvw8gVakSsQP5jy2ZYNig1z7UZJvINyXisiMfsIxlNOEp8q5rNqBt9opB3/LYbzxcXdH9Aj5CUfcyQpvDybeI75LKM9Atho/zJ8aT4WKmzYGYWLM3nSIZMK6tvn02NMFRTNeakJS8/TKsimzfB66HAm7JzalWynl/EkMm+o+8pXLXluFR+m2KLL8C/pmZURNf5S/dDlJyc7HTohbHbGJl8Fmt8YZwhcvrGHp/OJPNCrIuSTgu/qyq3IiL90phePvgYs6pxMvmR4VA35Xg0SiBHl5o6y1fZxY0hxs0a+1k9bbBNkG6mAPOX6SJx7FP6dd66GnHe5jIkKz/CivqW7Ta/cSlxaLIOdTe8CdwK6sG2iyI3vROIpZlUYH4vrT7VLuhR12NZt42xLyNrdwc2py+uPlCev7dORsrnCwNUUr7jRSxVVQ26Xj3lWc4a0zpv+lGC9CU+P4HUwgRvLy8Wxi0mre5xCxndIYHJrtsOQgFhFU7rypAYIrROD0JK3/WzVHPk97HrShY5szreeetQmcSbNCnmB93RlmxjW/7om+jBs3hWsPz6l2cQ7XTSnnpdIS0dndj3YztVD5f59HJyiKIIoxyLyaMeO2Zj3+wp052k5MXcvutwOeg5eWTD5APMuR3kX9ffm5lUGg4UAGDGQPQk2m832NzKAWpnZQA7wcYlNQIcxMjS+AQPOIZDkD//7N43cwgXtxjkJPB9+y6PwiHiLlsnLW4FY8dqhEppsbMGrYVUyn3K5jixvh19dgiP/zjjeFtXXFiZ4M4AGmqiKchIH5u/Q43levqIxRU1LFJDIesXwZA+PyKy02Ru68bkTpSWKvNUmHG4Ex8+rHGk9H9a3vzIhrv8SLcOn1dNxoyB19iuec5MV02i1FQhg+WCjKtttb1ohYwNvlu6K/sFoUc7MvQJeg2nxKDksiFq9+jeo8UPY+JT28aKvR8vr1XCJV33HixL5F8iZj/tOjvANviGK6xR6NV0+dk6vRcbOfgoZsboxmDhl3j0rAprBK1rCVn+4FiIbqkGW1YDg+jX84PfPrdmwHArrllRJs23XYmf8IGEqtK1e77SkraXEDHQw9agHt68dY9nRiRoON614WEi3TdOpxyhPP7srssY9EYDMXcMIyR0pUG5duGeKL+WUds9ZwF5JADgQ0aUdzqESbK2snewP0HqQYdT//nYvQBYZRTalRSUNWTa37KBQePIv2uDl+Q4raQAAOAjXMIMhxh1sLOGwaB2J7g4QEcjn3iXn/s4/H12/dtrTyFzEfiOuGW64JZnvIzMP+tS7GVLw3/XKAHGLFNJ7taxs1338PzqC/BYsHwBukU47WCOjmNkx+lcFOn2OGFS/+VT4oJX3e84dp4qqmB4PjOkS497l8baAirneT/1ITu+NqnUUKzI7wIhQ0XGDwYAAB7CAoHv+E5dt4I6wztWc7NOjAD1U/8Gyd2gG+SdTzFkmCakCb42pF+Xn1m+3zVrq08Y3FHlz6hIeybBJDOMcmJh5SP9RMfkmYWI5PxmQAnlMl6zACOlTeWIxnWsMO/xGt+MBqwqlFV/hgTn2QLkoTEK6JxoLzaY6BmRL5cFF8ysZLUW3JUx7eigv9UXG3yhsHmUl5Gu3hZvTjrHXN64jN2MR7uTIsWBN1czdXjcd1I4hdZt/et026pz+s2Pz7OyuLoy7ykyjYzkJZDr3Hv++5b+SqSQqB4AgGCEERM6QcScuK7/2YAIqVXy5SSQ6mnVCtbrfGh6ehONaPSRr3WI4yRDNJ4ChoThpjNKpc2IIXdzW8Vaq/v3SYaRx2qGd2wfaZNYpCt8yi7O8nrzWnV+Jg5beL3JdsF2YSCSLjmxSRplh0CuK/5WSiP3eEzT2vKksu9HKhSyG1ftXwp+ShnLfgW6X81Hdh0vFa9yNG+4RHQnUAJbv7ThsYx0UL1O+mbIG1LZLwJkQYkqUj2dhWqdpiMZ77coSnOfcduDv1hxs6boxhWF8UevbN9gV5eolPODfMf7Fb+KBQyLdgAAaJFO/AwzNrD+l7o/u5H/31C2gEJtfrN/XyU//zvaobcWWkQGYNam5kYnUH3uUOj/VreltTEU9m/r/n/oX+umP9yE8UkWCutRuH+tnulwK1ArB3MH1xN4AD4q+6+9QFhz2BgYWUCN/+2a4z/Ufz72qzmAzgyQ7h3glyPL6DffEx9acZxBZNIeaudkbgT9tz35B3vMJPxphHwfI5YG5lZwFXk7V+4rTpyGxQoRqW4QpT57DRvnGXQy8B2Jaaqghgwdcg2JQZoo0t4X82k7MUscXBURkkjJwY7cE08vVEXX57YwjeuEs62ZqTfQU261JQkTBFIpPkIfxJnWuTM+WndxeKegvanvQ15Q4k2wHjbSk+s8L5Zv2+Cb2U195gpo6EryuDKa8PWJodA1d8wFH63fqbmvALl8HwCALuC4r0eWBlbmJlB7hxNUgHQIcP9s2J0g0WyHU/fdDQwOq1Wq48Txm7+/hKda/tJAsbSWb+w1wwKW1agJWhleQFVAmfSs3+tT9698Vd7eWq+Nl7LDbWeaww7utZEF22kNkV7TKtDNhwkm/KC3/OFlwyBggiyeY8VpBsV5fTX/w41o07pmN+uHIqbxZ/Ctz0zcyL4rzDMflRb1ni3ZZ8x/SD4rStPzqqNuB9Nnh4fvAl1ir/FiQmSYKbAly2iIXKNvJLd+z/vUuy2imYWJzKGuO8qwyhmZ7WlkFiPiXTCqtZWsEsMEc96YeFi3uMKq5zE4FxpifbsId6NGVPhCLeuq0K88p3tz/hgBAMAa6cSJMYbawKxd/6WCfw8VYuFo72BtaX4LegI++Dh8iKGB/UluIyLHNvLP31pCrRzgF5xDeI0SKheOz4ZwffXLU3pxeAERn1lvRRbhYTcGGKL0l0mPmJaw9YLOnU9kTgUrC+s+gqrMe6x5KOUZ9gRjzPVHvyHLsOuI8rZDDmY1Re3JJbltVxBnh/wgQdudmVPck2G4onWiVi8l3DSe+FO2blLIvGEKCyTs9Dsk7KzlrgGc+Hc0nwmQN0MfsbZ5v3aBBabl7Zx9FtE7jaw2tTpP6eTVEjedkvGAaVRf1GzxgcjvF+DyEGaBAgAAbBEW3eLHj9KvHw0czK2t4APF/qYA9xUnAVrHduoCMpecfzXyxRpbkcmWRb0v9md9p0Ay68kP+UU6H6eCuof8eT0Ig6biEq/O05qXGXkYfNFmdZQdsc0RNmOlsXKDLDBeuZqf48Q3ec/UKkuhthOfbBN09sXv22A9ZnODyc/LAzjuK8Uh3v3zgIH3y7iNC6uOE8d3RC+tAw15SrN4Fdkreu6VK+qVRqLCpnV5iTIr0XcYyjXPCZ/pkItYrWS4k3qcDdURE1LTUiQ1nKu8JFDg1vWa5+ZHKjOBN+uOQdSmClpYH00NTVbziw0Vv3+7mit/E9Y05j8eicvzoDgcO31jB8/9dyaLvTrybgEAkI7wouI+lq/WTlA7mIGr/QmuXsETGYIYQ52gMGubE1zJsn9l8J9HiKWBDXxOhUP+/6JG3xCuT1txZqexkw+RlLImJEZuDyOaP8tIS0vI1+MqbBR77dZ9ETUOn9Fh91QizLCS6pTvr9ugXHgwBTyWeN8bEXGFzdBkIg1wXlHb4OD0Nn+Pdbvcd1uAM5nunXk74N8BxXn0acpggM8zsz/ZRv4tbB7Vs5FDT/Qyh3wYJFT1x7tzt/hLPoheVVbHUyUQzhpu5+gewvzgbPvidz1zrnCJMBkAgB8IYyT3dzE66M5n3Fbwc+GjdgxdtxUlkNN6u+U3d/aCdzpT0FXUH2tMaM4ZzIt4c4wrzUZma1gBFGXL+vrT1+rvdv4YmNQOBsUldyOXU7BFkClGtKh8PN2CmasluPXDK6MnZ+hKt2sw6OWS5SXfgB/KSLx9O9LTDZE5jed+eS1WOHXBEQCAIoReK/6d14juZK2KN33ECKQX3R8nQW4EVHVoYWqjFUIGXqR2bD/JorZREsUZ3V5L4Nm6xJ/D5LfFk6ed+Em9JfP0/PUGncZGnjpokl4LUd1azusSsiS8LFPlfJlLN2hjG7VxeHzeMsqPyi+Jd7/uEv3aUyXApyg6eXr4vbdTN9uz7xxBxlcjfSjIsu1olSRXsH5FYzOlaTMQAICsk1dpxtZGFkfY/Tvaq90eKkTy/z/gJrHtsJfWNJqalRVAH5RbQU2t8iXcH4o+fVZLBX9S0zwDCG95X6J2v019SXhrK91K6GHW9RiJcs/wsiBTAr+2HwFoaLqhYDCWVEb9eopUc8YklvoTwW+1mSsr8mr22Cv23MtybJ+J7a+0KqzYE59fJsgUE859oiLq+yV4cJMEbRaLB5S5EXqjl5WFBdVfAN1XZcjkavgr4aaxr9hYZ/L5kX5fW0lWYeNPAQDQRj7uC8neCPznA2xvtmuau1v5TWuXshx7+6fPapqYzU3smv8ZR29i15TJkVEEc8gqqsrIKbZA5DRkmpXblTjUZFjbWmU7R5FRxP5b7xepLV4CAEAMYeppEEk05xKwOkHimQ9j/k92I35bsLGzdrA2dDQ5gXKeo3Ah4J/SOcxNOKygRlB7ewM715P6sd/blh3U3trRzgj6L71t/cJBbBwNYUfYFfuTyng4FWLmYHmSjSuOI6L/esEwH8GQDczR1Pwk6x1yZPhf+8FyBFN/sYDYj4GHGNmfpMXFe0wTfx0y8HEMmlsamJ7knZH/2Eb+2i+245i8af8v3Q0RWPif3NV/83/9w79UiPzB/Wv1+20MOjqYw062q3zmYNpfK8X/k41AIRIyCcp/Ne4+QkgLnPr9e8leP78f8ZziXujuc3xUcFDbA6B7ziLuBe4+XEcBBxRHAg4/DLgXt/s0HCUcbmsf3J/n8/7L2/8M3X++CIBZ8Thk4JATdQeTKOFIY/uT/ui1w3u6+7jYWThPeVGA45yoQySUGk6oMSpw1LNn8Fp3n8BigtNadggSkdz/sHefESKDY9egAYed6NoL2z0iCw9zxgAOO2SEKJAkcIGsJwAOm7GF17V7dPQMnC4CQuDoM7Z7sbvnIOGxUkTA0adQ92J3j3dRw2HfEgNHG6lEFEsKuFgqkwNHmRI76hpPQIDbMyUG7/TuYSQGOKcXD0HunRJDJJYOTmw0JXCM0SZ4vbsnjkBwer8eTt1ntAmRagY41QZUwDGnmA4mg+DIVUcjH3Jn3T38ww0XmdOngb+ZYtpraPfMDB+coYXjG9o7WbTX2O4BEyE4Y2dpgH9lKOfoF5khLXDUMRZ4J3ZXTfAPkpJDkH+WYojk0sLJJaMDjj7BcrDgc3CCLQ6F/o3kdkT0vcMrR5XMcAY49vAKIsn0cJL9DqcbH21lsMKpHj4K93jCmeCES9IDxx5ZOVg8GE78k6Oyj+cA/GME6yxwjGkVeOm7x0jgHyM3DqfuM62CSPUZONVdiPh/jqYcHHF42awMwAlGU/byd49wkMPxw/bh751KOXr1Y8UIHGUI5KgroQYB7s8hEHiXd08zsMG5TMwEnGgI5Oi6NZmBY8xIHLWcyD6cuu+MxMF8MBwf5xxw8hkJ+ODvngQQgX8vP7aRAzuFe43ubtCLwxl9yAL8iyMHe+3ubpbDlzKOIOBfGQZAlENu+GKWFfi7lvzBhgThDL05kaF9WvLwsdzdepaFi6UQG/A/aMnvtb+7CSwHZ/86O/C/aHfvFbC776oIJ0CDA/gfdZ6PfmMzAgPH6PfCe7a78wlfElUcTt2v3/vHQ25X33L3Q3TWqwoCnKCdiigsNHBh0ecEjtwLPfjBzwwXlMLDmH9T3JJwAcdqgx4smgdONOwoXERt0KOXGoP7mNqngXXUlc3GDRyjA3owlRGO6nU4dW8H9OBQc8CFevCI6OMtE2Y4+VLngeM3Pw92AALnQNKR4cdzgQXOBVwe4CR9z4Px7HB42DHwe/qeB8eJF36T8pgmjhct+BJQjBc4ecvzYIf44RxKObaR47nEBucSBR9wwm7nUW96t45n4W/u29OITO3T6DzqpoQEP3CSRici4eRwwtP3MfBnj/NgufDtgNWDaccTib9L5I64mgCAoL2Jhv7z95QBZeAtNQDECPz86f8CAAD//3YzSdl9VQAA"); err != nil { + if err := gres.Add("H4sIAAAAAAAC/7SbBziV//vHH0Kyt8jMyDHOQTIiq2TvlYwyjnnsY4eUkS00RJRQNpGtkr2JbAplbzKy/lf/37d+jjhG35/ryrmUXvf7vu/P8zz387nvj5LsCTQSABPABIKl4FrAji8a4BQAh1rawPThUA57MysTGBQCNjGD68PhdmYGDnCovboaOoBCmXTJ5KNKTW2DLKSRHdzaKN0gC5GXU3zjsHISDQC2t5VkT2K2KXFdpAIAgAwAgP0NUu5j0MzEytoO+tsYT5As3l1OnCsr9iRky0yuJ/CU0DnLSP1fVIyPLpO2WA1IWSdIqna6g8r4WsguGKeKT6uLJvZcNj6p9ele/fhZLzH5vgvVVc9Moi0JqxKiuHDk8ueFi9TFdO7fGSFmtPZygPRTgIx0EwW2fWRZyceJP3rkhrTDXD6tRi+uYfzyZ1J28oMnAADpSP05vYc/8voWUGMz2H+9wVpYwfd3msdRUVJSylJXamVpkmqsVWZhUWz9umC/5ICLZwN3RJcFJSYkMT0ciWSxLSzAWF2VrLqbIDbElFyILuDPlFxUGeUyLpAsowPeahrIECv4Vsi9GG4vo6pCurR0nigip8zbyk4hSc+KlxdU2gcTBX55oT/TnOkEAEAiUi8o9vBCRULsirwEWP7KbzdUNGyandhkGuTVMaUbOWqk2aXVbeohKphNDbLN0rgyHDWjQ1jsjXJNGphgaXbWbJUvH9VrWEAglryPnYrNiifM2ushMp0QtGSU32tGLJzORwEAALkd6oA/1BHvoU7fxuy3rp+knb+/P4libxLEFAqDWR/I+zNuZ5Hx/vMdbPJfcG6IvPmkKIF354QqyXVpfBHci6Iadh5o9L43X1vLTs8TmF2ncQiSr+m/+4Dd7nbCc9AqS0qdQN/G8n1701xyZ//wroST1TQMfqZU8UtdujaZTv6SYotdH9T8sCZxY3m1+zJ6LSU8Xwcyz+h1Y+Nx48iQVElHPH/GPsvzJIbjXJ0d7dRcXupF6qea75yYh3myarcFrojcGwYVMJU9nYiROVssd2d5MEDP3Ns0fLnv1ABI+2ZrN8VnXPXFRDZGgaHPyRlk9TlUsiTSI3GmemIqRW+TwoXHzv9KpMOliciOnxcLCrLwUyENlyPXMTLAdADyzyTAGrMV7nLhoH0p9MCqJ2YPvtlADNfXN0xds42599i7Ivk6/QC1MnNCyLn+/k4XNxNSoUsAyaQl/0BZSK6zXuZ6ulZLEsgU62V1GEY0GlPByTlZciGp9GktYdsf16KHyafg24xNzlNTAio173DFTZ7ex/Msq7B3C0wY8raPmi+44mqGrUrRNl8kNuMTMreJ/4SPjo35vk4TzWttpsjz2plEZj9YaF0vrZ36FVii61SwFAAARpFGgWyPKJhYgy2tjX67HRku9jCaE8e38xsJey86d5iCiXEv2xIaHsvVyrxX7FIF7nERLmaCoCWHcsN593APLa/1bsNxKb81TOqTw11Pgwwel6inEUmMZrNQPcLlgUjQrxoyu/D01bJbFubO4TRCJgznB/nmJtmV3zWa0b2gulXIY3M7jycpoSvi5kvPL09Fek6DLhKDP89+mpTfMnqA0ZZtUpsYDXGDBaTBr8+KdHexzRQsTFV8VTTW5t+IkO95l91LT43tYt1IEepfTHgBW7EFhv3BkOZWy5fUBHHVxI7EOtvC9papK5gdytWt4Y+lncWVP0T2lr5fDEmgtI+f1JtuHU6Xz6HezlB6nWIxYmG6MuI6DA1xTtLzi14oMsuqtqURCIHxhMLJVCKjvy81GXw59SK++jYrG8EZjRKaG4tr+tpncqU3V+N8A6Zt6ud5L960HTEw8Fig7HFnTR8vWunUlZm341jOf9g2djtey3Iui6ruG/C9mG1dbQPnV+aSziqOW6IAAB7aMTJn72D5O3NpXdIRKVKdJ+fcPQOKz8mMlPHFk8vduc3CfUpwJOoKs5fitq96/+Y1Uvf1jvMwHE2RLZeFr/QX2KpuYTkRmt60muhtjfEtuS3Z0i5iDPebzaIV+OF5W3jk+t0YX/RRVDxzW94XF67Cza0e9MyEEAkNFlaimVAurlu/IxnEmaIkENH3KHSRLB2NWs8m6L3sqbd6W0MjXLDme/obyzTsQKmYDhsu4TJlagxL7VyKPnYmIUMRY5jkbNi58ddZZC15FSen6em/KwjTYYDHDOvx8a59CLyYHgMu7vzO6OF361T0pI+bk/JZvxTMi5V+lxTLaAqSEl/dZsNjNofpnxC1v4Mb95X/cQRL/SBOCa7ugrMGSv9zRVvwCpPQ88HSpy5c6k34grST591K8fnbNV+PPnceL3xY+vKFogFlkASe5DOMzeKr7uzuFqwOmSb6WuKsr/Xs6wUmr4Y4Zum8STHpKEJvFH6X/uziZoCblmOKvjHn84H7QWHgh1f88NUZ2q2oHlQY+P/QGiR0Vc6b2Sh8Nt5yJ1uq891boWkRXn/lig07TClye8seWWLP4rGVafjz3Gopi9PB4SoYYWQ459c5FpnAXjbo7I8Iqy4mf/6sycLyXF1I3MZZd2M5Ie3hAr/TRx2juMAwr3xKo0sbG84pXS+vchje1YYM8uiEnMewln/62C1DLabiJSu4Biya6+c2BuOs2xKvjKNizn2xGMZ2Ep5TI6iZ01ETeGrZH00CxjSnqmam+uryJvUa6YoIjkDQfJys56xTm66RTT43+fnsYhL6J5U00lia7h9VSy2sBl/enYj7wF3jUVnqDVMAYiVn5Kr0Hn/VJGRkc8j5RKrQkAxy8VDwnuk55/0i4EY7u0/OUmbEmsftqZQXo9P3VUN6yHJYwHMqMWexgi+oOW4INtdfwBkmctKN96zSQx26+aBOPUKyDU0OGparF9/BlPcdU5qz+8o1Oa/2CQydsdVKNK2nQpq0F/pDKbrvF2+2CRpquJ6bpbANxcxz4f8uxCDKRqUxNJbwTQ5dm3PQigorZm3ou4TuyTmGUycJ1GtX05jWsmfSuqvIlK93U6wEeMZltCVdmgtyvi3txKt+uVZ8cjDdB3dWe6R+gbzkon6dGe5EsnhW7psHTY9pUMkWmZOxiUbqKbn9a06j3xijUWuOiAqV3+QNcm8tDRbjLYF+0cJeGu5jKOg/c702jy3nCjrcZ4aJlmmu1kJwsyq0WyP0DWFsIR391qUNKIpHCTSZ3QpWNG3dzkFPrGD/oecSOL/9PC4ql77kdHdOu/uMP3NNAGauWGu5Ln5RAm2gkXOHX3er4srj03xxHEGv2pblybJPpSiqwXsteu4SkStryFLbBjm/xRzI73/UJU4zS7HgSDH2OjbgjUtBbKiUt+Jz6L3mbH/DdQ5Idt+JGnIPqt6VDLemWbq0iNDwZ7N3mS9leU9Csp3pqnorndojlglO38wvgaJ4+5+L9mCXJgm8gTHd/OlRTW6hXwRF8kQQcYY3z0Bab/CpuTUWUP+pBtLqhqtGfmXyTVs0EN+bVJ0vg6aUJiQyhEDYQbmyNXnSl274yn3njmFgp2/Yehxrwe7VWd4Yk9kz3sm9POAqy0rnw+lvzqZ24c5n/yJTftOH9GatFcp368OuUVXCdecnlzc51og6fKhGVEIfOlxsnmhgDpCjfQniXvH2n1eLSskSrSazRtk4ZyfypvbFveqNE55xlNdzPkeABl7K9lVGQnkjyusVMM+stcvn90xGeYl8uMouLmLmlzkme5OirFXCTBzF0WXwlay2wBk32Qy7hHevFlDMsxp410EwxbhzVK8izFNEtVGcb+VVvIBUJWzP1Z67VZZwuww9xpmEpYstMvpFo0NR9RX72+QFTfwRHWa8JAuMP4Q3XE8UwyOv34BAC0QL69MecD3D7xsRfwcGuVxkvc+huxCQmNr8YOaJEfaPVa2HBVJtRZhxo/hrj6W9319CI2xN/ATEUJn7Ork8XkafO7ciYzfkmPaFJH0z7ILwSg/ncu3pb5eEmMvjNAlHhhtPfeOfibw/ooPmIlT9tFHx5L2mBukPmuOPQ8rRv49cvh9aZ//1LvVYuKPcRIJ0lUc/KYBhuOChfdU/NIiz9NHLBy7eIFButWwsD9FJy6FKl9yLDxSqKJezXErR1Tx+XFhVURL1bsOprMvjvFTDIFjImzE9upIs2BCtjcNSXuDw8I2rwXafj1+BK64b4WqGoI6PYHl8Yl4c6Ds8wQBCcUeQkepsWVw9itTiWcuBlZZH7weHayI0uieJoJglacU5sjVPhHowbL2pLp/u4Y7TjDN548mCJrQsFlly1QPelRwli0rtow99oD2IZfVooryQP4OrKYHtsmMqJfXMXH73oxY5znzfJPGSK22pGd1i4owoSZgY6teUMPJKvteTztC6jZdSTzxrdHzW/AXdKs7a1Mhvk5C49EqZCvXpcH45frXmPlt6+cx+kYwL+ZbKbOvGhFR4sHtCHnilaOU4rkpCr7snGjk+teZURmvZg2kzxVA6eh2/ZU2ank9h8MDlTSuvnr8ywIlWToAhoUxZiTnBgctw8SrqrWa0QYuXuikllxVl4trSn8KFyNUZ27O0XQfY3Gsci2LRNdhPSbKtr0u6bykv3LAf23qR4MQtkcmtQRZ1JxaYdHxs7uDcEXaGjRrGNoYbl2vrewdzzn6M6fRUl8tHUi877qmQ26JAm0co1ukBtEhDM8lMobj0u57ZDMuBfMz16zSb3RHGcAZaUwP0Atv800pKLRo6Y112SsR3rzVe/cDgDeP7xBHkGaYX/zzIkzfEfJSraKiv1FzpW2sANtWDWgMhHdkQ79mURLfoNY+uYtZeUg6qb9Jq08ZLN3qDVcbsyylIqmv4cPy5uMtOe4sO3ECxaBLsriMG5KmE3199l0RMPE6vCrTT4D/o8Z+8Tll55dKmCb7L5gqgJDHGMtXxuiy7yElOWCv0OpczrVgyUYINyYT3cPiAb4mQBe4TV75hEeMNl0nnd4wcCidkzxT7z+hGvBSgDHVTu7DiksEX7IYx493HrshlFruZvEgky5T0Jp7vyXBlvXv8lXsvMSFPW2uepQbPhG7pdAXj+Uc5/9jM38b/VU2B3LwXUU4BwG1CZC8YJHtUU6b6hhbHeLGg2wcFMbS2MjYzAbvoW8J+Y6+ElCqwcZF4r7sHKH/sY8t23JIKY2NkZcTC0nufrRhE2lvdZXJ5eVqZhDFl7UmUtS+T3oAefcM4is7HoGtfxsX9LZLOPrPzD64P/pRV8VJq+urk+5fG50FWYm6OusUkfjZ2oCcomGpWKM71TsDVhGtNGIFCK5lGlDmPvxsXu/XRxsZWfvKcbBRLb5dJb3Qs7tnuFNclewd9r+rEoeGvIwzjDONt5QRi+6N6dO1iDBYwAls/GL/7rD/FNw6vvEYfyXb1x1vFANzZYIV5mc3Zm7HqDbxhKW3Koy65b7Z+v6lfl5ggHfgZFpRjBe3nNw5DmBnY8r+5gIXdSCXmIqiM44sbylpRYS/y/9Elro6Vh24rMS/Wc9b2fK2vccTrqDyszbnXmwzxK5YjDV6Lggw0WQFRDpgTkwOmzDao+d7PorgNt/TRFUBS9CIck6GfmU3vkMvPESuXNFa8Mg0IZlGwemzBLwjjWBRWjLSL7S3H705QKPyaZqfxnUTKpG6C8pncxcqwXOUmD89bD7WxUMBeQ4SBRVvcWzdurbi8pTLkobzzJE8Wo9kTr1BTgtVkMPOB0mZRsrvfIJ238/uSROOT1I20vRFM36ZZt55sg6bZUxiMlXxDWGnE3092j5E2mTgHfqf8NhxNpM4YCZGF5bcNZhOeQSFBv2ApXig16yBJDsQREn+OqikRNe4/v+xufi8oFO/H+3GrlinVSJWH5OHxbYKUryDR39s+o/zKRMRro7LzKADQhTQTVMgysTML3uqfQ4d4CTz0tklVQ2SulBIkh6Ytw+GDXar52D20DxQSxRW4UcirHadPkUpszD4wfI1SNDV/syq2+TMfTei5zdbV+rlvWy5cUXiz+jYnzJiMmrpOOnMJnPP23zJw8X+vjneHqm/AE/0jncBzBpsKVf8ssUlvDfeOuH552re4z7jTuE/UJIxhf7snW5shDMF+hVPRl7M9BKUjDejlUFN4xWR0ndRAS0tBnI0lDaxfmeNA1LGurVenQeetFWpd0z5JMCyiZ16VfvnL1XaTa/Hik/gPzSQ0ZP15bdeKoE01MiN+fM6PXt2Jc78tfZmnVQnTHw/LUp8nhvmFGbcGo2lv+IhOTswkduTAOqWphlZgwPtrm+TGaPW+W4yuaurjlDdSVSE5riXPSAnIhz3Fiwm7CV9gY0/NeXq9EXujGT0JCya7UvtIEvY98tMwhWq+3xmw/rxQDNAnmj+qwcLEju5VKQ+b6KvI1jaTteGjCYm/5y8++Lll3fmOY0WyHUH11V4cJnIsj63IrwXSakxQklL6b+mv4rBle+89r5OYx5Aiaem/hH9uPXTOnCqPJqJJL3bmekmci46hc0JzN71gv27w58tyWEWlrUvLnfPDQ/qrvfyUcKdYN093+pcOAnMB8FppI506jsd16Ru9Qu/ZKd0frr31y+oQetcYnjkvOjtc5C8fRvv8vqsb4xTti0fmAQ66iY/vo6md0X/DqtyqPN9ZrLXqNtoDgQpU48pYxt/LTm3GO2VQ4itQzNpZmEVwZmyZ5mXbaOXYpGEkwUNmLc0QOGirclKguG6BWLT2AUuLMtGQWbb/wLMHtybDZ6y4PFbdZ/neueJf+tYmaOAQiBUtzgsUcNlh2873624Jxd8WuUUaZLLSZv0c64vfmTH4l2aLZ6Ss+K5MfDGvSSveWgktmfGWUEv66axvnDORy/ZqshqwxchxMcmKdrp1+m2wn5Z/hb2CUAOjonLRzVGU87M8mWlb4I2lF4EjT0u3HSbGsAnNK524PjcFf0poS1n1XFkYSEp9o26gYvwRe7oy4Rz1ZFDPCgetax21+KbYxeeVReQ5VQUshH3b6L+uue1iz1T6EwBAeBLZ02evvWAzKzjUzkofdozNSiokOIihpdExHmoMByB//tm5VwYPE7Po4yTwaf6YeRoefpetlQa3kLFlOVwpL9dJncZCIvE+RW20aPe2HjuEx2+EcaSxLTo0/+J2LzpanAnIUA+br0WF5carQQtVFSxSA0Hrd0GQbl8isjNkbmtG5I4UlkqzlJjRuKMdHSsciT1fFjc+s+EuPtEpx7+gImXKcMHIrnbGVEdFPM9ELplFQMrFtsRepFDKBt/tlQu7gOCTbSn6WN2qU6JQculglXu0n9BjBjDxqWyjRD+NFJQp4JKu3enLj+NbIGY/4zLdy9ZXxxVaLfhhouBsue679XT8E6ZGGEZgofd49KxyKwQNK7GpfuAoiE6eOltqFYPI1Pm+70MNyTDcQm0rivjZRtWYUW9IiDJtk+cHTUl7cWF9XWx1qoEN13s8k8KBAzEuVY/iaL9zOqYLZvKltV09SW/Y+/i2Qbi4jiQowy7M88SvZdR4z4lfFgUAeFGR5Z0WaZKsrezh9sdIPehg6j8fOxcAq5Rck4KcorpUUzMbGDSC+rseeE+O00AKAAA+0iXMcIBRuJ01DAa1O8bFAToc+dg7+9xH4e+x099UdgqVi8Bn0C3FGbcg+X1E1lnnXC9bar67hrEwZqkicreW7a3yR+eX34G/BclmY1iE0fSlX3eIaDmTcUKyKVqI1G/xlNjFa+63HVpP5RQyvJ3s16HHvUttbQGV8byf9IgdX4tUoj9K+HdRkKwk5QsDAAAPaVHAe3SnblhBnRAdKzUvFyVA+9KzTnI38CZ56/OTUkyjkgRTVa9uyE4u3m+bttUjDGop9mOUp6GLNU4JpRidW/pMP9oyRjcXnpBVCyicuIpXy89IYVM0qH4DK/TOSKlPchVW8YllP4ZYp+ls1P5vp6EzIl3YYKIXRD5cFlww0zfLZeC25AkHuN5md1SQwOva4QuMtJW2eDOS6WayRvnspjxaracT4RcyNJIGRnzGhBJp3NamJhqXnV6Zf36bmsrVlnJPnmlwMDOW/Pq9t6i/IvZB+DVRJQAAQUgjJniMiDly3fiz6RBcpuDDSSDR2aAZpNv6yOTMBjrR8BMf62CHMYaHeHInxQ02nE4U2QwacNc2Fq40uK+OMQw+VTG4bftEi8TildyXtNxUr7oK5dnJaGyhtRrbOdu53gjahLgayRPbBDJtMa6J1dwjj2tWFscUfT5TniC7ec3+/cUvid/SPoDul/CS3cBLwisazhx4I7IdII6tl1f1VEoysPL6q43gOlLpr/xkgXFKEp2tr1VaTQaTP22ezst4wW0P/mrFzZqoE50Tyvdwaesmu5p4kYwvZBXvV/wK505aNAEAQINy7GeYkb71v9Tx2Yn8/3ayBRRq85v9+yr5+d/RD7y10CAzALM2MTM8hupzB0L/t7otrY2gsH9b9/9D/1o3/cEmjI6zUFgPw/1r9UwHW4Fawc3gLsfwAHxY9l97gbTmsNE3tIAa/ds1x3+o/3zsVXMArckgndu/JxkWMcw/ER9YcdAhM2kPtXM0M4T+2578gz1iEv40Qr6HEUt9MyuEiryJK+MDJ07VfKGwRDuIQo+9lI2TDoMMfFt8gjKwKvk6ubp4H/UD0q53sy+3Hy9wcBWGX0FJCHLgHn0uUPywMqOeaeR6GNuKqVoVPcVmY7wQQQCl/BOMPpyJ67dHhssvDWxnN9V0d2QGxpmDdbFRnt3gebd4ywbf1G58iMu/qi3eQ3U4duqZgaC2O+act+bv1NyXg1y9DwBAG3DU1yNLfSszY6g9/BgVIC0S3D+bdMdINNvB1D13AINCyxTKOXF8Z+8v4CkXvNeXzyvj/VbBMIdlNWyMno/nX+yfLzntW3HqvuqU4tbmWlmMhB1uE9MMdlCXjTTYTrOfVFszWycLdjH2B73lDy8bBn5jVLF0K05TKE7FtayOmw9NymvdrB8Jm8TQ4VvTjd5MuyvEM/vg5YNPbAne3/z6ZVMfaHhec9BpYRqCP/oY4BylfQETIsV8GvtKPjWRy8ObCQ2rmV+6toQ1UjFROdR0hhmWOSPSPA1NHwvfyR7W3ExQeswEc1offVQ+v8Sq69E3ExJsfSsHd71UREigjHVZ8FeeX93h/DEIAIA1yrETYwS1gVm7/EsF/y4qxMLBHm5taeYKPQYffBQ+xEDf/ji3EeEjG/nnby2hVnDEBQcPK1VA48LxXheqLHl/Sjcazz98iNU1IgcPu9rf4ERPvuSgyRu2LtC583HMSWBFIZ0nUKVZjxUPhUyDzqCTMz0P68iS7Voe3LFDDWI1QevMILlllx1thxoZq+XOzCnmyTBQ2DBappsYZhJD/CVNJz541iCRBRJ65iMKdupiWy9OzEfqIQLUjZAnrI13KpxhAS8zt8++CO+aQFUZX56lcPSqj55ITI5kGtYTMZ2PFP79AlwQzMyfDQCALdKiW+zoUfr1oz7czNoKMVDsddm4HzgJ0Fu2kuZQuWT8SlAvldoKj9XP6361P+szDpJaS3jEJ9z6NAnU3u93wYMwcDw67tosjVm+oYf+Vy1WB+lB23QhU1ZqKzfIHKPqtax0R96xeyZWqXJlrfhkG6Cz737fBisxa6uMf14ewFFfKQ7w7p8HDKJfRo1cWOWcOD6Dui9b0FHHNXKXUb0eznxwQVOtJnpdsyYrnm8l8vGkYulbwhfXyYWtlpLdST3OhlwXFVTRlCc1mCm6zJ/t1lbBY/6Z0pS/bs0hkMpEThPrs4mB8XJWroH86vdrGbLmsJpvfiMRuDyRuWHYr9a38dx/ZzLXqyXTFQCAV0gvKu4j+WrtCLWD6bvYH+PqvXgsQxAjqCMUZm1zjCtZ+q8M/vMIsdS3QcypUPD/X9QY60KVL5ec2KntZIOvSFgTEqM2hRLNnmWkoSHk7XQRMozSdr0vrMLhPTzgnkSEGfqmJHG1ohHKhQeTw2OJ8bkZHv26FppApA7OzGns65vY4uu0bpJZtQU4E2g/mjUBfi1QnCdfxvV7eT1TehJsZJths2ie1Ry6Ilc5ZEMhIco/Pp5z5XvTIXJNUQ1PmUAodaCJo70fs8PJ9t3veubc6wXCBAAAfiCNkczfxWi/O59RY/bPhY/W0n/DVoRARrN503fmrMCdV0yB19B+rDChOyUzz+PNMC7VGpquYPmfzl/U05vQrrzb+qN3TCsIFJ3Qjlpwmi2cTD68XunzmXrMDM2Lmz+8kjvT+1XbXYJA7xcsL/v4/1BEudC9LTlRFZFefe6X16KvxwUcAADIQeq1/N95jexO1iBv7i1KIDnv/jQectO/uEUTUwv9NaT3XVLL1rNUKhsFEZzhrZVYns3LfOlMvps8mVpxX9TqU87M3qi6Xl3NUw6N160nKl9Jr3hDFo+XaqKYJXX5Jk1UtRYOj3czo+yw7IJYe0WbyFRnMT+vvMjYmYFPdxzb2V6scgQaXYvwPk2WZkejcGUJ61c0NhJrNgIAAEg9fpVmZG1ocYjdv8O92u2iQq78/wfCHLYd9sKKek2tohyoQ7EBVNMg+4a7I+fLkEoS+IuKBh0gtHnnMpX7LarLQpubr6wEH6XeeCxe4BmWH2hC4Nv4wx8dXScEDMaSSK5cS5SoTR7DUnt28XtZytKSrIo99pI996IM2xCxvWqD3JI98flFghRRoYxnSiI+X4P6NkjQp7F4QCnrITe7WFlY0Pz4MXyU+o2vhX0Qqvk2hY1Fl8WH8vvaircKHXkOAIAW6lFfSHZH4D8fYHvTHRPc7Yp1DW2KMuxNX4ZUNDBra9g1/jOMXsOuIZUuJQ/mkJZXlpKRr4fIqEvVKjYpcKhIsTY2SLcOo57471D5/RyV+csAAIgiTT01MolmXPxWx0g880HM/8luxG8LNnbWcGsDB+NjKOc5DBcC/imdw8yYwwpqCLW317dzOa4fe71t2UHtrR3sDKH/0tvWLxzExsEAdohdsT+pjAdTIaZwy+NsXHEcEv3XC4b5EIZsYA4mZsdZ75BDw//aD5ZDmPqLBcR+BDzE0P44La4LRzTx1yEDH8WgmaW+yXHeGfmObOSv/WI7iklz+3/pbojEwv/krv6b/+sf/qVC5A/uX6vfa2PQAW4GO96uMt3+tL9Wiv8nG4lCFFSSE//VuPMAIQ1w6vfvJXj9/H7IU4q7oTtP8VEiQG33ge46ibgbuPNA3WkEoBgKcPBRwN24nSfgKBBwJ1GBQ5zJ+y9v73Nz//kiAKbFEvfgIZ6i259EgUCa3Zv0R68d0dOdR8TOIngqcgI4yik6ZEKpEIRaoQGHPW+GqHXnqSsmBK1lByCRyf0Pe+e5IDIEdjU6cNAprt2wnWOxiDCvk8BBB4uQBZIEIZDNBMBBc7WIunaOi9Ih6KIkBA4/V7sbu3P2ERGrSAQcfvJ0N3bneBcVArabGDjcGCWyWJ5GiKU8OXCYKbHDrvEYJLhdU2KITu8cRmJAcHr2AOTuKTFkYmkRxEZSAEcYbULUu3PiCISgd+Jg6h6jTchUMyCovkEJHHGKaX8yCIFceDjyAXfWncM/3AiRoTgD/M0U025DO2dmeBEMzRzd0O7Jot3Gdg6YCCIYo6MG/pWhnMNfZDdpgMOOsSA6sbNqQnyQ5ByA/LMUQyaXBkEuCS1w+AmW/QWfQxBsdiD0byQ3IKPvHl45rGR6OuDIwyvIJNMjSPY+mG50uJXBiqC67zDcowlnQhAuTg8ceWRlf/FgBPGxh2UfzQHExwjmWeAI0yqI0neOkSA+RvQOpu4xrYJMNR2C6lZk/D9HU/aPOKJsFgbgGKMpu/k7RzjIEfjBe/B3T6UcvvqBMQKHGQI57EooRoL7cwgE0eWd0wxsCC4TMgHHGgI5vG41ZuAIMxKHLSdSDqbuOSOxPx+MwMc6Bxx/RgIx+DsnAYQRgm99ZCP7dgp3G93ZoBdDMPqABfgXRw52293ZLEcsZexBwL8yDIAsh9yIxSwr8Hct+f0NXUQwVHMsQ3u05BFjubP1LI0QSwE24H/Qkt9tf2cTWAbBvi478L9od+8WsLPvKo8gQJUD+B91ng9/Y9MHA0fo9yJ6trPziVgS5R9M3avf+8dDbkffcudDdNqrEAIco52KLCzUCGHR4QQO3Qvd/8HPjBCUrIOYf1PcEnEBR2qD7i+aB0G0+WG4yNqghy81evYwtUcD67ArG8QNHKEDuj+VEYHqeTB1dwd0/1BzIIS655Dooy0TZgT5l88DR29+7u8ABMGBZ4eGH80FFgQXsHmA4/Q998ezI+DNj4Df1ffcP04XEOLUeEQTR4sWYgkofAE4fstzf4f4EBx6cWQjR3OJDcElMl7gmN3Ow970nI9m4W/u22PITO3R6DzspoQoH3CcRicy4eQIwpP2MPBnj3N/uYjtgKX9aUcTib9D5LaYEj+ApL2JjvHz9xQBRaCZCgAe8v/86f8CAAD//w4CtDV7VQAA"); err != nil { panic("add binary content to resource manager failed: " + err.Error()) } } From e9ce1bde873768847ad298f8db8b14d8a61675c6 Mon Sep 17 00:00:00 2001 From: John Guo Date: Thu, 21 Nov 2024 15:08:29 +0800 Subject: [PATCH 006/102] fix(database/gdb): incompatitable statement like `Order("id", "dasc")` (#3949) --- .../drivers/mysql/mysql_z_unit_issue_test.go | 32 ++++++++++++++++ .../drivers/mysql/mysql_z_unit_model_test.go | 2 +- .../sqlite/sqlite_z_unit_model_test.go | 2 +- .../sqlitecgo/sqlitecgo_z_unit_model_test.go | 2 +- database/gdb/gdb_model_order_group.go | 37 ++++++++++++++----- 5 files changed, 63 insertions(+), 12 deletions(-) diff --git a/contrib/drivers/mysql/mysql_z_unit_issue_test.go b/contrib/drivers/mysql/mysql_z_unit_issue_test.go index 6df225fa9f1..b3329a8fd91 100644 --- a/contrib/drivers/mysql/mysql_z_unit_issue_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_issue_test.go @@ -1345,3 +1345,35 @@ func Test_Issue3626(t *testing.T) { t.Assert(count, 1) }) } + +// https://github.com/gogf/gf/issues/3932 +func Test_Issue3932(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + one, err := db.Model(table).Order("id", "desc").One() + t.AssertNil(err) + t.Assert(one["id"], 10) + }) + gtest.C(t, func(t *gtest.T) { + one, err := db.Model(table).Order("id desc").One() + t.AssertNil(err) + t.Assert(one["id"], 10) + }) + gtest.C(t, func(t *gtest.T) { + one, err := db.Model(table).Order("id desc, nickname asc").One() + t.AssertNil(err) + t.Assert(one["id"], 10) + }) + gtest.C(t, func(t *gtest.T) { + one, err := db.Model(table).Order("id desc", "nickname asc").One() + t.AssertNil(err) + t.Assert(one["id"], 10) + }) + gtest.C(t, func(t *gtest.T) { + one, err := db.Model(table).Order("id desc").Order("nickname asc").One() + t.AssertNil(err) + t.Assert(one["id"], 10) + }) +} diff --git a/contrib/drivers/mysql/mysql_z_unit_model_test.go b/contrib/drivers/mysql/mysql_z_unit_model_test.go index 6cc4237be27..5f3033b36d0 100644 --- a/contrib/drivers/mysql/mysql_z_unit_model_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_model_test.go @@ -1293,7 +1293,7 @@ func Test_Model_OrderBy(t *testing.T) { }) gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Order("NULL").All() + result, err := db.Model(table).Order(gdb.Raw("NULL")).All() t.AssertNil(err) t.Assert(len(result), TableSize) t.Assert(result[0]["nickname"].String(), "name_1") diff --git a/contrib/drivers/sqlite/sqlite_z_unit_model_test.go b/contrib/drivers/sqlite/sqlite_z_unit_model_test.go index 99fde77228a..19e97bfa51a 100644 --- a/contrib/drivers/sqlite/sqlite_z_unit_model_test.go +++ b/contrib/drivers/sqlite/sqlite_z_unit_model_test.go @@ -1431,7 +1431,7 @@ func Test_Model_OrderBy(t *testing.T) { }) gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Order("NULL").All() + result, err := db.Model(table).Order(gdb.Raw("NULL")).All() t.AssertNil(err) t.Assert(len(result), TableSize) t.Assert(result[0]["nickname"].String(), "name_1") diff --git a/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_model_test.go b/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_model_test.go index b028294d909..613ef9c64b3 100644 --- a/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_model_test.go +++ b/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_model_test.go @@ -1390,7 +1390,7 @@ func Test_Model_OrderBy(t *testing.T) { }) gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Order("NULL").All() + result, err := db.Model(table).Order(gdb.Raw("NULL")).All() t.AssertNil(err) t.Assert(len(result), TableSize) t.Assert(result[0]["nickname"].String(), "name_1") diff --git a/database/gdb/gdb_model_order_group.go b/database/gdb/gdb_model_order_group.go index ec69818b6be..664dcf540a9 100644 --- a/database/gdb/gdb_model_order_group.go +++ b/database/gdb/gdb_model_order_group.go @@ -15,27 +15,42 @@ import ( // Order sets the "ORDER BY" statement for the model. // -// Eg: +// Example: // Order("id desc") +// Order("id", "desc") // Order("id desc,name asc") +// Order("id desc", "name asc") // Order("id desc").Order("name asc") // Order(gdb.Raw("field(id, 3,1,2)")). func (m *Model) Order(orderBy ...interface{}) *Model { if len(orderBy) == 0 { return m } - model := m.getModel() - if model.orderBy != "" { - model.orderBy += "," - } + var ( + core = m.db.GetCore() + model = m.getModel() + ) for _, v := range orderBy { + if model.orderBy != "" { + model.orderBy += "," + } switch v.(type) { case Raw, *Raw: model.orderBy += gconv.String(v) - return model + default: + orderByStr := gconv.String(v) + if gstr.Contains(orderByStr, " ") { + model.orderBy += core.QuoteString(orderByStr) + } else { + if gstr.Equal(orderByStr, "ASC") || gstr.Equal(orderByStr, "DESC") { + model.orderBy = gstr.TrimRight(model.orderBy, ",") + model.orderBy += " " + orderByStr + } else { + model.orderBy += core.QuoteWord(orderByStr) + } + } } } - model.orderBy += model.db.GetCore().QuoteString(gstr.JoinAny(orderBy, ", ")) return model } @@ -67,10 +82,14 @@ func (m *Model) Group(groupBy ...string) *Model { if len(groupBy) == 0 { return m } - model := m.getModel() + var ( + core = m.db.GetCore() + model = m.getModel() + ) + if model.groupBy != "" { model.groupBy += "," } - model.groupBy += model.db.GetCore().QuoteString(strings.Join(groupBy, ",")) + model.groupBy += core.QuoteString(strings.Join(groupBy, ",")) return model } From 3797d0eee4a3fc015171c029a1f6d023aea7db38 Mon Sep 17 00:00:00 2001 From: John Guo Date: Thu, 21 Nov 2024 20:51:46 +0800 Subject: [PATCH 007/102] feat: new version v2.8.1 (#3950) --- cmd/gf/go.mod | 14 ++++---- .../internal/cmd/testdata/build/varmap/go.mod | 2 +- contrib/config/apollo/go.mod | 2 +- contrib/config/consul/go.mod | 2 +- contrib/config/kubecm/go.mod | 2 +- contrib/config/nacos/go.mod | 2 +- contrib/config/polaris/go.mod | 2 +- contrib/drivers/clickhouse/go.mod | 2 +- contrib/drivers/dm/go.mod | 2 +- contrib/drivers/mssql/go.mod | 2 +- contrib/drivers/mysql/go.mod | 2 +- contrib/drivers/oracle/go.mod | 2 +- contrib/drivers/pgsql/go.mod | 2 +- contrib/drivers/sqlite/go.mod | 2 +- contrib/drivers/sqlitecgo/go.mod | 2 +- contrib/metric/otelmetric/go.mod | 2 +- contrib/nosql/redis/go.mod | 2 +- contrib/registry/etcd/go.mod | 2 +- contrib/registry/file/go.mod | 2 +- contrib/registry/nacos/go.mod | 2 +- contrib/registry/polaris/go.mod | 2 +- contrib/registry/zookeeper/go.mod | 2 +- contrib/rpc/grpcx/go.mod | 4 +-- contrib/sdk/httpclient/go.mod | 2 +- contrib/trace/otlpgrpc/go.mod | 2 +- contrib/trace/otlphttp/go.mod | 2 +- example/go.mod | 32 +++++++++---------- version.go | 2 +- 28 files changed, 50 insertions(+), 50 deletions(-) diff --git a/cmd/gf/go.mod b/cmd/gf/go.mod index 993446326b4..8b3d4d5b6bb 100644 --- a/cmd/gf/go.mod +++ b/cmd/gf/go.mod @@ -3,13 +3,13 @@ module github.com/gogf/gf/cmd/gf/v2 go 1.18 require ( - github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.8.0 - github.com/gogf/gf/contrib/drivers/mssql/v2 v2.8.0 - github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.0 - github.com/gogf/gf/contrib/drivers/oracle/v2 v2.8.0 - github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.8.0 - github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.8.0 - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.8.1 + github.com/gogf/gf/contrib/drivers/mssql/v2 v2.8.1 + github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.1 + github.com/gogf/gf/contrib/drivers/oracle/v2 v2.8.1 + github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.8.1 + github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.1 github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f github.com/olekukonko/tablewriter v0.0.5 golang.org/x/mod v0.17.0 diff --git a/cmd/gf/internal/cmd/testdata/build/varmap/go.mod b/cmd/gf/internal/cmd/testdata/build/varmap/go.mod index c716ecedd03..c8c721416c0 100644 --- a/cmd/gf/internal/cmd/testdata/build/varmap/go.mod +++ b/cmd/gf/internal/cmd/testdata/build/varmap/go.mod @@ -2,7 +2,7 @@ module github.com/gogf/gf/cmd/gf/cmd/gf/testdata/vardump/v2 go 1.18 -require github.com/gogf/gf/v2 v2.8.0 +require github.com/gogf/gf/v2 v2.8.1 require ( go.opentelemetry.io/otel v1.24.0 // indirect diff --git a/contrib/config/apollo/go.mod b/contrib/config/apollo/go.mod index deb3769f9fa..5f46be8af6f 100644 --- a/contrib/config/apollo/go.mod +++ b/contrib/config/apollo/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/apolloconfig/agollo/v4 v4.3.1 - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 ) require ( diff --git a/contrib/config/consul/go.mod b/contrib/config/consul/go.mod index 06b64caaa47..e87661382ac 100644 --- a/contrib/config/consul/go.mod +++ b/contrib/config/consul/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/consul/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 github.com/hashicorp/consul/api v1.24.0 github.com/hashicorp/go-cleanhttp v0.5.2 ) diff --git a/contrib/config/kubecm/go.mod b/contrib/config/kubecm/go.mod index 39953c34582..e6874aff1e2 100644 --- a/contrib/config/kubecm/go.mod +++ b/contrib/config/kubecm/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/kubecm/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 k8s.io/api v0.27.4 k8s.io/apimachinery v0.27.4 k8s.io/client-go v0.27.4 diff --git a/contrib/config/nacos/go.mod b/contrib/config/nacos/go.mod index e78e8dbc81c..02ab8739d06 100644 --- a/contrib/config/nacos/go.mod +++ b/contrib/config/nacos/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/nacos/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 github.com/nacos-group/nacos-sdk-go/v2 v2.2.5 ) diff --git a/contrib/config/polaris/go.mod b/contrib/config/polaris/go.mod index fedf4c7ec2a..82d374c0e98 100644 --- a/contrib/config/polaris/go.mod +++ b/contrib/config/polaris/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/polaris/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 github.com/polarismesh/polaris-go v1.5.8 ) diff --git a/contrib/drivers/clickhouse/go.mod b/contrib/drivers/clickhouse/go.mod index 634f26b7dbd..d52ad6820e3 100644 --- a/contrib/drivers/clickhouse/go.mod +++ b/contrib/drivers/clickhouse/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/ClickHouse/clickhouse-go/v2 v2.0.15 - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 github.com/google/uuid v1.3.0 github.com/shopspring/decimal v1.3.1 ) diff --git a/contrib/drivers/dm/go.mod b/contrib/drivers/dm/go.mod index dd7f7b14c4c..93a472dab26 100644 --- a/contrib/drivers/dm/go.mod +++ b/contrib/drivers/dm/go.mod @@ -6,7 +6,7 @@ replace github.com/gogf/gf/v2 => ../../../ require ( gitee.com/chunanyong/dm v1.8.12 - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 ) require ( diff --git a/contrib/drivers/mssql/go.mod b/contrib/drivers/mssql/go.mod index f8d77ae0cc9..604a87105f8 100644 --- a/contrib/drivers/mssql/go.mod +++ b/contrib/drivers/mssql/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/mssql/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 github.com/microsoft/go-mssqldb v1.7.1 ) diff --git a/contrib/drivers/mysql/go.mod b/contrib/drivers/mysql/go.mod index e0f581ea879..2b05cf39400 100644 --- a/contrib/drivers/mysql/go.mod +++ b/contrib/drivers/mysql/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/go-sql-driver/mysql v1.7.1 - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 ) require ( diff --git a/contrib/drivers/oracle/go.mod b/contrib/drivers/oracle/go.mod index f552aef2086..2a4e319c1f7 100644 --- a/contrib/drivers/oracle/go.mod +++ b/contrib/drivers/oracle/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/oracle/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 github.com/sijms/go-ora/v2 v2.7.10 ) diff --git a/contrib/drivers/pgsql/go.mod b/contrib/drivers/pgsql/go.mod index c306b28d6b7..74d72cb9b93 100644 --- a/contrib/drivers/pgsql/go.mod +++ b/contrib/drivers/pgsql/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/pgsql/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 github.com/lib/pq v1.10.9 ) diff --git a/contrib/drivers/sqlite/go.mod b/contrib/drivers/sqlite/go.mod index 87373617b90..48b040e0f58 100644 --- a/contrib/drivers/sqlite/go.mod +++ b/contrib/drivers/sqlite/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/glebarez/go-sqlite v1.21.2 - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 ) require ( diff --git a/contrib/drivers/sqlitecgo/go.mod b/contrib/drivers/sqlitecgo/go.mod index 3c1427cc01b..1435ed4ffdc 100644 --- a/contrib/drivers/sqlitecgo/go.mod +++ b/contrib/drivers/sqlitecgo/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/sqlitecgo/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 github.com/mattn/go-sqlite3 v1.14.17 ) diff --git a/contrib/metric/otelmetric/go.mod b/contrib/metric/otelmetric/go.mod index 25e767733a4..eada5401c14 100644 --- a/contrib/metric/otelmetric/go.mod +++ b/contrib/metric/otelmetric/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/metric/otelmetric/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 github.com/prometheus/client_golang v1.19.1 go.opentelemetry.io/contrib/instrumentation/runtime v0.49.0 go.opentelemetry.io/otel v1.24.0 diff --git a/contrib/nosql/redis/go.mod b/contrib/nosql/redis/go.mod index 493c07cfcde..23f73842120 100644 --- a/contrib/nosql/redis/go.mod +++ b/contrib/nosql/redis/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/nosql/redis/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 github.com/redis/go-redis/v9 v9.2.1 go.opentelemetry.io/otel v1.24.0 go.opentelemetry.io/otel/trace v1.24.0 diff --git a/contrib/registry/etcd/go.mod b/contrib/registry/etcd/go.mod index 1e8fc324672..487f54564b9 100644 --- a/contrib/registry/etcd/go.mod +++ b/contrib/registry/etcd/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/etcd/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 go.etcd.io/etcd/client/v3 v3.5.7 google.golang.org/grpc v1.59.0 ) diff --git a/contrib/registry/file/go.mod b/contrib/registry/file/go.mod index 9b1c19e165f..8e1bb98d450 100644 --- a/contrib/registry/file/go.mod +++ b/contrib/registry/file/go.mod @@ -2,7 +2,7 @@ module github.com/gogf/gf/contrib/registry/file/v2 go 1.20 -require github.com/gogf/gf/v2 v2.8.0 +require github.com/gogf/gf/v2 v2.8.1 require ( github.com/BurntSushi/toml v1.4.0 // indirect diff --git a/contrib/registry/nacos/go.mod b/contrib/registry/nacos/go.mod index 87450c326ee..f243e595425 100644 --- a/contrib/registry/nacos/go.mod +++ b/contrib/registry/nacos/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/nacos/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 github.com/nacos-group/nacos-sdk-go/v2 v2.2.7 ) diff --git a/contrib/registry/polaris/go.mod b/contrib/registry/polaris/go.mod index 9765866c047..b941c438788 100644 --- a/contrib/registry/polaris/go.mod +++ b/contrib/registry/polaris/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/polaris/v2 go 1.21 require ( - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 github.com/polarismesh/polaris-go v1.5.8 ) diff --git a/contrib/registry/zookeeper/go.mod b/contrib/registry/zookeeper/go.mod index ffe9c2ddbaf..3afa94bb497 100644 --- a/contrib/registry/zookeeper/go.mod +++ b/contrib/registry/zookeeper/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/go-zookeeper/zk v1.0.3 - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 golang.org/x/sync v0.7.0 ) diff --git a/contrib/rpc/grpcx/go.mod b/contrib/rpc/grpcx/go.mod index feaad421216..7040f915eba 100644 --- a/contrib/rpc/grpcx/go.mod +++ b/contrib/rpc/grpcx/go.mod @@ -3,8 +3,8 @@ module github.com/gogf/gf/contrib/rpc/grpcx/v2 go 1.20 require ( - github.com/gogf/gf/contrib/registry/file/v2 v2.8.0 - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/contrib/registry/file/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.1 go.opentelemetry.io/otel v1.24.0 go.opentelemetry.io/otel/trace v1.24.0 google.golang.org/grpc v1.64.1 diff --git a/contrib/sdk/httpclient/go.mod b/contrib/sdk/httpclient/go.mod index 546598490ad..ed6e4fa3b9f 100644 --- a/contrib/sdk/httpclient/go.mod +++ b/contrib/sdk/httpclient/go.mod @@ -2,7 +2,7 @@ module github.com/gogf/gf/contrib/sdk/httpclient/v2 go 1.20 -require github.com/gogf/gf/v2 v2.8.0 +require github.com/gogf/gf/v2 v2.8.1 require ( github.com/BurntSushi/toml v1.4.0 // indirect diff --git a/contrib/trace/otlpgrpc/go.mod b/contrib/trace/otlpgrpc/go.mod index 6b83963bffe..565db9acd0a 100644 --- a/contrib/trace/otlpgrpc/go.mod +++ b/contrib/trace/otlpgrpc/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/trace/otlpgrpc/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 go.opentelemetry.io/otel v1.24.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 diff --git a/contrib/trace/otlphttp/go.mod b/contrib/trace/otlphttp/go.mod index 222c13f8f79..6b817b4b6e8 100644 --- a/contrib/trace/otlphttp/go.mod +++ b/contrib/trace/otlphttp/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/trace/otlphttp/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/v2 v2.8.1 go.opentelemetry.io/otel v1.24.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 diff --git a/example/go.mod b/example/go.mod index 561a6c6e96c..7a992faf2cc 100644 --- a/example/go.mod +++ b/example/go.mod @@ -3,22 +3,22 @@ module github.com/gogf/gf/example go 1.21 require ( - github.com/gogf/gf/contrib/config/apollo/v2 v2.8.0 - github.com/gogf/gf/contrib/config/consul/v2 v2.8.0 - github.com/gogf/gf/contrib/config/kubecm/v2 v2.8.0 - github.com/gogf/gf/contrib/config/nacos/v2 v2.8.0 - github.com/gogf/gf/contrib/config/polaris/v2 v2.8.0 - github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.0 - github.com/gogf/gf/contrib/metric/otelmetric/v2 v2.8.0 - github.com/gogf/gf/contrib/nosql/redis/v2 v2.8.0 - github.com/gogf/gf/contrib/registry/etcd/v2 v2.8.0 - github.com/gogf/gf/contrib/registry/file/v2 v2.8.0 - github.com/gogf/gf/contrib/registry/nacos/v2 v2.8.0 - github.com/gogf/gf/contrib/registry/polaris/v2 v2.8.0 - github.com/gogf/gf/contrib/rpc/grpcx/v2 v2.8.0 - github.com/gogf/gf/contrib/trace/otlpgrpc/v2 v2.8.0 - github.com/gogf/gf/contrib/trace/otlphttp/v2 v2.8.0 - github.com/gogf/gf/v2 v2.8.0 + github.com/gogf/gf/contrib/config/apollo/v2 v2.8.1 + github.com/gogf/gf/contrib/config/consul/v2 v2.8.1 + github.com/gogf/gf/contrib/config/kubecm/v2 v2.8.1 + github.com/gogf/gf/contrib/config/nacos/v2 v2.8.1 + github.com/gogf/gf/contrib/config/polaris/v2 v2.8.1 + github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.1 + github.com/gogf/gf/contrib/metric/otelmetric/v2 v2.8.1 + github.com/gogf/gf/contrib/nosql/redis/v2 v2.8.1 + github.com/gogf/gf/contrib/registry/etcd/v2 v2.8.1 + github.com/gogf/gf/contrib/registry/file/v2 v2.8.1 + github.com/gogf/gf/contrib/registry/nacos/v2 v2.8.1 + github.com/gogf/gf/contrib/registry/polaris/v2 v2.8.1 + github.com/gogf/gf/contrib/rpc/grpcx/v2 v2.8.1 + github.com/gogf/gf/contrib/trace/otlpgrpc/v2 v2.8.1 + github.com/gogf/gf/contrib/trace/otlphttp/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.1 github.com/hashicorp/consul/api v1.24.0 github.com/hashicorp/go-cleanhttp v0.5.2 github.com/nacos-group/nacos-sdk-go/v2 v2.2.7 diff --git a/version.go b/version.go index 529e2f0493b..d6ce791b091 100644 --- a/version.go +++ b/version.go @@ -2,5 +2,5 @@ package gf const ( // VERSION is the current GoFrame version. - VERSION = "v2.8.0" + VERSION = "v2.8.1" ) From 15f94975db43c7b07c691191af2d7e13e252626d Mon Sep 17 00:00:00 2001 From: UncleChair Date: Sat, 23 Nov 2024 15:37:46 +0800 Subject: [PATCH 008/102] feat(net/goai): add enhanced response status interface (#3896) --- net/goai/goai_example.go | 11 ++ net/goai/goai_path.go | 6 +- net/goai/goai_response.go | 19 +++- net/goai/goai_response_ref.go | 17 ++- net/goai/goai_z_unit_issue_test.go | 101 +++++++++++------- net/goai/testdata/Issue3747JsonFile/401.json | 12 --- .../201.json | 0 7 files changed, 107 insertions(+), 59 deletions(-) delete mode 100644 net/goai/testdata/Issue3747JsonFile/401.json rename net/goai/testdata/{Issue3747JsonFile => Issue3889JsonFile}/201.json (100%) diff --git a/net/goai/goai_example.go b/net/goai/goai_example.go index 4f9ee6462ff..34ec816c29b 100644 --- a/net/goai/goai_example.go +++ b/net/goai/goai_example.go @@ -52,6 +52,17 @@ func (e *Examples) applyExamplesFile(path string) error { if err != nil { return err } + err = e.applyExamplesData(data) + if err != nil { + return err + } + return nil +} + +func (e *Examples) applyExamplesData(data interface{}) error { + if empty.IsNil(e) || empty.IsNil(data) { + return nil + } switch v := data.(type) { case map[string]interface{}: diff --git a/net/goai/goai_path.go b/net/goai/goai_path.go index 1727623e67f..2d5ac657681 100644 --- a/net/goai/goai_path.go +++ b/net/goai/goai_path.go @@ -255,12 +255,12 @@ func (oai *OpenApiV3) addPath(in addPathInput) error { // ================================================================================================================= // Other Responses. // ================================================================================================================= - if enhancedResponse, ok := outputObject.Interface().(ResponseStatusDef); ok { - for statusCode, data := range enhancedResponse.ResponseStatusMap() { + if enhancedResponse, ok := outputObject.Interface().(IEnhanceResponseStatus); ok { + for statusCode, data := range enhancedResponse.EnhanceResponseStatus() { if statusCode < 100 || statusCode >= 600 { return gerror.Newf("Invalid HTTP status code: %d", statusCode) } - if data == nil { + if data.Response == nil { continue } status := gconv.String(statusCode) diff --git a/net/goai/goai_response.go b/net/goai/goai_response.go index 5d68e019a13..1f81365f68f 100644 --- a/net/goai/goai_response.go +++ b/net/goai/goai_response.go @@ -12,13 +12,22 @@ import ( "github.com/gogf/gf/v2/util/gconv" ) -// StatusCode is http status for response. -type StatusCode = int +// EnhancedStatusCode is http status for response. +type EnhancedStatusCode = int -// ResponseStatusDef is used to enhance the documentation of the response. +// EnhancedStatusType is the structure for certain response status. +// Currently, it only supports `Response` and `Examples`. +// `Response` is the response structure +// `Examples` is the examples for the response, map[string]interface{}, []interface{} are supported. +type EnhancedStatusType struct { + Response any + Examples any +} + +// IEnhanceResponseStatus is used to enhance the documentation of the response. // Normal response structure could implement this interface to provide more information. -type ResponseStatusDef interface { - ResponseStatusMap() map[StatusCode]any +type IEnhanceResponseStatus interface { + EnhanceResponseStatus() map[EnhancedStatusCode]EnhancedStatusType } // Response is specified by OpenAPI/Swagger 3.0 standard. diff --git a/net/goai/goai_response_ref.go b/net/goai/goai_response_ref.go index ac957ddf189..683aa123335 100644 --- a/net/goai/goai_response_ref.go +++ b/net/goai/goai_response_ref.go @@ -26,7 +26,14 @@ type Responses map[string]ResponseRef // object could be someObject.Interface() // There may be some difference between someObject.Type() and reflect.TypeOf(object). -func (oai *OpenApiV3) getResponseFromObject(object interface{}, isDefault bool) (*Response, error) { +func (oai *OpenApiV3) getResponseFromObject(data interface{}, isDefault bool) (*Response, error) { + var object interface{} + enhancedResponse, isEnhanced := data.(EnhancedStatusType) + if isEnhanced { + object = enhancedResponse.Response + } else { + object = data + } // Add object schema to oai if err := oai.addSchema(object); err != nil { return nil, err @@ -86,6 +93,14 @@ func (oai *OpenApiV3) getResponseFromObject(object interface{}, isDefault bool) } } + // Override examples from enhanced response. + if isEnhanced { + err := examples.applyExamplesData(enhancedResponse.Examples) + if err != nil { + return nil, err + } + } + // Generate response schema from input. schemaRef, err := oai.getResponseSchemaRef(refInput) if err != nil { diff --git a/net/goai/goai_z_unit_issue_test.go b/net/goai/goai_z_unit_issue_test.go index c3d28ee2c87..9979bd23e65 100644 --- a/net/goai/goai_z_unit_issue_test.go +++ b/net/goai/goai_z_unit_issue_test.go @@ -13,6 +13,7 @@ import ( "time" "github.com/gogf/gf/v2/encoding/gjson" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/goai" @@ -119,71 +120,97 @@ func Test_Issue3135(t *testing.T) { }) } -type Issue3747CommonRes struct { +type Issue3889CommonRes struct { g.Meta `mime:"application/json"` Code int `json:"code"` Message string `json:"message"` Data interface{} `json:"data"` } -type Issue3747Req struct { +type Issue3889Req struct { g.Meta `path:"/default" method:"post"` Name string } -type Issue3747Res struct { - g.Meta `status:"201" resEg:"testdata/Issue3747JsonFile/201.json"` +type Issue3889Res struct { + g.Meta `status:"201" resEg:"testdata/Issue3889JsonFile/201.json"` Info string `json:"info" eg:"Created!"` } // Example case -type Issue3747Res401 struct { - g.Meta `resEg:"testdata/Issue3747JsonFile/401.json"` -} +type Issue3889Res401 struct{} // Override case 1 -type Issue3747Res402 struct { +type Issue3889Res402 struct { g.Meta `mime:"application/json"` } // Override case 2 -type Issue3747Res403 struct { +type Issue3889Res403 struct { Code int `json:"code"` Message string `json:"message"` } // Common response case -type Issue3747Res404 struct{} - -func (r Issue3747Res) ResponseStatusMap() map[goai.StatusCode]any { - return map[goai.StatusCode]any{ - 401: Issue3747Res401{}, - 402: Issue3747Res402{}, - 403: Issue3747Res403{}, - 404: Issue3747Res404{}, - 405: struct{}{}, - 407: interface{}(nil), - 406: nil, +type Issue3889Res404 struct{} + +var Issue3889ErrorRes = map[int][]gcode.Code{ + 401: { + gcode.New(1, "Aha, 401 - 1", nil), + gcode.New(2, "Aha, 401 - 2", nil), + }, +} + +func (r Issue3889Res) EnhanceResponseStatus() map[goai.EnhancedStatusCode]goai.EnhancedStatusType { + Codes401 := Issue3889ErrorRes[401] + // iterate Codes401 to generate Examples + var Examples401 []interface{} + for _, code := range Codes401 { + example := Issue3889CommonRes{ + Code: code.Code(), + Message: code.Message(), + Data: nil, + } + Examples401 = append(Examples401, example) + } + return map[goai.EnhancedStatusCode]goai.EnhancedStatusType{ + 401: { + Response: Issue3889Res401{}, + Examples: Examples401, + }, + 402: { + Response: Issue3889Res402{}, + }, + 403: { + Response: Issue3889Res403{}, + }, + 404: { + Response: Issue3889Res404{}, + }, + 500: { + Response: struct{}{}, + }, + 501: {}, } } -type Issue3747 struct{} +type Issue3889 struct{} -func (Issue3747) Default(ctx context.Context, req *Issue3747Req) (res *Issue3747Res, err error) { - res = &Issue3747Res{} +func (Issue3889) Default(ctx context.Context, req *Issue3889Req) (res *Issue3889Res, err error) { + res = &Issue3889Res{} return } -// https://github.com/gogf/gf/issues/3747 -func Test_Issue3747(t *testing.T) { +// https://github.com/gogf/gf/issues/3889 +func Test_Issue3889(t *testing.T) { gtest.C(t, func(t *gtest.T) { s := g.Server(guid.S()) openapi := s.GetOpenApi() - openapi.Config.CommonResponse = Issue3747CommonRes{} + openapi.Config.CommonResponse = Issue3889CommonRes{} openapi.Config.CommonResponseDataField = `Data` s.Use(ghttp.MiddlewareHandlerResponse) s.Group("/", func(group *ghttp.RouterGroup) { group.Bind( - new(Issue3747), + new(Issue3889), ) }) s.SetLogger(nil) @@ -205,29 +232,27 @@ func Test_Issue3747(t *testing.T) { t.AssertNE(j.Get(`paths./default.post.responses.402`).String(), "") t.AssertNE(j.Get(`paths./default.post.responses.403`).String(), "") t.AssertNE(j.Get(`paths./default.post.responses.404`).String(), "") - t.AssertNE(j.Get(`paths./default.post.responses.405`).String(), "") - t.Assert(j.Get(`paths./default.post.responses.406`).String(), "") - t.Assert(j.Get(`paths./default.post.responses.407`).String(), "") - + t.AssertNE(j.Get(`paths./default.post.responses.500`).String(), "") + t.Assert(j.Get(`paths./default.post.responses.501`).String(), "") // Check content commonResponseSchema := `{"properties":{"code":{"format":"int","type":"integer"},"data":{"properties":{},"type":"object"},"message":{"format":"string","type":"string"}},"type":"object"}` Status201ExamplesContent := `{"code 1":{"value":{"code":1,"data":"Good","message":"Aha, 201 - 1"}},"code 2":{"value":{"code":2,"data":"Not Bad","message":"Aha, 201 - 2"}}}` Status401ExamplesContent := `{"example 1":{"value":{"code":1,"data":null,"message":"Aha, 401 - 1"}},"example 2":{"value":{"code":2,"data":null,"message":"Aha, 401 - 2"}}}` - Status402SchemaContent := `{"$ref":"#/components/schemas/github.com.gogf.gf.v2.net.goai_test.Issue3747Res402"}` - Issue3747Res403Ref := `{"$ref":"#/components/schemas/github.com.gogf.gf.v2.net.goai_test.Issue3747Res403"}` + Status402SchemaContent := `{"$ref":"#/components/schemas/github.com.gogf.gf.v2.net.goai_test.Issue3889Res402"}` + Issue3889Res403Ref := `{"$ref":"#/components/schemas/github.com.gogf.gf.v2.net.goai_test.Issue3889Res403"}` t.Assert(j.Get(`paths./default.post.responses.201.content.application/json.examples`).String(), Status201ExamplesContent) t.Assert(j.Get(`paths./default.post.responses.401.content.application/json.examples`).String(), Status401ExamplesContent) t.Assert(j.Get(`paths./default.post.responses.402.content.application/json.schema`).String(), Status402SchemaContent) - t.Assert(j.Get(`paths./default.post.responses.403.content.application/json.schema`).String(), Issue3747Res403Ref) + t.Assert(j.Get(`paths./default.post.responses.403.content.application/json.schema`).String(), Issue3889Res403Ref) t.Assert(j.Get(`paths./default.post.responses.404.content.application/json.schema`).String(), commonResponseSchema) - t.Assert(j.Get(`paths./default.post.responses.405.content.application/json.schema`).String(), commonResponseSchema) + t.Assert(j.Get(`paths./default.post.responses.500.content.application/json.schema`).String(), commonResponseSchema) api := s.GetOpenApi() - reqPath := "github.com.gogf.gf.v2.net.goai_test.Issue3747Res403" + reqPath := "github.com.gogf.gf.v2.net.goai_test.Issue3889Res403" schema := api.Components.Schemas.Get(reqPath).Value - Issue3747Res403Schema := `{"properties":{"code":{"format":"int","type":"integer"},"message":{"format":"string","type":"string"}},"type":"object"}` - t.Assert(schema, Issue3747Res403Schema) + Issue3889Res403Schema := `{"properties":{"code":{"format":"int","type":"integer"},"message":{"format":"string","type":"string"}},"type":"object"}` + t.Assert(schema, Issue3889Res403Schema) }) } diff --git a/net/goai/testdata/Issue3747JsonFile/401.json b/net/goai/testdata/Issue3747JsonFile/401.json deleted file mode 100644 index 334599ef8de..00000000000 --- a/net/goai/testdata/Issue3747JsonFile/401.json +++ /dev/null @@ -1,12 +0,0 @@ -[ - { - "code": 1, - "message": "Aha, 401 - 1", - "data": null - }, - { - "code": 2, - "message": "Aha, 401 - 2", - "data": null - } -] \ No newline at end of file diff --git a/net/goai/testdata/Issue3747JsonFile/201.json b/net/goai/testdata/Issue3889JsonFile/201.json similarity index 100% rename from net/goai/testdata/Issue3747JsonFile/201.json rename to net/goai/testdata/Issue3889JsonFile/201.json From ee3eb8d48cd0496e9e5a67c2ee1f4f4e8358b088 Mon Sep 17 00:00:00 2001 From: Wlynxg Date: Sat, 23 Nov 2024 15:38:14 +0800 Subject: [PATCH 009/102] fix(net/goai): embedded struct with tags also expand as properties of the parent struct (#3956) --- net/goai/goai_shema.go | 2 +- net/goai/goai_z_unit_issue_test.go | 44 ++++++++++++++++++++++++++++++ 2 files changed, 45 insertions(+), 1 deletion(-) diff --git a/net/goai/goai_shema.go b/net/goai/goai_shema.go index f8a6be2d831..042e0f21537 100644 --- a/net/goai/goai_shema.go +++ b/net/goai/goai_shema.go @@ -176,7 +176,7 @@ func (oai *OpenApiV3) structToSchema(object interface{}) (*Schema, error) { // struct. structFields, _ := gstructs.Fields(gstructs.FieldsInput{ Pointer: object, - RecursiveOption: gstructs.RecursiveOptionEmbeddedNoTag, + RecursiveOption: gstructs.RecursiveOptionEmbedded, }) schema.Type = TypeObject for _, structField := range structFields { diff --git a/net/goai/goai_z_unit_issue_test.go b/net/goai/goai_z_unit_issue_test.go index 9979bd23e65..f9696d3d3a3 100644 --- a/net/goai/goai_z_unit_issue_test.go +++ b/net/goai/goai_z_unit_issue_test.go @@ -256,3 +256,47 @@ func Test_Issue3889(t *testing.T) { t.Assert(schema, Issue3889Res403Schema) }) } + +type Issue3930DefaultReq struct { + g.Meta `path:"/user/{id}" method:"get" tags:"User" summary:"Get one user"` + Id int64 `v:"required" dc:"user id"` +} +type Issue3930DefaultRes struct { + *Issue3930User `dc:"user"` +} +type Issue3930User struct { + Id uint `json:"id" orm:"id" description:"user id"` // user id +} + +type Issue3930 struct{} + +func (Issue3930) Default(ctx context.Context, req *Issue3930DefaultReq) (res *Issue3930DefaultRes, err error) { + res = &Issue3930DefaultRes{} + return +} + +// https://github.com/gogf/gf/issues/3930 +func Test_Issue3930(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + s := g.Server(guid.S()) + s.Use(ghttp.MiddlewareHandlerResponse) + s.Group("/", func(group *ghttp.RouterGroup) { + group.Bind( + new(Issue3930), + ) + }) + s.SetLogger(nil) + s.SetOpenApiPath("/api.json") + s.SetDumpRouterMap(false) + s.Start() + defer s.Shutdown() + + time.Sleep(100 * time.Millisecond) + + var ( + api = s.GetOpenApi() + reqPath = "github.com.gogf.gf.v2.net.goai_test.Issue3930DefaultRes" + ) + t.AssertNE(api.Components.Schemas.Get(reqPath).Value.Properties.Get("id"), nil) + }) +} From eb8024913d1ab3f2421b69e2f0edeb09a5f18e5f Mon Sep 17 00:00:00 2001 From: ninjashixuan <37137471+ninjashixuan@users.noreply.github.com> Date: Sat, 23 Nov 2024 15:38:52 +0800 Subject: [PATCH 010/102] feat(net/goai): add min, max, length, min-length, max-length and between support for OpenAPIv3 (#3914) --- net/goai/goai.go | 10 +++++-- net/goai/goai_shema.go | 51 ++++++++++++++++++++++++++++++++++++ net/goai/goai_z_unit_test.go | 36 +++++++++++++++++++++++-- 3 files changed, 93 insertions(+), 4 deletions(-) diff --git a/net/goai/goai.go b/net/goai/goai.go index d248374af57..d43b29920ca 100644 --- a/net/goai/goai.go +++ b/net/goai/goai.go @@ -63,8 +63,14 @@ const ( ) const ( - validationRuleKeyForRequired = `required` - validationRuleKeyForIn = `in:` + validationRuleKeyForRequired = `required` + validationRuleKeyForIn = `in:` + validationRuleKeyForMax = `max:` + validationRuleKeyForMin = `min:` + validationRuleKeyForLength = `length:` + validationRuleKeyForMaxLength = `max-length:` + validationRuleKeyForMinLength = `min-length:` + validationRuleKeyForBetween = `between:` ) var ( diff --git a/net/goai/goai_shema.go b/net/goai/goai_shema.go index 042e0f21537..9d1e1e7126a 100644 --- a/net/goai/goai_shema.go +++ b/net/goai/goai_shema.go @@ -8,6 +8,7 @@ package goai import ( "reflect" + "strings" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/container/gset" @@ -204,6 +205,56 @@ func (oai *OpenApiV3) structToSchema(object interface{}) (*Schema, error) { if validationRuleSet.Contains(validationRuleKeyForRequired) { schema.Required = append(schema.Required, key) } + + // Extract validation rules to schema. like min, max, length + lstRules := gstr.Split(ref.Value.ValidationRules, "|") + for _, rule := range lstRules { + if strings.HasPrefix(rule, validationRuleKeyForMax) { + if ref.Value.Type == "integer" || ref.Value.Type == "number" { + f := gconv.Float64(rule[4:]) + ref.Value.Max = &f + } + } + + if strings.HasPrefix(rule, validationRuleKeyForMaxLength) { + maxlength := gconv.Uint64(rule[11:]) + ref.Value.MaxLength = &maxlength + } + + if strings.HasPrefix(rule, validationRuleKeyForMin) { + if ref.Value.Type == "integer" || ref.Value.Type == "number" { + f := gconv.Float64(rule[4:]) + ref.Value.Min = &f + } + } + + if strings.HasPrefix(rule, validationRuleKeyForMinLength) { + minlength := gconv.Uint64(rule[11:]) + ref.Value.MinLength = minlength + } + + if strings.HasPrefix(rule, validationRuleKeyForLength) { + lengthRule := gstr.Split(rule[7:], ",") + if len(lengthRule) == 2 { + minlength := gconv.Uint64(lengthRule[0]) + ref.Value.MinLength = minlength + maxlength := gconv.Uint64(lengthRule[1]) + ref.Value.MaxLength = &maxlength + } + } + + if strings.HasPrefix(rule, validationRuleKeyForBetween) { + if ref.Value.Type == "integer" || ref.Value.Type == "number" { + lengthRule := gstr.Split(rule[8:], ",") + if len(lengthRule) == 2 { + minimum := gconv.Float64(lengthRule[0]) + ref.Value.Min = &minimum + maximum := gconv.Float64(lengthRule[1]) + ref.Value.Max = &maximum + } + } + } + } } if !isValidParameterName(key) { ignoreProperties = append(ignoreProperties, key) diff --git a/net/goai/goai_z_unit_test.go b/net/goai/goai_z_unit_test.go index cc875844eb4..f7e5d53a44e 100644 --- a/net/goai/goai_z_unit_test.go +++ b/net/goai/goai_z_unit_test.go @@ -1200,8 +1200,8 @@ func TestOpenApiV3_PathSecurity(t *testing.T) { type Req struct { gmeta.Meta `method:"PUT" security:"apiKey"` // 这里的apiKey要和openApi定义的key一致 - Product string `json:"product" v:"required" description:"Unique product key"` - Name string `json:"name" v:"required" description:"Instance name"` + Product string `json:"product" v:"required" description:"Unique product key"` + Name string `json:"name" v:"required" description:"Instance name"` } type Res struct{} @@ -1345,3 +1345,35 @@ func Test_XExtension(t *testing.T) { t.Assert(oai.String(), gtest.DataContent("XExtension", "expect.json")) }) } + +func Test_ValidationRules(t *testing.T) { + type Req struct { + g.Meta `path:"/rules" method:"POST" tags:"Rules" summary:"Validation rules."` + Name string `v:"required|min-length:3|max-length:32#required|min|max" dc:"Name"` + Age int `v:"required|min:1|max:100" dc:"Age"` + Grade int `v:"between:1,12#please enter the correct grade." dc:"Grade"` + Address string `v:"length:3,64" dc:"Address"` + } + + gtest.C(t, func(t *gtest.T) { + var ( + err error + oai = goai.New() + req = new(Req) + ) + err = oai.Add(goai.AddInput{ + Object: req, + }) + t.AssertNil(err) + + schema := oai.Components.Schemas.Get("github.com.gogf.gf.v2.net.goai_test.Req").Value + t.Assert(schema.Properties.Get("Name").Value.MinLength, 3) + t.Assert(schema.Properties.Get("Name").Value.MaxLength, 32) + t.Assert(schema.Properties.Get("Age").Value.Min, 1.0) + t.Assert(schema.Properties.Get("Age").Value.Max, 100.0) + t.Assert(schema.Properties.Get("Grade").Value.Min, 1.0) + t.Assert(schema.Properties.Get("Grade").Value.Max, 12.0) + t.Assert(schema.Properties.Get("Address").Value.MinLength, 3) + t.Assert(schema.Properties.Get("Address").Value.MaxLength, 64) + }) +} From e56371e7c9ba407f4d6d407cc27cf850a6f5e465 Mon Sep 17 00:00:00 2001 From: ppanphper Date: Sat, 23 Nov 2024 17:54:20 +0800 Subject: [PATCH 011/102] fix(cmd/gf): incorrect environment variables printing before cli does some environment changes (#3961) --- cmd/gf/internal/cmd/cmd_build.go | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/cmd/gf/internal/cmd/cmd_build.go b/cmd/gf/internal/cmd/cmd_build.go index 182ee370b78..2454da57473 100644 --- a/cmd/gf/internal/cmd/cmd_build.go +++ b/cmd/gf/internal/cmd/cmd_build.go @@ -138,11 +138,6 @@ type cBuildInput struct { type cBuildOutput struct{} func (c cBuild) Index(ctx context.Context, in cBuildInput) (out *cBuildOutput, err error) { - // print used go env - if in.DumpENV { - _, _ = Env.Index(ctx, cEnvInput{}) - } - mlog.SetHeaderPrint(true) mlog.Debugf(`build command input: %+v`, in) @@ -241,6 +236,10 @@ func (c cBuild) Index(ctx context.Context, in cBuildInput) (out *cBuildOutput, e } else { genv.MustSet("CGO_ENABLED", "0") } + // print used go env + if in.DumpENV { + _, _ = Env.Index(ctx, cEnvInput{}) + } for system, item := range platformMap { if len(customSystems) > 0 && customSystems[0] != "all" && !gstr.InArray(customSystems, system) { continue From 455830b842713e5be9eb73d1c308d29279358ce4 Mon Sep 17 00:00:00 2001 From: John Guo Date: Sat, 23 Nov 2024 18:35:02 +0800 Subject: [PATCH 012/102] test(database/gdb): add more unit testing cases for `Raw` feature (#3962) --- .../mysql_z_unit_feature_raw_type_test.go | 49 +++++++++++++++++-- database/gdb/gdb_model_select.go | 10 ++-- 2 files changed, 52 insertions(+), 7 deletions(-) diff --git a/contrib/drivers/mysql/mysql_z_unit_feature_raw_type_test.go b/contrib/drivers/mysql/mysql_z_unit_feature_raw_type_test.go index eb825678529..5bc008e300d 100644 --- a/contrib/drivers/mysql/mysql_z_unit_feature_raw_type_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_feature_raw_type_test.go @@ -7,6 +7,7 @@ package mysql_test import ( + "context" "testing" "github.com/gogf/gf/v2/database/gdb" @@ -14,7 +15,7 @@ import ( "github.com/gogf/gf/v2/test/gtest" ) -func Test_Insert_Raw(t *testing.T) { +func Test_Raw_Insert(t *testing.T) { table := createTable() defer dropTable(table) @@ -33,7 +34,7 @@ func Test_Insert_Raw(t *testing.T) { }) } -func Test_BatchInsert_Raw(t *testing.T) { +func Test_Raw_BatchInsert(t *testing.T) { table := createTable() defer dropTable(table) @@ -63,7 +64,7 @@ func Test_BatchInsert_Raw(t *testing.T) { }) } -func Test_Update_Raw(t *testing.T) { +func Test_Raw_Update(t *testing.T) { table := createInitTable() defer dropTable(table) @@ -84,3 +85,45 @@ func Test_Update_Raw(t *testing.T) { t.Assert(n, 1) }) } + +func Test_Raw_Where(t *testing.T) { + table1 := createTable("Test_Raw_Where_Table1") + table2 := createTable("Test_Raw_Where_Table2") + defer dropTable(table1) + defer dropTable(table2) + + // https://github.com/gogf/gf/issues/3922 + gtest.C(t, func(t *gtest.T) { + expectSql := "SELECT * FROM `Test_Raw_Where_Table1` AS A WHERE NOT EXISTS (SELECT B.id FROM `Test_Raw_Where_Table2` AS B WHERE `B`.`id`=A.id) LIMIT 1" + sql, err := gdb.ToSQL(ctx, func(ctx context.Context) error { + s := db.Model(table2).As("B").Ctx(ctx).Fields("B.id").Where("B.id", gdb.Raw("A.id")) + m := db.Model(table1).As("A").Ctx(ctx).Where("NOT EXISTS ?", s).Limit(1) + _, err := m.All() + return err + }) + t.AssertNil(err) + t.Assert(expectSql, sql) + }) + gtest.C(t, func(t *gtest.T) { + expectSql := "SELECT * FROM `Test_Raw_Where_Table1` AS A WHERE NOT EXISTS (SELECT B.id FROM `Test_Raw_Where_Table2` AS B WHERE B.id=A.id) LIMIT 1" + sql, err := gdb.ToSQL(ctx, func(ctx context.Context) error { + s := db.Model(table2).As("B").Ctx(ctx).Fields("B.id").Where(gdb.Raw("B.id=A.id")) + m := db.Model(table1).As("A").Ctx(ctx).Where("NOT EXISTS ?", s).Limit(1) + _, err := m.All() + return err + }) + t.AssertNil(err) + t.Assert(expectSql, sql) + }) + // https://github.com/gogf/gf/issues/3915 + gtest.C(t, func(t *gtest.T) { + expectSql := "SELECT * FROM `Test_Raw_Where_Table1` WHERE `passport` < `nickname`" + sql, err := gdb.ToSQL(ctx, func(ctx context.Context) error { + m := db.Model(table1).Ctx(ctx).WhereLT("passport", gdb.Raw("`nickname`")) + _, err := m.All() + return err + }) + t.AssertNil(err) + t.Assert(expectSql, sql) + }) +} diff --git a/database/gdb/gdb_model_select.go b/database/gdb/gdb_model_select.go index 98f91bd127f..a369f71ade2 100644 --- a/database/gdb/gdb_model_select.go +++ b/database/gdb/gdb_model_select.go @@ -283,10 +283,12 @@ func (m *Model) Scan(pointer interface{}, where ...interface{}) error { } } -// ScanAndCount scans a single record or record array that matches the given conditions and counts the total number of records that match those conditions. -// If useFieldForCount is true, it will use the fields specified in the model for counting; -// The pointer parameter is a pointer to a struct that the scanned data will be stored in. -// The pointerCount parameter is a pointer to an integer that will be set to the total number of records that match the given conditions. +// ScanAndCount scans a single record or record array that matches the given conditions and counts the total number +// of records that match those conditions. +// +// If `useFieldForCount` is true, it will use the fields specified in the model for counting; +// The `pointer` parameter is a pointer to a struct that the scanned data will be stored in. +// The `totalCount` parameter is a pointer to an integer that will be set to the total number of records that match the given conditions. // The where parameter is an optional list of conditions to use when retrieving records. // // Example: From 81aed066437181512d728d1488bd1ccbbb3b6696 Mon Sep 17 00:00:00 2001 From: John Guo Date: Wed, 27 Nov 2024 21:03:31 +0800 Subject: [PATCH 013/102] feat: README updates (#3974) --- README.MD | 60 ++++++------------------------------------------------- 1 file changed, 6 insertions(+), 54 deletions(-) diff --git a/README.MD b/README.MD index 1ffeca6ec13..5c2db9daab4 100644 --- a/README.MD +++ b/README.MD @@ -1,4 +1,3 @@ -# GoFrame
@@ -20,73 +19,26 @@
-`GoFrame` is a modular, powerful, high-performance and enterprise-class application development framework of Golang. +A powerful framework for faster, easier, and more efficient project development. -# Features - -- modular, loosely coupled design -- rich components, out-of-the-box -- automatic codes generating for efficiency -- simple and easy to use, detailed documentation -- interface designed components, with high scalability -- fully supported tracing and error stack feature -- specially developed and powerful ORM component -- robust engineering design specifications -- convenient development CLI tool provide -- OpenTelemetry observability features support -- OpenAPIV3 documentation generating, automatically -- much, much more...ready to explore? # Documentation - GoFrame Official Site: [https://goframe.org](https://goframe.org) +- GoFrame Official Site(en): [https://goframe.org/en](https://goframe.org/en) +- GoFrame Mirror Site(中文): [https://goframe.org.cn](https://goframe.org.cn) +- GoFrame Mirror Site(github pages): [https://pages.goframe.org](https://pages.goframe.org) - GoDoc API: [https://pkg.go.dev/github.com/gogf/gf/v2](https://pkg.go.dev/github.com/gogf/gf/v2) -# Installation - -Enter your repo. directory and execute following command: - -## primary module - -```bash -go get -u -v github.com/gogf/gf/v2 -``` - -## cli tool - -```bash -go install github.com/gogf/gf/cmd/gf/v2@latest -``` - -# Limitation - -``` -golang version >= 1.20 -``` - # Contributors -💖 Thanks all the contributors making GoFrame awesome! [[Contributors](https://github.com/gogf/gf/graphs/contributors)] 💖 +💖 [Thanks to all the contributors who made GoFrame possible](https://github.com/gogf/gf/graphs/contributors) 💖 - + # License `GoFrame` is licensed under the [MIT License](LICENSE), 100% free and open-source, forever. - - -# Donators - -If you love `GoFrame`, why not [buy developer a cup of coffee](https://goframe.org/supportus/donate)? - -# Sponsors - -We appreciate any kind of sponsorship for `GoFrame` development. If you've got some interesting, please contact WeChat `389961817` / Email `john@goframe.org`. - -# Thanks - -JetBrains -Atlassian From 5521d768ffe40fdb5a42fc0e4c77d21305409966 Mon Sep 17 00:00:00 2001 From: Luoyy <10894778+zishang520@users.noreply.github.com> Date: Wed, 27 Nov 2024 21:09:42 +0800 Subject: [PATCH 014/102] feat(cmd/gf): add `typeMapping` and `fieldMapping` feature support for command `gf gen genpbentity` (#3970) --- .../cmd/cmd_z_unit_gen_pbentity_test.go | 77 ++++++ .../internal/cmd/genpbentity/genpbentity.go | 224 ++++++++++++++---- .../genpbentity/generated/table_user.proto | 14 +- .../table_user_snake_screaming.proto | 14 +- .../cmd/testdata/issue/3545/table_user.proto | 14 +- .../cmd/testdata/issue/3685/table_user.proto | 23 ++ .../cmd/testdata/issue/3685/user.tpl.sql | 11 + 7 files changed, 307 insertions(+), 70 deletions(-) create mode 100644 cmd/gf/internal/cmd/testdata/issue/3685/table_user.proto create mode 100644 cmd/gf/internal/cmd/testdata/issue/3685/user.tpl.sql diff --git a/cmd/gf/internal/cmd/cmd_z_unit_gen_pbentity_test.go b/cmd/gf/internal/cmd/cmd_z_unit_gen_pbentity_test.go index 4a105697d74..851dc2a7edf 100644 --- a/cmd/gf/internal/cmd/cmd_z_unit_gen_pbentity_test.go +++ b/cmd/gf/internal/cmd/cmd_z_unit_gen_pbentity_test.go @@ -52,6 +52,8 @@ func Test_Gen_Pbentity_Default(t *testing.T) { NameCase: "", JsonCase: "", Option: "", + TypeMapping: nil, + FieldMapping: nil, } ) err = gutil.FillStructWithDefault(&in) @@ -115,6 +117,8 @@ func Test_Gen_Pbentity_NameCase_SnakeScreaming(t *testing.T) { NameCase: "SnakeScreaming", JsonCase: "", Option: "", + TypeMapping: nil, + FieldMapping: nil, } ) err = gutil.FillStructWithDefault(&in) @@ -179,6 +183,8 @@ func Test_Issue_3545(t *testing.T) { NameCase: "", JsonCase: "", Option: "", + TypeMapping: nil, + FieldMapping: nil, } ) err = gutil.FillStructWithDefault(&in) @@ -208,3 +214,74 @@ func Test_Issue_3545(t *testing.T) { } }) } + +// https://github.com/gogf/gf/issues/3685 +func Test_Issue_3685(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + err error + db = testDB + table = "table_user" + sqlContent = fmt.Sprintf( + gtest.DataContent(`issue`, `3685`, `user.tpl.sql`), + table, + ) + ) + dropTableWithDb(db, table) + array := gstr.SplitAndTrim(sqlContent, ";") + for _, v := range array { + if _, err = db.Exec(ctx, v); err != nil { + t.AssertNil(err) + } + } + defer dropTableWithDb(db, table) + + var ( + path = gfile.Temp(guid.S()) + in = genpbentity.CGenPbEntityInput{ + Path: path, + Package: "", + Link: link, + Tables: "", + Prefix: "", + RemovePrefix: "", + RemoveFieldPrefix: "", + NameCase: "", + JsonCase: "", + Option: "", + TypeMapping: map[genpbentity.DBFieldTypeName]genpbentity.CustomAttributeType{ + "json": { + Type: "google.protobuf.Value", + Import: "google/protobuf/struct.proto", + }, + }, + FieldMapping: nil, + } + ) + err = gutil.FillStructWithDefault(&in) + t.AssertNil(err) + + err = gfile.Mkdir(path) + t.AssertNil(err) + defer gfile.Remove(path) + + _, err = genpbentity.CGenPbEntity{}.PbEntity(ctx, in) + t.AssertNil(err) + + // files + files, err := gfile.ScanDir(path, "*.proto", false) + t.AssertNil(err) + t.Assert(files, []string{ + path + filepath.FromSlash("/table_user.proto"), + }) + + // contents + testPath := gtest.DataPath("issue", "3685") + expectFiles := []string{ + testPath + filepath.FromSlash("/table_user.proto"), + } + for i := range files { + t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i])) + } + }) +} diff --git a/cmd/gf/internal/cmd/genpbentity/genpbentity.go b/cmd/gf/internal/cmd/genpbentity/genpbentity.go index 12084671bac..29a660b0804 100644 --- a/cmd/gf/internal/cmd/genpbentity/genpbentity.go +++ b/cmd/gf/internal/cmd/genpbentity/genpbentity.go @@ -11,6 +11,7 @@ import ( "context" "fmt" "path/filepath" + "regexp" "strings" "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" @@ -18,6 +19,7 @@ import ( "github.com/gogf/gf/cmd/gf/v2/internal/consts" "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" @@ -43,6 +45,9 @@ type ( NameCase string `name:"nameCase" short:"n" brief:"{CGenPbEntityBriefNameCase}" d:"Camel"` JsonCase string `name:"jsonCase" short:"j" brief:"{CGenPbEntityBriefJsonCase}" d:"none"` Option string `name:"option" short:"o" brief:"{CGenPbEntityBriefOption}"` + + TypeMapping map[DBFieldTypeName]CustomAttributeType `name:"typeMapping" short:"y" brief:"{CGenPbEntityBriefTypeMapping}" orphan:"true"` + FieldMapping map[DBTableFieldName]CustomAttributeType `name:"fieldMapping" short:"fm" brief:"{CGenPbEntityBriefFieldMapping}" orphan:"true"` } CGenPbEntityOutput struct{} @@ -52,6 +57,13 @@ type ( TableName string // TableName specifies the table name of the table. NewTableName string // NewTableName specifies the prefix-stripped name of the table. } + + DBTableFieldName = string + DBFieldTypeName = string + CustomAttributeType struct { + Type string `brief:"custom attribute type name"` + Import string `brief:"custom import for this type"` + } ) const ( @@ -69,7 +81,7 @@ gf gen pbentity -r user_ CGenPbEntityAd = ` CONFIGURATION SUPPORT Options are also supported by configuration file. - It's suggested using configuration file instead of command line arguments making producing. + It's suggested using configuration file instead of command line arguments making producing. The configuration node name is "gf.gen.pbentity", which also supports multiple databases, for example(config.yaml): gfcli: gen: @@ -88,6 +100,13 @@ CONFIGURATION SUPPORT option go_package = "protobuf/demos"; option java_package = "protobuf/demos"; option php_namespace = "protobuf/demos"; + typeMapping: + json: + type: google.protobuf.Value + import: google/protobuf/struct.proto + jsonb: + type: google.protobuf.Value + import: google/protobuf/struct.proto ` CGenPbEntityBriefPath = `directory path for generated files storing` CGenPbEntityBriefPackage = `package path for all entity proto files` @@ -106,7 +125,7 @@ it's not necessary and the default value is "default" case for message attribute names, default is "Camel": | Case | Example | |---------------- |--------------------| -| Camel | AnyKindOfString | +| Camel | AnyKindOfString | | CamelLower | anyKindOfString | default | Snake | any_kind_of_string | | SnakeScreaming | ANY_KIND_OF_STRING | @@ -119,8 +138,95 @@ case for message attribute names, default is "Camel": case for message json tag, cases are the same as "nameCase", default "CamelLower". set it to "none" to ignore json tag generating. ` + + CGenPbEntityBriefTypeMapping = `custom local type mapping for generated struct attributes relevant to fields of table` + CGenPbEntityBriefFieldMapping = `custom local type mapping for generated struct attributes relevant to specific fields of table` ) +var defaultTypeMapping = map[DBFieldTypeName]CustomAttributeType{ + // gdb.LocalTypeString + "string": { + Type: "string", + }, + // gdb.LocalTypeTime + // "time": { + // Type: "google.protobuf.Duration", + // Import: "google/protobuf/duration.proto", + // }, + // gdb.LocalTypeDate + "date": { + Type: "google.protobuf.Timestamp", + Import: "google/protobuf/timestamp.proto", + }, + // gdb.LocalTypeDatetime + "datetime": { + Type: "google.protobuf.Timestamp", + Import: "google/protobuf/timestamp.proto", + }, + // gdb.LocalTypeInt + "int": { + Type: "int32", + }, + // gdb.LocalTypeUint + "uint": { + Type: "uint32", + }, + // gdb.LocalTypeInt64 + "int64": { + Type: "int64", + }, + // gdb.LocalTypeUint64 + "uint64": { + Type: "uint64", + }, + // gdb.LocalTypeIntSlice + "[]int": { + Type: "repeated int32", + }, + // gdb.LocalTypeInt64Slice + "[]int64": { + Type: "repeated int64", + }, + // gdb.LocalTypeUint64Slice + "[]uint64": { + Type: "repeated uint64", + }, + // gdb.LocalTypeInt64Bytes + "int64-bytes": { + Type: "repeated int64", + }, + // gdb.LocalTypeUint64Bytes + "uint64-bytes": { + Type: "repeated uint64", + }, + // gdb.LocalTypeFloat32 + "float32": { + Type: "float", + }, + // gdb.LocalTypeFloat64 + "float64": { + Type: "double", + }, + // gdb.LocalTypeBytes + "[]byte": { + Type: "bytes", + }, + // gdb.LocalTypeBool + "bool": { + Type: "bool", + }, + // gdb.LocalTypeJson + // "json": { + // Type: "google.protobuf.Value", + // Import: "google/protobuf/struct.proto", + // }, + // gdb.LocalTypeJsonb + // "jsonb": { + // Type: "google.protobuf.Value", + // Import: "google/protobuf/struct.proto", + // }, +} + func init() { gtag.Sets(g.MapStrStr{ `CGenPbEntityConfig`: CGenPbEntityConfig, @@ -138,6 +244,8 @@ func init() { `CGenPbEntityBriefNameCase`: CGenPbEntityBriefNameCase, `CGenPbEntityBriefJsonCase`: CGenPbEntityBriefJsonCase, `CGenPbEntityBriefOption`: CGenPbEntityBriefOption, + `CGenPbEntityBriefTypeMapping`: CGenPbEntityBriefTypeMapping, + `CGenPbEntityBriefFieldMapping`: CGenPbEntityBriefFieldMapping, }) } @@ -210,6 +318,16 @@ func doGenPbEntityForArray(ctx context.Context, index int, in CGenPbEntityInput) mlog.Fatalf("fetching tables failed: \n %v", err) } } + // merge default typeMapping to input typeMapping. + if in.TypeMapping == nil { + in.TypeMapping = defaultTypeMapping + } else { + for key, typeMapping := range defaultTypeMapping { + if _, ok := in.TypeMapping[key]; !ok { + in.TypeMapping[key] = typeMapping + } + } + } for _, tableName := range tableNames { newTableName := tableName @@ -234,18 +352,24 @@ func generatePbEntityContentFile(ctx context.Context, in CGenPbEntityInternalInp // Change the `newTableName` if `Prefix` is given. newTableName := in.Prefix + in.NewTableName var ( - imports string - tableNameCamelCase = gstr.CaseCamel(newTableName) - tableNameSnakeCase = gstr.CaseSnake(newTableName) - entityMessageDefine = generateEntityMessageDefinition(tableNameCamelCase, fieldMap, in) - fileName = gstr.Trim(tableNameSnakeCase, "-_.") - path = filepath.FromSlash(gfile.Join(in.Path, fileName+".proto")) + tableNameCamelCase = gstr.CaseCamel(newTableName) + tableNameSnakeCase = gstr.CaseSnake(newTableName) + entityMessageDefine, appendImports = generateEntityMessageDefinition(tableNameCamelCase, fieldMap, in) + fileName = gstr.Trim(tableNameSnakeCase, "-_.") + path = filepath.FromSlash(gfile.Join(in.Path, fileName+".proto")) ) - if gstr.Contains(entityMessageDefine, "google.protobuf.Timestamp") { - imports = `import "google/protobuf/timestamp.proto";` + packageImportStr := "" + var packageImportsArray = garray.NewStrArray() + if len(appendImports) > 0 { + for _, appendImport := range appendImports { + packageImportStr = fmt.Sprintf(`import "%s";`, appendImport) + if packageImportsArray.Search(packageImportStr) == -1 { + packageImportsArray.Append(packageImportStr) + } + } } entityContent := gstr.ReplaceByMap(getTplPbEntityContent(""), g.MapStrStr{ - "{Imports}": imports, + "{Imports}": packageImportsArray.Join("\n"), "{PackageName}": gfile.Basename(in.Package), "{GoPackage}": in.Package, "{OptionContent}": in.Option, @@ -259,14 +383,19 @@ func generatePbEntityContentFile(ctx context.Context, in CGenPbEntityInternalInp } // generateEntityMessageDefinition generates and returns the message definition for specified table. -func generateEntityMessageDefinition(entityName string, fieldMap map[string]*gdb.TableField, in CGenPbEntityInternalInput) string { +func generateEntityMessageDefinition(entityName string, fieldMap map[string]*gdb.TableField, in CGenPbEntityInternalInput) (string, []string) { var ( - buffer = bytes.NewBuffer(nil) - array = make([][]string, len(fieldMap)) - names = sortFieldKeyForPbEntity(fieldMap) + appendImports []string + buffer = bytes.NewBuffer(nil) + array = make([][]string, len(fieldMap)) + names = sortFieldKeyForPbEntity(fieldMap) ) for index, name := range names { - array[index] = generateMessageFieldForPbEntity(index+1, fieldMap[name], in) + var imports string + array[index], imports = generateMessageFieldForPbEntity(index+1, fieldMap[name], in) + if imports != "" { + appendImports = append(appendImports, imports) + } } tw := tablewriter.NewWriter(buffer) tw.SetBorder(false) @@ -277,48 +406,38 @@ func generateEntityMessageDefinition(entityName string, fieldMap map[string]*gdb tw.Render() stContent := buffer.String() // Let's do this hack of table writer for indent! - stContent = gstr.Replace(stContent, " #", "") + stContent = regexp.MustCompile(`\s+\n`).ReplaceAllString(gstr.Replace(stContent, " #", ""), "\n") buffer.Reset() buffer.WriteString(fmt.Sprintf("message %s {\n", entityName)) buffer.WriteString(stContent) buffer.WriteString("}") - return buffer.String() + return buffer.String(), appendImports } // generateMessageFieldForPbEntity generates and returns the message definition for specified field. -func generateMessageFieldForPbEntity(index int, field *gdb.TableField, in CGenPbEntityInternalInput) []string { +func generateMessageFieldForPbEntity(index int, field *gdb.TableField, in CGenPbEntityInternalInput) (attrLines []string, appendImport string) { var ( - localTypeName gdb.LocalType - comment string - jsonTagStr string - err error - ctx = gctx.GetInitCtx() + localTypeNameStr string + localTypeName gdb.LocalType + comment string + jsonTagStr string + err error + ctx = gctx.GetInitCtx() ) - localTypeName, err = in.DB.CheckLocalTypeForField(ctx, field.Type, nil) - if err != nil { - panic(err) - } - var typeMapping = map[gdb.LocalType]string{ - gdb.LocalTypeString: "string", - gdb.LocalTypeDate: "google.protobuf.Timestamp", - gdb.LocalTypeDatetime: "google.protobuf.Timestamp", - gdb.LocalTypeInt: "int32", - gdb.LocalTypeUint: "uint32", - gdb.LocalTypeInt64: "int64", - gdb.LocalTypeUint64: "uint64", - gdb.LocalTypeIntSlice: "repeated int32", - gdb.LocalTypeInt64Slice: "repeated int64", - gdb.LocalTypeUint64Slice: "repeated uint64", - gdb.LocalTypeInt64Bytes: "repeated int64", - gdb.LocalTypeUint64Bytes: "repeated uint64", - gdb.LocalTypeFloat32: "float", - gdb.LocalTypeFloat64: "double", - gdb.LocalTypeBytes: "bytes", - gdb.LocalTypeBool: "bool", - gdb.LocalTypeJson: "string", - gdb.LocalTypeJsonb: "string", + + if in.TypeMapping != nil && len(in.TypeMapping) > 0 { + localTypeName, err = in.DB.CheckLocalTypeForField(ctx, field.Type, nil) + if err != nil { + panic(err) + } + if localTypeName != "" { + if typeMapping, ok := in.TypeMapping[strings.ToLower(string(localTypeName))]; ok { + localTypeNameStr = typeMapping.Type + appendImport = typeMapping.Import + } + } } - localTypeNameStr := typeMapping[localTypeName] + if localTypeNameStr == "" { localTypeNameStr = "string" } @@ -351,12 +470,19 @@ func generateMessageFieldForPbEntity(index int, field *gdb.TableField, in CGenPb newFiledName = gstr.TrimLeftStr(newFiledName, v, 1) } + if in.FieldMapping != nil && len(in.FieldMapping) > 0 { + if typeMapping, ok := in.FieldMapping[fmt.Sprintf("%s.%s", in.TableName, newFiledName)]; ok { + localTypeNameStr = typeMapping.Type + appendImport = typeMapping.Import + } + } + return []string{ " #" + localTypeNameStr, " #" + formatCase(newFiledName, in.NameCase), " #= " + gconv.String(index) + jsonTagStr + ";", " #" + fmt.Sprintf(`// %s`, comment), - } + }, appendImport } func getTplPbEntityContent(tplEntityPath string) string { diff --git a/cmd/gf/internal/cmd/testdata/genpbentity/generated/table_user.proto b/cmd/gf/internal/cmd/testdata/genpbentity/generated/table_user.proto index e5074b491e4..874a55a05b3 100644 --- a/cmd/gf/internal/cmd/testdata/genpbentity/generated/table_user.proto +++ b/cmd/gf/internal/cmd/testdata/genpbentity/generated/table_user.proto @@ -11,11 +11,11 @@ option go_package = "unittest"; import "google/protobuf/timestamp.proto"; message TableUser { - uint32 Id = 1; // User ID - string Passport = 2; // User Passport - string Password = 3; // User Password - string Nickname = 4; // User Nickname - string Score = 5; // Total score amount. - google.protobuf.Timestamp CreateAt = 6; // Created Time - google.protobuf.Timestamp UpdateAt = 7; // Updated Time + uint32 Id = 1; // User ID + string Passport = 2; // User Passport + string Password = 3; // User Password + string Nickname = 4; // User Nickname + string Score = 5; // Total score amount. + google.protobuf.Timestamp CreateAt = 6; // Created Time + google.protobuf.Timestamp UpdateAt = 7; // Updated Time } \ No newline at end of file diff --git a/cmd/gf/internal/cmd/testdata/genpbentity/generated/table_user_snake_screaming.proto b/cmd/gf/internal/cmd/testdata/genpbentity/generated/table_user_snake_screaming.proto index 365999ece70..9613131dab3 100644 --- a/cmd/gf/internal/cmd/testdata/genpbentity/generated/table_user_snake_screaming.proto +++ b/cmd/gf/internal/cmd/testdata/genpbentity/generated/table_user_snake_screaming.proto @@ -11,11 +11,11 @@ option go_package = "unittest"; import "google/protobuf/timestamp.proto"; message TableUser { - uint32 ID = 1; // User ID - string PASSPORT = 2; // User Passport - string PASSWORD = 3; // User Password - string NICKNAME = 4; // User Nickname - string SCORE = 5; // Total score amount. - google.protobuf.Timestamp CREATE_AT = 6; // Created Time - google.protobuf.Timestamp UPDATE_AT = 7; // Updated Time + uint32 ID = 1; // User ID + string PASSPORT = 2; // User Passport + string PASSWORD = 3; // User Password + string NICKNAME = 4; // User Nickname + string SCORE = 5; // Total score amount. + google.protobuf.Timestamp CREATE_AT = 6; // Created Time + google.protobuf.Timestamp UPDATE_AT = 7; // Updated Time } \ No newline at end of file diff --git a/cmd/gf/internal/cmd/testdata/issue/3545/table_user.proto b/cmd/gf/internal/cmd/testdata/issue/3545/table_user.proto index 6282f3a61da..2b95b405626 100644 --- a/cmd/gf/internal/cmd/testdata/issue/3545/table_user.proto +++ b/cmd/gf/internal/cmd/testdata/issue/3545/table_user.proto @@ -11,11 +11,11 @@ option go_package = "github.com/gogf/gf/cmd/gf/v2/internal/cmd/api/pbentity"; import "google/protobuf/timestamp.proto"; message TableUser { - uint32 Id = 1; // User ID - string Passport = 2; // User Passport - string Password = 3; // User Password - string Nickname = 4; // User Nickname - string Score = 5; // Total score amount. - google.protobuf.Timestamp CreateAt = 6; // Created Time - google.protobuf.Timestamp UpdateAt = 7; // Updated Time + uint32 Id = 1; // User ID + string Passport = 2; // User Passport + string Password = 3; // User Password + string Nickname = 4; // User Nickname + string Score = 5; // Total score amount. + google.protobuf.Timestamp CreateAt = 6; // Created Time + google.protobuf.Timestamp UpdateAt = 7; // Updated Time } \ No newline at end of file diff --git a/cmd/gf/internal/cmd/testdata/issue/3685/table_user.proto b/cmd/gf/internal/cmd/testdata/issue/3685/table_user.proto new file mode 100644 index 00000000000..803cfa81f00 --- /dev/null +++ b/cmd/gf/internal/cmd/testdata/issue/3685/table_user.proto @@ -0,0 +1,23 @@ +// ========================================================================== +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// ========================================================================== + +syntax = "proto3"; + +package pbentity; + +option go_package = "github.com/gogf/gf/cmd/gf/v2/internal/cmd/api/pbentity"; + +import "google/protobuf/struct.proto"; +import "google/protobuf/timestamp.proto"; + +message TableUser { + uint32 Id = 1; // User ID + string Passport = 2; // User Passport + string Password = 3; // User Password + string Nickname = 4; // User Nickname + string Score = 5; // Total score amount. + google.protobuf.Value Data = 6; // User Data + google.protobuf.Timestamp CreateAt = 7; // Created Time + google.protobuf.Timestamp UpdateAt = 8; // Updated Time +} \ No newline at end of file diff --git a/cmd/gf/internal/cmd/testdata/issue/3685/user.tpl.sql b/cmd/gf/internal/cmd/testdata/issue/3685/user.tpl.sql new file mode 100644 index 00000000000..87493a6f8df --- /dev/null +++ b/cmd/gf/internal/cmd/testdata/issue/3685/user.tpl.sql @@ -0,0 +1,11 @@ +CREATE TABLE `%s` ( + `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'User ID', + `passport` varchar(45) NOT NULL COMMENT 'User Passport', + `password` varchar(45) NOT NULL COMMENT 'User Password', + `nickname` varchar(45) NOT NULL COMMENT 'User Nickname', + `score` decimal(10,2) unsigned DEFAULT NULL COMMENT 'Total score amount.', + `data` json DEFAULT NULL COMMENT 'User Data', + `create_at` datetime DEFAULT NULL COMMENT 'Created Time', + `update_at` datetime DEFAULT NULL COMMENT 'Updated Time', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb3; \ No newline at end of file From 16d73b5bdf3f1b1d644cd0d5eef435e87a60d76d Mon Sep 17 00:00:00 2001 From: 0x7a7a <298164449@qq.com> Date: Fri, 29 Nov 2024 18:25:13 +0800 Subject: [PATCH 015/102] fix(utils/gvalid): missing pkg path for enums pointer (#3983) --- util/gvalid/gvalid_z_unit_feature_rule_test.go | 11 +++++++++++ util/gvalid/internal/builtin/builtin_enums.go | 3 ++- 2 files changed, 13 insertions(+), 1 deletion(-) diff --git a/util/gvalid/gvalid_z_unit_feature_rule_test.go b/util/gvalid/gvalid_z_unit_feature_rule_test.go index c4c10d615a5..7d16bae83b8 100755 --- a/util/gvalid/gvalid_z_unit_feature_rule_test.go +++ b/util/gvalid/gvalid_z_unit_feature_rule_test.go @@ -1577,6 +1577,10 @@ func Test_Enums(t *testing.T) { Id int Enums EnumsTest `v:"enums"` } + type PointerParams struct { + Id int + Enums *EnumsTest `v:"enums"` + } type SliceParams struct { Id int Enums []EnumsTest `v:"foreach|enums"` @@ -1601,6 +1605,13 @@ func Test_Enums(t *testing.T) { }).Run(ctx) t.Assert(err, "The Enums value `c` should be in enums of: [\"a\",\"b\"]") + var b EnumsTest = "b" + err = g.Validator().Data(&PointerParams{ + Id: 1, + Enums: &b, + }).Run(ctx) + t.AssertNil(err) + err = g.Validator().Data(&SliceParams{ Id: 1, Enums: []EnumsTest{EnumsTestA, EnumsTestB}, diff --git a/util/gvalid/internal/builtin/builtin_enums.go b/util/gvalid/internal/builtin/builtin_enums.go index 071ec4d11fd..1c370f511f4 100644 --- a/util/gvalid/internal/builtin/builtin_enums.go +++ b/util/gvalid/internal/builtin/builtin_enums.go @@ -47,8 +47,9 @@ func (r RuleEnums) Run(in RunInput) error { var ( pkgPath = in.ValueType.PkgPath() typeName = in.ValueType.Name() + typeKind = in.ValueType.Kind() ) - if in.ValueType.Kind() == reflect.Slice { + if typeKind == reflect.Slice || typeKind == reflect.Ptr { pkgPath = in.ValueType.Elem().PkgPath() typeName = in.ValueType.Elem().Name() } From e572ed01b3eed62dfd0eac21a1cc120df9a4a490 Mon Sep 17 00:00:00 2001 From: yijiong <59520517+yzy613@users.noreply.github.com> Date: Sun, 1 Dec 2024 10:05:46 +0800 Subject: [PATCH 016/102] fix(net/ghttp): get origin through referer (#3990) --- net/ghttp/ghttp_response_cors.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/net/ghttp/ghttp_response_cors.go b/net/ghttp/ghttp_response_cors.go index 59772f5526c..7a80fe64773 100644 --- a/net/ghttp/ghttp_response_cors.go +++ b/net/ghttp/ghttp_response_cors.go @@ -64,8 +64,8 @@ func (r *Response) DefaultCORSOptions() CORSOptions { if origin := r.Request.Header.Get("Origin"); origin != "" { options.AllowOrigin = origin } else if referer := r.Request.Referer(); referer != "" { - if p := gstr.PosR(referer, "/", 6); p != -1 { - options.AllowOrigin = referer[:p] + if ref, err := url.Parse(referer); err == nil { + options.AllowOrigin = ref.Scheme + "://" + ref.Host } else { options.AllowOrigin = referer } From 9923975b1c024e297cb3d207f9082267e99af7c7 Mon Sep 17 00:00:00 2001 From: oldme <45782393+oldme-git@users.noreply.github.com> Date: Sun, 1 Dec 2024 10:16:03 +0800 Subject: [PATCH 017/102] feat(net/gipv4): add enhanced the conversion between uint32 and string (#3988) --- net/gipv4/gipv4.go | 19 +-------- net/gipv4/gipv4_convert.go | 59 ++++++++++++++++++++++++++ net/gipv4/gipv4_z_unit_convert_test.go | 54 +++++++++++++++++++++++ 3 files changed, 114 insertions(+), 18 deletions(-) create mode 100644 net/gipv4/gipv4_convert.go create mode 100644 net/gipv4/gipv4_z_unit_convert_test.go diff --git a/net/gipv4/gipv4.go b/net/gipv4/gipv4.go index ea52f913145..df0c3d6dd6e 100644 --- a/net/gipv4/gipv4.go +++ b/net/gipv4/gipv4.go @@ -6,33 +6,16 @@ // // Package gipv4 provides useful API for IPv4 address handling. + package gipv4 import ( - "encoding/binary" "fmt" - "net" "strconv" "github.com/gogf/gf/v2/text/gregex" ) -// Ip2long converts ip address to an uint32 integer. -func Ip2long(ip string) uint32 { - netIp := net.ParseIP(ip) - if netIp == nil { - return 0 - } - return binary.BigEndian.Uint32(netIp.To4()) -} - -// Long2ip converts an uint32 integer ip address to its string type address. -func Long2ip(long uint32) string { - ipByte := make([]byte, 4) - binary.BigEndian.PutUint32(ipByte, long) - return net.IP(ipByte).String() -} - // Validate checks whether given `ip` a valid IPv4 address. func Validate(ip string) bool { return gregex.IsMatchString(`^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$`, ip) diff --git a/net/gipv4/gipv4_convert.go b/net/gipv4/gipv4_convert.go new file mode 100644 index 00000000000..47d82555c4f --- /dev/null +++ b/net/gipv4/gipv4_convert.go @@ -0,0 +1,59 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. +// + +// Package gipv4 provides useful API for IPv4 address handling. + +package gipv4 + +import ( + "encoding/binary" + "net" +) + +// IpToLongBigEndian converts ip address to an uint32 integer with big endian. +func IpToLongBigEndian(ip string) uint32 { + netIp := net.ParseIP(ip) + if netIp == nil { + return 0 + } + return binary.BigEndian.Uint32(netIp.To4()) +} + +// LongToIpBigEndian converts an uint32 integer ip address to its string type address with big endian. +func LongToIpBigEndian(long uint32) string { + ipByte := make([]byte, 4) + binary.BigEndian.PutUint32(ipByte, long) + return net.IP(ipByte).String() +} + +// IpToLongLittleEndian converts ip address to an uint32 integer with little endian. +func IpToLongLittleEndian(ip string) uint32 { + netIp := net.ParseIP(ip) + if netIp == nil { + return 0 + } + return binary.LittleEndian.Uint32(netIp.To4()) +} + +// LongToIpLittleEndian converts an uint32 integer ip address to its string type address with little endian. +func LongToIpLittleEndian(long uint32) string { + ipByte := make([]byte, 4) + binary.LittleEndian.PutUint32(ipByte, long) + return net.IP(ipByte).String() +} + +// Ip2long converts ip address to an uint32 integer. +// Deprecated: Use IpToLongBigEndian instead. +func Ip2long(ip string) uint32 { + return IpToLongBigEndian(ip) +} + +// Long2ip converts an uint32 integer ip address to its string type address. +// Deprecated: Use LongToIpBigEndian instead. +func Long2ip(long uint32) string { + return LongToIpBigEndian(long) +} diff --git a/net/gipv4/gipv4_z_unit_convert_test.go b/net/gipv4/gipv4_z_unit_convert_test.go new file mode 100644 index 00000000000..19ef9c5f5ec --- /dev/null +++ b/net/gipv4/gipv4_z_unit_convert_test.go @@ -0,0 +1,54 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package gipv4_test + +import ( + "testing" + + "github.com/gogf/gf/v2/net/gipv4" + "github.com/gogf/gf/v2/test/gtest" +) + +const ( + ipv4 string = "192.168.1.1" + longBigEndian uint32 = 3232235777 + longLittleEndian uint32 = 16885952 +) + +func TestIpToLongBigEndian(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var u = gipv4.IpToLongBigEndian(ipv4) + t.Assert(u, longBigEndian) + + var u2 = gipv4.Ip2long(ipv4) + t.Assert(u2, longBigEndian) + }) +} + +func TestLongToIpBigEndian(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var s = gipv4.LongToIpBigEndian(longBigEndian) + t.Assert(s, ipv4) + + var s2 = gipv4.Long2ip(longBigEndian) + t.Assert(s2, ipv4) + }) +} + +func TestIpToLongLittleEndian(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var u = gipv4.IpToLongLittleEndian(ipv4) + t.Assert(u, longLittleEndian) + }) +} + +func TestLongToIpLittleEndian(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var s = gipv4.LongToIpLittleEndian(longLittleEndian) + t.Assert(s, ipv4) + }) +} From c1850d4ab563e0995cba2495168884cd1da7dd43 Mon Sep 17 00:00:00 2001 From: Wlynxg Date: Sun, 1 Dec 2024 11:27:35 +0800 Subject: [PATCH 018/102] feat(net/goai): support OpenAPIv3.1 in description field for schema object (#3978) --- net/goai/goai.go | 4 +++ net/goai/goai_shema_ref.go | 8 +++-- net/goai/goai_z_unit_issue_test.go | 53 ++++++++++++++++++++++++++++-- 3 files changed, 60 insertions(+), 5 deletions(-) diff --git a/net/goai/goai.go b/net/goai/goai.go index d43b29920ca..9228b89dc44 100644 --- a/net/goai/goai.go +++ b/net/goai/goai.go @@ -233,6 +233,10 @@ func formatRefToBytes(ref string) []byte { return []byte(fmt.Sprintf(`{"$ref":"#/components/schemas/%s"}`, ref)) } +func formatRefAndDescToBytes(ref, desc string) []byte { + return []byte(fmt.Sprintf(`{"$ref":"#/components/schemas/%s","description":"%s"}`, ref, desc)) +} + func isValidParameterName(key string) bool { return key != "-" } diff --git a/net/goai/goai_shema_ref.go b/net/goai/goai_shema_ref.go index 8fe6d4afe4b..63eef6894ba 100644 --- a/net/goai/goai_shema_ref.go +++ b/net/goai/goai_shema_ref.go @@ -19,8 +19,9 @@ import ( type SchemaRefs []SchemaRef type SchemaRef struct { - Ref string - Value *Schema + Ref string + Description string + Value *Schema } // isEmbeddedStructDefinition checks and returns whether given golang type is embedded struct definition, like: @@ -169,6 +170,7 @@ func (oai *OpenApiV3) newSchemaRefWithGolangType(golangType reflect.Type, tagMap } schemaRef.Ref = structTypeName schemaRef.Value = schema + schemaRef.Description = schema.Description } } } @@ -177,7 +179,7 @@ func (oai *OpenApiV3) newSchemaRefWithGolangType(golangType reflect.Type, tagMap func (r SchemaRef) MarshalJSON() ([]byte, error) { if r.Ref != "" { - return formatRefToBytes(r.Ref), nil + return formatRefAndDescToBytes(r.Ref, r.Description), nil } return json.Marshal(r.Value) } diff --git a/net/goai/goai_z_unit_issue_test.go b/net/goai/goai_z_unit_issue_test.go index f9696d3d3a3..67fed9a26aa 100644 --- a/net/goai/goai_z_unit_issue_test.go +++ b/net/goai/goai_z_unit_issue_test.go @@ -238,8 +238,8 @@ func Test_Issue3889(t *testing.T) { commonResponseSchema := `{"properties":{"code":{"format":"int","type":"integer"},"data":{"properties":{},"type":"object"},"message":{"format":"string","type":"string"}},"type":"object"}` Status201ExamplesContent := `{"code 1":{"value":{"code":1,"data":"Good","message":"Aha, 201 - 1"}},"code 2":{"value":{"code":2,"data":"Not Bad","message":"Aha, 201 - 2"}}}` Status401ExamplesContent := `{"example 1":{"value":{"code":1,"data":null,"message":"Aha, 401 - 1"}},"example 2":{"value":{"code":2,"data":null,"message":"Aha, 401 - 2"}}}` - Status402SchemaContent := `{"$ref":"#/components/schemas/github.com.gogf.gf.v2.net.goai_test.Issue3889Res402"}` - Issue3889Res403Ref := `{"$ref":"#/components/schemas/github.com.gogf.gf.v2.net.goai_test.Issue3889Res403"}` + Status402SchemaContent := `{"$ref":"#/components/schemas/github.com.gogf.gf.v2.net.goai_test.Issue3889Res402","description":""}` + Issue3889Res403Ref := `{"$ref":"#/components/schemas/github.com.gogf.gf.v2.net.goai_test.Issue3889Res403","description":""}` t.Assert(j.Get(`paths./default.post.responses.201.content.application/json.examples`).String(), Status201ExamplesContent) t.Assert(j.Get(`paths./default.post.responses.401.content.application/json.examples`).String(), Status401ExamplesContent) @@ -300,3 +300,52 @@ func Test_Issue3930(t *testing.T) { t.AssertNE(api.Components.Schemas.Get(reqPath).Value.Properties.Get("id"), nil) }) } + +type Issue3235DefaultReq struct { + g.Meta `path:"/user/{id}" method:"get" tags:"User" summary:"Get one user"` + Id int64 `v:"required" dc:"user id"` +} +type Issue3235DefaultRes struct { + Name string `dc:"test name desc"` + User *Issue3235User `dc:"test user desc"` +} +type Issue3235User struct { + Id uint `json:"id" orm:"id" description:"user id"` // user id +} + +type Issue3235 struct{} + +func (Issue3235) Default(ctx context.Context, req *Issue3235DefaultReq) (res *Issue3235DefaultRes, err error) { + res = &Issue3235DefaultRes{} + return +} + +// https://github.com/gogf/gf/issues/3235 +func Test_Issue3235(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + s := g.Server(guid.S()) + s.Use(ghttp.MiddlewareHandlerResponse) + s.Group("/", func(group *ghttp.RouterGroup) { + group.Bind( + new(Issue3235), + ) + }) + s.SetLogger(nil) + s.SetOpenApiPath("/api.json") + s.SetDumpRouterMap(false) + s.Start() + defer s.Shutdown() + + time.Sleep(100 * time.Millisecond) + + var ( + api = s.GetOpenApi() + reqPath = "github.com.gogf.gf.v2.net.goai_test.Issue3235DefaultRes" + ) + + t.Assert(api.Components.Schemas.Get(reqPath).Value.Properties.Get("Name").Value.Description, + "test name desc") + t.Assert(api.Components.Schemas.Get(reqPath).Value.Properties.Get("User").Description, + "test user desc") + }) +} From ec6e091882dd958b91a90af87a438eaf2995acb6 Mon Sep 17 00:00:00 2001 From: Long FlyBridge Date: Sun, 1 Dec 2024 11:29:09 +0800 Subject: [PATCH 019/102] chore: fix some function names in comment (#3967) --- database/gdb/gdb_model_soft_time.go | 2 +- encoding/gjson/gjson_api_encoding.go | 4 ++-- util/grand/grand_buffer.go | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/database/gdb/gdb_model_soft_time.go b/database/gdb/gdb_model_soft_time.go index aa6d50fea05..73e155275c8 100644 --- a/database/gdb/gdb_model_soft_time.go +++ b/database/gdb/gdb_model_soft_time.go @@ -183,7 +183,7 @@ func (m *softTimeMaintainer) GetFieldNameAndTypeForDelete( ) } -// getSoftFieldName retrieves and returns the field name of the table for possible key. +// getSoftFieldNameAndType retrieves and returns the field name of the table for possible key. func (m *softTimeMaintainer) getSoftFieldNameAndType( ctx context.Context, schema string, table string, checkFiledNames []string, diff --git a/encoding/gjson/gjson_api_encoding.go b/encoding/gjson/gjson_api_encoding.go index 7f08f0cccbd..23a0ae86fcd 100644 --- a/encoding/gjson/gjson_api_encoding.go +++ b/encoding/gjson/gjson_api_encoding.go @@ -207,7 +207,7 @@ func (j *Json) ToProperties() ([]byte, error) { return gproperties.Encode(j.Map()) } -// TopropertiesString properties to string +// ToPropertiesString properties to string func (j *Json) ToPropertiesString() (string, error) { b, e := j.ToProperties() return string(b), e @@ -221,7 +221,7 @@ func (j *Json) MustToProperties() []byte { return result } -// MustTopropertiesString +// MustToPropertiesString func (j *Json) MustToPropertiesString() string { return string(j.MustToProperties()) } diff --git a/util/grand/grand_buffer.go b/util/grand/grand_buffer.go index 4527c25a20b..4f527babc3b 100644 --- a/util/grand/grand_buffer.go +++ b/util/grand/grand_buffer.go @@ -28,7 +28,7 @@ func init() { go asyncProducingRandomBufferBytesLoop() } -// asyncProducingRandomBufferBytes is a named goroutine, which uses an asynchronous goroutine +// asyncProducingRandomBufferBytesLoop is a named goroutine, which uses an asynchronous goroutine // to produce the random bytes, and a buffer chan to store the random bytes. // So it has high performance to generate random numbers. func asyncProducingRandomBufferBytesLoop() { From 5aa7504bb2269d913783dd213a7bdcf45d910d2a Mon Sep 17 00:00:00 2001 From: houseme Date: Sun, 1 Dec 2024 23:43:44 +0800 Subject: [PATCH 020/102] fix(util/gpage): code scanning alert no. 9: Potentially unsafe quoting (#3992) --- .github/workflows/golangci-lint.yml | 17 ++++------------- util/gpage/gpage.go | 5 +++-- 2 files changed, 7 insertions(+), 15 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 42f1cc6eb2f..0aa08c04960 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -1,17 +1,8 @@ -# Tencent is pleased to support the open source community by making Polaris available. +# Copyright GoFrame Author(https://goframe.org). All Rights Reserved. # -# Copyright (C) 2019 THL A29 Limited, a Tencent company. All rights reserved. -# -# Licensed under the BSD 3-Clause License (the "License"); -# you may not use this file except in compliance with the License. -# You may obtain a copy of the License at -# -# https://opensource.org/licenses/BSD-3-Clause -# -# Unless required by applicable law or agreed to in writing, software distributed -# under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR -# CONDITIONS OF ANY KIND, either express or implied. See the License for the -# specific language governing permissions and limitations under the License. +# This Source Code Form is subject to the terms of the MIT License. +# If a copy of the MIT was not distributed with this file, +# You can obtain one at https://github.com/gogf/gf. name: GolangCI-Lint on: diff --git a/util/gpage/gpage.go b/util/gpage/gpage.go index 1570ff1e2c6..afdb3e65062 100644 --- a/util/gpage/gpage.go +++ b/util/gpage/gpage.go @@ -9,6 +9,7 @@ package gpage import ( "fmt" + "html" "math" "github.com/gogf/gf/v2/text/gstr" @@ -215,12 +216,12 @@ func (p *Page) GetLink(page int, text, title string) string { if len(p.AjaxActionName) > 0 { return fmt.Sprintf( `%s`, - p.LinkStyle, p.AjaxActionName, p.GetUrl(page), title, text, + p.LinkStyle, p.AjaxActionName, p.GetUrl(page), html.EscapeString(title), text, ) } else { return fmt.Sprintf( `%s`, - p.LinkStyle, p.GetUrl(page), title, text, + p.LinkStyle, p.GetUrl(page), html.EscapeString(title), text, ) } } From 42eae41599a75feb5cd858a6b07e2c0e71b0d961 Mon Sep 17 00:00:00 2001 From: houseme Date: Sun, 1 Dec 2024 23:44:48 +0800 Subject: [PATCH 021/102] fix(util/gutil): code scanning alert no. 17: Potentially unsafe quoting (#3993) --- util/gutil/gutil_dump.go | 1 + 1 file changed, 1 insertion(+) diff --git a/util/gutil/gutil_dump.go b/util/gutil/gutil_dump.go index d30f79b6fa3..69282cf993f 100644 --- a/util/gutil/gutil_dump.go +++ b/util/gutil/gutil_dump.go @@ -465,6 +465,7 @@ func doDumpDefault(in doDumpInternalInput) { func addSlashesForString(s string) string { return gstr.ReplaceByMap(s, map[string]string{ `"`: `\"`, + `'`: `\'`, "\r": `\r`, "\t": `\t`, "\n": `\n`, From 2c916f8222e317b1c31a4ff2c3f91d6946a114a9 Mon Sep 17 00:00:00 2001 From: John Guo Date: Sun, 1 Dec 2024 23:47:51 +0800 Subject: [PATCH 022/102] fix(database/gdb): issue where the `Count/Value/Array` query logic was incompatible with the old version when users extended the returned result fields using the `Select` Hook (#3995) --- .../drivers/mysql/mysql_z_unit_issue_test.go | 34 +++++- database/gdb/gdb.go | 21 ++-- database/gdb/gdb_core.go | 2 +- database/gdb/gdb_core_ctx.go | 2 - database/gdb/gdb_model_cache.go | 9 +- database/gdb/gdb_model_hook.go | 11 +- database/gdb/gdb_model_select.go | 108 ++++++++++++------ 7 files changed, 132 insertions(+), 55 deletions(-) diff --git a/contrib/drivers/mysql/mysql_z_unit_issue_test.go b/contrib/drivers/mysql/mysql_z_unit_issue_test.go index b3329a8fd91..58ceeb0a5f3 100644 --- a/contrib/drivers/mysql/mysql_z_unit_issue_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_issue_test.go @@ -13,6 +13,7 @@ import ( "testing" "time" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gtime" @@ -1283,12 +1284,12 @@ func Test_Issue3754(t *testing.T) { func Test_Issue3626(t *testing.T) { table := "issue3626" array := gstr.SplitAndTrim(gtest.DataContent(`issue3626.sql`), ";") + defer dropTable(table) for _, v := range array { if _, err := db.Exec(ctx, v); err != nil { gtest.Error(err) } } - defer dropTable(table) // Insert. gtest.C(t, func(t *gtest.T) { @@ -1377,3 +1378,34 @@ func Test_Issue3932(t *testing.T) { t.Assert(one["id"], 10) }) } + +// https://github.com/gogf/gf/issues/3968 +func Test_Issue3968(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + var hook = gdb.HookHandler{ + Select: func(ctx context.Context, in *gdb.HookSelectInput) (result gdb.Result, err error) { + result, err = in.Next(ctx) + if err != nil { + return nil, err + } + if result != nil { + for i, _ := range result { + result[i]["location"] = gvar.New("ny") + } + } + return + }, + } + var ( + count int + result gdb.Result + ) + err := db.Model(table).Hook(hook).ScanAndCount(&result, &count, false) + t.AssertNil(err) + t.Assert(count, 10) + t.Assert(len(result), 10) + }) +} diff --git a/database/gdb/gdb.go b/database/gdb/gdb.go index 80fc265648e..74d76e5c8a1 100644 --- a/database/gdb/gdb.go +++ b/database/gdb/gdb.go @@ -396,12 +396,13 @@ const ( linkPattern = `(\w+):([\w\-\$]*):(.*?)@(\w+?)\((.+?)\)/{0,1}([^\?]*)\?{0,1}(.*)` ) -type queryType int +type SelectType int const ( - queryTypeNormal queryType = iota - queryTypeCount - queryTypeValue + SelectTypeDefault SelectType = iota + SelectTypeCount + SelectTypeValue + SelectTypeArray ) type joinOperator string @@ -700,13 +701,13 @@ func getConfigNodeByWeight(cg ConfigGroup) *ConfigNode { } // Exclude the right border value. var ( - min = 0 - max = 0 - random = grand.N(0, total-1) + minWeight = 0 + maxWeight = 0 + random = grand.N(0, total-1) ) for i := 0; i < len(cg); i++ { - max = min + cg[i].Weight*100 - if random >= min && random < max { + maxWeight = minWeight + cg[i].Weight*100 + if random >= minWeight && random < maxWeight { // ==================================================== // Return a COPY of the ConfigNode. // ==================================================== @@ -714,7 +715,7 @@ func getConfigNodeByWeight(cg ConfigGroup) *ConfigNode { node = cg[i] return &node } - min = max + minWeight = maxWeight } return nil } diff --git a/database/gdb/gdb_core.go b/database/gdb/gdb_core.go index 3bce0512f1b..ec14ffd1be2 100644 --- a/database/gdb/gdb_core.go +++ b/database/gdb/gdb_core.go @@ -278,7 +278,7 @@ func (c *Core) doUnion(ctx context.Context, unionType int, unions ...*Model) *Mo unionTypeStr = "UNION" } for _, v := range unions { - sqlWithHolder, holderArgs := v.getFormattedSqlAndArgs(ctx, queryTypeNormal, false) + sqlWithHolder, holderArgs := v.getFormattedSqlAndArgs(ctx, SelectTypeDefault, false) if composedSqlStr == "" { composedSqlStr += fmt.Sprintf(`(%s)`, sqlWithHolder) } else { diff --git a/database/gdb/gdb_core_ctx.go b/database/gdb/gdb_core_ctx.go index d77e33a02b1..ea8ca4b665a 100644 --- a/database/gdb/gdb_core_ctx.go +++ b/database/gdb/gdb_core_ctx.go @@ -23,8 +23,6 @@ type internalCtxData struct { } // column stores column data in ctx for internal usage purpose. -// Deprecated. -// TODO remove this usage in future. type internalColumnData struct { // The first column in result response from database server. // This attribute is used for Value/Count selection statement purpose, diff --git a/database/gdb/gdb_model_cache.go b/database/gdb/gdb_model_cache.go index c1b6ca82041..76592cdec29 100644 --- a/database/gdb/gdb_model_cache.go +++ b/database/gdb/gdb_model_cache.go @@ -90,7 +90,7 @@ func (m *Model) getSelectResultFromCache(ctx context.Context, sql string, args . } func (m *Model) saveSelectResultToCache( - ctx context.Context, queryType queryType, result Result, sql string, args ...interface{}, + ctx context.Context, selectType SelectType, result Result, sql string, args ...interface{}, ) (err error) { if !m.cacheEnabled || m.tx != nil { return @@ -108,18 +108,19 @@ func (m *Model) saveSelectResultToCache( // Special handler for Value/Count operations result. if len(result) > 0 { var core = m.db.GetCore() - switch queryType { - case queryTypeValue, queryTypeCount: + switch selectType { + case SelectTypeValue, SelectTypeArray, SelectTypeCount: if internalData := core.getInternalColumnFromCtx(ctx); internalData != nil { if result[0][internalData.FirstResultColumn].IsEmpty() { result = nil } } + default: } } // In case of Cache Penetration. - if result.IsEmpty() { + if result != nil && result.IsEmpty() { if m.cacheOption.Force { result = Result{} } else { diff --git a/database/gdb/gdb_model_hook.go b/database/gdb/gdb_model_hook.go index 7dd00740578..3428990a73c 100644 --- a/database/gdb/gdb_model_hook.go +++ b/database/gdb/gdb_model_hook.go @@ -66,11 +66,12 @@ type internalParamHookDelete struct { // which is usually not be interesting for upper business hook handler. type HookSelectInput struct { internalParamHookSelect - Model *Model // Current operation Model. - Table string // The table name that to be used. Update this attribute to change target table name. - Schema string // The schema name that to be used. Update this attribute to change target schema name. - Sql string // The sql string that to be committed. - Args []interface{} // The arguments of sql. + Model *Model // Current operation Model. + Table string // The table name that to be used. Update this attribute to change target table name. + Schema string // The schema name that to be used. Update this attribute to change target schema name. + Sql string // The sql string that to be committed. + Args []interface{} // The arguments of sql. + SelectType SelectType // The type of this SELECT operation. } // HookInsertInput holds the parameters for insert hook operation. diff --git a/database/gdb/gdb_model_select.go b/database/gdb/gdb_model_select.go index a369f71ade2..8c6433abf02 100644 --- a/database/gdb/gdb_model_select.go +++ b/database/gdb/gdb_model_select.go @@ -28,7 +28,7 @@ import ( // see Model.Where. func (m *Model) All(where ...interface{}) (Result, error) { var ctx = m.GetCtx() - return m.doGetAll(ctx, false, where...) + return m.doGetAll(ctx, SelectTypeDefault, false, where...) } // AllAndCount retrieves all records and the total count of records from the model. @@ -69,7 +69,7 @@ func (m *Model) AllAndCount(useFieldForCount bool) (result Result, totalCount in } // Retrieve all records - result, err = m.doGetAll(m.GetCtx(), false) + result, err = m.doGetAll(m.GetCtx(), SelectTypeDefault, false) return } @@ -110,7 +110,7 @@ func (m *Model) One(where ...interface{}) (Record, error) { if len(where) > 0 { return m.Where(where[0], where[1:]...).One() } - all, err := m.doGetAll(ctx, true) + all, err := m.doGetAll(ctx, SelectTypeDefault, true) if err != nil { return nil, err } @@ -136,24 +136,41 @@ func (m *Model) Array(fieldsAndWhere ...interface{}) ([]Value, error) { return m.Fields(gconv.String(fieldsAndWhere[0])).Array() } } - all, err := m.All() + + var ( + field string + core = m.db.GetCore() + ctx = core.injectInternalColumn(m.GetCtx()) + ) + all, err := m.doGetAll(ctx, SelectTypeArray, false) if err != nil { return nil, err } - var field string if len(all) > 0 { - var recordFields = m.getRecordFields(all[0]) - if len(recordFields) > 1 { - // it returns error if there are multiple fields in the result record. - return nil, gerror.NewCodef( - gcode.CodeInvalidParameter, - `invalid fields for "Array" operation, result fields number "%d"%s, but expect one`, - len(recordFields), - gjson.MustEncodeString(recordFields), + internalData := core.getInternalColumnFromCtx(ctx) + if internalData == nil { + return nil, gerror.NewCode( + gcode.CodeInternalError, + `query count error: the internal context data is missing. there's internal issue should be fixed`, ) } - if len(recordFields) == 1 { - field = recordFields[0] + // If FirstResultColumn present, it returns the value of the first record of the first field. + // It means it use no cache mechanism, while cache mechanism makes `internalData` missing. + field = internalData.FirstResultColumn + if field == "" { + // Fields number check. + var recordFields = m.getRecordFields(all[0]) + if len(recordFields) == 1 { + field = recordFields[0] + } else { + // it returns error if there are multiple fields in the result record. + return nil, gerror.NewCodef( + gcode.CodeInvalidParameter, + `invalid fields for "Array" operation, result fields number "%d"%s, but expect one`, + len(recordFields), + gjson.MustEncodeString(recordFields), + ) + } } } return all.Array(field), nil @@ -398,13 +415,26 @@ func (m *Model) Value(fieldsAndWhere ...interface{}) (Value, error) { } } var ( - sqlWithHolder, holderArgs = m.getFormattedSqlAndArgs(ctx, queryTypeValue, true) - all, err = m.doGetAllBySql(ctx, queryTypeValue, sqlWithHolder, holderArgs...) + sqlWithHolder, holderArgs = m.getFormattedSqlAndArgs(ctx, SelectTypeValue, true) + all, err = m.doGetAllBySql(ctx, SelectTypeValue, sqlWithHolder, holderArgs...) ) if err != nil { return nil, err } if len(all) > 0 { + internalData := core.getInternalColumnFromCtx(ctx) + if internalData == nil { + return nil, gerror.NewCode( + gcode.CodeInternalError, + `query count error: the internal context data is missing. there's internal issue should be fixed`, + ) + } + // If FirstResultColumn present, it returns the value of the first record of the first field. + // It means it use no cache mechanism, while cache mechanism makes `internalData` missing. + if v, ok := all[0][internalData.FirstResultColumn]; ok { + return v, nil + } + // Fields number check. var recordFields = m.getRecordFields(all[0]) if len(recordFields) == 1 { for _, v := range all[0] { @@ -445,13 +475,26 @@ func (m *Model) Count(where ...interface{}) (int, error) { return m.Where(where[0], where[1:]...).Count() } var ( - sqlWithHolder, holderArgs = m.getFormattedSqlAndArgs(ctx, queryTypeCount, false) - all, err = m.doGetAllBySql(ctx, queryTypeCount, sqlWithHolder, holderArgs...) + sqlWithHolder, holderArgs = m.getFormattedSqlAndArgs(ctx, SelectTypeCount, false) + all, err = m.doGetAllBySql(ctx, SelectTypeCount, sqlWithHolder, holderArgs...) ) if err != nil { return 0, err } if len(all) > 0 { + internalData := core.getInternalColumnFromCtx(ctx) + if internalData == nil { + return 0, gerror.NewCode( + gcode.CodeInternalError, + `query count error: the internal context data is missing. there's internal issue should be fixed`, + ) + } + // If FirstResultColumn present, it returns the value of the first record of the first field. + // It means it use no cache mechanism, while cache mechanism makes `internalData` missing. + if v, ok := all[0][internalData.FirstResultColumn]; ok { + return v.Int(), nil + } + // Fields number check. var recordFields = m.getRecordFields(all[0]) if len(recordFields) == 1 { for _, v := range all[0] { @@ -616,17 +659,17 @@ func (m *Model) Having(having interface{}, args ...interface{}) *Model { // The parameter `limit1` specifies whether limits querying only one record if m.limit is not set. // The optional parameter `where` is the same as the parameter of Model.Where function, // see Model.Where. -func (m *Model) doGetAll(ctx context.Context, limit1 bool, where ...interface{}) (Result, error) { +func (m *Model) doGetAll(ctx context.Context, selectType SelectType, limit1 bool, where ...interface{}) (Result, error) { if len(where) > 0 { return m.Where(where[0], where[1:]...).All() } - sqlWithHolder, holderArgs := m.getFormattedSqlAndArgs(ctx, queryTypeNormal, limit1) - return m.doGetAllBySql(ctx, queryTypeNormal, sqlWithHolder, holderArgs...) + sqlWithHolder, holderArgs := m.getFormattedSqlAndArgs(ctx, selectType, limit1) + return m.doGetAllBySql(ctx, selectType, sqlWithHolder, holderArgs...) } // doGetAllBySql does the select statement on the database. func (m *Model) doGetAllBySql( - ctx context.Context, queryType queryType, sql string, args ...interface{}, + ctx context.Context, selectType SelectType, sql string, args ...interface{}, ) (result Result, err error) { if result, err = m.getSelectResultFromCache(ctx, sql, args...); err != nil || result != nil { return @@ -639,24 +682,25 @@ func (m *Model) doGetAllBySql( }, handler: m.hookHandler.Select, }, - Model: m, - Table: m.tables, - Sql: sql, - Args: m.mergeArguments(args), + Model: m, + Table: m.tables, + Sql: sql, + Args: m.mergeArguments(args), + SelectType: selectType, } if result, err = in.Next(ctx); err != nil { return } - err = m.saveSelectResultToCache(ctx, queryType, result, sql, args...) + err = m.saveSelectResultToCache(ctx, selectType, result, sql, args...) return } func (m *Model) getFormattedSqlAndArgs( - ctx context.Context, queryType queryType, limit1 bool, + ctx context.Context, selectType SelectType, limit1 bool, ) (sqlWithHolder string, holderArgs []interface{}) { - switch queryType { - case queryTypeCount: + switch selectType { + case SelectTypeCount: queryFields := "COUNT(1)" if len(m.fields) > 0 { // DO NOT quote the m.fields here, in case of fields like: @@ -698,7 +742,7 @@ func (m *Model) getFormattedSqlAndArgs( func (m *Model) getHolderAndArgsAsSubModel(ctx context.Context) (holder string, args []interface{}) { holder, args = m.getFormattedSqlAndArgs( - ctx, queryTypeNormal, false, + ctx, SelectTypeDefault, false, ) args = m.mergeArguments(args) return From 2d0cd7b770f5136aee32678083c595e91bc0dc4d Mon Sep 17 00:00:00 2001 From: John Guo Date: Mon, 2 Dec 2024 21:39:04 +0800 Subject: [PATCH 023/102] refactor(cmd/gf): change default src value to `api`, path to `internal/packed/packed_enums.go` for command `gen enums` (#3996) --- cmd/gf/internal/cmd/genenums/genenums.go | 9 +++++---- cmd/gf/internal/cmd/genenums/genenums_parser.go | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/cmd/gf/internal/cmd/genenums/genenums.go b/cmd/gf/internal/cmd/genenums/genenums.go index 8fa5662ff34..b4c3b3d0827 100644 --- a/cmd/gf/internal/cmd/genenums/genenums.go +++ b/cmd/gf/internal/cmd/genenums/genenums.go @@ -8,6 +8,7 @@ package genenums import ( "context" + "golang.org/x/tools/go/packages" "github.com/gogf/gf/cmd/gf/v2/internal/consts" @@ -22,8 +23,8 @@ type ( CGenEnums struct{} CGenEnumsInput struct { g.Meta `name:"enums" config:"{CGenEnumsConfig}" brief:"{CGenEnumsBrief}" eg:"{CGenEnumsEg}"` - Src string `name:"src" short:"s" dc:"source folder path to be parsed" d:"."` - Path string `name:"path" short:"p" dc:"output go file path storing enums content" d:"internal/boot/boot_enums.go"` + Src string `name:"src" short:"s" dc:"source folder path to be parsed" d:"api"` + Path string `name:"path" short:"p" dc:"output go file path storing enums content" d:"internal/packed/packed_enums.go"` Prefixes []string `name:"prefixes" short:"x" dc:"only exports packages that starts with specified prefixes"` } CGenEnumsOutput struct{} @@ -34,8 +35,8 @@ const ( CGenEnumsBrief = `parse go files in current project and generate enums go file` CGenEnumsEg = ` gf gen enums -gf gen enums -p internal/boot/boot_enums.go -gf gen enums -p internal/boot/boot_enums.go -s . +gf gen enums -p internal/packed/packed_enums.go +gf gen enums -p internal/packed/packed_enums.go -s . gf gen enums -x github.com/gogf ` ) diff --git a/cmd/gf/internal/cmd/genenums/genenums_parser.go b/cmd/gf/internal/cmd/genenums/genenums_parser.go index 2cacf95d6a3..66858a0ddd3 100644 --- a/cmd/gf/internal/cmd/genenums/genenums_parser.go +++ b/cmd/gf/internal/cmd/genenums/genenums_parser.go @@ -9,11 +9,11 @@ package genenums import ( "go/constant" "go/types" - "golang.org/x/tools/go/packages" "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" + "golang.org/x/tools/go/packages" ) const pkgLoadMode = 0xffffff From 532e665841450dc1499ea3202cc3a688b48d9dd6 Mon Sep 17 00:00:00 2001 From: John Guo Date: Tue, 3 Dec 2024 15:24:49 +0800 Subject: [PATCH 024/102] fix(database/gdb): move `Raw` parameter from args to sql statement before committed to db driver (#3997) --- .../drivers/mysql/mysql_z_unit_issue_test.go | 48 ++++++ contrib/drivers/mysql/testdata/issue3915.sql | 9 ++ database/gdb/gdb_core.go | 4 - database/gdb/gdb_func.go | 22 ++- text/gstr/gstr_replace.go | 93 ++++++++++++ text/gstr/gstr_z_example_test.go | 47 ++++++ text/gstr/gstr_z_unit_replace_test.go | 141 ++++++++++++++++++ 7 files changed, 353 insertions(+), 11 deletions(-) create mode 100644 contrib/drivers/mysql/testdata/issue3915.sql diff --git a/contrib/drivers/mysql/mysql_z_unit_issue_test.go b/contrib/drivers/mysql/mysql_z_unit_issue_test.go index 58ceeb0a5f3..549988036d4 100644 --- a/contrib/drivers/mysql/mysql_z_unit_issue_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_issue_test.go @@ -1409,3 +1409,51 @@ func Test_Issue3968(t *testing.T) { t.Assert(len(result), 10) }) } + +// https://github.com/gogf/gf/issues/3915 +func Test_Issue3915(t *testing.T) { + table := "issue3915" + array := gstr.SplitAndTrim(gtest.DataContent(`issue3915.sql`), ";") + for _, v := range array { + if _, err := db.Exec(ctx, v); err != nil { + gtest.Error(err) + } + } + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + //db.SetDebug(true) + all, err := db.Model(table).Where("a < b").All() + t.AssertNil(err) + t.Assert(len(all), 1) + t.Assert(all[0]["id"], 1) + + all, err = db.Model(table).Where(gdb.Raw("a < b")).All() + t.AssertNil(err) + t.Assert(len(all), 1) + t.Assert(all[0]["id"], 1) + + all, err = db.Model(table).WhereLT("a", gdb.Raw("`b`")).All() + t.AssertNil(err) + t.Assert(len(all), 1) + t.Assert(all[0]["id"], 1) + }) + + gtest.C(t, func(t *gtest.T) { + //db.SetDebug(true) + all, err := db.Model(table).Where("a > b").All() + t.AssertNil(err) + t.Assert(len(all), 1) + t.Assert(all[0]["id"], 2) + + all, err = db.Model(table).Where(gdb.Raw("a > b")).All() + t.AssertNil(err) + t.Assert(len(all), 1) + t.Assert(all[0]["id"], 2) + + all, err = db.Model(table).WhereGT("a", gdb.Raw("`b`")).All() + t.AssertNil(err) + t.Assert(len(all), 1) + t.Assert(all[0]["id"], 2) + }) +} diff --git a/contrib/drivers/mysql/testdata/issue3915.sql b/contrib/drivers/mysql/testdata/issue3915.sql new file mode 100644 index 00000000000..6fa6b86c8df --- /dev/null +++ b/contrib/drivers/mysql/testdata/issue3915.sql @@ -0,0 +1,9 @@ +CREATE TABLE `issue3915` ( + `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'user id', + `a` float DEFAULT NULL COMMENT 'user name', + `b` float DEFAULT NULL COMMENT 'user status', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +INSERT INTO `issue3915` (`id`,`a`,`b`) VALUES (1,1,2); +INSERT INTO `issue3915` (`id`,`a`,`b`) VALUES (2,5,4); \ No newline at end of file diff --git a/database/gdb/gdb_core.go b/database/gdb/gdb_core.go index ec14ffd1be2..0a88a17ecc6 100644 --- a/database/gdb/gdb_core.go +++ b/database/gdb/gdb_core.go @@ -789,9 +789,5 @@ func (c *Core) IsSoftCreatedFieldName(fieldName string) bool { // The internal handleArguments function might be called twice during the SQL procedure, // but do not worry about it, it's safe and efficient. func (c *Core) FormatSqlBeforeExecuting(sql string, args []interface{}) (newSql string, newArgs []interface{}) { - // DO NOT do this as there may be multiple lines and comments in the sql. - // sql = gstr.Trim(sql) - // sql = gstr.Replace(sql, "\n", " ") - // sql, _ = gregex.ReplaceString(`\s{2,}`, ` `, sql) return handleSliceAndStructArgsForSql(sql, args) } diff --git a/database/gdb/gdb_func.go b/database/gdb/gdb_func.go index 752710d1cf4..ce5258e9983 100644 --- a/database/gdb/gdb_func.go +++ b/database/gdb/gdb_func.go @@ -608,7 +608,7 @@ func formatWhereHolder(ctx context.Context, db DB, in formatWhereHolderInput) (n // =============================================================== if subModel, ok := in.Args[i].(*Model); ok { index := -1 - whereStr, _ = gregex.ReplaceStringFunc(`(\?)`, whereStr, func(s string) string { + whereStr = gstr.ReplaceFunc(whereStr, `?`, func(s string) string { index++ if i+len(newArgs) == index { sqlWithHolder, holderArgs := subModel.getHolderAndArgsAsSubModel(ctx) @@ -843,7 +843,7 @@ func handleSliceAndStructArgsForSql( counter = 0 replaced = false ) - newSql, _ = gregex.ReplaceStringFunc(`\?`, newSql, func(s string) string { + newSql = gstr.ReplaceFunc(newSql, `?`, func(s string) string { if replaced { return s } @@ -856,9 +856,20 @@ func handleSliceAndStructArgsForSql( return s }) - // Special struct handling. - case reflect.Struct: + default: switch oldArg.(type) { + // Do not append Raw arg to args but directly into the sql. + case Raw, *Raw: + var counter = 0 + newSql = gstr.ReplaceFunc(newSql, `?`, func(s string) string { + counter++ + if counter == index+insertHolderCount+1 { + return gconv.String(oldArg) + } + return s + }) + continue + // The underlying driver supports time.Time/*time.Time types. case time.Time, *time.Time: newArgs = append(newArgs, oldArg) @@ -881,9 +892,6 @@ func handleSliceAndStructArgsForSql( } } newArgs = append(newArgs, oldArg) - - default: - newArgs = append(newArgs, oldArg) } } return diff --git a/text/gstr/gstr_replace.go b/text/gstr/gstr_replace.go index 1449f9be005..94b650813ef 100644 --- a/text/gstr/gstr_replace.go +++ b/text/gstr/gstr_replace.go @@ -92,3 +92,96 @@ func ReplaceIByMap(origin string, replaces map[string]string) string { } return origin } + +// ReplaceFunc returns a copy of the string `origin` in which each non-overlapping substring +// that matches the given search string is replaced by the result of function `f` applied to that substring. +// The function `f` is called with each matching substring as its argument and must return a string to be used +// as the replacement value. +func ReplaceFunc(origin string, search string, f func(string) string) string { + if search == "" { + return origin + } + var ( + searchLen = len(search) + originLen = len(origin) + ) + // If search string is longer than origin string, no match is possible + if searchLen > originLen { + return origin + } + var ( + result strings.Builder + lastMatch int + currentPos int + ) + // Pre-allocate the builder capacity to avoid reallocations + result.Grow(originLen) + + for currentPos < originLen { + pos := Pos(origin[currentPos:], search) + if pos == -1 { + break + } + pos += currentPos + // Append unmatched portion + result.WriteString(origin[lastMatch:pos]) + // Apply replacement function and append result + match := origin[pos : pos+searchLen] + result.WriteString(f(match)) + // Update positions + lastMatch = pos + searchLen + currentPos = lastMatch + } + // Append remaining unmatched portion + if lastMatch < originLen { + result.WriteString(origin[lastMatch:]) + } + return result.String() +} + +// ReplaceIFunc returns a copy of the string `origin` in which each non-overlapping substring +// that matches the given search string is replaced by the result of function `f` applied to that substring. +// The match is done case-insensitively. +// The function `f` is called with each matching substring as its argument and must return a string to be used +// as the replacement value. +func ReplaceIFunc(origin string, search string, f func(string) string) string { + if search == "" { + return origin + } + var ( + searchLen = len(search) + originLen = len(origin) + ) + // If search string is longer than origin string, no match is possible + if searchLen > originLen { + return origin + } + var ( + result strings.Builder + lastMatch int + currentPos int + ) + // Pre-allocate the builder capacity to avoid reallocations + result.Grow(originLen) + + for currentPos < originLen { + pos := PosI(origin[currentPos:], search) + if pos == -1 { + break + } + pos += currentPos + // Append unmatched portion + result.WriteString(origin[lastMatch:pos]) + // Apply replacement function and append result + match := origin[pos : pos+searchLen] + result.WriteString(f(match)) + // Update positions + lastMatch = pos + searchLen + currentPos = lastMatch + } + // Append remaining unmatched portion + if lastMatch < originLen { + result.WriteString(origin[lastMatch:]) + } + return result.String() +} diff --git a/text/gstr/gstr_z_example_test.go b/text/gstr/gstr_z_example_test.go index c3499dda54b..afaefee0b61 100644 --- a/text/gstr/gstr_z_example_test.go +++ b/text/gstr/gstr_z_example_test.go @@ -8,6 +8,8 @@ package gstr_test import ( "fmt" + "strconv" + "strings" "github.com/gogf/gf/v2/text/gstr" ) @@ -1018,6 +1020,51 @@ func ExampleReplaceIByMap() { // goframe is very nice } +func ExampleReplaceFunc() { + str := "hello gf 2018~2020!" + // Replace "gf" with a custom function that returns "GoFrame" + result := gstr.ReplaceFunc(str, "gf", func(s string) string { + return "GoFrame" + }) + fmt.Println(result) + + // Replace numbers with their doubled values + result = gstr.ReplaceFunc("1 2 3", "2", func(s string) string { + n, _ := strconv.Atoi(s) + return strconv.Itoa(n * 2) + }) + fmt.Println(result) + + // Output: + // hello GoFrame 2018~2020! + // 1 4 3 +} + +func ExampleReplaceIFunc() { + str := "Hello GF, hello gf, HELLO Gf!" + // Replace any case variation of "gf" with "GoFrame" + result := gstr.ReplaceIFunc(str, "gf", func(s string) string { + return "GoFrame" + }) + fmt.Println(result) + + // Preserve the original case of each match + result = gstr.ReplaceIFunc(str, "gf", func(s string) string { + if s == strings.ToUpper(s) { + return "GOFRAME" + } + if s == strings.ToLower(s) { + return "goframe" + } + return "GoFrame" + }) + fmt.Println(result) + + // Output: + // Hello GoFrame, hello GoFrame, HELLO GoFrame! + // Hello GOFRAME, hello goframe, HELLO GoFrame! +} + // similartext func ExampleSimilarText() { var ( diff --git a/text/gstr/gstr_z_unit_replace_test.go b/text/gstr/gstr_z_unit_replace_test.go index 81e049f3745..fbc66fca61c 100644 --- a/text/gstr/gstr_z_unit_replace_test.go +++ b/text/gstr/gstr_z_unit_replace_test.go @@ -9,6 +9,7 @@ package gstr_test import ( + "strings" "testing" "github.com/gogf/gf/v2/frame/g" @@ -88,3 +89,143 @@ func Test_ReplaceI_2(t *testing.T) { t.Assert(gstr.ReplaceI("aaa", "A", "AA", 4), `AAAAAA`) }) } + +func Test_ReplaceIFunc(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + origin = "hello GF 2018~2020!" + search = "gf" + ) + // Simple replacement + result := gstr.ReplaceIFunc(origin, search, func(s string) string { + return "GoFrame" + }) + t.Assert(result, "hello GoFrame 2018~2020!") + + // Replace with original string + result = gstr.ReplaceIFunc(origin, search, func(s string) string { + return s + }) + t.Assert(result, origin) + + // Replace with empty string + result = gstr.ReplaceIFunc(origin, search, func(s string) string { + return "" + }) + t.Assert(result, "hello 2018~2020!") + + // Replace multiple occurrences with different cases + origin = "GF is best, gf is nice, Gf is excellent" + result = gstr.ReplaceIFunc(origin, search, func(s string) string { + return "GoFrame" + }) + t.Assert(result, "GoFrame is best, GoFrame is nice, GoFrame is excellent") + + // Empty search string + result = gstr.ReplaceIFunc(origin, "", func(s string) string { + return "GoFrame" + }) + t.Assert(result, origin) + + // Empty origin string + result = gstr.ReplaceIFunc("", search, func(s string) string { + return "GoFrame" + }) + t.Assert(result, "") + + // Replace with longer string + result = gstr.ReplaceIFunc("GF", search, func(s string) string { + return "GoFrame" + }) + t.Assert(result, "GoFrame") + + // Replace with shorter string + result = gstr.ReplaceIFunc("GF", search, func(s string) string { + return "g" + }) + t.Assert(result, "g") + + // Replace with mixed case patterns + origin = "gf GF Gf gF" + result = gstr.ReplaceIFunc(origin, search, func(s string) string { + return strings.ToUpper(s) + }) + t.Assert(result, "GF GF GF GF") + }) +} + +func Test_ReplaceFunc(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + origin = "hello gf 2018~2020!" + search = "gf" + ) + // Simple replacement + result := gstr.ReplaceFunc(origin, search, func(s string) string { + return "GoFrame" + }) + t.Assert(result, "hello GoFrame 2018~2020!") + + // Replace with original string + result = gstr.ReplaceFunc(origin, search, func(s string) string { + return s + }) + t.Assert(result, origin) + + // Replace with empty string + result = gstr.ReplaceFunc(origin, search, func(s string) string { + return "" + }) + t.Assert(result, "hello 2018~2020!") + + // Replace multiple occurrences + origin = "gf is best, gf is nice" + result = gstr.ReplaceFunc(origin, search, func(s string) string { + return "GoFrame" + }) + t.Assert(result, "GoFrame is best, GoFrame is nice") + + // Empty search string + result = gstr.ReplaceFunc(origin, "", func(s string) string { + return "GoFrame" + }) + t.Assert(result, origin) + + // Empty origin string + result = gstr.ReplaceFunc("", search, func(s string) string { + return "GoFrame" + }) + t.Assert(result, "") + + // Case sensitive + origin = "GF is best, gf is nice" + result = gstr.ReplaceFunc(origin, search, func(s string) string { + return "GoFrame" + }) + t.Assert(result, "GF is best, GoFrame is nice") + + // Replace with longer string + result = gstr.ReplaceFunc("gf", search, func(s string) string { + return "GoFrame" + }) + t.Assert(result, "GoFrame") + + // Replace with shorter string + result = gstr.ReplaceFunc("gf", search, func(s string) string { + return "g" + }) + t.Assert(result, "g") + }) + gtest.C(t, func(t *gtest.T) { + var ( + origin = "gggg" + search = "g" + replace = "gg" + ) + // Simple replacement + result := gstr.ReplaceFunc(origin, search, func(s string) string { + return replace + }) + t.Assert(result, "gggggggg") + }) +} From e2cafa35e0cf2af7db1a6c431b1b1b95d783f301 Mon Sep 17 00:00:00 2001 From: wanna Date: Thu, 5 Dec 2024 14:42:30 +0800 Subject: [PATCH 025/102] fix(cmd/gf): custom tags repeatedly added using command `gf gen pb` with `-a` option (#3966) --- cmd/gf/internal/cmd/cmd_z_unit_gen_pb_test.go | 39 +++++++++++++++++++ cmd/gf/internal/cmd/genpb/genpb_tag.go | 4 ++ .../cmd/testdata/issue/3953/issue3953.proto | 16 ++++++++ 3 files changed, 59 insertions(+) create mode 100644 cmd/gf/internal/cmd/testdata/issue/3953/issue3953.proto diff --git a/cmd/gf/internal/cmd/cmd_z_unit_gen_pb_test.go b/cmd/gf/internal/cmd/cmd_z_unit_gen_pb_test.go index f1ec5be5cbc..0f9e0913733 100644 --- a/cmd/gf/internal/cmd/cmd_z_unit_gen_pb_test.go +++ b/cmd/gf/internal/cmd/cmd_z_unit_gen_pb_test.go @@ -48,3 +48,42 @@ func TestGenPbIssue3882(t *testing.T) { t.Assert(gstr.Contains(genContent, exceptText), true) }) } + +// This issue only occurs when executing multiple times +// and the subsequent OutputApi is the parent directory of the previous execution +func TestGenPbIssue3953(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + outputPath = gfile.Temp(guid.S()) + outputApiPath = filepath.Join(outputPath, "api") + outputCtrlPath = filepath.Join(outputPath, "controller") + + protobufFolder = gtest.DataPath("issue", "3953") + in = genpb.CGenPbInput{ + Path: protobufFolder, + OutputApi: outputApiPath, + OutputCtrl: outputCtrlPath, + } + err error + ) + err = gfile.Mkdir(outputApiPath) + t.AssertNil(err) + err = gfile.Mkdir(outputCtrlPath) + t.AssertNil(err) + defer gfile.Remove(outputPath) + + _, err = genpb.CGenPb{}.Pb(ctx, in) + // do twice,and set outputApi to outputPath + in.OutputApi = outputPath + _, err = genpb.CGenPb{}.Pb(ctx, in) + t.AssertNil(err) + + var ( + genContent = gfile.GetContents(filepath.Join(outputApiPath, "issue3953.pb.go")) + // The old version would have appeared `v:"required" v:"required"` + // but the new version of the code will appear `v:"required"` only once + notExceptText = `v:"required" v:"required"` + ) + t.Assert(gstr.Contains(genContent, notExceptText), false) + }) +} diff --git a/cmd/gf/internal/cmd/genpb/genpb_tag.go b/cmd/gf/internal/cmd/genpb/genpb_tag.go index f8cfad7e5b8..ac74e28ebce 100644 --- a/cmd/gf/internal/cmd/genpb/genpb_tag.go +++ b/cmd/gf/internal/cmd/genpb/genpb_tag.go @@ -71,6 +71,10 @@ func (c CGenPb) doTagReplacement(ctx context.Context, content string) (string, e if !lineTagMap.IsEmpty() { tagContent := c.listMapToStructTag(lineTagMap) lineTagMap.Clear() + // If already have it, don't add it anymore + if gstr.Contains(gstr.StrTill(line, "` //"), tagContent) { + continue + } line, _ = gregex.ReplaceString("`(.+)`", fmt.Sprintf("`$1 %s`", tagContent), line) } lines[index] = line diff --git a/cmd/gf/internal/cmd/testdata/issue/3953/issue3953.proto b/cmd/gf/internal/cmd/testdata/issue/3953/issue3953.proto new file mode 100644 index 00000000000..8bc86fba1f7 --- /dev/null +++ b/cmd/gf/internal/cmd/testdata/issue/3953/issue3953.proto @@ -0,0 +1,16 @@ +syntax = "proto3"; +package account; + +option go_package = "account/v1"; + +service Account { + rpc getUserByIds (Req) returns (Resp) { + } +} + +message Req { + repeated int64 ids = 1; // v: required +} +message Resp { + repeated string data = 1; +} From 7cd672d22c8e6fecc64d938c7555c4db20409523 Mon Sep 17 00:00:00 2001 From: Hunk Zhu Date: Thu, 5 Dec 2024 14:44:21 +0800 Subject: [PATCH 026/102] feat(cmd/gf): add interface functions generating for embedded struct of logic struct in command `gen service` (#3802) --- .../cmd/cmd_z_unit_gen_service_test.go | 2 + cmd/gf/internal/cmd/genservice/genservice.go | 63 +++++++++-- .../cmd/genservice/genservice_ast_parse.go | 102 +++++++++++++++++- .../cmd/genservice/genservice_calculate.go | 75 +++++++++++++ .../testdata/genservice/logic/base/base.go | 17 +++ .../genservice/logic/base/base_destory.go | 13 +++ .../testdata/genservice/logic/base/sub/sub.go | 14 +++ .../testdata/genservice/logic/logic_expect.go | 1 + .../genservice/logic/user/supper_vip_user.go | 27 +++++ .../testdata/genservice/logic/user/user.go | 2 + .../genservice/logic/user/vip_user.go | 29 +++++ .../cmd/testdata/genservice/service/base.go | 32 ++++++ .../cmd/testdata/genservice/service/user.go | 68 +++++++++++- 13 files changed, 436 insertions(+), 9 deletions(-) create mode 100644 cmd/gf/internal/cmd/testdata/genservice/logic/base/base.go create mode 100644 cmd/gf/internal/cmd/testdata/genservice/logic/base/base_destory.go create mode 100644 cmd/gf/internal/cmd/testdata/genservice/logic/base/sub/sub.go create mode 100644 cmd/gf/internal/cmd/testdata/genservice/logic/user/supper_vip_user.go create mode 100644 cmd/gf/internal/cmd/testdata/genservice/logic/user/vip_user.go create mode 100644 cmd/gf/internal/cmd/testdata/genservice/service/base.go diff --git a/cmd/gf/internal/cmd/cmd_z_unit_gen_service_test.go b/cmd/gf/internal/cmd/cmd_z_unit_gen_service_test.go index e2362bbb5e2..8aeff4bb5f2 100644 --- a/cmd/gf/internal/cmd/cmd_z_unit_gen_service_test.go +++ b/cmd/gf/internal/cmd/cmd_z_unit_gen_service_test.go @@ -57,6 +57,7 @@ func Test_Gen_Service_Default(t *testing.T) { t.AssertNil(err) t.Assert(files, []string{ dstFolder + filepath.FromSlash("/article.go"), + dstFolder + filepath.FromSlash("/base.go"), dstFolder + filepath.FromSlash("/delivery.go"), dstFolder + filepath.FromSlash("/user.go"), }) @@ -65,6 +66,7 @@ func Test_Gen_Service_Default(t *testing.T) { testPath := gtest.DataPath("genservice", "service") expectFiles := []string{ testPath + filepath.FromSlash("/article.go"), + testPath + filepath.FromSlash("/base.go"), testPath + filepath.FromSlash("/delivery.go"), testPath + filepath.FromSlash("/user.go"), } diff --git a/cmd/gf/internal/cmd/genservice/genservice.go b/cmd/gf/internal/cmd/genservice/genservice.go index e02ed91ea4a..568782a6cdf 100644 --- a/cmd/gf/internal/cmd/genservice/genservice.go +++ b/cmd/gf/internal/cmd/genservice/genservice.go @@ -94,6 +94,20 @@ const ( genServiceFileLockSeconds = 10 ) +type fileInfo struct { + PkgItems []pkgItem + FuncItems []funcItem +} + +type folderInfo struct { + SrcPackageName string + SrcImportedPackages *garray.SortedStrArray + SrcStructFunctions *gmap.ListMap + DstFilePath string + + FileInfos []*fileInfo +} + func (c CGenService) Service(ctx context.Context, in CGenServiceInput) (out *CGenServiceOutput, err error) { in.SrcFolder = filepath.ToSlash(in.SrcFolder) in.SrcFolder = gstr.TrimRight(in.SrcFolder, `/`) @@ -163,7 +177,12 @@ func (c CGenService) Service(ctx context.Context, in CGenServiceInput) (out *CGe return nil, err } // it will use goroutine to generate service files for each package. - var wg = sync.WaitGroup{} + var ( + folderInfos []folderInfo + wg = sync.WaitGroup{} + allStructItems = make(map[string][]string) + ) + for _, srcFolderPath := range srcFolderPaths { if !gfile.IsDir(srcFolderPath) { continue @@ -175,7 +194,7 @@ func (c CGenService) Service(ctx context.Context, in CGenServiceInput) (out *CGe if len(files) == 0 { continue } - // Parse single logic package folder. + var ( srcPackageName = gfile.Basename(srcFolderPath) srcImportedPackages = garray.NewSortedStrArray().SetUnique(true) @@ -184,14 +203,46 @@ func (c CGenService) Service(ctx context.Context, in CGenServiceInput) (out *CGe c.getDstFileNameCase(srcPackageName, in.DstFileNameCase)+".go", ) ) - generatedDstFilePathSet.Add(dstFilePath) - // if it were to use goroutine, - // it would cause the order of the generated functions in the file to be disordered. + + folder := folderInfo{ + SrcPackageName: srcPackageName, + SrcImportedPackages: srcImportedPackages, + SrcStructFunctions: srcStructFunctions, + DstFilePath: dstFilePath, + } + for _, file := range files { - pkgItems, funcItems, err := c.parseItemsInSrc(file) + pkgItems, structItems, funcItems, err := c.parseItemsInSrc(file) if err != nil { return nil, err } + for k, v := range structItems { + allStructItems[k] = v + } + folder.FileInfos = append(folder.FileInfos, &fileInfo{ + PkgItems: pkgItems, + FuncItems: funcItems, + }) + } + + folderInfos = append(folderInfos, folder) + } + + folderInfos = c.calculateStructEmbeddedFuncInfos(folderInfos, allStructItems) + + for _, folder := range folderInfos { + // Parse single logic package folder. + var ( + srcPackageName = folder.SrcPackageName + srcImportedPackages = folder.SrcImportedPackages + srcStructFunctions = folder.SrcStructFunctions + dstFilePath = folder.DstFilePath + ) + generatedDstFilePathSet.Add(dstFilePath) + // if it were to use goroutine, + // it would cause the order of the generated functions in the file to be disordered. + for _, file := range folder.FileInfos { + pkgItems, funcItems := file.PkgItems, file.FuncItems // Calculate imported packages for service generating. err = c.calculateImportedItems(in, pkgItems, funcItems, srcImportedPackages) diff --git a/cmd/gf/internal/cmd/genservice/genservice_ast_parse.go b/cmd/gf/internal/cmd/genservice/genservice_ast_parse.go index c4205cc5809..974ec7e6ce9 100644 --- a/cmd/gf/internal/cmd/genservice/genservice_ast_parse.go +++ b/cmd/gf/internal/cmd/genservice/genservice_ast_parse.go @@ -10,8 +10,10 @@ import ( "go/ast" "go/parser" "go/token" + "strings" "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gstructs" "github.com/gogf/gf/v2/text/gstr" ) @@ -32,7 +34,7 @@ type funcItem struct { // parseItemsInSrc parses the pkgItem and funcItem from the specified file. // It can't skip the private methods. // It can't skip the imported packages of import alias equal to `_`. -func (c CGenService) parseItemsInSrc(filePath string) (pkgItems []pkgItem, funcItems []funcItem, err error) { +func (c CGenService) parseItemsInSrc(filePath string) (pkgItems []pkgItem, structItems map[string][]string, funcItems []funcItem, err error) { var ( fileContent = gfile.GetContents(filePath) fileSet = token.NewFileSet() @@ -43,11 +45,107 @@ func (c CGenService) parseItemsInSrc(filePath string) (pkgItems []pkgItem, funcI return } + structItems = make(map[string][]string) + pkg := node.Name.Name + pkgAliasMap := make(map[string]string) ast.Inspect(node, func(n ast.Node) bool { switch x := n.(type) { case *ast.ImportSpec: // parse the imported packages. - pkgItems = append(pkgItems, c.parseImportPackages(x)) + pkgItem := c.parseImportPackages(x) + pkgItems = append(pkgItems, pkgItem) + pkgPath := strings.Trim(pkgItem.Path, "\"") + pkgPath = strings.ReplaceAll(pkgPath, "\\", "/") + tmp := strings.Split(pkgPath, "/") + srcPkg := tmp[len(tmp)-1] + if srcPkg != pkgItem.Alias { + pkgAliasMap[pkgItem.Alias] = srcPkg + } + case *ast.TypeSpec: // type define + switch xType := x.Type.(type) { + case *ast.StructType: // define struct + // parse the struct declaration. + var structName = pkg + "." + x.Name.Name + var structEmbeddedStruct []string + for _, field := range xType.Fields.List { + if len(field.Names) > 0 || field.Tag == nil { // not anonymous field + continue + } + + tagValue := strings.Trim(field.Tag.Value, "`") + tagValue = strings.TrimSpace(tagValue) + if len(tagValue) == 0 { // not set tag + continue + } + tags := gstructs.ParseTag(tagValue) + + if v, ok := tags["gen"]; !ok || v != "extend" { + continue + } + + var embeddedStruct string + switch v := field.Type.(type) { + case *ast.Ident: + if embeddedStruct, err = c.astExprToString(v); err != nil { + embeddedStruct = "" + break + } + embeddedStruct = pkg + "." + embeddedStruct + case *ast.StarExpr: + if embeddedStruct, err = c.astExprToString(v.X); err != nil { + embeddedStruct = "" + break + } + embeddedStruct = pkg + "." + embeddedStruct + case *ast.SelectorExpr: + var pkg string + if pkg, err = c.astExprToString(v.X); err != nil { + embeddedStruct = "" + break + } + if v, ok := pkgAliasMap[pkg]; ok { + pkg = v + } + if embeddedStruct, err = c.astExprToString(v.Sel); err != nil { + embeddedStruct = "" + break + } + embeddedStruct = pkg + "." + embeddedStruct + } + + if embeddedStruct == "" { + continue + } + structEmbeddedStruct = append(structEmbeddedStruct, embeddedStruct) + + } + if len(structEmbeddedStruct) > 0 { + structItems[structName] = structEmbeddedStruct + } + case *ast.Ident: // define ident + var ( + structName = pkg + "." + x.Name.Name + typeName = pkg + "." + xType.Name + ) + structItems[structName] = []string{typeName} + case *ast.SelectorExpr: // define selector + var ( + structName = pkg + "." + x.Name.Name + selecotrPkg string + typeName string + ) + if selecotrPkg, err = c.astExprToString(xType.X); err != nil { + break + } + if v, ok := pkgAliasMap[selecotrPkg]; ok { + selecotrPkg = v + } + if typeName, err = c.astExprToString(xType.Sel); err != nil { + break + } + typeName = selecotrPkg + "." + typeName + structItems[structName] = []string{typeName} + } case *ast.FuncDecl: // parse the function items. diff --git a/cmd/gf/internal/cmd/genservice/genservice_calculate.go b/cmd/gf/internal/cmd/genservice/genservice_calculate.go index 53553a0403c..15f575c04a4 100644 --- a/cmd/gf/internal/cmd/genservice/genservice_calculate.go +++ b/cmd/gf/internal/cmd/genservice/genservice_calculate.go @@ -150,3 +150,78 @@ func (c CGenService) tidyResult(resultSlice []map[string]string) (resultStr stri } return } + +func (c CGenService) getStructFuncItems(structName string, allStructItems map[string][]string, funcItemsWithoutEmbed map[string][]*funcItem) (funcItems []*funcItem) { + funcItemNameSet := map[string]struct{}{} + + if items, ok := funcItemsWithoutEmbed[structName]; ok { + funcItems = append(funcItems, items...) + for _, item := range items { + funcItemNameSet[item.MethodName] = struct{}{} + } + } + + embeddedStructNames, ok := allStructItems[structName] + if !ok { + return + } + + for _, embeddedStructName := range embeddedStructNames { + items := c.getStructFuncItems(embeddedStructName, allStructItems, funcItemsWithoutEmbed) + + for _, item := range items { + if _, ok := funcItemNameSet[item.MethodName]; ok { + continue + } + funcItemNameSet[item.MethodName] = struct{}{} + funcItems = append(funcItems, item) + } + } + + return +} + +func (c CGenService) calculateStructEmbeddedFuncInfos(folderInfos []folderInfo, allStructItems map[string][]string) (newFolerInfos []folderInfo) { + funcItemsWithoutEmbed := make(map[string][]*funcItem) + funcItemMap := make(map[string]*([]funcItem)) + funcItemsWithoutEmbedMap := make(map[string]*funcItem) + + newFolerInfos = append(newFolerInfos, folderInfos...) + + for _, folder := range newFolerInfos { + for k := range folder.FileInfos { + fi := folder.FileInfos[k] + for k := range fi.FuncItems { + item := &fi.FuncItems[k] + receiver := folder.SrcPackageName + "." + strings.ReplaceAll(item.Receiver, "*", "") + funcItemMap[receiver] = &fi.FuncItems + funcItemsWithoutEmbed[receiver] = append(funcItemsWithoutEmbed[receiver], item) + funcItemsWithoutEmbedMap[fmt.Sprintf("%s:%s", receiver, item.MethodName)] = item + } + } + } + + for receiver, structItems := range allStructItems { + receiverName := strings.ReplaceAll(receiver, "*", "") + for _, structName := range structItems { + // Get the list of methods for the corresponding structName. + for _, funcItem := range c.getStructFuncItems(structName, allStructItems, funcItemsWithoutEmbed) { + if _, ok := funcItemsWithoutEmbedMap[fmt.Sprintf("%s:%s", receiverName, funcItem.MethodName)]; ok { + continue + } + if funcItemsPtr, ok := funcItemMap[receiverName]; ok { + newFuncItem := *funcItem + newFuncItem.Receiver = getReceiverName(receiver) + (*funcItemsPtr) = append((*funcItemsPtr), newFuncItem) + } + } + } + } + + return +} + +func getReceiverName(receiver string) string { + ss := strings.Split(receiver, ".") + return ss[len(ss)-1] +} diff --git a/cmd/gf/internal/cmd/testdata/genservice/logic/base/base.go b/cmd/gf/internal/cmd/testdata/genservice/logic/base/base.go new file mode 100644 index 00000000000..b125e658ab5 --- /dev/null +++ b/cmd/gf/internal/cmd/testdata/genservice/logic/base/base.go @@ -0,0 +1,17 @@ +package base + +type Base = sBase + +type sBase struct { + baseDestory `gen:"extend"` +} + +// sBase Init +func (*sBase) Init() { + +} + +// sBase Destory +func (*sBase) Destory() { + +} diff --git a/cmd/gf/internal/cmd/testdata/genservice/logic/base/base_destory.go b/cmd/gf/internal/cmd/testdata/genservice/logic/base/base_destory.go new file mode 100644 index 00000000000..03005182847 --- /dev/null +++ b/cmd/gf/internal/cmd/testdata/genservice/logic/base/base_destory.go @@ -0,0 +1,13 @@ +package base + +type baseDestory struct{} + +// baseDestory Destory +func (baseDestory) Destory() { + +} + +// baseDestory BeforeDestory +func (baseDestory) BeforeDestory() { + +} diff --git a/cmd/gf/internal/cmd/testdata/genservice/logic/base/sub/sub.go b/cmd/gf/internal/cmd/testdata/genservice/logic/base/sub/sub.go new file mode 100644 index 00000000000..447d141faba --- /dev/null +++ b/cmd/gf/internal/cmd/testdata/genservice/logic/base/sub/sub.go @@ -0,0 +1,14 @@ +package sub + +type SubBase struct { +} + +// subbase init +func (*SubBase) Init() { + +} + +// subbase GetSubBase +func (*SubBase) GetSubBase() { + +} diff --git a/cmd/gf/internal/cmd/testdata/genservice/logic/logic_expect.go b/cmd/gf/internal/cmd/testdata/genservice/logic/logic_expect.go index 6efcac5e82e..df1ebdae9d4 100644 --- a/cmd/gf/internal/cmd/testdata/genservice/logic/logic_expect.go +++ b/cmd/gf/internal/cmd/testdata/genservice/logic/logic_expect.go @@ -6,6 +6,7 @@ package logic import ( _ "github.com/gogf/gf/cmd/gf/v2/internal/cmd/testdata/genservice/logic/article" + _ "github.com/gogf/gf/cmd/gf/v2/internal/cmd/testdata/genservice/logic/base" _ "github.com/gogf/gf/cmd/gf/v2/internal/cmd/testdata/genservice/logic/delivery" _ "github.com/gogf/gf/cmd/gf/v2/internal/cmd/testdata/genservice/logic/user" ) diff --git a/cmd/gf/internal/cmd/testdata/genservice/logic/user/supper_vip_user.go b/cmd/gf/internal/cmd/testdata/genservice/logic/user/supper_vip_user.go new file mode 100644 index 00000000000..bb498295b38 --- /dev/null +++ b/cmd/gf/internal/cmd/testdata/genservice/logic/user/supper_vip_user.go @@ -0,0 +1,27 @@ +package user + +import ( + "context" + + "github.com/gogf/gf/cmd/gf/v2/internal/cmd/testdata/genservice/service" +) + +func init() { + service.RegisterSuperVipUser(&sSuperVipUser{ + sVipUser: &sVipUser{}, + }) +} + +type sSuperVipUser struct { + *sVipUser `gen:"extend"` +} + +// Get supper vip user level +func (s sSuperVipUser) GetVipLevel(ctx context.Context) (vipLevel int, err error) { + return 1, nil +} + +// Set supper vip user level +func (s *sSuperVipUser) SetVipLevel(ctx context.Context, id int, vipLevel int) (err error) { + return nil +} diff --git a/cmd/gf/internal/cmd/testdata/genservice/logic/user/user.go b/cmd/gf/internal/cmd/testdata/genservice/logic/user/user.go index a95e22740e4..1f0b57baf91 100644 --- a/cmd/gf/internal/cmd/testdata/genservice/logic/user/user.go +++ b/cmd/gf/internal/cmd/testdata/genservice/logic/user/user.go @@ -9,6 +9,7 @@ package user import ( "context" + "github.com/gogf/gf/cmd/gf/v2/internal/cmd/testdata/genservice/logic/base" "github.com/gogf/gf/cmd/gf/v2/internal/cmd/testdata/genservice/service" ) @@ -17,6 +18,7 @@ func init() { } type sUser struct { + base.Base } func New() *sUser { diff --git a/cmd/gf/internal/cmd/testdata/genservice/logic/user/vip_user.go b/cmd/gf/internal/cmd/testdata/genservice/logic/user/vip_user.go new file mode 100644 index 00000000000..70516dfd8ee --- /dev/null +++ b/cmd/gf/internal/cmd/testdata/genservice/logic/user/vip_user.go @@ -0,0 +1,29 @@ +package user + +import ( + "context" + + bbb "github.com/gogf/gf/cmd/gf/v2/internal/cmd/testdata/genservice/logic/base" + "github.com/gogf/gf/cmd/gf/v2/internal/cmd/testdata/genservice/service" +) + +func init() { + service.RegisterVipUser(&sVipUser{}) +} + +type mybase = bbb.Base + +type sVipUser struct { + sUser `gen:"extend"` + mybase `gen:"extend"` +} + +// Create creates a new vip user. +func (s *sVipUser) Create(ctx context.Context, name string, vipLevel int) (id int, err error) { + return 0, nil +} + +// Get vip user level +func (s *sVipUser) GetVipLevel() (vipLevel int, err error) { + return 1, nil +} diff --git a/cmd/gf/internal/cmd/testdata/genservice/service/base.go b/cmd/gf/internal/cmd/testdata/genservice/service/base.go new file mode 100644 index 00000000000..a9eede1ff79 --- /dev/null +++ b/cmd/gf/internal/cmd/testdata/genservice/service/base.go @@ -0,0 +1,32 @@ +// ================================================================================ +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. +// You can delete these comments if you wish manually maintain this interface file. +// ================================================================================ + +package service + +type ( + IBase interface { + // sBase Init + Init() + // sBase Destory + Destory() + // baseDestory BeforeDestory + BeforeDestory() + } +) + +var ( + localBase IBase +) + +func Base() IBase { + if localBase == nil { + panic("implement not found for interface IBase, forgot register?") + } + return localBase +} + +func RegisterBase(i IBase) { + localBase = i +} diff --git a/cmd/gf/internal/cmd/testdata/genservice/service/user.go b/cmd/gf/internal/cmd/testdata/genservice/service/user.go index 731ee87c50f..925d3610333 100644 --- a/cmd/gf/internal/cmd/testdata/genservice/service/user.go +++ b/cmd/gf/internal/cmd/testdata/genservice/service/user.go @@ -10,6 +10,28 @@ import ( ) type ( + ISuperVipUser interface { + // Get supper vip user level + GetVipLevel(ctx context.Context) (vipLevel int, err error) + // Set supper vip user level + SetVipLevel(ctx context.Context, id int, vipLevel int) (err error) + // Create creates a new vip user. + Create(ctx context.Context, name string, vipLevel int) (id int, err error) + // GetOne retrieves user by id. + GetOne(ctx context.Context, id int) (name string, err error) + // GetList retrieves user list. + GetList(ctx context.Context) (names []string, err error) + // Update updates user by id. + Update(ctx context.Context, id int) (name string, err error) + // Delete deletes user by id. + Delete(ctx context.Context, id int) (err error) + // sBase Init + Init() + // sBase Destory + Destory() + // baseDestory BeforeDestory + BeforeDestory() + } IUser interface { // Create creates a new user. Create(ctx context.Context, name string) (id int, err error) @@ -22,12 +44,45 @@ type ( // Delete deletes user by id. Delete(ctx context.Context, id int) (err error) } + IVipUser interface { + // Create creates a new vip user. + Create(ctx context.Context, name string, vipLevel int) (id int, err error) + // Get vip user level + GetVipLevel() (vipLevel int, err error) + // GetOne retrieves user by id. + GetOne(ctx context.Context, id int) (name string, err error) + // GetList retrieves user list. + GetList(ctx context.Context) (names []string, err error) + // Update updates user by id. + Update(ctx context.Context, id int) (name string, err error) + // Delete deletes user by id. + Delete(ctx context.Context, id int) (err error) + // sBase Init + Init() + // sBase Destory + Destory() + // baseDestory BeforeDestory + BeforeDestory() + } ) var ( - localUser IUser + localSuperVipUser ISuperVipUser + localUser IUser + localVipUser IVipUser ) +func SuperVipUser() ISuperVipUser { + if localSuperVipUser == nil { + panic("implement not found for interface ISuperVipUser, forgot register?") + } + return localSuperVipUser +} + +func RegisterSuperVipUser(i ISuperVipUser) { + localSuperVipUser = i +} + func User() IUser { if localUser == nil { panic("implement not found for interface IUser, forgot register?") @@ -38,3 +93,14 @@ func User() IUser { func RegisterUser(i IUser) { localUser = i } + +func VipUser() IVipUser { + if localVipUser == nil { + panic("implement not found for interface IVipUser, forgot register?") + } + return localVipUser +} + +func RegisterVipUser(i IVipUser) { + localVipUser = i +} From 77cb7fb412d81c4221c45db44bd5f27392849fd0 Mon Sep 17 00:00:00 2001 From: oldme <45782393+oldme-git@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:44:40 +0800 Subject: [PATCH 027/102] test(drivers/mssql): add unit testing cases of transaction (#3818) --- .../drivers/mssql/mssql_z_unit_basic_test.go | 1 - .../drivers/mssql/mssql_z_unit_init_test.go | 2 +- .../mssql/mssql_z_unit_transaction_test.go | 983 ++++++++++++++++++ 3 files changed, 984 insertions(+), 2 deletions(-) create mode 100644 contrib/drivers/mssql/mssql_z_unit_transaction_test.go diff --git a/contrib/drivers/mssql/mssql_z_unit_basic_test.go b/contrib/drivers/mssql/mssql_z_unit_basic_test.go index b283f30479a..bb67e2e478b 100644 --- a/contrib/drivers/mssql/mssql_z_unit_basic_test.go +++ b/contrib/drivers/mssql/mssql_z_unit_basic_test.go @@ -231,7 +231,6 @@ func Test_DB_Insert(t *testing.T) { one, err := db.Model(table).Where("id", 3).One() t.AssertNil(err) - fmt.Println(one) t.Assert(one["ID"].Int(), 3) t.Assert(one["PASSPORT"].String(), "user_3") t.Assert(one["PASSWORD"].String(), "25d55ad283aa400af464c76d713c07ad") diff --git a/contrib/drivers/mssql/mssql_z_unit_init_test.go b/contrib/drivers/mssql/mssql_z_unit_init_test.go index a5db58e4d4d..c7d67d079d4 100644 --- a/contrib/drivers/mssql/mssql_z_unit_init_test.go +++ b/contrib/drivers/mssql/mssql_z_unit_init_test.go @@ -126,7 +126,7 @@ func createInitTable(table ...string) (name string) { "passport": fmt.Sprintf(`user_%d`, i), "password": fmt.Sprintf(`pass_%d`, i), "nickname": fmt.Sprintf(`name_%d`, i), - "create_time": gtime.Now(), + "create_time": "2018-10-24 10:00:00", }) } result, err := db.Insert(context.Background(), name, array.Slice()) diff --git a/contrib/drivers/mssql/mssql_z_unit_transaction_test.go b/contrib/drivers/mssql/mssql_z_unit_transaction_test.go new file mode 100644 index 00000000000..bb3ad90d781 --- /dev/null +++ b/contrib/drivers/mssql/mssql_z_unit_transaction_test.go @@ -0,0 +1,983 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package mssql_test + +import ( + "context" + "fmt" + "testing" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gctx" + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/test/gtest" +) + +func Test_TX_Query(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + _, err = tx.Query("SELECT ?", 1) + t.AssertNil(err) + + _, err = tx.Query("SELECT ?+?", 1, 2) + t.AssertNil(err) + + _, err = tx.Query("SELECT ?+?", g.Slice{1, 2}) + t.AssertNil(err) + + _, err = tx.Query("ERROR") + t.AssertNE(err, nil) + + err = tx.Commit() + t.AssertNil(err) + }) +} + +func Test_TX_Exec(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + _, err = tx.Exec("SELECT ?", 1) + t.AssertNil(err) + + _, err = tx.Exec("SELECT ?+?", 1, 2) + t.AssertNil(err) + + _, err = tx.Exec("SELECT ?+?", g.Slice{1, 2}) + t.AssertNil(err) + + _, err = tx.Exec("ERROR") + t.AssertNE(err, nil) + + err = tx.Commit() + t.AssertNil(err) + }) +} + +func Test_TX_Commit(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + err = tx.Commit() + t.AssertNil(err) + }) +} + +func Test_TX_Rollback(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + err = tx.Rollback() + t.AssertNil(err) + }) +} + +func Test_TX_Prepare(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + st, err := tx.Prepare("SELECT 100") + t.AssertNil(err) + + rows, err := st.Query() + t.AssertNil(err) + + var value int + if rows.Next() { + err = rows.Scan(&value) + t.AssertNil(err) + + } + t.Assert(value, 100) + + err = rows.Close() + t.AssertNil(err) + + err = tx.Commit() + t.AssertNil(err) + }) +} + +func Test_TX_Insert(t *testing.T) { + table := createTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + user := tx.Model(table) + _, err = user.Data(g.Map{ + "id": 1, + "passport": "t1", + "password": "25d55ad283aa400af464c76d713c07ad", + "nickname": "T1", + "create_time": gtime.Now().String(), + }).Insert() + t.AssertNil(err) + + _, err = tx.Insert(table, g.Map{ + "id": 2, + "passport": "t1", + "password": "25d55ad283aa400af464c76d713c07ad", + "nickname": "T1", + "create_time": gtime.Now().String(), + }) + t.AssertNil(err) + + n, err := tx.Model(table).Count() + t.AssertNil(err) + + t.Assert(n, int64(2)) + + err = tx.Commit() + t.AssertNil(err) + }) +} + +func Test_TX_BatchInsert(t *testing.T) { + table := createTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + _, err = tx.Insert(table, g.List{ + { + "id": 2, + "passport": "t", + "password": "25d55ad283aa400af464c76d713c07ad", + "nickname": "T2", + "create_time": gtime.Now().String(), + }, + { + "id": 3, + "passport": "t3", + "password": "25d55ad283aa400af464c76d713c07ad", + "nickname": "T3", + "create_time": gtime.Now().String(), + }, + }, 10) + t.AssertNil(err) + + err = tx.Commit() + t.AssertNil(err) + + n, err := db.Model(table).Count() + t.AssertNil(err) + + t.Assert(n, int64(2)) + }) +} + +func Test_TX_Update(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + result, err := tx.Update(table, "create_time='2019-10-24 10:00:00'", "id=3") + t.AssertNil(err) + + n, _ := result.RowsAffected() + t.Assert(n, 1) + err = tx.Commit() + t.AssertNil(err) + + _, err = tx.Model(table).Fields("create_time").Where("id", 3).Value() + t.AssertNE(err, nil) + + value, err := db.Model(table).Fields("create_time").Where("id", 3).Value() + t.AssertNil(err) + + t.Assert(value.String(), "2019-10-24 10:00:00") + }) +} + +func Test_TX_GetAll(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + result, err := tx.GetAll(fmt.Sprintf("SELECT * FROM %s WHERE id=?", table), 1) + t.AssertNil(err) + + t.Assert(len(result), 1) + err = tx.Commit() + t.AssertNil(err) + }) +} + +func Test_TX_GetOne(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + record, err := tx.GetOne(fmt.Sprintf("SELECT * FROM %s WHERE passport=?", table), "user_2") + t.AssertNil(err) + + t.AssertNE(record, nil) + t.Assert(record["NICKNAME"].String(), "name_2") + + err = tx.Commit() + t.AssertNil(err) + }) +} + +func Test_TX_GetValue(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + value, err := tx.GetValue(fmt.Sprintf("SELECT id FROM %s WHERE passport=?", table), "user_3") + t.AssertNil(err) + + t.Assert(value.Int(), 3) + err = tx.Commit() + t.AssertNil(err) + }) +} + +func Test_TX_GetCount(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + count, err := tx.GetCount("SELECT * FROM " + table) + t.AssertNil(err) + + t.Assert(count, int64(TableSize)) + err = tx.Commit() + t.AssertNil(err) + }) +} + +func Test_TX_GetStruct(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + type User struct { + Id int + Passport string + Password string + NickName string + CreateTime gtime.Time + } + user := new(User) + err = tx.GetStruct(user, fmt.Sprintf("SELECT * FROM %s WHERE id=?", table), 3) + t.AssertNil(err) + + t.Assert(user.NickName, "name_3") + t.Assert(user.CreateTime.String(), "2018-10-24 10:00:00") + err = tx.Commit() + t.AssertNil(err) + }) + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + type User struct { + Id int + Passport string + Password string + NickName string + CreateTime *gtime.Time + } + user := new(User) + err = tx.GetStruct(user, fmt.Sprintf("SELECT * FROM %s WHERE id=?", table), 3) + t.AssertNil(err) + + t.Assert(user.NickName, "name_3") + t.Assert(user.CreateTime.String(), "2018-10-24 10:00:00") + err = tx.Commit() + t.AssertNil(err) + }) +} + +func Test_TX_GetStructs(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + type User struct { + Id int + Passport string + Password string + NickName string + CreateTime gtime.Time + } + var users []User + err = tx.GetStructs(&users, fmt.Sprintf("SELECT * FROM %s WHERE id>=?", table), 1) + t.AssertNil(err) + + t.Assert(len(users), TableSize) + t.Assert(users[0].Id, 1) + t.Assert(users[1].Id, 2) + t.Assert(users[2].Id, 3) + t.Assert(users[0].NickName, "name_1") + t.Assert(users[1].NickName, "name_2") + t.Assert(users[2].NickName, "name_3") + t.Assert(users[2].CreateTime.String(), "2018-10-24 10:00:00") + err = tx.Commit() + t.AssertNil(err) + }) + + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + type User struct { + Id int + Passport string + Password string + NickName string + CreateTime *gtime.Time + } + var users []User + err = tx.GetStructs(&users, fmt.Sprintf("SELECT * FROM %s WHERE id>=?", table), 1) + t.AssertNil(err) + + t.Assert(len(users), TableSize) + t.Assert(users[0].Id, 1) + t.Assert(users[1].Id, 2) + t.Assert(users[2].Id, 3) + t.Assert(users[0].NickName, "name_1") + t.Assert(users[1].NickName, "name_2") + t.Assert(users[2].NickName, "name_3") + t.Assert(users[2].CreateTime.String(), "2018-10-24 10:00:00") + err = tx.Commit() + t.AssertNil(err) + }) +} + +func Test_TX_GetScan(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + type User struct { + Id int + Passport string + Password string + NickName string + CreateTime gtime.Time + } + user := new(User) + err = tx.GetScan(user, fmt.Sprintf("SELECT * FROM %s WHERE id=?", table), 3) + t.AssertNil(err) + + t.Assert(user.NickName, "name_3") + t.Assert(user.CreateTime.String(), "2018-10-24 10:00:00") + err = tx.Commit() + t.AssertNil(err) + }) + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + type User struct { + Id int + Passport string + Password string + NickName string + CreateTime *gtime.Time + } + user := new(User) + err = tx.GetScan(user, fmt.Sprintf("SELECT * FROM %s WHERE id=?", table), 3) + t.AssertNil(err) + + t.Assert(user.NickName, "name_3") + t.Assert(user.CreateTime.String(), "2018-10-24 10:00:00") + err = tx.Commit() + t.AssertNil(err) + }) + + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + type User struct { + Id int + Passport string + Password string + NickName string + CreateTime gtime.Time + } + var users []User + err = tx.GetScan(&users, fmt.Sprintf("SELECT * FROM %s WHERE id>=?", table), 1) + t.AssertNil(err) + + t.Assert(len(users), TableSize) + t.Assert(users[0].Id, 1) + t.Assert(users[1].Id, 2) + t.Assert(users[2].Id, 3) + t.Assert(users[0].NickName, "name_1") + t.Assert(users[1].NickName, "name_2") + t.Assert(users[2].NickName, "name_3") + t.Assert(users[2].CreateTime.String(), "2018-10-24 10:00:00") + err = tx.Commit() + t.AssertNil(err) + }) + + gtest.C(t, func(t *gtest.T) { + tx, err := db.Begin(ctx) + t.AssertNil(err) + + type User struct { + Id int + Passport string + Password string + NickName string + CreateTime *gtime.Time + } + var users []User + err = tx.GetScan(&users, fmt.Sprintf("SELECT * FROM %s WHERE id>=?", table), 1) + t.AssertNil(err) + + t.Assert(len(users), TableSize) + t.Assert(users[0].Id, 1) + t.Assert(users[1].Id, 2) + t.Assert(users[2].Id, 3) + t.Assert(users[0].NickName, "name_1") + t.Assert(users[1].NickName, "name_2") + t.Assert(users[2].NickName, "name_3") + t.Assert(users[2].CreateTime.String(), "2018-10-24 10:00:00") + err = tx.Commit() + t.AssertNil(err) + }) +} + +func Test_TX_Delete(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + table := createInitTable() + defer dropTable(table) + tx, err := db.Begin(ctx) + t.AssertNil(err) + + _, err = tx.Delete(table, "1=1") + t.AssertNil(err) + + err = tx.Commit() + t.AssertNil(err) + + n, err := db.Model(table).Count() + t.AssertNil(err) + + t.Assert(n, int64(0)) + t.Assert(tx.IsClosed(), true) + }) + + gtest.C(t, func(t *gtest.T) { + table := createInitTable() + defer dropTable(table) + tx, err := db.Begin(ctx) + if err != nil { + gtest.Error(err) + } + _, err = tx.Delete(table, "1=1") + t.AssertNil(err) + + n, err := tx.Model(table).Count() + t.AssertNil(err) + + t.Assert(n, int64(0)) + err = tx.Rollback() + t.AssertNil(err) + + n, err = db.Model(table).Count() + t.AssertNil(err) + + t.Assert(n, int64(TableSize)) + t.AssertNE(n, int64(0)) + t.Assert(tx.IsClosed(), true) + }) +} + +func Test_Transaction(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + ctx := context.TODO() + err := db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + _, err := tx.Ctx(ctx).Replace(table, g.Map{ + "id": 1, + "passport": "USER_1", + "password": "PASS_1", + "nickname": "NAME_1", + "create_time": gtime.Now().String(), + }) + t.AssertNil(err) + + t.Assert(tx.IsClosed(), false) + return gerror.New("error") + }) + t.AssertNE(err, nil) + + value, err := db.Model(table).Ctx(ctx).Fields("nickname").Where("id", 1).Value() + t.AssertNil(err) + t.Assert(value.String(), "name_1") + }) +} + +func Test_Transaction_Panic(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + ctx := context.TODO() + err := db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + _, err := tx.Replace(table, g.Map{ + "id": 1, + "passport": "USER_1", + "password": "PASS_1", + "nickname": "NAME_1", + "create_time": gtime.Now().String(), + }) + t.AssertNil(err) + + panic("error") + return nil + }) + t.AssertNE(err, nil) + + value, err := db.Model(table).Fields("nickname").Where("id", 1).Value() + t.AssertNil(err) + + t.Assert(value.String(), "name_1") + }) +} + +// TODO +// MSSQL does not support nested transaction. +// So the following test cases are not supported. +// If the problem is solved in the future, the test cases will be enabled. + +// func Test_Transaction_Nested_Begin_Rollback_Commit(t *testing.T) { +// table := createTable() +// defer dropTable(table) +// +// gtest.C(t, func(t *gtest.T) { +// tx, err := db.Begin(ctx) +// t.AssertNil(err) +// +// // tx begin. +// err = tx.Begin() +// t.AssertNil(err) +// +// // tx rollback. +// _, err = tx.Model(table).Data(g.Map{ +// "id": 1, +// "passport": "user_1", +// "password": "pass_1", +// "nickname": "name_1", +// }).Insert() +// err = tx.Rollback() +// t.AssertNil(err) +// +// // tx commit. +// _, err = tx.Model(table).Data(g.Map{ +// "id": 2, +// "passport": "user_2", +// "password": "pass_2", +// "nickname": "name_2", +// }).Insert() +// err = tx.Commit() +// t.AssertNil(err) +// +// // check data. +// all, err := db.Model(table).All() +// t.AssertNil(err) +// +// t.Assert(len(all), 1) +// t.Assert(all[0]["id"], 2) +// }) +// } +// +// func Test_Transaction_Nested_TX_Transaction_UseTX(t *testing.T) { +// table := createTable() +// defer dropTable(table) +// +// db.SetDebug(true) +// defer db.SetDebug(false) +// +// gtest.C(t, func(t *gtest.T) { +// var ( +// err error +// ctx = context.TODO() +// ) +// err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// // commit +// err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// _, err = tx.Model(table).Data(g.Map{ +// "id": 1, +// "passport": "USER_1", +// "password": "PASS_1", +// "nickname": "NAME_1", +// "create_time": gtime.Now().String(), +// }).Insert() +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// // rollback +// err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// _, err = tx.Model(table).Data(g.Map{ +// "id": 2, +// "passport": "USER_2", +// "password": "PASS_2", +// "nickname": "NAME_2", +// "create_time": gtime.Now().String(), +// }).Insert() +// t.AssertNil(err) +// +// panic("error") +// return err +// }) +// t.AssertNE(err, nil) +// return nil +// }) +// t.AssertNil(err) +// +// all, err := db.Ctx(ctx).Model(table).All() +// t.AssertNil(err) +// +// t.Assert(len(all), 1) +// t.Assert(all[0]["id"], 1) +// +// // another record. +// err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// // commit +// err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// _, err = tx.Model(table).Data(g.Map{ +// "id": 3, +// "passport": "USER_1", +// "password": "PASS_1", +// "nickname": "NAME_1", +// "create_time": gtime.Now().String(), +// }).Insert() +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// // rollback +// err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// _, err = tx.Model(table).Data(g.Map{ +// "id": 4, +// "passport": "USER_2", +// "password": "PASS_2", +// "nickname": "NAME_2", +// "create_time": gtime.Now().String(), +// }).Insert() +// t.AssertNil(err) +// +// panic("error") +// return err +// }) +// t.AssertNE(err, nil) +// return nil +// }) +// t.AssertNil(err) +// +// all, err = db.Ctx(ctx).Model(table).All() +// t.AssertNil(err) +// +// t.Assert(len(all), 2) +// t.Assert(all[0]["id"], 1) +// t.Assert(all[1]["id"], 3) +// }) +// } +// +// func Test_Transaction_Nested_TX_Transaction_UseDB(t *testing.T) { +// table := createTable() +// defer dropTable(table) +// +// // db.SetDebug(true) +// // defer db.SetDebug(false) +// +// gtest.C(t, func(t *gtest.T) { +// var ( +// err error +// ctx = context.TODO() +// ) +// err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// // commit +// err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// _, err = db.Model(table).Ctx(ctx).Data(g.Map{ +// "id": 1, +// "passport": "USER_1", +// "password": "PASS_1", +// "nickname": "NAME_1", +// "create_time": gtime.Now().String(), +// }).Insert() +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// // rollback +// err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// _, err = tx.Model(table).Ctx(ctx).Data(g.Map{ +// "id": 2, +// "passport": "USER_2", +// "password": "PASS_2", +// "nickname": "NAME_2", +// "create_time": gtime.Now().String(), +// }).Insert() +// t.AssertNil(err) +// +// // panic makes this transaction rollback. +// panic("error") +// return err +// }) +// t.AssertNE(err, nil) +// return nil +// }) +// t.AssertNil(err) +// +// all, err := db.Model(table).All() +// t.AssertNil(err) +// +// t.Assert(len(all), 1) +// t.Assert(all[0]["id"], 1) +// +// err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// // commit +// err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// _, err = db.Model(table).Ctx(ctx).Data(g.Map{ +// "id": 3, +// "passport": "USER_1", +// "password": "PASS_1", +// "nickname": "NAME_1", +// "create_time": gtime.Now().String(), +// }).Insert() +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// return err +// }) +// t.AssertNil(err) +// +// // rollback +// err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { +// _, err = tx.Model(table).Ctx(ctx).Data(g.Map{ +// "id": 4, +// "passport": "USER_2", +// "password": "PASS_2", +// "nickname": "NAME_2", +// "create_time": gtime.Now().String(), +// }).Insert() +// t.AssertNil(err) +// +// // panic makes this transaction rollback. +// panic("error") +// return err +// }) +// t.AssertNE(err, nil) +// return nil +// }) +// t.AssertNil(err) +// +// all, err = db.Model(table).All() +// t.AssertNil(err) +// +// t.Assert(len(all), 2) +// t.Assert(all[0]["id"], 1) +// t.Assert(all[1]["id"], 3) +// }) +// } +// +// func Test_Transaction_Nested_SavePoint_RollbackTo(t *testing.T) { +// table := createTable() +// defer dropTable(table) +// +// gtest.C(t, func(t *gtest.T) { +// tx, err := db.Begin(ctx) +// t.AssertNil(err) +// +// // tx save point. +// _, err = tx.Model(table).Data(g.Map{ +// "id": 1, +// "passport": "user_1", +// "password": "pass_1", +// "nickname": "name_1", +// }).Insert() +// err = tx.SavePoint("MyPoint") +// t.AssertNil(err) +// +// _, err = tx.Model(table).Data(g.Map{ +// "id": 2, +// "passport": "user_2", +// "password": "pass_2", +// "nickname": "name_2", +// }).Insert() +// // tx rollback to. +// err = tx.RollbackTo("MyPoint") +// t.AssertNil(err) +// +// // tx commit. +// err = tx.Commit() +// t.AssertNil(err) +// +// // check data. +// all, err := db.Model(table).All() +// t.AssertNil(err) +// +// t.Assert(len(all), 1) +// t.Assert(all[0]["id"], 1) +// }) +// } + +func Test_Transaction_Method(t *testing.T) { + table := createTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + var err error + err = db.Transaction(gctx.New(), func(ctx context.Context, tx gdb.TX) error { + _, err = db.Model(table).Ctx(ctx).Data(g.Map{ + "id": 1, + "passport": "t1", + "password": "25d55ad283aa400af464c76d713c07ad", + "nickname": "T1", + "create_time": gtime.Now().String(), + }).Insert() + t.AssertNil(err) + + _, err = db.Ctx(ctx).Exec(ctx, fmt.Sprintf( + "insert into %s(passport , password , nickname , create_time , id ) "+ + "VALUES('t2','25d55ad283aa400af464c76d713c07ad','T2','2021-08-25 21:53:00',2) ", + table)) + t.AssertNil(err) + + return gerror.New("rollback") + }) + t.AssertNE(err, nil) + + count, err := db.Model(table).Count() + t.AssertNil(err) + + t.Assert(count, int64(0)) + }) +} From c0f2ef73483083c93cb9a036a6da9d753f64d1c1 Mon Sep 17 00:00:00 2001 From: mingzaily <44798713+mingzaily@users.noreply.github.com> Date: Thu, 5 Dec 2024 14:47:39 +0800 Subject: [PATCH 028/102] feat(gctx): rename and remove gctx functions to prevent ambiguity (#3892) --- net/ghttp/ghttp_request_param_ctx.go | 2 -- os/gctx/gctx.go | 18 ++++++++++++++++-- os/gctx/gctx_z_unit_test.go | 2 +- 3 files changed, 17 insertions(+), 5 deletions(-) diff --git a/net/ghttp/ghttp_request_param_ctx.go b/net/ghttp/ghttp_request_param_ctx.go index 685cfa90928..4d42205c7c2 100644 --- a/net/ghttp/ghttp_request_param_ctx.go +++ b/net/ghttp/ghttp_request_param_ctx.go @@ -30,8 +30,6 @@ func (r *Request) Context() context.Context { if RequestFromCtx(ctx) == nil { // Inject Request object into context. ctx = context.WithValue(ctx, ctxKeyForRequest, r) - // Add default tracing info if using default tracing provider. - ctx = gctx.WithCtx(ctx) // Update the values of the original HTTP request. *r.Request = *r.Request.WithContext(ctx) } diff --git a/os/gctx/gctx.go b/os/gctx/gctx.go index e0bcb666705..a3117fd78c5 100644 --- a/os/gctx/gctx.go +++ b/os/gctx/gctx.go @@ -44,15 +44,15 @@ func init() { context.Background(), propagation.MapCarrier(m), ) - initCtx = WithCtx(initCtx) } // New creates and returns a context which contains context id. func New() context.Context { - return WithCtx(context.Background()) + return WithSpan(context.Background(), "gctx.New") } // WithCtx creates and returns a context containing context id upon given parent context `ctx`. +// Deprecated: use WithSpan instead. func WithCtx(ctx context.Context) context.Context { if CtxId(ctx) != "" { return ctx @@ -63,6 +63,20 @@ func WithCtx(ctx context.Context) context.Context { return ctx } +// WithSpan creates and returns a context containing span upon given parent context `ctx`. +func WithSpan(ctx context.Context, spanName string) context.Context { + if CtxId(ctx) != "" { + return ctx + } + if spanName == "" { + spanName = "gctx.WithSpan" + } + var span *gtrace.Span + ctx, span = gtrace.NewSpan(ctx, spanName) + defer span.End() + return ctx +} + // CtxId retrieves and returns the context id from context. func CtxId(ctx context.Context) string { return gtrace.GetTraceID(ctx) diff --git a/os/gctx/gctx_z_unit_test.go b/os/gctx/gctx_z_unit_test.go index aa09b92ff8b..25d63b5730d 100644 --- a/os/gctx/gctx_z_unit_test.go +++ b/os/gctx/gctx_z_unit_test.go @@ -25,7 +25,7 @@ func Test_New(t *testing.T) { func Test_WithCtx(t *testing.T) { gtest.C(t, func(t *gtest.T) { ctx := context.WithValue(context.TODO(), "TEST", 1) - ctx = gctx.WithCtx(ctx) + ctx = gctx.WithSpan(ctx, "test") t.AssertNE(gctx.CtxId(ctx), "") t.Assert(ctx.Value("TEST"), 1) }) From 5fa33411fc2853b81c9212f18ad2dacaf769ba86 Mon Sep 17 00:00:00 2001 From: wanna Date: Thu, 5 Dec 2024 15:49:50 +0800 Subject: [PATCH 029/102] chore: add example for openapi/swagger authentication (#4004) --- example/httpserver/swagger/main.go | 9 +++++++ net/ghttp/ghttp_server_config_api.go | 5 ++++ ...ttp_z_unit_feature_openapi_swagger_test.go | 25 +++++++++++++++++++ 3 files changed, 39 insertions(+) diff --git a/example/httpserver/swagger/main.go b/example/httpserver/swagger/main.go index d453588d3e2..3d934352c86 100644 --- a/example/httpserver/swagger/main.go +++ b/example/httpserver/swagger/main.go @@ -45,5 +45,14 @@ func main() { new(Hello), ) }) + // if api.json requires authentication, add openApiBasicAuth handler + s.BindHookHandler(s.GetOpenApiPath(), ghttp.HookBeforeServe, openApiBasicAuth) s.Run() } + +func openApiBasicAuth(r *ghttp.Request) { + if !r.BasicAuth("OpenApiAuthUserName", "OpenApiAuthPass", "Restricted") { + r.ExitAll() + return + } +} diff --git a/net/ghttp/ghttp_server_config_api.go b/net/ghttp/ghttp_server_config_api.go index d9a66d3cb09..a89888b1fba 100644 --- a/net/ghttp/ghttp_server_config_api.go +++ b/net/ghttp/ghttp_server_config_api.go @@ -21,3 +21,8 @@ func (s *Server) SetSwaggerUITemplate(swaggerUITemplate string) { func (s *Server) SetOpenApiPath(path string) { s.config.OpenApiPath = path } + +// GetOpenApiPath returns the configuration of `OpenApiPath` of server. +func (s *Server) GetOpenApiPath() string { + return s.config.OpenApiPath +} diff --git a/net/ghttp/ghttp_z_unit_feature_openapi_swagger_test.go b/net/ghttp/ghttp_z_unit_feature_openapi_swagger_test.go index e46db1ddf1e..2ce097ac9e1 100644 --- a/net/ghttp/ghttp_z_unit_feature_openapi_swagger_test.go +++ b/net/ghttp/ghttp_z_unit_feature_openapi_swagger_test.go @@ -185,3 +185,28 @@ func Test_OpenApi_Method_All_Swagger(t *testing.T) { t.Assert(gstr.Contains(c.GetContent(ctx, "/api.json"), `/test/error`), true) }) } + +func Test_OpenApi_Auth(t *testing.T) { + s := g.Server(guid.S()) + apiPath := "/api.json" + s.SetOpenApiPath(apiPath) + s.BindHookHandler(s.GetOpenApiPath(), ghttp.HookBeforeServe, openApiBasicAuth) + s.Start() + defer s.Shutdown() + gtest.C(t, func(t *gtest.T) { + t.Assert(s.GetOpenApiPath(), apiPath) + c := g.Client() + c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) + t.Assert(c.GetContent(ctx, apiPath), "Unauthorized") + c.SetBasicAuth("OpenApiAuthUserName", "OpenApiAuthPass") + cc := c.GetContent(ctx, apiPath) + t.AssertNE(cc, "Unauthorized") + }) +} + +func openApiBasicAuth(r *ghttp.Request) { + if !r.BasicAuth("OpenApiAuthUserName", "OpenApiAuthPass", "Restricted") { + r.ExitAll() + return + } +} From 4ad061faffd35be2e62099fbb1e6b5d77f8b69f4 Mon Sep 17 00:00:00 2001 From: ninjashixuan <37137471+ninjashixuan@users.noreply.github.com> Date: Thu, 5 Dec 2024 15:50:59 +0800 Subject: [PATCH 030/102] feat(contrib/drivers/pgsql): add array type `varchar[]` and `text[]` converting to Go `[]string` support (#4000) --- contrib/drivers/pgsql/pgsql_convert.go | 13 ++++ .../drivers/pgsql/pgsql_z_unit_init_test.go | 2 + .../drivers/pgsql/pgsql_z_unit_model_test.go | 59 +++++++++++++++++++ database/gdb/gdb.go | 1 + 4 files changed, 75 insertions(+) diff --git a/contrib/drivers/pgsql/pgsql_convert.go b/contrib/drivers/pgsql/pgsql_convert.go index 71657669b24..8ccd6e54fe0 100644 --- a/contrib/drivers/pgsql/pgsql_convert.go +++ b/contrib/drivers/pgsql/pgsql_convert.go @@ -8,6 +8,7 @@ package pgsql import ( "context" + "github.com/lib/pq" "reflect" "strings" @@ -72,6 +73,10 @@ func (d *Driver) CheckLocalTypeForField(ctx context.Context, fieldType string, f "_int8": return gdb.LocalTypeInt64Slice, nil + case + "_varchar", "_text": + return gdb.LocalTypeStringSlice, nil + default: return d.Core.CheckLocalTypeForField(ctx, fieldType, fieldValue) } @@ -116,6 +121,14 @@ func (d *Driver) ConvertValueForLocal(ctx context.Context, fieldType string, fie ), ), nil + // String slice. + case "_varchar", "_text": + var result pq.StringArray + if err := result.Scan(fieldValue); err != nil { + return nil, err + } + return result, nil + default: return d.Core.ConvertValueForLocal(ctx, fieldType, fieldValue) } diff --git a/contrib/drivers/pgsql/pgsql_z_unit_init_test.go b/contrib/drivers/pgsql/pgsql_z_unit_init_test.go index c2033e30125..023efdee1c4 100644 --- a/contrib/drivers/pgsql/pgsql_z_unit_init_test.go +++ b/contrib/drivers/pgsql/pgsql_z_unit_init_test.go @@ -83,6 +83,8 @@ func createTableWithDb(db gdb.DB, table ...string) (name string) { password varchar(32) NOT NULL, nickname varchar(45) NOT NULL, create_time timestamp NOT NULL, + favorite_movie varchar[], + favorite_music text[], PRIMARY KEY (id) ) ;`, name, )); err != nil { diff --git a/contrib/drivers/pgsql/pgsql_z_unit_model_test.go b/contrib/drivers/pgsql/pgsql_z_unit_model_test.go index 634de6dc821..d7748f07f17 100644 --- a/contrib/drivers/pgsql/pgsql_z_unit_model_test.go +++ b/contrib/drivers/pgsql/pgsql_z_unit_model_test.go @@ -611,3 +611,62 @@ func Test_OrderRandom(t *testing.T) { t.Assert(len(result), TableSize) }) } + +func Test_ConvertSliceString(t *testing.T) { + table := createTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + type User struct { + Id int + Passport string + Password string + NickName string + CreateTime *gtime.Time + FavoriteMovie []string + FavoriteMusic []string + } + + var ( + user User + user2 User + err error + ) + + // slice string not null + _, err = db.Model(table).Data(g.Map{ + "id": 1, + "passport": "p1", + "password": "pw1", + "nickname": "n1", + "create_time": CreateTime, + "favorite_movie": g.Slice{"Iron-Man", "Spider-Man"}, + "favorite_music": g.Slice{"Hey jude", "Let it be"}, + }).Insert() + t.AssertNil(err) + + err = db.Model(table).Where("id", 1).Scan(&user) + t.AssertNil(err) + t.Assert(len(user.FavoriteMusic), 2) + t.Assert(user.FavoriteMusic[0], "Hey jude") + t.Assert(user.FavoriteMusic[1], "Let it be") + t.Assert(len(user.FavoriteMovie), 2) + t.Assert(user.FavoriteMovie[0], "Iron-Man") + t.Assert(user.FavoriteMovie[1], "Spider-Man") + + // slice string null + _, err = db.Model(table).Data(g.Map{ + "id": 2, + "passport": "p1", + "password": "pw1", + "nickname": "n1", + "create_time": CreateTime, + }).Insert() + t.AssertNil(err) + + err = db.Model(table).Where("id", 2).Scan(&user2) + t.AssertNil(err) + t.Assert(user2.FavoriteMusic, nil) + t.Assert(len(user2.FavoriteMovie), 0) + }) +} diff --git a/database/gdb/gdb.go b/database/gdb/gdb.go index 74d76e5c8a1..f9851dbaca4 100644 --- a/database/gdb/gdb.go +++ b/database/gdb/gdb.go @@ -458,6 +458,7 @@ const ( LocalTypeIntSlice LocalType = "[]int" LocalTypeInt64Slice LocalType = "[]int64" LocalTypeUint64Slice LocalType = "[]uint64" + LocalTypeStringSlice LocalType = "[]string" LocalTypeInt64Bytes LocalType = "int64-bytes" LocalTypeUint64Bytes LocalType = "uint64-bytes" LocalTypeFloat32 LocalType = "float32" From c9b0237fc7126d8b90fbd39c1cd39691b72baecf Mon Sep 17 00:00:00 2001 From: John Guo Date: Thu, 5 Dec 2024 20:21:19 +0800 Subject: [PATCH 031/102] feat: version v2.8.2 (#4009) --- .set_version.sh | 11 +++---- README.MD | 2 +- cmd/gf/go.mod | 14 ++++---- .../internal/cmd/testdata/build/varmap/go.mod | 2 +- contrib/config/apollo/go.mod | 2 +- contrib/config/consul/go.mod | 2 +- contrib/config/kubecm/go.mod | 2 +- contrib/config/nacos/go.mod | 2 +- contrib/config/polaris/go.mod | 2 +- contrib/drivers/clickhouse/go.mod | 2 +- contrib/drivers/dm/go.mod | 2 +- contrib/drivers/mssql/go.mod | 2 +- contrib/drivers/mysql/go.mod | 2 +- contrib/drivers/oracle/go.mod | 2 +- contrib/drivers/pgsql/go.mod | 2 +- contrib/drivers/sqlite/go.mod | 2 +- contrib/drivers/sqlitecgo/go.mod | 2 +- contrib/metric/otelmetric/go.mod | 2 +- contrib/nosql/redis/go.mod | 2 +- contrib/registry/etcd/go.mod | 2 +- contrib/registry/file/go.mod | 2 +- contrib/registry/nacos/go.mod | 2 +- contrib/registry/polaris/go.mod | 2 +- contrib/registry/zookeeper/go.mod | 2 +- contrib/rpc/grpcx/go.mod | 4 +-- contrib/sdk/httpclient/go.mod | 2 +- contrib/trace/otlpgrpc/go.mod | 2 +- contrib/trace/otlphttp/go.mod | 2 +- example/go.mod | 32 +++++++++---------- version.go | 2 +- 30 files changed, 56 insertions(+), 57 deletions(-) diff --git a/.set_version.sh b/.set_version.sh index 5789cab7f6b..fc225795b47 100755 --- a/.set_version.sh +++ b/.set_version.sh @@ -27,12 +27,11 @@ if [[ $? -ne 0 ]]; then fi if [[ true ]]; then - echo "package gf" > version.go - echo "" >> version.go - echo "const (" >> version.go - echo -e "\t// VERSION is the current GoFrame version." >> version.go - echo -e "\tVERSION = \"${newVersion}\"" >> version.go - echo ")" >> version.go + # Use sed to replace the version number in version.go + sed -i '' 's/VERSION = ".*"/VERSION = "'${newVersion}'"/' version.go + + # Use sed to replace the version number in README.MD + sed -i '' 's/version=[^"]*/version='${newVersion}'/' README.MD fi if [ -f "go.work" ]; then diff --git a/README.MD b/README.MD index 5c2db9daab4..10082791e63 100644 --- a/README.MD +++ b/README.MD @@ -36,7 +36,7 @@ A powerful framework for faster, easier, and more efficient project development. 💖 [Thanks to all the contributors who made GoFrame possible](https://github.com/gogf/gf/graphs/contributors) 💖 - + # License diff --git a/cmd/gf/go.mod b/cmd/gf/go.mod index 8b3d4d5b6bb..f4c9e6bc558 100644 --- a/cmd/gf/go.mod +++ b/cmd/gf/go.mod @@ -3,13 +3,13 @@ module github.com/gogf/gf/cmd/gf/v2 go 1.18 require ( - github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.8.1 - github.com/gogf/gf/contrib/drivers/mssql/v2 v2.8.1 - github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.1 - github.com/gogf/gf/contrib/drivers/oracle/v2 v2.8.1 - github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.8.1 - github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.8.1 - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.8.2 + github.com/gogf/gf/contrib/drivers/mssql/v2 v2.8.2 + github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.2 + github.com/gogf/gf/contrib/drivers/oracle/v2 v2.8.2 + github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.8.2 + github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.2 github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f github.com/olekukonko/tablewriter v0.0.5 golang.org/x/mod v0.17.0 diff --git a/cmd/gf/internal/cmd/testdata/build/varmap/go.mod b/cmd/gf/internal/cmd/testdata/build/varmap/go.mod index c8c721416c0..d2d0e9e4f0b 100644 --- a/cmd/gf/internal/cmd/testdata/build/varmap/go.mod +++ b/cmd/gf/internal/cmd/testdata/build/varmap/go.mod @@ -2,7 +2,7 @@ module github.com/gogf/gf/cmd/gf/cmd/gf/testdata/vardump/v2 go 1.18 -require github.com/gogf/gf/v2 v2.8.1 +require github.com/gogf/gf/v2 v2.8.2 require ( go.opentelemetry.io/otel v1.24.0 // indirect diff --git a/contrib/config/apollo/go.mod b/contrib/config/apollo/go.mod index 5f46be8af6f..149eaf58139 100644 --- a/contrib/config/apollo/go.mod +++ b/contrib/config/apollo/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/apolloconfig/agollo/v4 v4.3.1 - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 ) require ( diff --git a/contrib/config/consul/go.mod b/contrib/config/consul/go.mod index e87661382ac..57f58b9ef69 100644 --- a/contrib/config/consul/go.mod +++ b/contrib/config/consul/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/consul/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 github.com/hashicorp/consul/api v1.24.0 github.com/hashicorp/go-cleanhttp v0.5.2 ) diff --git a/contrib/config/kubecm/go.mod b/contrib/config/kubecm/go.mod index e6874aff1e2..bb52676f965 100644 --- a/contrib/config/kubecm/go.mod +++ b/contrib/config/kubecm/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/kubecm/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 k8s.io/api v0.27.4 k8s.io/apimachinery v0.27.4 k8s.io/client-go v0.27.4 diff --git a/contrib/config/nacos/go.mod b/contrib/config/nacos/go.mod index 02ab8739d06..702c942a21a 100644 --- a/contrib/config/nacos/go.mod +++ b/contrib/config/nacos/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/nacos/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 github.com/nacos-group/nacos-sdk-go/v2 v2.2.5 ) diff --git a/contrib/config/polaris/go.mod b/contrib/config/polaris/go.mod index 82d374c0e98..827108778fc 100644 --- a/contrib/config/polaris/go.mod +++ b/contrib/config/polaris/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/polaris/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 github.com/polarismesh/polaris-go v1.5.8 ) diff --git a/contrib/drivers/clickhouse/go.mod b/contrib/drivers/clickhouse/go.mod index d52ad6820e3..846f678bf1b 100644 --- a/contrib/drivers/clickhouse/go.mod +++ b/contrib/drivers/clickhouse/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/ClickHouse/clickhouse-go/v2 v2.0.15 - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 github.com/google/uuid v1.3.0 github.com/shopspring/decimal v1.3.1 ) diff --git a/contrib/drivers/dm/go.mod b/contrib/drivers/dm/go.mod index 93a472dab26..677112a1732 100644 --- a/contrib/drivers/dm/go.mod +++ b/contrib/drivers/dm/go.mod @@ -6,7 +6,7 @@ replace github.com/gogf/gf/v2 => ../../../ require ( gitee.com/chunanyong/dm v1.8.12 - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 ) require ( diff --git a/contrib/drivers/mssql/go.mod b/contrib/drivers/mssql/go.mod index 604a87105f8..e8e9579aa3f 100644 --- a/contrib/drivers/mssql/go.mod +++ b/contrib/drivers/mssql/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/mssql/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 github.com/microsoft/go-mssqldb v1.7.1 ) diff --git a/contrib/drivers/mysql/go.mod b/contrib/drivers/mysql/go.mod index 2b05cf39400..c66f8e6532e 100644 --- a/contrib/drivers/mysql/go.mod +++ b/contrib/drivers/mysql/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/go-sql-driver/mysql v1.7.1 - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 ) require ( diff --git a/contrib/drivers/oracle/go.mod b/contrib/drivers/oracle/go.mod index 2a4e319c1f7..832cfd41bf4 100644 --- a/contrib/drivers/oracle/go.mod +++ b/contrib/drivers/oracle/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/oracle/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 github.com/sijms/go-ora/v2 v2.7.10 ) diff --git a/contrib/drivers/pgsql/go.mod b/contrib/drivers/pgsql/go.mod index 74d72cb9b93..afeff53ffc4 100644 --- a/contrib/drivers/pgsql/go.mod +++ b/contrib/drivers/pgsql/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/pgsql/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 github.com/lib/pq v1.10.9 ) diff --git a/contrib/drivers/sqlite/go.mod b/contrib/drivers/sqlite/go.mod index 48b040e0f58..75be93aa41c 100644 --- a/contrib/drivers/sqlite/go.mod +++ b/contrib/drivers/sqlite/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/glebarez/go-sqlite v1.21.2 - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 ) require ( diff --git a/contrib/drivers/sqlitecgo/go.mod b/contrib/drivers/sqlitecgo/go.mod index 1435ed4ffdc..a122142e587 100644 --- a/contrib/drivers/sqlitecgo/go.mod +++ b/contrib/drivers/sqlitecgo/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/sqlitecgo/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 github.com/mattn/go-sqlite3 v1.14.17 ) diff --git a/contrib/metric/otelmetric/go.mod b/contrib/metric/otelmetric/go.mod index eada5401c14..69f56d644dc 100644 --- a/contrib/metric/otelmetric/go.mod +++ b/contrib/metric/otelmetric/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/metric/otelmetric/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 github.com/prometheus/client_golang v1.19.1 go.opentelemetry.io/contrib/instrumentation/runtime v0.49.0 go.opentelemetry.io/otel v1.24.0 diff --git a/contrib/nosql/redis/go.mod b/contrib/nosql/redis/go.mod index 23f73842120..88355cc7bda 100644 --- a/contrib/nosql/redis/go.mod +++ b/contrib/nosql/redis/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/nosql/redis/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 github.com/redis/go-redis/v9 v9.2.1 go.opentelemetry.io/otel v1.24.0 go.opentelemetry.io/otel/trace v1.24.0 diff --git a/contrib/registry/etcd/go.mod b/contrib/registry/etcd/go.mod index 487f54564b9..b0f6723d5ef 100644 --- a/contrib/registry/etcd/go.mod +++ b/contrib/registry/etcd/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/etcd/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 go.etcd.io/etcd/client/v3 v3.5.7 google.golang.org/grpc v1.59.0 ) diff --git a/contrib/registry/file/go.mod b/contrib/registry/file/go.mod index 8e1bb98d450..161b5809ad9 100644 --- a/contrib/registry/file/go.mod +++ b/contrib/registry/file/go.mod @@ -2,7 +2,7 @@ module github.com/gogf/gf/contrib/registry/file/v2 go 1.20 -require github.com/gogf/gf/v2 v2.8.1 +require github.com/gogf/gf/v2 v2.8.2 require ( github.com/BurntSushi/toml v1.4.0 // indirect diff --git a/contrib/registry/nacos/go.mod b/contrib/registry/nacos/go.mod index f243e595425..b222f7e61c6 100644 --- a/contrib/registry/nacos/go.mod +++ b/contrib/registry/nacos/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/nacos/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 github.com/nacos-group/nacos-sdk-go/v2 v2.2.7 ) diff --git a/contrib/registry/polaris/go.mod b/contrib/registry/polaris/go.mod index b941c438788..2a5d0b95ba7 100644 --- a/contrib/registry/polaris/go.mod +++ b/contrib/registry/polaris/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/polaris/v2 go 1.21 require ( - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 github.com/polarismesh/polaris-go v1.5.8 ) diff --git a/contrib/registry/zookeeper/go.mod b/contrib/registry/zookeeper/go.mod index 3afa94bb497..f3d8f183d3d 100644 --- a/contrib/registry/zookeeper/go.mod +++ b/contrib/registry/zookeeper/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/go-zookeeper/zk v1.0.3 - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 golang.org/x/sync v0.7.0 ) diff --git a/contrib/rpc/grpcx/go.mod b/contrib/rpc/grpcx/go.mod index 7040f915eba..1089fa5c8a3 100644 --- a/contrib/rpc/grpcx/go.mod +++ b/contrib/rpc/grpcx/go.mod @@ -3,8 +3,8 @@ module github.com/gogf/gf/contrib/rpc/grpcx/v2 go 1.20 require ( - github.com/gogf/gf/contrib/registry/file/v2 v2.8.1 - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/contrib/registry/file/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.2 go.opentelemetry.io/otel v1.24.0 go.opentelemetry.io/otel/trace v1.24.0 google.golang.org/grpc v1.64.1 diff --git a/contrib/sdk/httpclient/go.mod b/contrib/sdk/httpclient/go.mod index ed6e4fa3b9f..bc85f281c0e 100644 --- a/contrib/sdk/httpclient/go.mod +++ b/contrib/sdk/httpclient/go.mod @@ -2,7 +2,7 @@ module github.com/gogf/gf/contrib/sdk/httpclient/v2 go 1.20 -require github.com/gogf/gf/v2 v2.8.1 +require github.com/gogf/gf/v2 v2.8.2 require ( github.com/BurntSushi/toml v1.4.0 // indirect diff --git a/contrib/trace/otlpgrpc/go.mod b/contrib/trace/otlpgrpc/go.mod index 565db9acd0a..72e88496adb 100644 --- a/contrib/trace/otlpgrpc/go.mod +++ b/contrib/trace/otlpgrpc/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/trace/otlpgrpc/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 go.opentelemetry.io/otel v1.24.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 diff --git a/contrib/trace/otlphttp/go.mod b/contrib/trace/otlphttp/go.mod index 6b817b4b6e8..1c7b4364790 100644 --- a/contrib/trace/otlphttp/go.mod +++ b/contrib/trace/otlphttp/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/trace/otlphttp/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 go.opentelemetry.io/otel v1.24.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 diff --git a/example/go.mod b/example/go.mod index 7a992faf2cc..0841ae83936 100644 --- a/example/go.mod +++ b/example/go.mod @@ -3,22 +3,22 @@ module github.com/gogf/gf/example go 1.21 require ( - github.com/gogf/gf/contrib/config/apollo/v2 v2.8.1 - github.com/gogf/gf/contrib/config/consul/v2 v2.8.1 - github.com/gogf/gf/contrib/config/kubecm/v2 v2.8.1 - github.com/gogf/gf/contrib/config/nacos/v2 v2.8.1 - github.com/gogf/gf/contrib/config/polaris/v2 v2.8.1 - github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.1 - github.com/gogf/gf/contrib/metric/otelmetric/v2 v2.8.1 - github.com/gogf/gf/contrib/nosql/redis/v2 v2.8.1 - github.com/gogf/gf/contrib/registry/etcd/v2 v2.8.1 - github.com/gogf/gf/contrib/registry/file/v2 v2.8.1 - github.com/gogf/gf/contrib/registry/nacos/v2 v2.8.1 - github.com/gogf/gf/contrib/registry/polaris/v2 v2.8.1 - github.com/gogf/gf/contrib/rpc/grpcx/v2 v2.8.1 - github.com/gogf/gf/contrib/trace/otlpgrpc/v2 v2.8.1 - github.com/gogf/gf/contrib/trace/otlphttp/v2 v2.8.1 - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/contrib/config/apollo/v2 v2.8.2 + github.com/gogf/gf/contrib/config/consul/v2 v2.8.2 + github.com/gogf/gf/contrib/config/kubecm/v2 v2.8.2 + github.com/gogf/gf/contrib/config/nacos/v2 v2.8.2 + github.com/gogf/gf/contrib/config/polaris/v2 v2.8.2 + github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.2 + github.com/gogf/gf/contrib/metric/otelmetric/v2 v2.8.2 + github.com/gogf/gf/contrib/nosql/redis/v2 v2.8.2 + github.com/gogf/gf/contrib/registry/etcd/v2 v2.8.2 + github.com/gogf/gf/contrib/registry/file/v2 v2.8.2 + github.com/gogf/gf/contrib/registry/nacos/v2 v2.8.2 + github.com/gogf/gf/contrib/registry/polaris/v2 v2.8.2 + github.com/gogf/gf/contrib/rpc/grpcx/v2 v2.8.2 + github.com/gogf/gf/contrib/trace/otlpgrpc/v2 v2.8.2 + github.com/gogf/gf/contrib/trace/otlphttp/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.2 github.com/hashicorp/consul/api v1.24.0 github.com/hashicorp/go-cleanhttp v0.5.2 github.com/nacos-group/nacos-sdk-go/v2 v2.2.7 diff --git a/version.go b/version.go index d6ce791b091..31fc31ef69c 100644 --- a/version.go +++ b/version.go @@ -2,5 +2,5 @@ package gf const ( // VERSION is the current GoFrame version. - VERSION = "v2.8.1" + VERSION = "v2.8.2" ) From ba968949f72450d85fac0853f40ad5ed6f0f7c29 Mon Sep 17 00:00:00 2001 From: John Guo Date: Thu, 5 Dec 2024 22:02:47 +0800 Subject: [PATCH 032/102] fix(database/gdb): orm tag from embedded struct is missing in `with` feature (#4011) --- .../drivers/mysql/mysql_z_unit_issue_test.go | 99 +++++++++++++++++++ contrib/drivers/mysql/testdata/issue2119.sql | 47 +++++++++ database/gdb/gdb_model_with.go | 23 +++-- 3 files changed, 162 insertions(+), 7 deletions(-) create mode 100644 contrib/drivers/mysql/testdata/issue2119.sql diff --git a/contrib/drivers/mysql/mysql_z_unit_issue_test.go b/contrib/drivers/mysql/mysql_z_unit_issue_test.go index 549988036d4..04a24bc194a 100644 --- a/contrib/drivers/mysql/mysql_z_unit_issue_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_issue_test.go @@ -1457,3 +1457,102 @@ func Test_Issue3915(t *testing.T) { t.Assert(all[0]["id"], 2) }) } + +type RoleBase struct { + gmeta.Meta `orm:"table:sys_role"` + Name string `json:"name" description:"角色名称" ` + Code string `json:"code" description:"角色 code" ` + Description string `json:"description" description:"描述信息" ` + Weight int `json:"weight" description:"排序" ` + StatusId int `json:"statusId" description:"发布状态" ` + CreatedAt *gtime.Time `json:"createdAt" description:"" ` + UpdatedAt *gtime.Time `json:"updatedAt" description:"" ` +} + +type Role struct { + gmeta.Meta `orm:"table:sys_role"` + RoleBase + Id uint `json:"id" description:""` + Status *Status `json:"status" description:"发布状态" orm:"with:id=status_id" ` +} + +type StatusBase struct { + gmeta.Meta `orm:"table:sys_status"` + En string `json:"en" description:"英文名称" ` + Cn string `json:"cn" description:"中文名称" ` + Weight int `json:"weight" description:"排序权重" ` +} + +type Status struct { + gmeta.Meta `orm:"table:sys_status"` + StatusBase + Id uint `json:"id" description:""` +} + +// https://github.com/gogf/gf/issues/2119 +func Test_Issue2119(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + tables := []string{ + "sys_role", + "sys_status", + } + + defer dropTable(tables[0]) + defer dropTable(tables[1]) + _ = tables + array := gstr.SplitAndTrim(gtest.DataContent(`issue2119.sql`), ";") + for _, v := range array { + _, err := db.Exec(ctx, v) + t.AssertNil(err) + } + roles := make([]*Role, 0) + err := db.Ctx(context.Background()).Model(&Role{}).WithAll().Scan(&roles) + t.AssertNil(err) + expectStatus := []*Status{ + { + StatusBase: StatusBase{ + En: "undecided", + Cn: "未决定", + Weight: 800, + }, + Id: 2, + }, + { + StatusBase: StatusBase{ + En: "on line", + Cn: "上线", + Weight: 900, + }, + Id: 1, + }, + { + StatusBase: StatusBase{ + En: "on line", + Cn: "上线", + Weight: 900, + }, + Id: 1, + }, + { + StatusBase: StatusBase{ + En: "on line", + Cn: "上线", + Weight: 900, + }, + Id: 1, + }, + { + StatusBase: StatusBase{ + En: "on line", + Cn: "上线", + Weight: 900, + }, + Id: 1, + }, + } + + for i := 0; i < len(roles); i++ { + t.Assert(roles[i].Status, expectStatus[i]) + } + }) +} diff --git a/contrib/drivers/mysql/testdata/issue2119.sql b/contrib/drivers/mysql/testdata/issue2119.sql new file mode 100644 index 00000000000..89da7d17a7e --- /dev/null +++ b/contrib/drivers/mysql/testdata/issue2119.sql @@ -0,0 +1,47 @@ +SET NAMES utf8mb4; +SET FOREIGN_KEY_CHECKS = 0; + +-- ---------------------------- +-- Table structure for sys_role +-- ---------------------------- +DROP TABLE IF EXISTS `sys_role`; +CREATE TABLE `sys_role` ( + `id` int(0) UNSIGNED NOT NULL AUTO_INCREMENT COMMENT '||s', + `name` varchar(30) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '角色名称||s,r', + `code` varchar(100) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '角色 code||s,r', + `description` varchar(500) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '描述信息|text', + `weight` int(0) UNSIGNED NOT NULL DEFAULT 0 COMMENT '排序||r|min:0#发布状态不能小于 0', + `status_id` int(0) UNSIGNED NOT NULL DEFAULT 1 COMMENT '发布状态|hasOne|f:status,fk:id', + `created_at` datetime(0) NULL DEFAULT NULL, + `updated_at` datetime(0) NULL DEFAULT NULL, + PRIMARY KEY (`id`) USING BTREE, + INDEX `code`(`code`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 1091 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '系统角色表' ROW_FORMAT = Compact; + +-- ---------------------------- +-- Records of sys_role +-- ---------------------------- +INSERT INTO `sys_role` VALUES (1, '开发人员', 'developer', '123123', 900, 2, '2022-09-03 21:25:03', '2022-09-09 23:35:23'); +INSERT INTO `sys_role` VALUES (2, '管理员', 'admin', '', 800, 1, '2022-09-03 21:25:03', '2022-09-09 23:00:17'); +INSERT INTO `sys_role` VALUES (3, '运营', 'operator', '', 700, 1, '2022-09-03 21:25:03', '2022-09-03 21:25:03'); +INSERT INTO `sys_role` VALUES (4, '客服', 'service', '', 600, 1, '2022-09-03 21:25:03', '2022-09-03 21:25:03'); +INSERT INTO `sys_role` VALUES (5, '收银', 'account', '', 500, 1, '2022-09-03 21:25:03', '2022-09-03 21:25:03'); + +-- ---------------------------- +-- Table structure for sys_status +-- ---------------------------- +DROP TABLE IF EXISTS `sys_status`; +CREATE TABLE `sys_status` ( + `id` int(0) UNSIGNED NOT NULL AUTO_INCREMENT, + `en` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '英文名称', + `cn` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL DEFAULT '' COMMENT '中文名称', + `weight` int(0) UNSIGNED NOT NULL DEFAULT 0 COMMENT '排序权重', + PRIMARY KEY (`id`) USING BTREE +) ENGINE = InnoDB AUTO_INCREMENT = 7 CHARACTER SET = utf8mb4 COLLATE = utf8mb4_general_ci COMMENT = '发布状态' ROW_FORMAT = Dynamic; + +-- ---------------------------- +-- Records of sys_status +-- ---------------------------- +INSERT INTO `sys_status` VALUES (1, 'on line', '上线', 900); +INSERT INTO `sys_status` VALUES (2, 'undecided', '未决定', 800); +INSERT INTO `sys_status` VALUES (3, 'off line', '下线', 700); \ No newline at end of file diff --git a/database/gdb/gdb_model_with.go b/database/gdb/gdb_model_with.go index 1bef5a60f86..fcd36aeec9b 100644 --- a/database/gdb/gdb_model_with.go +++ b/database/gdb/gdb_model_with.go @@ -145,13 +145,17 @@ func (m *Model) doWithScanStruct(pointer interface{}) error { bindToReflectValue = bindToReflectValue.Addr() } - // It automatically retrieves struct field names from current attribute struct/slice. - if structType, err := gstructs.StructType(field.Value); err != nil { + if structFields, err := gstructs.Fields(gstructs.FieldsInput{ + Pointer: field.Value, + RecursiveOption: gstructs.RecursiveOptionEmbeddedNoTag, + }); err != nil { return err } else { - fieldKeys = structType.FieldKeys() + fieldKeys = make([]string, len(structFields)) + for i, field := range structFields { + fieldKeys[i] = field.Name() + } } - // Recursively with feature checks. model = m.db.With(field.Value).Hook(m.hookHandler) if m.withAll { @@ -267,11 +271,16 @@ func (m *Model) doWithScanStructs(pointer interface{}) error { if gutil.IsEmpty(relatedTargetValue) { return nil } - // It automatically retrieves struct field names from current attribute struct/slice. - if structType, err := gstructs.StructType(field.Value); err != nil { + if structFields, err := gstructs.Fields(gstructs.FieldsInput{ + Pointer: field.Value, + RecursiveOption: gstructs.RecursiveOptionEmbeddedNoTag, + }); err != nil { return err } else { - fieldKeys = structType.FieldKeys() + fieldKeys = make([]string, len(structFields)) + for i, field := range structFields { + fieldKeys[i] = field.Name() + } } // Recursively with feature checks. model = m.db.With(field.Value).Hook(m.hookHandler) From b8142bf1fc6ae47a967f0b059a1d51843222362a Mon Sep 17 00:00:00 2001 From: John Guo Date: Fri, 6 Dec 2024 14:16:03 +0800 Subject: [PATCH 033/102] feat(os/gsession): add `RegenerateId/MustRegenerateId` support (#4012) --- os/gsession/gsession_session.go | 88 ++++++++++++++++++----- os/gsession/gsession_z_unit_test.go | 108 ++++++++++++++++++++++++++++ 2 files changed, 179 insertions(+), 17 deletions(-) diff --git a/os/gsession/gsession_session.go b/os/gsession/gsession_session.go index c89b4239c43..1844b51de2b 100644 --- a/os/gsession/gsession_session.go +++ b/os/gsession/gsession_session.go @@ -45,7 +45,7 @@ func (s *Session) init() error { // Retrieve stored session data from storage. if s.manager.storage != nil { s.data, err = s.manager.storage.GetSession(s.ctx, s.id, s.manager.GetTTL()) - if err != nil && err != ErrorDisabled { + if err != nil && !gerror.Is(err, ErrorDisabled) { intlog.Errorf(s.ctx, `session restoring failed for id "%s": %+v`, s.id, err) return err } @@ -59,7 +59,7 @@ func (s *Session) init() error { } else { // Use default session id creating function of storage. s.id, err = s.manager.storage.New(s.ctx, s.manager.ttl) - if err != nil && err != ErrorDisabled { + if err != nil && !gerror.Is(err, ErrorDisabled) { intlog.Errorf(s.ctx, "create session id failed: %+v", err) return err } @@ -89,12 +89,12 @@ func (s *Session) Close() error { size := s.data.Size() if s.dirty { err := s.manager.storage.SetSession(s.ctx, s.id, s.data, s.manager.ttl) - if err != nil && err != ErrorDisabled { + if err != nil && !gerror.Is(err, ErrorDisabled) { return err } } else if size > 0 { err := s.manager.storage.UpdateTTL(s.ctx, s.id, s.manager.ttl) - if err != nil && err != ErrorDisabled { + if err != nil && !gerror.Is(err, ErrorDisabled) { return err } } @@ -108,11 +108,10 @@ func (s *Session) Set(key string, value interface{}) (err error) { return err } if err = s.manager.storage.Set(s.ctx, s.id, key, value, s.manager.ttl); err != nil { - if err == ErrorDisabled { - s.data.Set(key, value) - } else { + if !gerror.Is(err, ErrorDisabled) { return err } + s.data.Set(key, value) } s.dirty = true return nil @@ -124,11 +123,10 @@ func (s *Session) SetMap(data map[string]interface{}) (err error) { return err } if err = s.manager.storage.SetMap(s.ctx, s.id, data, s.manager.ttl); err != nil { - if err == ErrorDisabled { - s.data.Sets(data) - } else { + if !gerror.Is(err, ErrorDisabled) { return err } + s.data.Sets(data) } s.dirty = true return nil @@ -144,11 +142,10 @@ func (s *Session) Remove(keys ...string) (err error) { } for _, key := range keys { if err = s.manager.storage.Remove(s.ctx, s.id, key); err != nil { - if err == ErrorDisabled { - s.data.Remove(key) - } else { + if !gerror.Is(err, ErrorDisabled) { return err } + s.data.Remove(key) } } s.dirty = true @@ -164,7 +161,7 @@ func (s *Session) RemoveAll() (err error) { return err } if err = s.manager.storage.RemoveAll(s.ctx, s.id); err != nil { - if err != ErrorDisabled { + if !gerror.Is(err, ErrorDisabled) { return err } } @@ -215,7 +212,7 @@ func (s *Session) Data() (sessionData map[string]interface{}, err error) { return nil, err } sessionData, err = s.manager.storage.Data(s.ctx, s.id) - if err != nil && err != ErrorDisabled { + if err != nil && !gerror.Is(err, ErrorDisabled) { intlog.Errorf(s.ctx, `%+v`, err) } if sessionData != nil { @@ -233,7 +230,7 @@ func (s *Session) Size() (size int, err error) { return 0, err } size, err = s.manager.storage.GetSize(s.ctx, s.id) - if err != nil && err != ErrorDisabled { + if err != nil && !gerror.Is(err, ErrorDisabled) { intlog.Errorf(s.ctx, `%+v`, err) } if size > 0 { @@ -273,7 +270,7 @@ func (s *Session) Get(key string, def ...interface{}) (value *gvar.Var, err erro return nil, err } v, err := s.manager.storage.Get(s.ctx, s.id, key) - if err != nil && err != ErrorDisabled { + if err != nil && !gerror.Is(err, ErrorDisabled) { intlog.Errorf(s.ctx, `%+v`, err) return nil, err } @@ -357,3 +354,60 @@ func (s *Session) MustRemove(keys ...string) { panic(err) } } + +// RegenerateId regenerates a new session id for current session. +// It keeps the session data and updates the session id with a new one. +// This is commonly used to prevent session fixation attacks and increase security. +// +// The parameter `deleteOld` specifies whether to delete the old session data: +// - If true: the old session data will be deleted immediately +// - If false: the old session data will be kept and expire according to its TTL +func (s *Session) RegenerateId(deleteOld bool) (newId string, err error) { + if err = s.init(); err != nil { + return "", err + } + + // Generate new session id + if s.idFunc != nil { + newId = s.idFunc(s.manager.ttl) + } else { + newId, err = s.manager.storage.New(s.ctx, s.manager.ttl) + if err != nil && !gerror.Is(err, ErrorDisabled) { + return "", err + } + if newId == "" { + newId = NewSessionId() + } + } + + // If using storage, need to copy data to new id + if s.manager.storage != nil { + if err = s.manager.storage.SetSession(s.ctx, newId, s.data, s.manager.ttl); err != nil { + if !gerror.Is(err, ErrorDisabled) { + return "", err + } + } + // Delete old session data if requested + if deleteOld { + if err = s.manager.storage.RemoveAll(s.ctx, s.id); err != nil { + if !gerror.Is(err, ErrorDisabled) { + return "", err + } + } + } + } + + // Update session id + s.id = newId + s.dirty = true + return newId, nil +} + +// MustRegenerateId performs as function RegenerateId, but it panics if any error occurs. +func (s *Session) MustRegenerateId(deleteOld bool) string { + newId, err := s.RegenerateId(deleteOld) + if err != nil { + panic(err) + } + return newId +} diff --git a/os/gsession/gsession_z_unit_test.go b/os/gsession/gsession_z_unit_test.go index 54940183cc0..613c00dc465 100644 --- a/os/gsession/gsession_z_unit_test.go +++ b/os/gsession/gsession_z_unit_test.go @@ -7,11 +7,15 @@ package gsession import ( + "context" "testing" + "time" "github.com/gogf/gf/v2/test/gtest" ) +var ctx = context.TODO() + func Test_NewSessionId(t *testing.T) { gtest.C(t, func(t *gtest.T) { id1 := NewSessionId() @@ -20,3 +24,107 @@ func Test_NewSessionId(t *testing.T) { t.Assert(len(id1), 32) }) } + +func Test_Session_RegenerateId(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + // 1. Test with memory storage + storage := NewStorageMemory() + manager := New(time.Hour, storage) + session := manager.New(ctx) + + // Store some data + err := session.Set("key1", "value1") + t.AssertNil(err) + err = session.Set("key2", "value2") + t.AssertNil(err) + + // Get original session id + oldId := session.MustId() + + // Test regenerate with deleteOld = true + newId1, err := session.RegenerateId(true) + t.AssertNil(err) + t.AssertNE(oldId, newId1) + + // Verify data is preserved + v1 := session.MustGet("key1") + t.Assert(v1.String(), "value1") + v2 := session.MustGet("key2") + t.Assert(v2.String(), "value2") + + // Verify old session is deleted + oldSession := manager.New(ctx) + err = oldSession.SetId(oldId) + t.AssertNil(err) + v3 := oldSession.MustGet("key1") + t.Assert(v3.IsNil(), true) + + // Test regenerate with deleteOld = false + currentId := newId1 + newId2, err := session.RegenerateId(false) + t.AssertNil(err) + t.AssertNE(currentId, newId2) + + // Verify data is preserved in new session + v4 := session.MustGet("key1") + t.Assert(v4.String(), "value1") + + // Create another session instance with the previous id + prevSession := manager.New(ctx) + err = prevSession.SetId(currentId) + t.AssertNil(err) + // Data should still be accessible in previous session + v5 := prevSession.MustGet("key1") + t.Assert(v5.String(), "value1") + }) + + gtest.C(t, func(t *gtest.T) { + // 2. Test with custom id function + storage := NewStorageMemory() + manager := New(time.Hour, storage) + session := manager.New(ctx) + + customId := "custom_session_id" + err := session.SetIdFunc(func(ttl time.Duration) string { + return customId + }) + t.AssertNil(err) + + newId, err := session.RegenerateId(true) + t.AssertNil(err) + t.Assert(newId, customId) + }) + + gtest.C(t, func(t *gtest.T) { + // 3. Test with disabled storage + storage := &StorageBase{} // implements Storage interface but all methods return ErrorDisabled + manager := New(time.Hour, storage) + session := manager.New(ctx) + + // Should still work even with disabled storage + newId, err := session.RegenerateId(true) + t.AssertNil(err) + t.Assert(len(newId), 32) + }) +} + +// Test MustRegenerateId +func Test_Session_MustRegenerateId(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + storage := NewStorageMemory() + manager := New(time.Hour, storage) + session := manager.New(ctx) + + // Normal case should not panic + t.AssertNil(session.Set("key", "value")) + newId := session.MustRegenerateId(true) + t.Assert(len(newId), 32) + + // Test with disabled storage (should not panic) + storage2 := &StorageBase{} + manager2 := New(time.Hour, storage2) + session2 := manager2.New(ctx) + newId2 := session2.MustRegenerateId(true) + t.Assert(len(newId2), 32) + }) +} From 2066aa4803ecaa5ddb42f4d2e5916227a29be9d1 Mon Sep 17 00:00:00 2001 From: John Guo Date: Sat, 7 Dec 2024 14:01:31 +0800 Subject: [PATCH 034/102] feat(database/gdb): add transaction propagation&isolation level&readonly features (#4013) --- .../drivers/mysql/mysql_z_unit_init_test.go | 4 +- .../mysql/mysql_z_unit_transaction_test.go | 625 +++++++++++++++++- database/gdb/gdb.go | 383 +++++++++-- database/gdb/gdb_core.go | 14 +- database/gdb/gdb_core_transaction.go | 576 +++++----------- database/gdb/gdb_core_txcore.go | 412 ++++++++++++ database/gdb/gdb_core_underlying.go | 14 +- database/gdb/gdb_model_transaction.go | 14 + 8 files changed, 1527 insertions(+), 515 deletions(-) create mode 100644 database/gdb/gdb_core_txcore.go diff --git a/contrib/drivers/mysql/mysql_z_unit_init_test.go b/contrib/drivers/mysql/mysql_z_unit_init_test.go index 1326378c36e..f0621741c7b 100644 --- a/contrib/drivers/mysql/mysql_z_unit_init_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_init_test.go @@ -10,6 +10,7 @@ import ( "context" "fmt" "testing" + "time" "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/database/gdb" @@ -41,7 +42,8 @@ var ( func init() { nodeDefault := gdb.ConfigNode{ - Link: fmt.Sprintf("mysql:root:%s@tcp(127.0.0.1:3306)/?loc=Local&parseTime=true", TestDbPass), + ExecTimeout: time.Second * 2, + Link: fmt.Sprintf("mysql:root:%s@tcp(127.0.0.1:3306)/?loc=Local&parseTime=true", TestDbPass), } partitionDefault := gdb.ConfigNode{ Link: fmt.Sprintf("mysql:root:%s@tcp(127.0.0.1:3307)/?loc=Local&parseTime=true", TestDbPass), diff --git a/contrib/drivers/mysql/mysql_z_unit_transaction_test.go b/contrib/drivers/mysql/mysql_z_unit_transaction_test.go index b0e2a0cc19e..89ed7eba7a5 100644 --- a/contrib/drivers/mysql/mysql_z_unit_transaction_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_transaction_test.go @@ -8,6 +8,7 @@ package mysql_test import ( "context" + "database/sql" "fmt" "testing" @@ -807,12 +808,12 @@ func Test_Transaction_Nested_TX_Transaction_UseTX(t *testing.T) { ) err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { // commit - err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - _, err = tx.Model(table).Data(g.Map{ + err = tx.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + err = tx2.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + err = tx2.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + err = tx2.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + err = tx2.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + _, err = tx2.Model(table).Data(g.Map{ "id": 1, "passport": "USER_1", "password": "PASS_1", @@ -842,8 +843,8 @@ func Test_Transaction_Nested_TX_Transaction_UseTX(t *testing.T) { t.AssertNil(err) // rollback - err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - _, err = tx.Model(table).Data(g.Map{ + err = tx.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + _, err = tx2.Model(table).Data(g.Map{ "id": 2, "passport": "USER_2", "password": "PASS_2", @@ -869,12 +870,12 @@ func Test_Transaction_Nested_TX_Transaction_UseTX(t *testing.T) { // another record. err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { // commit - err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - _, err = tx.Model(table).Data(g.Map{ + err = tx.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + err = tx2.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + err = tx2.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + err = tx2.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + err = tx2.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + _, err = tx2.Model(table).Data(g.Map{ "id": 3, "passport": "USER_1", "password": "PASS_1", @@ -904,8 +905,8 @@ func Test_Transaction_Nested_TX_Transaction_UseTX(t *testing.T) { t.AssertNil(err) // rollback - err = tx.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - _, err = tx.Model(table).Data(g.Map{ + err = tx.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + _, err = tx2.Model(table).Data(g.Map{ "id": 4, "passport": "USER_2", "password": "PASS_2", @@ -945,11 +946,11 @@ func Test_Transaction_Nested_TX_Transaction_UseDB(t *testing.T) { ) err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { // commit - err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + err = db.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + err = db.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + err = db.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + err = db.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + err = db.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { _, err = db.Model(table).Ctx(ctx).Data(g.Map{ "id": 1, "passport": "USER_1", @@ -980,8 +981,8 @@ func Test_Transaction_Nested_TX_Transaction_UseDB(t *testing.T) { t.AssertNil(err) // rollback - err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - _, err = tx.Model(table).Ctx(ctx).Data(g.Map{ + err = db.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + _, err = tx2.Model(table).Ctx(ctx).Data(g.Map{ "id": 2, "passport": "USER_2", "password": "PASS_2", @@ -1007,11 +1008,11 @@ func Test_Transaction_Nested_TX_Transaction_UseDB(t *testing.T) { err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { // commit - err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + err = db.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + err = db.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + err = db.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + err = db.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + err = db.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { _, err = db.Model(table).Ctx(ctx).Data(g.Map{ "id": 3, "passport": "USER_1", @@ -1042,8 +1043,8 @@ func Test_Transaction_Nested_TX_Transaction_UseDB(t *testing.T) { t.AssertNil(err) // rollback - err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { - _, err = tx.Model(table).Ctx(ctx).Data(g.Map{ + err = db.Transaction(ctx, func(ctx context.Context, tx2 gdb.TX) error { + _, err = tx2.Model(table).Ctx(ctx).Data(g.Map{ "id": 4, "passport": "USER_2", "password": "PASS_2", @@ -1143,3 +1144,567 @@ func Test_Transaction_Method(t *testing.T) { t.Assert(count, int64(0)) }) } + +func Test_Transaction_Propagation(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + table := createTable() + defer dropTable(table) + + // Test PropagationRequired + err := db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + // Insert initial record + _, err := tx.Insert(table, g.Map{ + "id": 1, + "passport": "required", + }) + t.AssertNil(err) + + // Nested transaction with PropagationRequired + err = tx.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationRequired, + }, func(ctx context.Context, tx2 gdb.TX) error { + // Should use the same transaction + _, err := tx2.Insert(table, g.Map{ + "id": 2, + "passport": "required_nested", + }) + return err + }) + t.AssertNil(err) + + return nil + }) + t.AssertNil(err) + + // Verify both records exist + count, err := db.Model(table).Count() + t.AssertNil(err) + t.Assert(count, int64(2)) + }) + + gtest.C(t, func(t *gtest.T) { + table := createTable() + defer dropTable(table) + + // Test PropagationRequiresNew + err := db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + // Insert in outer transaction + _, err := tx.Insert(table, g.Map{ + "id": 3, + "passport": "outer", + }) + t.AssertNil(err) + + // Inner transaction with PropagationRequiresNew + err = tx.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationRequiresNew, + }, func(ctx context.Context, tx2 gdb.TX) error { + // This is a new transaction + _, _ = tx2.Insert(table, g.Map{ + "id": 4, + "passport": "inner_new", + }) + // Simulate error to test independent rollback + return gerror.New("rollback inner transaction") + }) + // Inner transaction error should not affect outer transaction + t.AssertNE(err, nil) + + return nil + }) + t.AssertNil(err) + + // Verify only outer transaction record exists + count, err := db.Model(table).Where("passport", "outer").Count() + t.AssertNil(err) + t.Assert(count, int64(1)) + }) + + gtest.C(t, func(t *gtest.T) { + table := createTable() + defer dropTable(table) + + // Test PropagationNested + err := db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + // Insert in outer transaction + _, err := tx.Insert(table, g.Map{ + "id": 5, + "passport": "nested_outer", + }) + t.AssertNil(err) + + // Nested transaction + err = tx.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationNested, + }, func(ctx context.Context, tx2 gdb.TX) error { + _, _ = tx2.Insert(table, g.Map{ + "id": 6, + "passport": "nested_inner", + }) + // Simulate error to test savepoint rollback + return gerror.New("rollback to savepoint") + }) + t.AssertNE(err, nil) + + // Insert another record after nested transaction rollback + _, err = tx.Insert(table, g.Map{ + "id": 7, + "passport": "nested_after", + }) + t.AssertNil(err) + + return nil + }) + t.AssertNil(err) + + // Verify outer transaction records exist, but nested transaction record doesn't + count, err := db.Model(table).Where("passport", "nested_inner").Count() + t.AssertNil(err) + t.Assert(count, int64(0)) + + count, err = db.Model(table).Where("passport IN(?,?)", + "nested_outer", "nested_after").Count() + t.AssertNil(err) + t.Assert(count, int64(2)) + }) + + gtest.C(t, func(t *gtest.T) { + table := createTable() + defer dropTable(table) + + // Test PropagationNotSupported + err := db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + // Insert in transaction + _, err := tx.Insert(table, g.Map{ + "id": 8, + "passport": "tx_record", + }) + t.AssertNil(err) + + // Non-transactional operation + err = tx.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationNotSupported, + }, func(ctx context.Context, tx2 gdb.TX) error { + // Should execute without transaction + t.Assert(tx2, nil) + _, err := db.Insert(ctx, table, g.Map{ + "id": 9, + "passport": "non_tx_record", + }) + return err + }) + t.AssertNil(err) + + return gerror.New("rollback outer transaction") + }) + t.AssertNE(err, nil) + + // Verify transactional record is rolled back but non-transactional record exists + count, err := db.Model(table).Where("passport", "tx_record").Count() + t.AssertNil(err) + t.Assert(count, int64(0)) + + count, err = db.Model(table).Where("passport", "non_tx_record").Count() + t.AssertNil(err) + t.Assert(count, int64(1)) + }) + + gtest.C(t, func(t *gtest.T) { + table := createTable() + defer dropTable(table) + + // Test PropagationMandatory + err := db.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationMandatory, + }, func(ctx context.Context, tx gdb.TX) error { + return nil + }) + // Should fail because no transaction exists + t.AssertNE(err, nil) + + // Test within an existing transaction + err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + return tx.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationMandatory, + }, func(ctx context.Context, tx2 gdb.TX) error { + // Should succeed because transaction exists + _, err := tx2.Insert(table, g.Map{ + "id": 10, + "passport": "mandatory", + }) + return err + }) + }) + t.AssertNil(err) + }) + + gtest.C(t, func(t *gtest.T) { + table := createTable() + defer dropTable(table) + + // Test PropagationNever + err := db.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationNever, + }, func(ctx context.Context, tx gdb.TX) error { + // Should execute without transaction + t.Assert(tx, nil) + _, err := db.Insert(ctx, table, g.Map{ + "id": 11, + "passport": "never", + }) + return err + }) + t.AssertNil(err) + + // Test within an existing transaction + err = db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + return tx.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationNever, + }, func(ctx context.Context, tx2 gdb.TX) error { + return nil + }) + }) + // Should fail because transaction exists + t.AssertNE(err, nil) + }) +} + +func Test_Transaction_Propagation_Complex(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + table1 := createTable() + table2 := createTable() + defer dropTable(table1) + defer dropTable(table2) + + // Test nested transactions with different propagation behaviors + err := db.Transaction(ctx, func(ctx context.Context, tx1 gdb.TX) error { + // Insert in outer transaction + _, err := tx1.Insert(table1, g.Map{ + "id": 1, + "passport": "outer", + }) + t.AssertNil(err) + + // First nested transaction (NESTED) + err = tx1.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationNested, + }, func(ctx context.Context, tx2 gdb.TX) error { + _, err := tx2.Insert(table1, g.Map{ + "id": 2, + "passport": "nested1", + }) + t.AssertNil(err) + + // Second nested transaction (REQUIRES_NEW) + err = tx2.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationRequiresNew, + }, func(ctx context.Context, tx3 gdb.TX) error { + _, _ = tx3.Insert(table1, g.Map{ + "id": 3, + "passport": "new1", + }) + // This will be rolled back independently + return gerror.New("rollback new transaction") + }) + t.AssertNE(err, nil) + + // Third nested transaction (NESTED) + return tx2.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationNested, + }, func(ctx context.Context, tx3 gdb.TX) error { + _, _ = tx3.Insert(table1, g.Map{ + "id": 4, + "passport": "nested2", + }) + // This will rollback to the savepoint + return gerror.New("rollback nested transaction") + }) + }) + t.AssertNE(err, nil) + + // Fourth transaction (NOT_SUPPORTED) + // Note that, it locks table if it continues using table1. + err = tx1.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationNotSupported, + }, func(ctx context.Context, tx2 gdb.TX) error { + // Should execute without transaction + t.Assert(tx2, nil) + + _, err := db.Insert(ctx, table2, g.Map{ + "id": 5, + "passport": "not_supported", + }) + return err + }) + t.AssertNil(err) + + return nil + }) + t.AssertNil(err) + + // Verify final state + // 1. "outer" should exist (committed) + count, err := db.Model(table1).Where("passport", "outer").Count() + t.AssertNil(err) + t.Assert(count, int64(1)) + + // 2. "nested1" should not exist (rolled back due to error) + count, err = db.Model(table1).Where("passport", "nested1").Count() + t.AssertNil(err) + t.Assert(count, int64(0)) + + // 3. "new1" should not exist (rolled back independently) + count, err = db.Model(table1).Where("passport", "new1").Count() + t.AssertNil(err) + t.Assert(count, int64(0)) + + // 4. "nested2" should not exist (rolled back to savepoint) + count, err = db.Model(table1).Where("passport", "nested2").Count() + t.AssertNil(err) + t.Assert(count, int64(0)) + + // 5. "not_supported" should exist (non-transactional) + count, err = db.Model(table2).Where("passport", "not_supported").Count() + t.AssertNil(err) + t.Assert(count, int64(1)) + }) + + gtest.C(t, func(t *gtest.T) { + table := createTable() + defer dropTable(table) + + // Test transaction suspension and resume + err := db.Transaction(ctx, func(ctx context.Context, tx1 gdb.TX) error { + // Insert in outer transaction + _, err := tx1.Insert(table, g.Map{ + "id": 6, + "passport": "suspend_outer", + "password": "pass6", + "nickname": "suspend_outer", + "create_time": gtime.Now().String(), + }) + t.AssertNil(err) + + // Suspend current transaction (NOT_SUPPORTED) + err = tx1.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationNotSupported, + }, func(ctx context.Context, tx2 gdb.TX) error { + // Should execute without transaction + t.Assert(tx2, nil) + + // Start a new independent transaction + return db.Transaction(ctx, func(ctx context.Context, tx3 gdb.TX) error { + _, err := tx3.Insert(table, g.Map{ + "id": 7, + "passport": "independent", + "password": "pass7", + "nickname": "independent", + "create_time": gtime.Now().String(), + }) + return err + }) + }) + t.AssertNil(err) + + // Resume original transaction + _, err = tx1.Insert(table, g.Map{ + "id": 8, + "passport": "suspend_resume", + "password": "pass8", + "nickname": "suspend_resume", + "create_time": gtime.Now().String(), + }) + t.AssertNil(err) + + // Simulate error to rollback outer transaction + return gerror.New("rollback outer transaction") + }) + t.AssertNE(err, nil) + + // Verify final state + // 1. "suspend_outer" and "suspend_resume" should not exist (rolled back) + count, err := db.Model(table).Where("passport IN(?,?)", + "suspend_outer", "suspend_resume").Count() + t.AssertNil(err) + t.Assert(count, int64(0)) + + // 2. "independent" should exist (committed independently) + count, err = db.Model(table).Where("passport", "independent").Count() + t.AssertNil(err) + t.Assert(count, int64(1)) + }) +} + +func Test_Transaction_ReadOnly(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + // Test read-only transaction + err := db.TransactionWithOptions(ctx, gdb.TxOptions{ + ReadOnly: true, + }, func(ctx context.Context, tx gdb.TX) error { + // Try to modify data in read-only transaction + _, err := tx.Update(table, g.Map{"passport": "changed"}, "id=1") + // Should return error + return err + }) + t.AssertNE(err, nil) + + // Verify data was not modified + v, err := db.Model(table).Where("id=1").Value("passport") + t.AssertNil(err) + t.Assert(v.String(), "user_1") + }) +} + +func Test_Transaction_Isolation(t *testing.T) { + // Test READ UNCOMMITTED + gtest.C(t, func(t *gtest.T) { + table := createInitTable() + defer dropTable(table) + err := db.TransactionWithOptions(ctx, gdb.TxOptions{ + Isolation: sql.LevelReadUncommitted, + }, func(ctx context.Context, tx1 gdb.TX) error { + // Update value in first transaction + _, err := tx1.Update(table, g.Map{"passport": "dirty_read"}, "id=1") + t.AssertNil(err) + + // Start another transaction to verify dirty read + err = db.TransactionWithOptions(ctx, gdb.TxOptions{ + Isolation: sql.LevelReadUncommitted, + }, func(ctx context.Context, tx2 gdb.TX) error { + // Should see uncommitted change in READ UNCOMMITTED + v, err := tx2.Model(table).Where("id=1").Value("passport") + t.AssertNil(err) + t.Assert(v.String(), "dirty_read") + return nil + }) + t.AssertNil(err) + + // Rollback the first transaction + return gerror.New("rollback first transaction") + }) + t.AssertNE(err, nil) + + // Verify the value is rolled back + v, err := db.Model(table).Where("id=1").Value("passport") + t.AssertNil(err) + t.Assert(v.String(), "user_1") + }) + + // Test REPEATABLE READ (default) + gtest.C(t, func(t *gtest.T) { + table := createInitTable() + defer dropTable(table) + + // Start a transaction with REPEATABLE READ isolation + err := db.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationRequiresNew, + Isolation: sql.LevelRepeatableRead, + }, func(ctx context.Context, tx1 gdb.TX) error { + // First read + v1, err := tx1.Model(table).Where("id=1").Value("passport") + t.AssertNil(err) + initialValue := v1.String() + + // Another transaction updates and commits the value + err = db.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationRequiresNew, + }, func(ctx context.Context, tx2 gdb.TX) error { + _, err := tx2.Update(table, g.Map{ + "passport": "changed_value", + }, "id=1") + t.AssertNil(err) + return nil + }) + t.AssertNil(err) + + // Verify the change is visible outside transaction + v, err := db.Model(table).Where("id=1").Value("passport") + t.AssertNil(err) + t.Assert(v.String(), "changed_value") + + // Should still see old value in REPEATABLE READ transaction + v2, err := tx1.Model(table).Where("id=1").Value("passport") + t.AssertNil(err) + t.Assert(v2.String(), initialValue) + + // Even after multiple reads, should still see the same value + v3, err := tx1.Model(table).Where("id=1").Value("passport") + t.AssertNil(err) + t.Assert(v3.String(), initialValue) + + return nil + }) + t.AssertNil(err) + + // After transaction ends, should see the committed change + v, err := db.Model(table).Where("id=1").Value("passport") + t.AssertNil(err) + t.Assert(v.String(), "changed_value") + }) + + // Test SERIALIZABLE + gtest.C(t, func(t *gtest.T) { + table := createInitTable() + defer dropTable(table) + + err := db.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationRequiresNew, + Isolation: sql.LevelSerializable, + }, func(ctx context.Context, tx1 gdb.TX) error { + // Read all records + _, err := tx1.Model(table).All() + t.AssertNil(err) + + // Try concurrent insert in another transaction + err = db.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationRequiresNew, + Isolation: sql.LevelSerializable, + }, func(ctx context.Context, tx2 gdb.TX) error { + _, err := tx2.Insert(table, g.Map{ + "id": 1000, + "passport": "new_user", + }) + return err + }) + t.AssertNE(err, nil) + return nil + }) + t.AssertNil(err) + }) + + // Test READ COMMITTED + gtest.C(t, func(t *gtest.T) { + table := createInitTable() + defer dropTable(table) + err := db.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationRequiresNew, + Isolation: sql.LevelReadCommitted, + }, func(ctx context.Context, tx1 gdb.TX) error { + // First read + v1, err := tx1.Model(table).Where("id=1").Value("passport") + t.AssertNil(err) + initialValue := v1.String() + + // Another transaction updates and commits + err = db.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationRequiresNew, + Isolation: sql.LevelReadCommitted, + }, func(ctx context.Context, tx2 gdb.TX) error { + _, err := tx2.Update(table, g.Map{"passport": "committed_value"}, "id=1") + return err + }) + t.AssertNil(err) + + // Should see new value in READ COMMITTED + v2, err := tx1.Model(table).Where("id=1").Value("passport") + t.AssertNil(err) + t.Assert(v2.String(), "committed_value") + t.AssertNE(v2.String(), initialValue) + return nil + }) + t.AssertNil(err) + }) +} diff --git a/database/gdb/gdb.go b/database/gdb/gdb.go index f9851dbaca4..a8c2a2bdf22 100644 --- a/database/gdb/gdb.go +++ b/database/gdb/gdb.go @@ -48,7 +48,7 @@ type DB interface { // Raw creates and returns a model based on a raw sql not a table. Raw(rawSql string, args ...interface{}) *Model - // Schema creates and returns a schema. + // Schema switches to a specified schema. // Also see Core.Schema. Schema(schema string) *Schema @@ -58,7 +58,6 @@ type DB interface { // Open creates a raw connection object for database with given node configuration. // Note that it is not recommended using the function manually. - // Also see DriverMysql.Open. Open(config *ConfigNode) (*sql.DB, error) // Ctx is a chaining function, which creates and returns a new DB that is a shallow copy @@ -78,173 +77,422 @@ type DB interface { // Query APIs. // =========================================================================== - Query(ctx context.Context, sql string, args ...interface{}) (Result, error) // See Core.Query. - Exec(ctx context.Context, sql string, args ...interface{}) (sql.Result, error) // See Core.Exec. - Prepare(ctx context.Context, sql string, execOnMaster ...bool) (*Stmt, error) // See Core.Prepare. + // Query executes a SQL query that returns rows using given SQL and arguments. + // The args are for any placeholder parameters in the query. + Query(ctx context.Context, sql string, args ...interface{}) (Result, error) + + // Exec executes a SQL query that doesn't return rows (e.g., INSERT, UPDATE, DELETE). + // It returns sql.Result for accessing LastInsertId or RowsAffected. + Exec(ctx context.Context, sql string, args ...interface{}) (sql.Result, error) + + // Prepare creates a prepared statement for later queries or executions. + // The execOnMaster parameter determines whether the statement executes on master node. + Prepare(ctx context.Context, sql string, execOnMaster ...bool) (*Stmt, error) // =========================================================================== // Common APIs for CURD. // =========================================================================== - Insert(ctx context.Context, table string, data interface{}, batch ...int) (sql.Result, error) // See Core.Insert. - InsertIgnore(ctx context.Context, table string, data interface{}, batch ...int) (sql.Result, error) // See Core.InsertIgnore. - InsertAndGetId(ctx context.Context, table string, data interface{}, batch ...int) (int64, error) // See Core.InsertAndGetId. - Replace(ctx context.Context, table string, data interface{}, batch ...int) (sql.Result, error) // See Core.Replace. - Save(ctx context.Context, table string, data interface{}, batch ...int) (sql.Result, error) // See Core.Save. - Update(ctx context.Context, table string, data interface{}, condition interface{}, args ...interface{}) (sql.Result, error) // See Core.Update. - Delete(ctx context.Context, table string, condition interface{}, args ...interface{}) (sql.Result, error) // See Core.Delete. + // Insert inserts one or multiple records into table. + // The data can be a map, struct, or slice of maps/structs. + // The optional batch parameter specifies the batch size for bulk inserts. + Insert(ctx context.Context, table string, data interface{}, batch ...int) (sql.Result, error) + + // InsertIgnore inserts records but ignores duplicate key errors. + // It works like Insert but adds IGNORE keyword to the SQL statement. + InsertIgnore(ctx context.Context, table string, data interface{}, batch ...int) (sql.Result, error) + + // InsertAndGetId inserts a record and returns the auto-generated ID. + // It's a convenience method combining Insert with LastInsertId. + InsertAndGetId(ctx context.Context, table string, data interface{}, batch ...int) (int64, error) + + // Replace inserts or replaces records using REPLACE INTO syntax. + // Existing records with same unique key will be deleted and re-inserted. + Replace(ctx context.Context, table string, data interface{}, batch ...int) (sql.Result, error) + + // Save inserts or updates records using INSERT ... ON DUPLICATE KEY UPDATE syntax. + // It updates existing records instead of replacing them entirely. + Save(ctx context.Context, table string, data interface{}, batch ...int) (sql.Result, error) + + // Update updates records in table that match the condition. + // The data can be a map or struct containing the new values. + // The condition specifies the WHERE clause with optional placeholder args. + Update(ctx context.Context, table string, data interface{}, condition interface{}, args ...interface{}) (sql.Result, error) + + // Delete deletes records from table that match the condition. + // The condition specifies the WHERE clause with optional placeholder args. + Delete(ctx context.Context, table string, condition interface{}, args ...interface{}) (sql.Result, error) // =========================================================================== // Internal APIs for CURD, which can be overwritten by custom CURD implements. // =========================================================================== - DoSelect(ctx context.Context, link Link, sql string, args ...interface{}) (result Result, err error) // See Core.DoSelect. - DoInsert(ctx context.Context, link Link, table string, data List, option DoInsertOption) (result sql.Result, err error) // See Core.DoInsert. - DoUpdate(ctx context.Context, link Link, table string, data interface{}, condition string, args ...interface{}) (result sql.Result, err error) // See Core.DoUpdate. - DoDelete(ctx context.Context, link Link, table string, condition string, args ...interface{}) (result sql.Result, err error) // See Core.DoDelete. + // DoSelect executes a SELECT query using the given link and returns the result. + // This is an internal method that can be overridden by custom implementations. + DoSelect(ctx context.Context, link Link, sql string, args ...interface{}) (result Result, err error) + + // DoInsert performs the actual INSERT operation with given options. + // This is an internal method that can be overridden by custom implementations. + DoInsert(ctx context.Context, link Link, table string, data List, option DoInsertOption) (result sql.Result, err error) + + // DoUpdate performs the actual UPDATE operation. + // This is an internal method that can be overridden by custom implementations. + DoUpdate(ctx context.Context, link Link, table string, data interface{}, condition string, args ...interface{}) (result sql.Result, err error) - DoQuery(ctx context.Context, link Link, sql string, args ...interface{}) (result Result, err error) // See Core.DoQuery. - DoExec(ctx context.Context, link Link, sql string, args ...interface{}) (result sql.Result, err error) // See Core.DoExec. + // DoDelete performs the actual DELETE operation. + // This is an internal method that can be overridden by custom implementations. + DoDelete(ctx context.Context, link Link, table string, condition string, args ...interface{}) (result sql.Result, err error) - DoFilter(ctx context.Context, link Link, sql string, args []interface{}) (newSql string, newArgs []interface{}, err error) // See Core.DoFilter. - DoCommit(ctx context.Context, in DoCommitInput) (out DoCommitOutput, err error) // See Core.DoCommit. + // DoQuery executes a query that returns rows. + // This is an internal method that can be overridden by custom implementations. + DoQuery(ctx context.Context, link Link, sql string, args ...interface{}) (result Result, err error) - DoPrepare(ctx context.Context, link Link, sql string) (*Stmt, error) // See Core.DoPrepare. + // DoExec executes a query that doesn't return rows. + // This is an internal method that can be overridden by custom implementations. + DoExec(ctx context.Context, link Link, sql string, args ...interface{}) (result sql.Result, err error) + + // DoFilter processes and filters SQL and args before execution. + // This is an internal method that can be overridden to implement custom SQL filtering. + DoFilter(ctx context.Context, link Link, sql string, args []interface{}) (newSql string, newArgs []interface{}, err error) + + // DoCommit handles the actual commit operation for transactions. + // This is an internal method that can be overridden by custom implementations. + DoCommit(ctx context.Context, in DoCommitInput) (out DoCommitOutput, err error) + + // DoPrepare creates a prepared statement on the given link. + // This is an internal method that can be overridden by custom implementations. + DoPrepare(ctx context.Context, link Link, sql string) (*Stmt, error) // =========================================================================== // Query APIs for convenience purpose. // =========================================================================== - GetAll(ctx context.Context, sql string, args ...interface{}) (Result, error) // See Core.GetAll. - GetOne(ctx context.Context, sql string, args ...interface{}) (Record, error) // See Core.GetOne. - GetValue(ctx context.Context, sql string, args ...interface{}) (Value, error) // See Core.GetValue. - GetArray(ctx context.Context, sql string, args ...interface{}) ([]Value, error) // See Core.GetArray. - GetCount(ctx context.Context, sql string, args ...interface{}) (int, error) // See Core.GetCount. - GetScan(ctx context.Context, objPointer interface{}, sql string, args ...interface{}) error // See Core.GetScan. - Union(unions ...*Model) *Model // See Core.Union. - UnionAll(unions ...*Model) *Model // See Core.UnionAll. + // GetAll executes a query and returns all rows as Result. + // It's a convenience wrapper around Query. + GetAll(ctx context.Context, sql string, args ...interface{}) (Result, error) + + // GetOne executes a query and returns the first row as Record. + // It's useful when you expect only one row to be returned. + GetOne(ctx context.Context, sql string, args ...interface{}) (Record, error) + + // GetValue executes a query and returns the first column of the first row. + // It's useful for queries like SELECT COUNT(*) or getting a single value. + GetValue(ctx context.Context, sql string, args ...interface{}) (Value, error) + + // GetArray executes a query and returns the first column of all rows. + // It's useful for queries like SELECT id FROM table. + GetArray(ctx context.Context, sql string, args ...interface{}) ([]Value, error) + + // GetCount executes a COUNT query and returns the result as an integer. + // It's a convenience method for counting rows. + GetCount(ctx context.Context, sql string, args ...interface{}) (int, error) + + // GetScan executes a query and scans the result into the given object pointer. + // It automatically maps database columns to struct fields or slice elements. + GetScan(ctx context.Context, objPointer interface{}, sql string, args ...interface{}) error + + // Union combines multiple SELECT queries using UNION operator. + // It returns a new Model that represents the combined query. + Union(unions ...*Model) *Model + + // UnionAll combines multiple SELECT queries using UNION ALL operator. + // Unlike Union, it keeps duplicate rows in the result. + UnionAll(unions ...*Model) *Model // =========================================================================== // Master/Slave specification support. // =========================================================================== - Master(schema ...string) (*sql.DB, error) // See Core.Master. - Slave(schema ...string) (*sql.DB, error) // See Core.Slave. + // Master returns a connection to the master database node. + // The optional schema parameter specifies which database schema to use. + Master(schema ...string) (*sql.DB, error) + + // Slave returns a connection to a slave database node. + // The optional schema parameter specifies which database schema to use. + Slave(schema ...string) (*sql.DB, error) // =========================================================================== // Ping-Pong. // =========================================================================== - PingMaster() error // See Core.PingMaster. - PingSlave() error // See Core.PingSlave. + // PingMaster checks if the master database node is accessible. + // It returns an error if the connection fails. + PingMaster() error + + // PingSlave checks if any slave database node is accessible. + // It returns an error if no slave connections are available. + PingSlave() error // =========================================================================== // Transaction. // =========================================================================== - Begin(ctx context.Context) (TX, error) // See Core.Begin. - Transaction(ctx context.Context, f func(ctx context.Context, tx TX) error) error // See Core.Transaction. + // Begin starts a new transaction and returns a TX interface. + // The returned TX must be committed or rolled back to release resources. + Begin(ctx context.Context) (TX, error) + + // BeginWithOptions starts a new transaction with the given options and returns a TX interface. + // The options allow specifying isolation level and read-only mode. + // The returned TX must be committed or rolled back to release resources. + BeginWithOptions(ctx context.Context, opts TxOptions) (TX, error) + + // Transaction executes a function within a transaction. + // It automatically handles commit/rollback based on whether f returns an error. + Transaction(ctx context.Context, f func(ctx context.Context, tx TX) error) error + + // TransactionWithOptions executes a function within a transaction with specific options. + // It allows customizing transaction behavior like isolation level and timeout. + TransactionWithOptions(ctx context.Context, opts TxOptions, f func(ctx context.Context, tx TX) error) error // =========================================================================== // Configuration methods. // =========================================================================== - GetCache() *gcache.Cache // See Core.GetCache. - SetDebug(debug bool) // See Core.SetDebug. - GetDebug() bool // See Core.GetDebug. - GetSchema() string // See Core.GetSchema. - GetPrefix() string // See Core.GetPrefix. - GetGroup() string // See Core.GetGroup. - SetDryRun(enabled bool) // See Core.SetDryRun. - GetDryRun() bool // See Core.GetDryRun. - SetLogger(logger glog.ILogger) // See Core.SetLogger. - GetLogger() glog.ILogger // See Core.GetLogger. - GetConfig() *ConfigNode // See Core.GetConfig. - SetMaxIdleConnCount(n int) // See Core.SetMaxIdleConnCount. - SetMaxOpenConnCount(n int) // See Core.SetMaxOpenConnCount. - SetMaxConnLifeTime(d time.Duration) // See Core.SetMaxConnLifeTime. + // GetCache returns the cache instance used by this database. + // The cache is used for query results caching. + GetCache() *gcache.Cache + + // SetDebug enables or disables debug mode for SQL logging. + // When enabled, all SQL statements and their execution time are logged. + SetDebug(debug bool) + + // GetDebug returns whether debug mode is enabled. + GetDebug() bool + + // GetSchema returns the current database schema name. + GetSchema() string + + // GetPrefix returns the table name prefix used by this database. + GetPrefix() string + + // GetGroup returns the configuration group name of this database. + GetGroup() string + + // SetDryRun enables or disables dry-run mode. + // In dry-run mode, SQL statements are generated but not executed. + SetDryRun(enabled bool) + + // GetDryRun returns whether dry-run mode is enabled. + GetDryRun() bool + + // SetLogger sets a custom logger for database operations. + // The logger must implement glog.ILogger interface. + SetLogger(logger glog.ILogger) + + // GetLogger returns the current logger used by this database. + GetLogger() glog.ILogger + + // GetConfig returns the configuration node used by this database. + GetConfig() *ConfigNode + + // SetMaxIdleConnCount sets the maximum number of idle connections in the pool. + SetMaxIdleConnCount(n int) + + // SetMaxOpenConnCount sets the maximum number of open connections to the database. + SetMaxOpenConnCount(n int) + + // SetMaxConnLifeTime sets the maximum amount of time a connection may be reused. + SetMaxConnLifeTime(d time.Duration) // =========================================================================== // Utility methods. // =========================================================================== - Stats(ctx context.Context) []StatsItem // See Core.Stats. - GetCtx() context.Context // See Core.GetCtx. - GetCore() *Core // See Core.GetCore - GetChars() (charLeft string, charRight string) // See Core.GetChars. - Tables(ctx context.Context, schema ...string) (tables []string, err error) // See Core.Tables. The driver must implement this function. - TableFields(ctx context.Context, table string, schema ...string) (map[string]*TableField, error) // See Core.TableFields. The driver must implement this function. - ConvertValueForField(ctx context.Context, fieldType string, fieldValue interface{}) (interface{}, error) // See Core.ConvertValueForField - ConvertValueForLocal(ctx context.Context, fieldType string, fieldValue interface{}) (interface{}, error) // See Core.ConvertValueForLocal - CheckLocalTypeForField(ctx context.Context, fieldType string, fieldValue interface{}) (LocalType, error) // See Core.CheckLocalTypeForField - FormatUpsert(columns []string, list List, option DoInsertOption) (string, error) // See Core.DoFormatUpsert - OrderRandomFunction() string // See Core.OrderRandomFunction + // Stats returns statistics about the database connection pool. + // It includes information like the number of active and idle connections. + Stats(ctx context.Context) []StatsItem + + // GetCtx returns the context associated with this database instance. + GetCtx() context.Context + + // GetCore returns the underlying Core instance of this database. + GetCore() *Core + + // GetChars returns the left and right quote characters used for escaping identifiers. + // For example, in MySQL these are backticks: ` and `. + GetChars() (charLeft string, charRight string) + + // Tables returns a list of all table names in the specified schema. + // If no schema is specified, it uses the default schema. + Tables(ctx context.Context, schema ...string) (tables []string, err error) + + // TableFields returns detailed information about all fields in the specified table. + // The returned map keys are field names and values contain field metadata. + TableFields(ctx context.Context, table string, schema ...string) (map[string]*TableField, error) + + // ConvertValueForField converts a value to the appropriate type for a database field. + // It handles type conversion from Go types to database-specific types. + ConvertValueForField(ctx context.Context, fieldType string, fieldValue interface{}) (interface{}, error) + + // ConvertValueForLocal converts a database value to the appropriate Go type. + // It handles type conversion from database-specific types to Go types. + ConvertValueForLocal(ctx context.Context, fieldType string, fieldValue interface{}) (interface{}, error) + + // CheckLocalTypeForField checks if a Go value is compatible with a database field type. + // It returns the appropriate LocalType and any conversion errors. + CheckLocalTypeForField(ctx context.Context, fieldType string, fieldValue interface{}) (LocalType, error) + + // FormatUpsert formats an upsert (INSERT ... ON DUPLICATE KEY UPDATE) statement. + // It generates the appropriate SQL based on the columns, values, and options provided. + FormatUpsert(columns []string, list List, option DoInsertOption) (string, error) + + // OrderRandomFunction returns the SQL function for random ordering. + // The implementation is database-specific (e.g., RAND() for MySQL). + OrderRandomFunction() string } // TX defines the interfaces for ORM transaction operations. type TX interface { Link + // Ctx binds a context to current transaction. + // The context is used for operations like timeout control. Ctx(ctx context.Context) TX + + // Raw creates and returns a model based on a raw SQL. + // The rawSql can contain placeholders ? and corresponding args. Raw(rawSql string, args ...interface{}) *Model + + // Model creates and returns a Model from given table name/struct. + // The parameter can be table name as string, or struct/*struct type. Model(tableNameQueryOrStruct ...interface{}) *Model + + // With creates and returns a Model from given object. + // It automatically analyzes the object and generates corresponding SQL. With(object interface{}) *Model // =========================================================================== // Nested transaction if necessary. // =========================================================================== + // Begin starts a nested transaction. + // It creates a new savepoint for current transaction. Begin() error + + // Commit commits current transaction/savepoint. + // For nested transactions, it releases the current savepoint. Commit() error + + // Rollback rolls back current transaction/savepoint. + // For nested transactions, it rolls back to the current savepoint. Rollback() error + + // Transaction executes given function in a nested transaction. + // It automatically handles commit/rollback based on function's error return. Transaction(ctx context.Context, f func(ctx context.Context, tx TX) error) (err error) + // TransactionWithOptions executes given function in a nested transaction with options. + // It allows customizing transaction behavior like isolation level. + TransactionWithOptions(ctx context.Context, opts TxOptions, f func(ctx context.Context, tx TX) error) error + // =========================================================================== // Core method. // =========================================================================== + // Query executes a query that returns rows using given SQL and arguments. + // The args are for any placeholder parameters in the query. Query(sql string, args ...interface{}) (result Result, err error) + + // Exec executes a query that doesn't return rows. + // For example: INSERT, UPDATE, DELETE. Exec(sql string, args ...interface{}) (sql.Result, error) + + // Prepare creates a prepared statement for later queries or executions. + // Multiple queries or executions may be run concurrently from the statement. Prepare(sql string) (*Stmt, error) // =========================================================================== // Query. // =========================================================================== + // GetAll executes a query and returns all rows as Result. + // It's a convenient wrapper for Query. GetAll(sql string, args ...interface{}) (Result, error) + + // GetOne executes a query and returns the first row as Record. + // It's useful when you expect only one row to be returned. GetOne(sql string, args ...interface{}) (Record, error) + + // GetStruct executes a query and scans the result into given struct. + // The obj should be a pointer to struct. GetStruct(obj interface{}, sql string, args ...interface{}) error + + // GetStructs executes a query and scans all results into given struct slice. + // The objPointerSlice should be a pointer to slice of struct. GetStructs(objPointerSlice interface{}, sql string, args ...interface{}) error + + // GetScan executes a query and scans the result into given variables. + // The pointer can be type of struct/*struct/[]struct/[]*struct. GetScan(pointer interface{}, sql string, args ...interface{}) error + + // GetValue executes a query and returns the first column of first row. + // It's useful for queries like SELECT COUNT(*). GetValue(sql string, args ...interface{}) (Value, error) + + // GetCount executes a query that should return a count value. + // It's a convenient wrapper for count queries. GetCount(sql string, args ...interface{}) (int64, error) // =========================================================================== // CURD. // =========================================================================== + // Insert inserts one or multiple records into table. + // The data can be map/struct/*struct/[]map/[]struct/[]*struct. Insert(table string, data interface{}, batch ...int) (sql.Result, error) + + // InsertIgnore inserts one or multiple records with IGNORE option. + // It ignores records that would cause duplicate key conflicts. InsertIgnore(table string, data interface{}, batch ...int) (sql.Result, error) + + // InsertAndGetId inserts one record and returns its id value. + // It's commonly used with auto-increment primary key. InsertAndGetId(table string, data interface{}, batch ...int) (int64, error) + + // Replace inserts or replaces records using REPLACE INTO syntax. + // Existing records with same unique key will be deleted and re-inserted. Replace(table string, data interface{}, batch ...int) (sql.Result, error) + + // Save inserts or updates records using INSERT ... ON DUPLICATE KEY UPDATE syntax. + // It updates existing records instead of replacing them entirely. Save(table string, data interface{}, batch ...int) (sql.Result, error) + + // Update updates records in table that match given condition. + // The data can be map/struct, and condition supports various formats. Update(table string, data interface{}, condition interface{}, args ...interface{}) (sql.Result, error) + + // Delete deletes records from table that match given condition. + // The condition supports various formats with optional arguments. Delete(table string, condition interface{}, args ...interface{}) (sql.Result, error) // =========================================================================== // Utility methods. // =========================================================================== + // GetCtx returns the context that is bound to current transaction. GetCtx() context.Context + + // GetDB returns the underlying DB interface object. GetDB() DB + + // GetSqlTX returns the underlying *sql.Tx object. + // Note: be very careful when using this method. GetSqlTX() *sql.Tx + + // IsClosed checks if current transaction is closed. + // A transaction is closed after Commit or Rollback. IsClosed() bool // =========================================================================== // Save point feature. // =========================================================================== + // SavePoint creates a save point with given name. + // It's used in nested transactions to create rollback points. SavePoint(point string) error + + // RollbackTo rolls back transaction to previously created save point. + // If the save point doesn't exist, it returns an error. RollbackTo(point string) error } @@ -287,6 +535,7 @@ type DoCommitInput struct { Sql string Args []interface{} Type SqlType + TxOptions sql.TxOptions IsTransaction bool } @@ -380,9 +629,6 @@ const ( defaultMaxIdleConnCount = 10 // Max idle connection count in pool. defaultMaxOpenConnCount = 0 // Max open connection count in pool. Default is no limit. defaultMaxConnLifeTime = 30 * time.Second // Max lifetime for per connection in pool in seconds. - ctxTimeoutTypeExec = 0 - ctxTimeoutTypeQuery = 1 - ctxTimeoutTypePrepare = 2 cachePrefixTableFields = `TableFields:` cachePrefixSelectCache = `SelectCache:` commandEnvKeyForDryRun = "gf.gdb.dryrun" @@ -396,6 +642,15 @@ const ( linkPattern = `(\w+):([\w\-\$]*):(.*?)@(\w+?)\((.+?)\)/{0,1}([^\?]*)\?{0,1}(.*)` ) +type ctxTimeoutType int + +const ( + ctxTimeoutTypeExec ctxTimeoutType = iota + ctxTimeoutTypeQuery + ctxTimeoutTypePrepare + ctxTimeoutTypeTrans +) + type SelectType int const ( @@ -640,7 +895,7 @@ func Instance(name ...string) (db DB, err error) { // The returned node is a clone of configuration node, which is safe for later modification. // // The parameter `master` specifies whether retrieving a master node, or else a slave node -// if master-slave configured. +// if master-slave nodes are configured. func getConfigNodeByGroup(group string, master bool) (*ConfigNode, error) { if list, ok := configs.config[group]; ok { // Separates master and slave configuration nodes array. diff --git a/database/gdb/gdb_core.go b/database/gdb/gdb_core.go index 0a88a17ecc6..f75ff878f37 100644 --- a/database/gdb/gdb_core.go +++ b/database/gdb/gdb_core.go @@ -72,24 +72,30 @@ func (c *Core) GetCtx() context.Context { } // GetCtxTimeout returns the context and cancel function for specified timeout type. -func (c *Core) GetCtxTimeout(ctx context.Context, timeoutType int) (context.Context, context.CancelFunc) { +func (c *Core) GetCtxTimeout(ctx context.Context, timeoutType ctxTimeoutType) (context.Context, context.CancelFunc) { if ctx == nil { ctx = c.db.GetCtx() } else { ctx = context.WithValue(ctx, "WrappedByGetCtxTimeout", nil) } + var config = c.db.GetConfig() switch timeoutType { case ctxTimeoutTypeExec: if c.db.GetConfig().ExecTimeout > 0 { - return context.WithTimeout(ctx, c.db.GetConfig().ExecTimeout) + return context.WithTimeout(ctx, config.ExecTimeout) } case ctxTimeoutTypeQuery: if c.db.GetConfig().QueryTimeout > 0 { - return context.WithTimeout(ctx, c.db.GetConfig().QueryTimeout) + return context.WithTimeout(ctx, config.QueryTimeout) } case ctxTimeoutTypePrepare: if c.db.GetConfig().PrepareTimeout > 0 { - return context.WithTimeout(ctx, c.db.GetConfig().PrepareTimeout) + return context.WithTimeout(ctx, config.PrepareTimeout) + } + + case ctxTimeoutTypeTrans: + if c.db.GetConfig().TranTimeout > 0 { + return context.WithTimeout(ctx, config.TranTimeout) } default: panic(gerror.NewCodef(gcode.CodeInvalidParameter, "invalid context timeout type: %d", timeoutType)) diff --git a/database/gdb/gdb_core_transaction.go b/database/gdb/gdb_core_transaction.go index e098982c2a4..897b179b1d2 100644 --- a/database/gdb/gdb_core_transaction.go +++ b/database/gdb/gdb_core_transaction.go @@ -9,25 +9,50 @@ package gdb import ( "context" "database/sql" - "reflect" "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/reflection" - "github.com/gogf/gf/v2/text/gregex" - "github.com/gogf/gf/v2/util/gconv" ) -// TXCore is the struct for transaction management. -type TXCore struct { - db DB // db is the current gdb database manager. - tx *sql.Tx // tx is the raw and underlying transaction manager. - ctx context.Context // ctx is the context for this transaction only. - master *sql.DB // master is the raw and underlying database manager. - transactionId string // transactionId is a unique id generated by this object for this transaction. - transactionCount int // transactionCount marks the times that Begins. - isClosed bool // isClosed marks this transaction has already been committed or rolled back. +// Propagation defines transaction propagation behavior. +type Propagation string + +const ( + // PropagationRequired starts a new transaction if not in a transaction, + // or uses the existing transaction if already in a transaction. + PropagationRequired Propagation = "" // REQUIRED + + // PropagationSupports executes within the existing transaction if present, + // otherwise executes without transaction. + PropagationSupports Propagation = "SUPPORTS" + + // PropagationRequiresNew starts a new transaction, and suspends the current transaction if one exists. + PropagationRequiresNew Propagation = "REQUIRES_NEW" + + // PropagationNested starts a nested transaction if already in a transaction, + // or behaves like PropagationRequired if not in a transaction. + PropagationNested Propagation = "NESTED" + + // PropagationNotSupported executes non-transactional, suspends any existing transaction. + PropagationNotSupported Propagation = "NOT_SUPPORTED" + + // PropagationMandatory executes in a transaction, fails if no existing transaction. + PropagationMandatory Propagation = "MANDATORY" + + // PropagationNever executes non-transactional, fails if in an existing transaction. + PropagationNever Propagation = "NEVER" +) + +// TxOptions defines options for transaction control. +type TxOptions struct { + // Propagation specifies the propagation behavior. + Propagation Propagation + // Isolation is the transaction isolation level. + // If zero, the driver or database's default level is used. + Isolation sql.IsolationLevel + // ReadOnly is used to mark the transaction as read-only. + ReadOnly bool } const ( @@ -38,15 +63,38 @@ const ( var transactionIdGenerator = gtype.NewUint64() +// DefaultTxOptions returns the default transaction options. +func DefaultTxOptions() TxOptions { + return TxOptions{ + Propagation: PropagationRequired, + } +} + // Begin starts and returns the transaction object. // You should call Commit or Rollback functions of the transaction object // if you no longer use the transaction. Commit or Rollback functions will also // close the transaction automatically. func (c *Core) Begin(ctx context.Context) (tx TX, err error) { - return c.doBeginCtx(ctx) + return c.BeginWithOptions(ctx, DefaultTxOptions()) } -func (c *Core) doBeginCtx(ctx context.Context) (TX, error) { +// BeginWithOptions starts and returns the transaction object with given options. +// The options allow specifying the isolation level and read-only mode. +// You should call Commit or Rollback functions of the transaction object +// if you no longer use the transaction. Commit or Rollback functions will also +// close the transaction automatically. +func (c *Core) BeginWithOptions(ctx context.Context, opts TxOptions) (tx TX, err error) { + if ctx == nil { + ctx = c.db.GetCtx() + } + ctx = c.injectInternalCtxData(ctx) + return c.doBeginCtx(ctx, sql.TxOptions{ + Isolation: opts.Isolation, + ReadOnly: opts.ReadOnly, + }) +} + +func (c *Core) doBeginCtx(ctx context.Context, opts sql.TxOptions) (TX, error) { master, err := c.db.Master() if err != nil { return nil, err @@ -56,6 +104,7 @@ func (c *Core) doBeginCtx(ctx context.Context) (TX, error) { Db: master, Sql: "BEGIN", Type: SqlTypeBegin, + TxOptions: opts, IsTransaction: true, }) return out.Tx, err @@ -69,22 +118,105 @@ func (c *Core) doBeginCtx(ctx context.Context) (TX, error) { // Note that, you should not Commit or Rollback the transaction in function `f` // as it is automatically handled by this function. func (c *Core) Transaction(ctx context.Context, f func(ctx context.Context, tx TX) error) (err error) { + return c.TransactionWithOptions(ctx, DefaultTxOptions(), f) +} + +// TransactionWithOptions wraps the transaction logic with propagation options using function `f`. +func (c *Core) TransactionWithOptions( + ctx context.Context, opts TxOptions, f func(ctx context.Context, tx TX) error, +) (err error) { if ctx == nil { ctx = c.db.GetCtx() } ctx = c.injectInternalCtxData(ctx) - // Check transaction object from context. - var tx TX - tx = TXFromCtx(ctx, c.db.GetGroup()) - if tx != nil { - return tx.Transaction(ctx, f) + + // Check current transaction from context + var ( + group = c.db.GetGroup() + currentTx = TXFromCtx(ctx, group) + ) + switch opts.Propagation { + case PropagationRequired: + if currentTx != nil { + return currentTx.Transaction(ctx, f) + } + return c.createNewTransaction(ctx, opts, f) + + case PropagationSupports: + return f(ctx, currentTx) + + case PropagationMandatory: + if currentTx == nil { + return gerror.NewCode( + gcode.CodeInvalidOperation, + "transaction propagation MANDATORY requires an existing transaction", + ) + } + return f(ctx, currentTx) + + case PropagationRequiresNew: + ctx = WithoutTX(ctx, group) + return c.createNewTransaction(ctx, opts, f) + + case PropagationNotSupported: + ctx = WithoutTX(ctx, group) + return f(ctx, nil) + + case PropagationNever: + if currentTx != nil { + return gerror.NewCode( + gcode.CodeInvalidOperation, + "transaction propagation NEVER cannot run within an existing transaction", + ) + } + return f(ctx, nil) + + case PropagationNested: + if currentTx != nil { + // Create savepoint for nested transaction + if err = currentTx.Begin(); err != nil { + return err + } + defer func() { + if err != nil { + if rbErr := currentTx.Rollback(); rbErr != nil { + err = gerror.Wrap(err, rbErr.Error()) + } + } + }() + return f(ctx, currentTx) + } + return c.createNewTransaction(ctx, opts, f) + + default: + return gerror.NewCodef( + gcode.CodeInvalidParameter, + "unsupported propagation behavior: %s", + opts.Propagation, + ) } - tx, err = c.doBeginCtx(ctx) +} + +// createNewTransaction handles creating and managing a new transaction +func (c *Core) createNewTransaction( + ctx context.Context, opts TxOptions, f func(ctx context.Context, tx TX) error, +) (err error) { + // Begin transaction with options + tx, err := c.doBeginCtx(ctx, sql.TxOptions{ + Isolation: opts.Isolation, + ReadOnly: opts.ReadOnly, + }) if err != nil { return err } - // Inject transaction object into context. - tx = tx.Ctx(WithTX(tx.GetCtx(), tx)) + + // Inject transaction object into context + ctx = WithTX(tx.GetCtx(), tx) + err = callTxFunc(tx.Ctx(ctx), f) + return +} + +func callTxFunc(tx TX, f func(ctx context.Context, tx TX) error) (err error) { defer func() { if err == nil { if exception := recover(); exception != nil { @@ -128,6 +260,12 @@ func WithTX(ctx context.Context, tx TX) context.Context { return ctx } +// WithoutTX removed transaction object from context and returns a new context. +func WithoutTX(ctx context.Context, group string) context.Context { + ctx = context.WithValue(ctx, transactionKeyForContext(group), nil) + return ctx +} + // TXFromCtx retrieves and returns transaction object from context. // It is usually used in nested transaction feature, and it returns nil if it is not set previously. func TXFromCtx(ctx context.Context, group string) TX { @@ -150,395 +288,3 @@ func TXFromCtx(ctx context.Context, group string) TX { func transactionKeyForContext(group string) string { return contextTransactionKeyPrefix + group } - -// transactionKeyForNestedPoint forms and returns the transaction key at current save point. -func (tx *TXCore) transactionKeyForNestedPoint() string { - return tx.db.GetCore().QuoteWord(transactionPointerPrefix + gconv.String(tx.transactionCount)) -} - -// Ctx sets the context for current transaction. -func (tx *TXCore) Ctx(ctx context.Context) TX { - tx.ctx = ctx - if tx.ctx != nil { - tx.ctx = tx.db.GetCore().injectInternalCtxData(tx.ctx) - } - return tx -} - -// GetCtx returns the context for current transaction. -func (tx *TXCore) GetCtx() context.Context { - return tx.ctx -} - -// GetDB returns the DB for current transaction. -func (tx *TXCore) GetDB() DB { - return tx.db -} - -// GetSqlTX returns the underlying transaction object for current transaction. -func (tx *TXCore) GetSqlTX() *sql.Tx { - return tx.tx -} - -// Commit commits current transaction. -// Note that it releases previous saved transaction point if it's in a nested transaction procedure, -// or else it commits the hole transaction. -func (tx *TXCore) Commit() error { - if tx.transactionCount > 0 { - tx.transactionCount-- - _, err := tx.Exec("RELEASE SAVEPOINT " + tx.transactionKeyForNestedPoint()) - return err - } - _, err := tx.db.DoCommit(tx.ctx, DoCommitInput{ - Tx: tx.tx, - Sql: "COMMIT", - Type: SqlTypeTXCommit, - IsTransaction: true, - }) - if err == nil { - tx.isClosed = true - } - return err -} - -// Rollback aborts current transaction. -// Note that it aborts current transaction if it's in a nested transaction procedure, -// or else it aborts the hole transaction. -func (tx *TXCore) Rollback() error { - if tx.transactionCount > 0 { - tx.transactionCount-- - _, err := tx.Exec("ROLLBACK TO SAVEPOINT " + tx.transactionKeyForNestedPoint()) - return err - } - _, err := tx.db.DoCommit(tx.ctx, DoCommitInput{ - Tx: tx.tx, - Sql: "ROLLBACK", - Type: SqlTypeTXRollback, - IsTransaction: true, - }) - if err == nil { - tx.isClosed = true - } - return err -} - -// IsClosed checks and returns this transaction has already been committed or rolled back. -func (tx *TXCore) IsClosed() bool { - return tx.isClosed -} - -// Begin starts a nested transaction procedure. -func (tx *TXCore) Begin() error { - _, err := tx.Exec("SAVEPOINT " + tx.transactionKeyForNestedPoint()) - if err != nil { - return err - } - tx.transactionCount++ - return nil -} - -// SavePoint performs `SAVEPOINT xxx` SQL statement that saves transaction at current point. -// The parameter `point` specifies the point name that will be saved to server. -func (tx *TXCore) SavePoint(point string) error { - _, err := tx.Exec("SAVEPOINT " + tx.db.GetCore().QuoteWord(point)) - return err -} - -// RollbackTo performs `ROLLBACK TO SAVEPOINT xxx` SQL statement that rollbacks to specified saved transaction. -// The parameter `point` specifies the point name that was saved previously. -func (tx *TXCore) RollbackTo(point string) error { - _, err := tx.Exec("ROLLBACK TO SAVEPOINT " + tx.db.GetCore().QuoteWord(point)) - return err -} - -// Transaction wraps the transaction logic using function `f`. -// It rollbacks the transaction and returns the error from function `f` if -// it returns non-nil error. It commits the transaction and returns nil if -// function `f` returns nil. -// -// Note that, you should not Commit or Rollback the transaction in function `f` -// as it is automatically handled by this function. -func (tx *TXCore) Transaction(ctx context.Context, f func(ctx context.Context, tx TX) error) (err error) { - if ctx != nil { - tx.ctx = ctx - } - // Check transaction object from context. - if TXFromCtx(tx.ctx, tx.db.GetGroup()) == nil { - // Inject transaction object into context. - tx.ctx = WithTX(tx.ctx, tx) - } - err = tx.Begin() - if err != nil { - return err - } - defer func() { - if err == nil { - if exception := recover(); exception != nil { - if v, ok := exception.(error); ok && gerror.HasStack(v) { - err = v - } else { - err = gerror.NewCodef(gcode.CodeInternalPanic, "%+v", exception) - } - } - } - if err != nil { - if e := tx.Rollback(); e != nil { - err = e - } - } else { - if e := tx.Commit(); e != nil { - err = e - } - } - }() - err = f(tx.ctx, tx) - return -} - -// Query does query operation on transaction. -// See Core.Query. -func (tx *TXCore) Query(sql string, args ...interface{}) (result Result, err error) { - return tx.db.DoQuery(tx.ctx, &txLink{tx.tx}, sql, args...) -} - -// Exec does none query operation on transaction. -// See Core.Exec. -func (tx *TXCore) Exec(sql string, args ...interface{}) (sql.Result, error) { - return tx.db.DoExec(tx.ctx, &txLink{tx.tx}, sql, args...) -} - -// Prepare creates a prepared statement for later queries or executions. -// Multiple queries or executions may be run concurrently from the -// returned statement. -// The caller must call the statement's Close method -// when the statement is no longer needed. -func (tx *TXCore) Prepare(sql string) (*Stmt, error) { - return tx.db.DoPrepare(tx.ctx, &txLink{tx.tx}, sql) -} - -// GetAll queries and returns data records from database. -func (tx *TXCore) GetAll(sql string, args ...interface{}) (Result, error) { - return tx.Query(sql, args...) -} - -// GetOne queries and returns one record from database. -func (tx *TXCore) GetOne(sql string, args ...interface{}) (Record, error) { - list, err := tx.GetAll(sql, args...) - if err != nil { - return nil, err - } - if len(list) > 0 { - return list[0], nil - } - return nil, nil -} - -// GetStruct queries one record from database and converts it to given struct. -// The parameter `pointer` should be a pointer to struct. -func (tx *TXCore) GetStruct(obj interface{}, sql string, args ...interface{}) error { - one, err := tx.GetOne(sql, args...) - if err != nil { - return err - } - return one.Struct(obj) -} - -// GetStructs queries records from database and converts them to given struct. -// The parameter `pointer` should be type of struct slice: []struct/[]*struct. -func (tx *TXCore) GetStructs(objPointerSlice interface{}, sql string, args ...interface{}) error { - all, err := tx.GetAll(sql, args...) - if err != nil { - return err - } - return all.Structs(objPointerSlice) -} - -// GetScan queries one or more records from database and converts them to given struct or -// struct array. -// -// If parameter `pointer` is type of struct pointer, it calls GetStruct internally for -// the conversion. If parameter `pointer` is type of slice, it calls GetStructs internally -// for conversion. -func (tx *TXCore) GetScan(pointer interface{}, sql string, args ...interface{}) error { - reflectInfo := reflection.OriginTypeAndKind(pointer) - if reflectInfo.InputKind != reflect.Ptr { - return gerror.NewCodef( - gcode.CodeInvalidParameter, - "params should be type of pointer, but got: %v", - reflectInfo.InputKind, - ) - } - switch reflectInfo.OriginKind { - case reflect.Array, reflect.Slice: - return tx.GetStructs(pointer, sql, args...) - - case reflect.Struct: - return tx.GetStruct(pointer, sql, args...) - } - return gerror.NewCodef( - gcode.CodeInvalidParameter, - `in valid parameter type "%v", of which element type should be type of struct/slice`, - reflectInfo.InputType, - ) -} - -// GetValue queries and returns the field value from database. -// The sql should query only one field from database, or else it returns only one -// field of the result. -func (tx *TXCore) GetValue(sql string, args ...interface{}) (Value, error) { - one, err := tx.GetOne(sql, args...) - if err != nil { - return nil, err - } - for _, v := range one { - return v, nil - } - return nil, nil -} - -// GetCount queries and returns the count from database. -func (tx *TXCore) GetCount(sql string, args ...interface{}) (int64, error) { - if !gregex.IsMatchString(`(?i)SELECT\s+COUNT\(.+\)\s+FROM`, sql) { - sql, _ = gregex.ReplaceString(`(?i)(SELECT)\s+(.+)\s+(FROM)`, `$1 COUNT($2) $3`, sql) - } - value, err := tx.GetValue(sql, args...) - if err != nil { - return 0, err - } - return value.Int64(), nil -} - -// Insert does "INSERT INTO ..." statement for the table. -// If there's already one unique record of the data in the table, it returns error. -// -// The parameter `data` can be type of map/gmap/struct/*struct/[]map/[]struct, etc. -// Eg: -// Data(g.Map{"uid": 10000, "name":"john"}) -// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"}) -// -// The parameter `batch` specifies the batch operation count when given data is slice. -func (tx *TXCore) Insert(table string, data interface{}, batch ...int) (sql.Result, error) { - if len(batch) > 0 { - return tx.Model(table).Ctx(tx.ctx).Data(data).Batch(batch[0]).Insert() - } - return tx.Model(table).Ctx(tx.ctx).Data(data).Insert() -} - -// InsertIgnore does "INSERT IGNORE INTO ..." statement for the table. -// If there's already one unique record of the data in the table, it ignores the inserting. -// -// The parameter `data` can be type of map/gmap/struct/*struct/[]map/[]struct, etc. -// Eg: -// Data(g.Map{"uid": 10000, "name":"john"}) -// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"}) -// -// The parameter `batch` specifies the batch operation count when given data is slice. -func (tx *TXCore) InsertIgnore(table string, data interface{}, batch ...int) (sql.Result, error) { - if len(batch) > 0 { - return tx.Model(table).Ctx(tx.ctx).Data(data).Batch(batch[0]).InsertIgnore() - } - return tx.Model(table).Ctx(tx.ctx).Data(data).InsertIgnore() -} - -// InsertAndGetId performs action Insert and returns the last insert id that automatically generated. -func (tx *TXCore) InsertAndGetId(table string, data interface{}, batch ...int) (int64, error) { - if len(batch) > 0 { - return tx.Model(table).Ctx(tx.ctx).Data(data).Batch(batch[0]).InsertAndGetId() - } - return tx.Model(table).Ctx(tx.ctx).Data(data).InsertAndGetId() -} - -// Replace does "REPLACE INTO ..." statement for the table. -// If there's already one unique record of the data in the table, it deletes the record -// and inserts a new one. -// -// The parameter `data` can be type of map/gmap/struct/*struct/[]map/[]struct, etc. -// Eg: -// Data(g.Map{"uid": 10000, "name":"john"}) -// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"}) -// -// The parameter `data` can be type of map/gmap/struct/*struct/[]map/[]struct, etc. -// If given data is type of slice, it then does batch replacing, and the optional parameter -// `batch` specifies the batch operation count. -func (tx *TXCore) Replace(table string, data interface{}, batch ...int) (sql.Result, error) { - if len(batch) > 0 { - return tx.Model(table).Ctx(tx.ctx).Data(data).Batch(batch[0]).Replace() - } - return tx.Model(table).Ctx(tx.ctx).Data(data).Replace() -} - -// Save does "INSERT INTO ... ON DUPLICATE KEY UPDATE..." statement for the table. -// It updates the record if there's primary or unique index in the saving data, -// or else it inserts a new record into the table. -// -// The parameter `data` can be type of map/gmap/struct/*struct/[]map/[]struct, etc. -// Eg: -// Data(g.Map{"uid": 10000, "name":"john"}) -// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"}) -// -// If given data is type of slice, it then does batch saving, and the optional parameter -// `batch` specifies the batch operation count. -func (tx *TXCore) Save(table string, data interface{}, batch ...int) (sql.Result, error) { - if len(batch) > 0 { - return tx.Model(table).Ctx(tx.ctx).Data(data).Batch(batch[0]).Save() - } - return tx.Model(table).Ctx(tx.ctx).Data(data).Save() -} - -// Update does "UPDATE ... " statement for the table. -// -// The parameter `data` can be type of string/map/gmap/struct/*struct, etc. -// Eg: "uid=10000", "uid", 10000, g.Map{"uid": 10000, "name":"john"} -// -// The parameter `condition` can be type of string/map/gmap/slice/struct/*struct, etc. -// It is commonly used with parameter `args`. -// Eg: -// "uid=10000", -// "uid", 10000 -// "money>? AND name like ?", 99999, "vip_%" -// "status IN (?)", g.Slice{1,2,3} -// "age IN(?,?)", 18, 50 -// User{ Id : 1, UserName : "john"}. -func (tx *TXCore) Update(table string, data interface{}, condition interface{}, args ...interface{}) (sql.Result, error) { - return tx.Model(table).Ctx(tx.ctx).Data(data).Where(condition, args...).Update() -} - -// Delete does "DELETE FROM ... " statement for the table. -// -// The parameter `condition` can be type of string/map/gmap/slice/struct/*struct, etc. -// It is commonly used with parameter `args`. -// Eg: -// "uid=10000", -// "uid", 10000 -// "money>? AND name like ?", 99999, "vip_%" -// "status IN (?)", g.Slice{1,2,3} -// "age IN(?,?)", 18, 50 -// User{ Id : 1, UserName : "john"}. -func (tx *TXCore) Delete(table string, condition interface{}, args ...interface{}) (sql.Result, error) { - return tx.Model(table).Ctx(tx.ctx).Where(condition, args...).Delete() -} - -// QueryContext implements interface function Link.QueryContext. -func (tx *TXCore) QueryContext(ctx context.Context, sql string, args ...interface{}) (*sql.Rows, error) { - return tx.tx.QueryContext(ctx, sql, args...) -} - -// ExecContext implements interface function Link.ExecContext. -func (tx *TXCore) ExecContext(ctx context.Context, sql string, args ...interface{}) (sql.Result, error) { - return tx.tx.ExecContext(ctx, sql, args...) -} - -// PrepareContext implements interface function Link.PrepareContext. -func (tx *TXCore) PrepareContext(ctx context.Context, sql string) (*sql.Stmt, error) { - return tx.tx.PrepareContext(ctx, sql) -} - -// IsOnMaster implements interface function Link.IsOnMaster. -func (tx *TXCore) IsOnMaster() bool { - return true -} - -// IsTransaction implements interface function Link.IsTransaction. -func (tx *TXCore) IsTransaction() bool { - return true -} diff --git a/database/gdb/gdb_core_txcore.go b/database/gdb/gdb_core_txcore.go new file mode 100644 index 00000000000..187ea27cdd9 --- /dev/null +++ b/database/gdb/gdb_core_txcore.go @@ -0,0 +1,412 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package gdb + +import ( + "context" + "database/sql" + "reflect" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/reflection" + "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/util/gconv" +) + +// TXCore is the struct for transaction management. +type TXCore struct { + db DB // db is the current gdb database manager. + tx *sql.Tx // tx is the raw and underlying transaction manager. + ctx context.Context // ctx is the context for this transaction only. + master *sql.DB // master is the raw and underlying database manager. + transactionId string // transactionId is a unique id generated by this object for this transaction. + transactionCount int // transactionCount marks the times that Begins. + isClosed bool // isClosed marks this transaction has already been committed or rolled back. +} + +// transactionKeyForNestedPoint forms and returns the transaction key at current save point. +func (tx *TXCore) transactionKeyForNestedPoint() string { + return tx.db.GetCore().QuoteWord( + transactionPointerPrefix + gconv.String(tx.transactionCount), + ) +} + +// Ctx sets the context for current transaction. +func (tx *TXCore) Ctx(ctx context.Context) TX { + tx.ctx = ctx + if tx.ctx != nil { + tx.ctx = tx.db.GetCore().injectInternalCtxData(tx.ctx) + } + return tx +} + +// GetCtx returns the context for current transaction. +func (tx *TXCore) GetCtx() context.Context { + return tx.ctx +} + +// GetDB returns the DB for current transaction. +func (tx *TXCore) GetDB() DB { + return tx.db +} + +// GetSqlTX returns the underlying transaction object for current transaction. +func (tx *TXCore) GetSqlTX() *sql.Tx { + return tx.tx +} + +// Commit commits current transaction. +// Note that it releases previous saved transaction point if it's in a nested transaction procedure, +// or else it commits the hole transaction. +func (tx *TXCore) Commit() error { + if tx.transactionCount > 0 { + tx.transactionCount-- + _, err := tx.Exec("RELEASE SAVEPOINT " + tx.transactionKeyForNestedPoint()) + return err + } + _, err := tx.db.DoCommit(tx.ctx, DoCommitInput{ + Tx: tx.tx, + Sql: "COMMIT", + Type: SqlTypeTXCommit, + IsTransaction: true, + }) + if err == nil { + tx.isClosed = true + } + return err +} + +// Rollback aborts current transaction. +// Note that it aborts current transaction if it's in a nested transaction procedure, +// or else it aborts the hole transaction. +func (tx *TXCore) Rollback() error { + if tx.transactionCount > 0 { + tx.transactionCount-- + _, err := tx.Exec("ROLLBACK TO SAVEPOINT " + tx.transactionKeyForNestedPoint()) + return err + } + _, err := tx.db.DoCommit(tx.ctx, DoCommitInput{ + Tx: tx.tx, + Sql: "ROLLBACK", + Type: SqlTypeTXRollback, + IsTransaction: true, + }) + if err == nil { + tx.isClosed = true + } + return err +} + +// IsClosed checks and returns this transaction has already been committed or rolled back. +func (tx *TXCore) IsClosed() bool { + return tx.isClosed +} + +// Begin starts a nested transaction procedure. +func (tx *TXCore) Begin() error { + _, err := tx.Exec("SAVEPOINT " + tx.transactionKeyForNestedPoint()) + if err != nil { + return err + } + tx.transactionCount++ + return nil +} + +// SavePoint performs `SAVEPOINT xxx` SQL statement that saves transaction at current point. +// The parameter `point` specifies the point name that will be saved to server. +func (tx *TXCore) SavePoint(point string) error { + _, err := tx.Exec("SAVEPOINT " + tx.db.GetCore().QuoteWord(point)) + return err +} + +// RollbackTo performs `ROLLBACK TO SAVEPOINT xxx` SQL statement that rollbacks to specified saved transaction. +// The parameter `point` specifies the point name that was saved previously. +func (tx *TXCore) RollbackTo(point string) error { + _, err := tx.Exec("ROLLBACK TO SAVEPOINT " + tx.db.GetCore().QuoteWord(point)) + return err +} + +// Transaction wraps the transaction logic using function `f`. +// It rollbacks the transaction and returns the error from function `f` if +// it returns non-nil error. It commits the transaction and returns nil if +// function `f` returns nil. +// +// Note that, you should not Commit or Rollback the transaction in function `f` +// as it is automatically handled by this function. +func (tx *TXCore) Transaction(ctx context.Context, f func(ctx context.Context, tx TX) error) (err error) { + if ctx != nil { + tx.ctx = ctx + } + // Check transaction object from context. + if TXFromCtx(tx.ctx, tx.db.GetGroup()) == nil { + // Inject transaction object into context. + tx.ctx = WithTX(tx.ctx, tx) + } + if err = tx.Begin(); err != nil { + return err + } + err = callTxFunc(tx, f) + return +} + +// TransactionWithOptions wraps the transaction logic with propagation options using function `f`. +func (tx *TXCore) TransactionWithOptions( + ctx context.Context, opts TxOptions, f func(ctx context.Context, tx TX) error, +) (err error) { + return tx.db.TransactionWithOptions(ctx, opts, f) +} + +// Query does query operation on transaction. +// See Core.Query. +func (tx *TXCore) Query(sql string, args ...interface{}) (result Result, err error) { + return tx.db.DoQuery(tx.ctx, &txLink{tx.tx}, sql, args...) +} + +// Exec does none query operation on transaction. +// See Core.Exec. +func (tx *TXCore) Exec(sql string, args ...interface{}) (sql.Result, error) { + return tx.db.DoExec(tx.ctx, &txLink{tx.tx}, sql, args...) +} + +// Prepare creates a prepared statement for later queries or executions. +// Multiple queries or executions may be run concurrently from the +// returned statement. +// The caller must call the statement's Close method +// when the statement is no longer needed. +func (tx *TXCore) Prepare(sql string) (*Stmt, error) { + return tx.db.DoPrepare(tx.ctx, &txLink{tx.tx}, sql) +} + +// GetAll queries and returns data records from database. +func (tx *TXCore) GetAll(sql string, args ...interface{}) (Result, error) { + return tx.Query(sql, args...) +} + +// GetOne queries and returns one record from database. +func (tx *TXCore) GetOne(sql string, args ...interface{}) (Record, error) { + list, err := tx.GetAll(sql, args...) + if err != nil { + return nil, err + } + if len(list) > 0 { + return list[0], nil + } + return nil, nil +} + +// GetStruct queries one record from database and converts it to given struct. +// The parameter `pointer` should be a pointer to struct. +func (tx *TXCore) GetStruct(obj interface{}, sql string, args ...interface{}) error { + one, err := tx.GetOne(sql, args...) + if err != nil { + return err + } + return one.Struct(obj) +} + +// GetStructs queries records from database and converts them to given struct. +// The parameter `pointer` should be type of struct slice: []struct/[]*struct. +func (tx *TXCore) GetStructs(objPointerSlice interface{}, sql string, args ...interface{}) error { + all, err := tx.GetAll(sql, args...) + if err != nil { + return err + } + return all.Structs(objPointerSlice) +} + +// GetScan queries one or more records from database and converts them to given struct or +// struct array. +// +// If parameter `pointer` is type of struct pointer, it calls GetStruct internally for +// the conversion. If parameter `pointer` is type of slice, it calls GetStructs internally +// for conversion. +func (tx *TXCore) GetScan(pointer interface{}, sql string, args ...interface{}) error { + reflectInfo := reflection.OriginTypeAndKind(pointer) + if reflectInfo.InputKind != reflect.Ptr { + return gerror.NewCodef( + gcode.CodeInvalidParameter, + "params should be type of pointer, but got: %v", + reflectInfo.InputKind, + ) + } + switch reflectInfo.OriginKind { + case reflect.Array, reflect.Slice: + return tx.GetStructs(pointer, sql, args...) + + case reflect.Struct: + return tx.GetStruct(pointer, sql, args...) + + default: + } + return gerror.NewCodef( + gcode.CodeInvalidParameter, + `in valid parameter type "%v", of which element type should be type of struct/slice`, + reflectInfo.InputType, + ) +} + +// GetValue queries and returns the field value from database. +// The sql should query only one field from database, or else it returns only one +// field of the result. +func (tx *TXCore) GetValue(sql string, args ...interface{}) (Value, error) { + one, err := tx.GetOne(sql, args...) + if err != nil { + return nil, err + } + for _, v := range one { + return v, nil + } + return nil, nil +} + +// GetCount queries and returns the count from database. +func (tx *TXCore) GetCount(sql string, args ...interface{}) (int64, error) { + if !gregex.IsMatchString(`(?i)SELECT\s+COUNT\(.+\)\s+FROM`, sql) { + sql, _ = gregex.ReplaceString(`(?i)(SELECT)\s+(.+)\s+(FROM)`, `$1 COUNT($2) $3`, sql) + } + value, err := tx.GetValue(sql, args...) + if err != nil { + return 0, err + } + return value.Int64(), nil +} + +// Insert does "INSERT INTO ..." statement for the table. +// If there's already one unique record of the data in the table, it returns error. +// +// The parameter `data` can be type of map/gmap/struct/*struct/[]map/[]struct, etc. +// Eg: +// Data(g.Map{"uid": 10000, "name":"john"}) +// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"}) +// +// The parameter `batch` specifies the batch operation count when given data is slice. +func (tx *TXCore) Insert(table string, data interface{}, batch ...int) (sql.Result, error) { + if len(batch) > 0 { + return tx.Model(table).Ctx(tx.ctx).Data(data).Batch(batch[0]).Insert() + } + return tx.Model(table).Ctx(tx.ctx).Data(data).Insert() +} + +// InsertIgnore does "INSERT IGNORE INTO ..." statement for the table. +// If there's already one unique record of the data in the table, it ignores the inserting. +// +// The parameter `data` can be type of map/gmap/struct/*struct/[]map/[]struct, etc. +// Eg: +// Data(g.Map{"uid": 10000, "name":"john"}) +// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"}) +// +// The parameter `batch` specifies the batch operation count when given data is slice. +func (tx *TXCore) InsertIgnore(table string, data interface{}, batch ...int) (sql.Result, error) { + if len(batch) > 0 { + return tx.Model(table).Ctx(tx.ctx).Data(data).Batch(batch[0]).InsertIgnore() + } + return tx.Model(table).Ctx(tx.ctx).Data(data).InsertIgnore() +} + +// InsertAndGetId performs action Insert and returns the last insert id that automatically generated. +func (tx *TXCore) InsertAndGetId(table string, data interface{}, batch ...int) (int64, error) { + if len(batch) > 0 { + return tx.Model(table).Ctx(tx.ctx).Data(data).Batch(batch[0]).InsertAndGetId() + } + return tx.Model(table).Ctx(tx.ctx).Data(data).InsertAndGetId() +} + +// Replace does "REPLACE INTO ..." statement for the table. +// If there's already one unique record of the data in the table, it deletes the record +// and inserts a new one. +// +// The parameter `data` can be type of map/gmap/struct/*struct/[]map/[]struct, etc. +// Eg: +// Data(g.Map{"uid": 10000, "name":"john"}) +// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"}) +// +// The parameter `data` can be type of map/gmap/struct/*struct/[]map/[]struct, etc. +// If given data is type of slice, it then does batch replacing, and the optional parameter +// `batch` specifies the batch operation count. +func (tx *TXCore) Replace(table string, data interface{}, batch ...int) (sql.Result, error) { + if len(batch) > 0 { + return tx.Model(table).Ctx(tx.ctx).Data(data).Batch(batch[0]).Replace() + } + return tx.Model(table).Ctx(tx.ctx).Data(data).Replace() +} + +// Save does "INSERT INTO ... ON DUPLICATE KEY UPDATE..." statement for the table. +// It updates the record if there's primary or unique index in the saving data, +// or else it inserts a new record into the table. +// +// The parameter `data` can be type of map/gmap/struct/*struct/[]map/[]struct, etc. +// Eg: +// Data(g.Map{"uid": 10000, "name":"john"}) +// Data(g.Slice{g.Map{"uid": 10000, "name":"john"}, g.Map{"uid": 20000, "name":"smith"}) +// +// If given data is type of slice, it then does batch saving, and the optional parameter +// `batch` specifies the batch operation count. +func (tx *TXCore) Save(table string, data interface{}, batch ...int) (sql.Result, error) { + if len(batch) > 0 { + return tx.Model(table).Ctx(tx.ctx).Data(data).Batch(batch[0]).Save() + } + return tx.Model(table).Ctx(tx.ctx).Data(data).Save() +} + +// Update does "UPDATE ... " statement for the table. +// +// The parameter `data` can be type of string/map/gmap/struct/*struct, etc. +// Eg: "uid=10000", "uid", 10000, g.Map{"uid": 10000, "name":"john"} +// +// The parameter `condition` can be type of string/map/gmap/slice/struct/*struct, etc. +// It is commonly used with parameter `args`. +// Eg: +// "uid=10000", +// "uid", 10000 +// "money>? AND name like ?", 99999, "vip_%" +// "status IN (?)", g.Slice{1,2,3} +// "age IN(?,?)", 18, 50 +// User{ Id : 1, UserName : "john"}. +func (tx *TXCore) Update(table string, data interface{}, condition interface{}, args ...interface{}) (sql.Result, error) { + return tx.Model(table).Ctx(tx.ctx).Data(data).Where(condition, args...).Update() +} + +// Delete does "DELETE FROM ... " statement for the table. +// +// The parameter `condition` can be type of string/map/gmap/slice/struct/*struct, etc. +// It is commonly used with parameter `args`. +// Eg: +// "uid=10000", +// "uid", 10000 +// "money>? AND name like ?", 99999, "vip_%" +// "status IN (?)", g.Slice{1,2,3} +// "age IN(?,?)", 18, 50 +// User{ Id : 1, UserName : "john"}. +func (tx *TXCore) Delete(table string, condition interface{}, args ...interface{}) (sql.Result, error) { + return tx.Model(table).Ctx(tx.ctx).Where(condition, args...).Delete() +} + +// QueryContext implements interface function Link.QueryContext. +func (tx *TXCore) QueryContext(ctx context.Context, sql string, args ...interface{}) (*sql.Rows, error) { + return tx.tx.QueryContext(ctx, sql, args...) +} + +// ExecContext implements interface function Link.ExecContext. +func (tx *TXCore) ExecContext(ctx context.Context, sql string, args ...interface{}) (sql.Result, error) { + return tx.tx.ExecContext(ctx, sql, args...) +} + +// PrepareContext implements interface function Link.PrepareContext. +func (tx *TXCore) PrepareContext(ctx context.Context, sql string) (*sql.Stmt, error) { + return tx.tx.PrepareContext(ctx, sql) +} + +// IsOnMaster implements interface function Link.IsOnMaster. +func (tx *TXCore) IsOnMaster() bool { + return true +} + +// IsTransaction implements interface function Link.IsTransaction. +func (tx *TXCore) IsTransaction() bool { + return true +} diff --git a/database/gdb/gdb_core_underlying.go b/database/gdb/gdb_core_underlying.go index dbdc59eb350..166f5785b68 100644 --- a/database/gdb/gdb_core_underlying.go +++ b/database/gdb/gdb_core_underlying.go @@ -187,7 +187,13 @@ func (c *Core) DoCommit(ctx context.Context, in DoCommitInput) (out DoCommitOutp // Execution cased by type. switch in.Type { case SqlTypeBegin: - if sqlTx, err = in.Db.Begin(); err == nil { + ctx, cancelFuncForTimeout = c.GetCtxTimeout(ctx, ctxTimeoutTypeTrans) + defer cancelFuncForTimeout() + formattedSql = fmt.Sprintf( + `%s (IosolationLevel: %s, ReadOnly: %t)`, + formattedSql, in.TxOptions.Isolation.String(), in.TxOptions.ReadOnly, + ) + if sqlTx, err = in.Db.BeginTx(ctx, &in.TxOptions); err == nil { out.Tx = &TXCore{ db: c.db, tx: sqlTx, @@ -206,6 +212,8 @@ func (c *Core) DoCommit(ctx context.Context, in DoCommitInput) (out DoCommitOutp err = in.Tx.Rollback() case SqlTypeExecContext: + ctx, cancelFuncForTimeout = c.GetCtxTimeout(ctx, ctxTimeoutTypeExec) + defer cancelFuncForTimeout() if c.db.GetDryRun() { sqlResult = new(SqlResult) } else { @@ -214,10 +222,14 @@ func (c *Core) DoCommit(ctx context.Context, in DoCommitInput) (out DoCommitOutp out.RawResult = sqlResult case SqlTypeQueryContext: + ctx, cancelFuncForTimeout = c.GetCtxTimeout(ctx, ctxTimeoutTypeQuery) + defer cancelFuncForTimeout() sqlRows, err = in.Link.QueryContext(ctx, in.Sql, in.Args...) out.RawResult = sqlRows case SqlTypePrepareContext: + ctx, cancelFuncForTimeout = c.GetCtxTimeout(ctx, ctxTimeoutTypePrepare) + defer cancelFuncForTimeout() sqlStmt, err = in.Link.PrepareContext(ctx, in.Sql) out.RawResult = sqlStmt diff --git a/database/gdb/gdb_model_transaction.go b/database/gdb/gdb_model_transaction.go index e186db37ff3..c4b577ec938 100644 --- a/database/gdb/gdb_model_transaction.go +++ b/database/gdb/gdb_model_transaction.go @@ -26,3 +26,17 @@ func (m *Model) Transaction(ctx context.Context, f func(ctx context.Context, tx } return m.db.Transaction(ctx, f) } + +// TransactionWithOptions executes transaction with options. +// The parameter `opts` specifies the transaction options. +// The parameter `f` specifies the function that will be called within the transaction. +// If f returns error, the transaction will be rolled back, or else the transaction will be committed. +func (m *Model) TransactionWithOptions(ctx context.Context, opts TxOptions, f func(ctx context.Context, tx TX) error) (err error) { + if ctx == nil { + ctx = m.GetCtx() + } + if m.tx != nil { + return m.tx.Transaction(ctx, f) + } + return m.db.TransactionWithOptions(ctx, opts, f) +} From b0b84a393761db30d68b17d176f1fb138dfd785a Mon Sep 17 00:00:00 2001 From: houseme Date: Sat, 7 Dec 2024 14:17:33 +0800 Subject: [PATCH 035/102] ci(gci/import): improve golangci.yml and add gci linter (#4010) --- .github/workflows/doc-build.yml | 2 +- .github/workflows/golangci-lint.yml | 6 +- .github/workflows/release.yml | 2 +- .golangci.yml | 63 ++++++++++++++----- cmd/gf/gfcmd/gfcmd.go | 3 +- cmd/gf/internal/cmd/cmd_doc.go | 3 +- cmd/gf/internal/cmd/cmd_fix.go | 8 +-- cmd/gf/internal/cmd/cmd_init.go | 7 ++- cmd/gf/internal/cmd/cmd_up.go | 5 +- .../internal/cmd/cmd_z_unit_gen_ctrl_test.go | 3 +- .../internal/cmd/cmd_z_unit_gen_dao_test.go | 3 +- cmd/gf/internal/cmd/cmd_z_unit_gen_pb_test.go | 3 +- .../cmd/cmd_z_unit_gen_pbentity_test.go | 3 +- .../cmd/cmd_z_unit_gen_service_test.go | 3 +- .../internal/cmd/genctrl/genctrl_calculate.go | 3 +- .../cmd/genctrl/genctrl_generate_ctrl.go | 5 +- .../genctrl/genctrl_generate_ctrl_clear.go | 3 +- .../cmd/genctrl/genctrl_generate_interface.go | 7 ++- .../cmd/genctrl/genctrl_generate_sdk.go | 5 +- cmd/gf/internal/cmd/gendao/gendao.go | 2 +- cmd/gf/internal/cmd/genenums/genenums.go | 5 +- .../internal/cmd/genenums/genenums_parser.go | 3 +- cmd/gf/internal/cmd/genpb/genpb.go | 3 +- cmd/gf/internal/cmd/genpb/genpb_controller.go | 3 +- cmd/gf/internal/cmd/genpb/genpb_tag.go | 3 +- .../internal/cmd/genpbentity/genpbentity.go | 7 ++- .../cmd/genservice/genservice_calculate.go | 3 +- .../cmd/genservice/genservice_generate.go | 7 ++- .../genservice_generate_template.go | 3 +- .../genservice/logic/article/article.go | 3 +- .../genservice/logic/article/article_extra.go | 5 +- .../issue/3835/logic/issue3835/issue3835.go | 1 + cmd/gf/internal/utility/utils/utils_test.go | 3 +- cmd/gf/main.go | 5 +- .../garray_z_example_normal_any_test.go | 3 +- .../garray_z_example_normal_int_test.go | 3 +- .../garray_z_example_normal_str_test.go | 3 +- .../garray_z_example_sorted_str_test.go | 3 +- .../garray/garray_z_unit_normal_any_test.go | 3 +- .../garray/garray_z_unit_normal_int_test.go | 3 +- .../garray/garray_z_unit_normal_str_test.go | 3 +- .../garray/garray_z_unit_sorted_any_test.go | 3 +- .../garray/garray_z_unit_sorted_int_test.go | 3 +- .../garray/garray_z_unit_sorted_str_test.go | 3 +- container/gmap/gmap_hash_any_any_map.go | 3 +- container/gmap/gmap_hash_int_any_map.go | 3 +- container/gtree/gtree_avltree.go | 1 + container/gtree/gtree_btree.go | 1 + container/gtree/gtree_redblacktree.go | 1 + contrib/config/consul/consul_test.go | 8 +-- contrib/config/kubecm/kubecm_test.go | 3 +- contrib/config/nacos/nacos_test.go | 3 +- .../clickhouse_z_unit_issue_test.go | 3 +- contrib/drivers/dm/dm_convert.go | 1 - contrib/drivers/dm/dm_do_filter.go | 1 - contrib/drivers/dm/dm_open.go | 1 - contrib/drivers/dm/dm_table_fields.go | 1 - .../drivers/mssql/mssql_z_unit_model_test.go | 3 +- .../mysql/mysql_z_unit_feature_with_test.go | 3 +- contrib/drivers/oracle/oracle_do_insert.go | 3 +- .../oracle/oracle_z_unit_basic_test.go | 3 +- contrib/drivers/pgsql/pgsql_convert.go | 3 +- contrib/drivers/pgsql/pgsql_do_filter.go | 1 + contrib/drivers/pgsql/pgsql_do_insert.go | 1 + .../drivers/pgsql/pgsql_z_unit_init_test.go | 4 +- .../drivers/pgsql/pgsql_z_unit_issue_test.go | 1 - .../otelmetric/otelmetric_z_unit_http_test.go | 3 +- .../otelmetric/otelmetric_z_unit_test.go | 3 +- contrib/nosql/redis/redis_z_group_set_test.go | 3 +- .../nosql/redis/redis_z_unit_config_test.go | 2 +- .../redis/redis_z_unit_gcache_adapter_test.go | 2 +- contrib/registry/etcd/etcd_z_test.go | 3 +- contrib/registry/file/file_z_basic_test.go | 3 +- contrib/registry/file/file_z_http_test.go | 3 +- contrib/registry/nacos/nacos.go | 9 +-- contrib/registry/nacos/nacos_discovery.go | 5 +- contrib/registry/nacos/nacos_register.go | 3 +- contrib/registry/nacos/nacos_service.go | 3 +- contrib/registry/nacos/nacos_watcher.go | 3 +- contrib/registry/nacos/nacos_z_test.go | 6 +- contrib/registry/zookeeper/zookeeper.go | 3 +- .../registry/zookeeper/zookeeper_registrar.go | 5 +- .../registry/zookeeper/zookeeper_watcher.go | 5 +- contrib/rpc/grpcx/grpcx_interceptor_client.go | 3 +- contrib/rpc/grpcx/grpcx_interceptor_server.go | 5 +- contrib/rpc/grpcx/grpcx_registry_file.go | 4 +- contrib/rpc/grpcx/grpcx_unit_z_ctx_test.go | 3 +- .../grpcx_unit_z_grpc_server_basic_test.go | 7 ++- contrib/rpc/grpcx/grpcx_unit_z_issue_test.go | 8 ++- .../internal/balancer/balancer_builder.go | 1 + .../tracing/tracing_interceptor_client.go | 3 +- .../tracing/tracing_interceptor_server.go | 3 +- .../httpclient_z_unit_feature_handler_test.go | 3 +- database/gdb/gdb_core_underlying.go | 3 +- debug/gdebug/gdebug_grid.go | 6 +- encoding/gcharset/gcharset.go | 16 +++-- encoding/ghtml/ghtml.go | 3 +- encoding/gurl/url.go | 2 +- errors/gerror/gerror_error.go | 6 +- errors/gerror/gerror_error_stack.go | 2 +- example/balancer/http/client/client.go | 3 +- example/balancer/http/server/server.go | 3 +- example/balancer/polaris/client/client.go | 3 +- example/balancer/polaris/server/server.go | 3 +- example/config/apollo/boot/boot.go | 3 +- example/config/consul/boot/boot.go | 4 +- example/config/kubecm/boot_in_pod/boot.go | 3 +- example/config/kubecm/boot_out_pod/boot.go | 3 +- example/config/nacos/boot/boot.go | 3 +- example/config/polaris/boot/boot.go | 3 +- .../driver-encrypt-decrypt-password/main.go | 3 +- example/metric/basic/main.go | 3 +- example/metric/callback/main.go | 3 +- example/metric/dynamic_attributes/main.go | 3 +- example/metric/global_attributes/main.go | 3 +- example/metric/http_client/main.go | 3 +- example/metric/http_server/main.go | 3 +- example/metric/meter_attributes/main.go | 3 +- example/nosql/redis/adapter/main.go | 4 +- example/registry/etcd/grpc/client/client.go | 6 +- .../etcd/grpc/controller/helloworld.go | 1 + example/registry/etcd/grpc/server/server.go | 1 + example/registry/etcd/http/client/client.go | 3 +- example/registry/etcd/http/server/server.go | 3 +- example/registry/file/client/client.go | 3 +- example/registry/file/server/server.go | 3 +- example/registry/nacos/grpc/client/client.go | 6 +- .../nacos/grpc/controller/helloworld.go | 1 + example/registry/nacos/grpc/server/server.go | 1 + example/registry/nacos/http/client/client.go | 3 +- example/registry/nacos/http/server/server.go | 3 +- example/registry/polaris/client/client.go | 3 +- example/registry/polaris/server/server.go | 3 +- example/rpc/grpcx/balancer/client/client.go | 6 +- .../grpcx/balancer/controller/helloworld.go | 1 + example/rpc/grpcx/balancer/server/server.go | 1 + example/rpc/grpcx/basic/client/client.go | 6 +- .../rpc/grpcx/basic/controller/helloworld.go | 1 + example/rpc/grpcx/basic/server/server.go | 1 + example/rpc/grpcx/ctx/client/client.go | 6 +- .../rpc/grpcx/ctx/controller/helloworld.go | 4 +- example/rpc/grpcx/ctx/server/server.go | 1 + example/rpc/grpcx/rawgrpc/client/client.go | 9 +-- example/rpc/grpcx/rawgrpc/server/server.go | 6 +- example/rpc/grpcx/resolver/client/client.go | 6 +- .../grpcx/resolver/controller/helloworld.go | 1 + example/rpc/grpcx/resolver/server/server.go | 1 + example/trace/grpc-with-db/client/client.go | 8 ++- example/trace/grpc-with-db/server/server.go | 16 ++--- example/trace/http-with-db/client/client.go | 3 +- example/trace/http-with-db/server/server.go | 4 +- example/trace/http/client/client.go | 3 +- example/trace/http/server/server.go | 3 +- example/trace/inprocess-grpc/main.go | 3 +- example/trace/inprocess/main.go | 3 +- example/trace/otlp/grpc/main.go | 4 +- example/trace/otlp/http/main.go | 3 +- example/trace/provider/grpc/main.go | 4 +- example/trace/provider/http/main.go | 3 +- i18n/gi18n/gi18n_z_unit_test.go | 8 +-- internal/errors/errors.go | 8 +-- internal/utils/utils_debug.go | 6 +- internal/utils/utils_is.go | 4 +- internal/utils/utils_str.go | 28 ++++----- net/ghttp/ghttp_z_unit_feature_https_test.go | 4 +- net/ghttp/ghttp_z_unit_feature_pprof_test.go | 3 +- .../ghttp_z_unit_feature_request_file_test.go | 3 +- .../ghttp_z_unit_feature_response_test.go | 5 +- net/gtrace/gtrace.go | 2 +- net/gtrace/gtrace_content.go | 1 - net/gtrace/gtrace_z_unit_test.go | 1 - os/gcache/gcache_adapter_memory_lru.go | 3 +- os/gcache/gcache_cache.go | 1 + os/gfsnotify/gfsnotify_watcher_loop.go | 4 +- os/gres/gres_z_unit_test.go | 4 +- os/gstructs/gstructs_field.go | 4 +- os/gstructs/gstructs_field_tag.go | 2 +- os/gtime/gtime.go | 4 +- os/gtimer/gtimer_entry.go | 3 +- util/grand/grand_buffer.go | 8 +-- util/gtag/gtag_enums.go | 6 +- util/gutil/gutil_z_example_test.go | 1 + 182 files changed, 429 insertions(+), 307 deletions(-) diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml index 9ab2d274f46..32d6f7d1a5b 100644 --- a/.github/workflows/doc-build.yml +++ b/.github/workflows/doc-build.yml @@ -22,7 +22,7 @@ jobs: - name: Set Up Golang Environment uses: actions/setup-go@v5 with: - go-version: 1.22.5 + go-version: 1.23.4 cache: false - name: download goframe docs run: ./download.sh diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 0aa08c04960..567a5239a94 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -27,7 +27,7 @@ jobs: golangci: strategy: matrix: - go-version: [ '1.20','1.21.4','1.22', '1.23' ] + go-version: [ '1.20','1.21.4','1.22','1.23' ] name: golangci-lint runs-on: ubuntu-latest steps: @@ -41,5 +41,5 @@ jobs: uses: golangci/golangci-lint-action@v6 with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. - version: v1.60.1 - args: --timeout 3m0s + version: v1.62.2 + args: --timeout 3m0s \ No newline at end of file diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 8197933887c..b9729849cd6 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,7 +21,7 @@ jobs: - name: Set Up Golang Environment uses: actions/setup-go@v5 with: - go-version: 1.22.5 + go-version: 1.23.4 - name: Build CLI Binary run: | diff --git a/.golangci.yml b/.golangci.yml index 35b2998c8de..0ee2b141e5c 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -40,9 +40,11 @@ linters: - errcheck # Errcheck is a program for checking for unchecked errors in go programs. - errchkjson # Checks types passed to the JSON encoding functions. Reports unsupported types and optionally reports occasions, where the check for the returned error can be omitted. - funlen # Tool for detection of long functions + - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification + - goimports # Check import statements are formatted according to the 'goimport' command. Reformat imports in autofix mode. + - gci # Gci controls Go package import order and makes it always deterministic. - goconst # Finds repeated strings that could be replaced by a constant - gocritic # Provides diagnostics that check for bugs, performance and style issues. - - gofmt # Gofmt checks whether code was gofmt-ed. By default this tool runs with -s option to check for code simplification - gosimple # Linter for Go source code that specializes in simplifying code - govet # Vet examines Go source code and reports suspicious constructs, such as Printf calls whose arguments do not align with the format string - misspell # Finds commonly misspelled English words in comments @@ -79,7 +81,51 @@ linters-settings: locale: US ignore-words: - cancelled - + # https://golangci-lint.run/usage/linters/#gofmt + gofmt: + # Simplify code: gofmt with `-s` option. + # Default: true + simplify: true + # Apply the rewrite rules to the source before reformatting. + # https://pkg.go.dev/cmd/gofmt + # Default: [] + rewrite-rules: [ ] + # - pattern: 'interface{}' + # replacement: 'any' + # - pattern: 'a[b:len(a)]' + # replacement: 'a[b:]' + goimports: + # A comma-separated list of prefixes, which, if set, checks import paths + # with the given prefixes are grouped after 3rd-party packages. + # Default: "" + local-prefixes: github.com/gogf/gf/v2 + gci: + # Section configuration to compare against. + # Section names are case-insensitive and may contain parameters in (). + # The default order of sections is `standard > default > custom > blank > dot > alias > localmodule`, + # If `custom-order` is `true`, it follows the order of `sections` option. + # Default: ["standard", "default"] + sections: + - standard # Standard section: captures all standard packages. + - blank # Blank section: contains all blank imports. This section is not present unless explicitly enabled. + - default # Default section: contains all imports that could not be matched to another section type. + - dot # Dot section: contains all dot imports. This section is not present unless explicitly enabled. + # - alias # Alias section: contains all alias imports. This section is not present unless explicitly enabled. + # - localmodule # Local module section: contains all local packages. This section is not present unless explicitly enabled. + - prefix(github.com/gogf/gf) # Custom section: groups all imports with the specified Prefix. + - prefix(github.com/gogf/gf/cmd) # Custom section: groups all imports with the specified Prefix. + - prefix(github.com/gogf/gfcontrib) # Custom section: groups all imports with the specified Prefix. + - prefix(github.com/gogf/gf/example) # Custom section: groups all imports with the specified Prefix. + # Skip generated files. + # Default: true + skip-generated: true + # Enable custom order of sections. + # If `true`, make the section order the same as the order of `sections`. + # Default: false + custom-order: true + # Drops lexical ordering for custom sections. + # Default: false + no-lex-order: true # https://golangci-lint.run/usage/linters/#revive # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md revive: @@ -259,16 +305,3 @@ linters-settings: # Default: ["*"] checks: [ "all","-SA1019","-SA4015","-SA1029","-SA1016","-SA9003","-SA4006","-SA6003" ] - # https://golangci-lint.run/usage/linters/#gofmt - gofmt: - # Simplify code: gofmt with `-s` option. - # Default: true - simplify: true - # Apply the rewrite rules to the source before reformatting. - # https://pkg.go.dev/cmd/gofmt - # Default: [] - rewrite-rules: [ ] - # - pattern: 'interface{}' - # replacement: 'any' - # - pattern: 'a[b:len(a)]' - # replacement: 'a[b:]' diff --git a/cmd/gf/gfcmd/gfcmd.go b/cmd/gf/gfcmd/gfcmd.go index 4a8dd0622f7..7e4b55336b9 100644 --- a/cmd/gf/gfcmd/gfcmd.go +++ b/cmd/gf/gfcmd/gfcmd.go @@ -10,6 +10,8 @@ import ( "context" "runtime" + _ "github.com/gogf/gf/cmd/gf/v2/internal/packed" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" @@ -19,7 +21,6 @@ import ( "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/cmd/gf/v2/internal/cmd" - _ "github.com/gogf/gf/cmd/gf/v2/internal/packed" "github.com/gogf/gf/cmd/gf/v2/internal/utility/allyes" "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" ) diff --git a/cmd/gf/internal/cmd/cmd_doc.go b/cmd/gf/internal/cmd/cmd_doc.go index 78501a8a1c5..2f5a012cb97 100644 --- a/cmd/gf/internal/cmd/cmd_doc.go +++ b/cmd/gf/internal/cmd/cmd_doc.go @@ -16,10 +16,11 @@ import ( "path/filepath" "time" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" "github.com/gogf/gf/v2/encoding/gcompress" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" + + "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" ) const ( diff --git a/cmd/gf/internal/cmd/cmd_fix.go b/cmd/gf/internal/cmd/cmd_fix.go index 94276095e66..479252a7355 100644 --- a/cmd/gf/internal/cmd/cmd_fix.go +++ b/cmd/gf/internal/cmd/cmd_fix.go @@ -9,14 +9,14 @@ package cmd import ( "context" - "github.com/gogf/gf/v2/os/gproc" - "github.com/gogf/gf/v2/text/gregex" - - "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gproc" + "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" + + "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" ) var ( diff --git a/cmd/gf/internal/cmd/cmd_init.go b/cmd/gf/internal/cmd/cmd_init.go index e7bf79fec73..5b583345d6f 100644 --- a/cmd/gf/internal/cmd/cmd_init.go +++ b/cmd/gf/internal/cmd/cmd_init.go @@ -12,9 +12,6 @@ import ( "os" "strings" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/allyes" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gcmd" "github.com/gogf/gf/v2/os/gfile" @@ -22,6 +19,10 @@ import ( "github.com/gogf/gf/v2/os/gres" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gtag" + + "github.com/gogf/gf/cmd/gf/v2/internal/utility/allyes" + "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" + "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" ) var ( diff --git a/cmd/gf/internal/cmd/cmd_up.go b/cmd/gf/internal/cmd/cmd_up.go index 2bef38896f9..4a43e5b6a4c 100644 --- a/cmd/gf/internal/cmd/cmd_up.go +++ b/cmd/gf/internal/cmd/cmd_up.go @@ -13,14 +13,15 @@ import ( "github.com/gogf/selfupdate" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" "github.com/gogf/gf/v2/container/gset" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gproc" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gtag" + + "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" + "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" ) var ( diff --git a/cmd/gf/internal/cmd/cmd_z_unit_gen_ctrl_test.go b/cmd/gf/internal/cmd/cmd_z_unit_gen_ctrl_test.go index 1270cc67427..55986b48006 100644 --- a/cmd/gf/internal/cmd/cmd_z_unit_gen_ctrl_test.go +++ b/cmd/gf/internal/cmd/cmd_z_unit_gen_ctrl_test.go @@ -10,11 +10,12 @@ import ( "path/filepath" "testing" - "github.com/gogf/gf/cmd/gf/v2/internal/cmd/genctrl" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/guid" "github.com/gogf/gf/v2/util/gutil" + + "github.com/gogf/gf/cmd/gf/v2/internal/cmd/genctrl" ) func Test_Gen_Ctrl_Default(t *testing.T) { diff --git a/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_test.go b/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_test.go index dd920b66388..fbefdb88fb7 100644 --- a/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_test.go +++ b/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_test.go @@ -11,7 +11,6 @@ import ( "path/filepath" "testing" - "github.com/gogf/gf/cmd/gf/v2/internal/cmd/gendao" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gcfg" @@ -20,6 +19,8 @@ import ( "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/guid" "github.com/gogf/gf/v2/util/gutil" + + "github.com/gogf/gf/cmd/gf/v2/internal/cmd/gendao" ) func Test_Gen_Dao_Default(t *testing.T) { diff --git a/cmd/gf/internal/cmd/cmd_z_unit_gen_pb_test.go b/cmd/gf/internal/cmd/cmd_z_unit_gen_pb_test.go index 0f9e0913733..4ba3c179d6d 100644 --- a/cmd/gf/internal/cmd/cmd_z_unit_gen_pb_test.go +++ b/cmd/gf/internal/cmd/cmd_z_unit_gen_pb_test.go @@ -10,11 +10,12 @@ import ( "path/filepath" "testing" - "github.com/gogf/gf/cmd/gf/v2/internal/cmd/genpb" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/guid" + + "github.com/gogf/gf/cmd/gf/v2/internal/cmd/genpb" ) func TestGenPbIssue3882(t *testing.T) { diff --git a/cmd/gf/internal/cmd/cmd_z_unit_gen_pbentity_test.go b/cmd/gf/internal/cmd/cmd_z_unit_gen_pbentity_test.go index 851dc2a7edf..89770f5ba6f 100644 --- a/cmd/gf/internal/cmd/cmd_z_unit_gen_pbentity_test.go +++ b/cmd/gf/internal/cmd/cmd_z_unit_gen_pbentity_test.go @@ -11,12 +11,13 @@ import ( "path/filepath" "testing" - "github.com/gogf/gf/cmd/gf/v2/internal/cmd/genpbentity" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/guid" "github.com/gogf/gf/v2/util/gutil" + + "github.com/gogf/gf/cmd/gf/v2/internal/cmd/genpbentity" ) func Test_Gen_Pbentity_Default(t *testing.T) { diff --git a/cmd/gf/internal/cmd/cmd_z_unit_gen_service_test.go b/cmd/gf/internal/cmd/cmd_z_unit_gen_service_test.go index 8aeff4bb5f2..40ee7158ed5 100644 --- a/cmd/gf/internal/cmd/cmd_z_unit_gen_service_test.go +++ b/cmd/gf/internal/cmd/cmd_z_unit_gen_service_test.go @@ -10,11 +10,12 @@ import ( "path/filepath" "testing" - "github.com/gogf/gf/cmd/gf/v2/internal/cmd/genservice" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/guid" "github.com/gogf/gf/v2/util/gutil" + + "github.com/gogf/gf/cmd/gf/v2/internal/cmd/genservice" ) func Test_Gen_Service_Default(t *testing.T) { diff --git a/cmd/gf/internal/cmd/genctrl/genctrl_calculate.go b/cmd/gf/internal/cmd/genctrl/genctrl_calculate.go index 3fb8825ade0..db27022ee25 100644 --- a/cmd/gf/internal/cmd/genctrl/genctrl_calculate.go +++ b/cmd/gf/internal/cmd/genctrl/genctrl_calculate.go @@ -7,10 +7,11 @@ package genctrl import ( - "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" + + "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" ) func (c CGenCtrl) getApiItemsInSrc(apiModuleFolderPath string) (items []apiItem, err error) { diff --git a/cmd/gf/internal/cmd/genctrl/genctrl_generate_ctrl.go b/cmd/gf/internal/cmd/genctrl/genctrl_generate_ctrl.go index d966338f8a1..6c427462f7c 100644 --- a/cmd/gf/internal/cmd/genctrl/genctrl_generate_ctrl.go +++ b/cmd/gf/internal/cmd/genctrl/genctrl_generate_ctrl.go @@ -11,12 +11,13 @@ import ( "path/filepath" "strings" - "github.com/gogf/gf/cmd/gf/v2/internal/consts" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" "github.com/gogf/gf/v2/container/gset" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/text/gstr" + + "github.com/gogf/gf/cmd/gf/v2/internal/consts" + "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" ) type controllerGenerator struct{} diff --git a/cmd/gf/internal/cmd/genctrl/genctrl_generate_ctrl_clear.go b/cmd/gf/internal/cmd/genctrl/genctrl_generate_ctrl_clear.go index af328f8dd6e..fd493a73ff1 100644 --- a/cmd/gf/internal/cmd/genctrl/genctrl_generate_ctrl_clear.go +++ b/cmd/gf/internal/cmd/genctrl/genctrl_generate_ctrl_clear.go @@ -9,9 +9,10 @@ package genctrl import ( "fmt" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/text/gstr" + + "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" ) type controllerClearer struct{} diff --git a/cmd/gf/internal/cmd/genctrl/genctrl_generate_interface.go b/cmd/gf/internal/cmd/genctrl/genctrl_generate_interface.go index c678c01943a..dfd9fab57e2 100644 --- a/cmd/gf/internal/cmd/genctrl/genctrl_generate_interface.go +++ b/cmd/gf/internal/cmd/genctrl/genctrl_generate_interface.go @@ -10,15 +10,16 @@ import ( "fmt" "path/filepath" - "github.com/gogf/gf/cmd/gf/v2/internal/consts" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/container/gset" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" + + "github.com/gogf/gf/cmd/gf/v2/internal/consts" + "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" + "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" ) type apiInterfaceGenerator struct{} diff --git a/cmd/gf/internal/cmd/genctrl/genctrl_generate_sdk.go b/cmd/gf/internal/cmd/genctrl/genctrl_generate_sdk.go index b5a82afb694..1e79266b085 100644 --- a/cmd/gf/internal/cmd/genctrl/genctrl_generate_sdk.go +++ b/cmd/gf/internal/cmd/genctrl/genctrl_generate_sdk.go @@ -10,13 +10,14 @@ import ( "fmt" "path/filepath" - "github.com/gogf/gf/cmd/gf/v2/internal/consts" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" "github.com/gogf/gf/v2/container/gset" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" + + "github.com/gogf/gf/cmd/gf/v2/internal/consts" + "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" ) type apiSdkGenerator struct{} diff --git a/cmd/gf/internal/cmd/gendao/gendao.go b/cmd/gf/internal/cmd/gendao/gendao.go index a19d0c5a1b1..d571aada6fb 100644 --- a/cmd/gf/internal/cmd/gendao/gendao.go +++ b/cmd/gf/internal/cmd/gendao/gendao.go @@ -13,7 +13,6 @@ import ( "golang.org/x/mod/modfile" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" @@ -24,6 +23,7 @@ import ( "github.com/gogf/gf/v2/util/gtag" "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" + "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" ) const ( diff --git a/cmd/gf/internal/cmd/genenums/genenums.go b/cmd/gf/internal/cmd/genenums/genenums.go index b4c3b3d0827..a214072c290 100644 --- a/cmd/gf/internal/cmd/genenums/genenums.go +++ b/cmd/gf/internal/cmd/genenums/genenums.go @@ -11,12 +11,13 @@ import ( "golang.org/x/tools/go/packages" - "github.com/gogf/gf/cmd/gf/v2/internal/consts" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gtag" + + "github.com/gogf/gf/cmd/gf/v2/internal/consts" + "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" ) type ( diff --git a/cmd/gf/internal/cmd/genenums/genenums_parser.go b/cmd/gf/internal/cmd/genenums/genenums_parser.go index 66858a0ddd3..21b9f96d98d 100644 --- a/cmd/gf/internal/cmd/genenums/genenums_parser.go +++ b/cmd/gf/internal/cmd/genenums/genenums_parser.go @@ -10,10 +10,11 @@ import ( "go/constant" "go/types" + "golang.org/x/tools/go/packages" + "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" - "golang.org/x/tools/go/packages" ) const pkgLoadMode = 0xffffff diff --git a/cmd/gf/internal/cmd/genpb/genpb.go b/cmd/gf/internal/cmd/genpb/genpb.go index 023cdb984ce..9167f28d2bf 100644 --- a/cmd/gf/internal/cmd/genpb/genpb.go +++ b/cmd/gf/internal/cmd/genpb/genpb.go @@ -9,11 +9,12 @@ package genpb import ( "context" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gproc" "github.com/gogf/gf/v2/util/gtag" + + "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" ) type ( diff --git a/cmd/gf/internal/cmd/genpb/genpb_controller.go b/cmd/gf/internal/cmd/genpb/genpb_controller.go index fdafe96d98a..5c365902a58 100644 --- a/cmd/gf/internal/cmd/genpb/genpb_controller.go +++ b/cmd/gf/internal/cmd/genpb/genpb_controller.go @@ -11,11 +11,12 @@ import ( "fmt" "strings" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" + + "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" ) type generateControllerInput struct { diff --git a/cmd/gf/internal/cmd/genpb/genpb_tag.go b/cmd/gf/internal/cmd/genpb/genpb_tag.go index ac74e28ebce..65a6c8ed790 100644 --- a/cmd/gf/internal/cmd/genpb/genpb_tag.go +++ b/cmd/gf/internal/cmd/genpb/genpb_tag.go @@ -10,13 +10,14 @@ import ( "context" "fmt" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" + + "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" ) type generateStructTagInput struct { diff --git a/cmd/gf/internal/cmd/genpbentity/genpbentity.go b/cmd/gf/internal/cmd/genpbentity/genpbentity.go index 29a660b0804..e7138850d30 100644 --- a/cmd/gf/internal/cmd/genpbentity/genpbentity.go +++ b/cmd/gf/internal/cmd/genpbentity/genpbentity.go @@ -14,11 +14,8 @@ import ( "regexp" "strings" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" "github.com/olekukonko/tablewriter" - "github.com/gogf/gf/cmd/gf/v2/internal/consts" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" @@ -29,6 +26,10 @@ import ( "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/gtag" + + "github.com/gogf/gf/cmd/gf/v2/internal/consts" + "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" + "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" ) type ( diff --git a/cmd/gf/internal/cmd/genservice/genservice_calculate.go b/cmd/gf/internal/cmd/genservice/genservice_calculate.go index 15f575c04a4..268585cb4f3 100644 --- a/cmd/gf/internal/cmd/genservice/genservice_calculate.go +++ b/cmd/gf/internal/cmd/genservice/genservice_calculate.go @@ -10,12 +10,13 @@ import ( "fmt" "strings" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" + + "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" ) func (c CGenService) calculateImportedItems( diff --git a/cmd/gf/internal/cmd/genservice/genservice_generate.go b/cmd/gf/internal/cmd/genservice/genservice_generate.go index a11d54e7f83..cfb691ec703 100644 --- a/cmd/gf/internal/cmd/genservice/genservice_generate.go +++ b/cmd/gf/internal/cmd/genservice/genservice_generate.go @@ -10,13 +10,14 @@ import ( "bytes" "fmt" - "github.com/gogf/gf/cmd/gf/v2/internal/consts" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/text/gstr" + + "github.com/gogf/gf/cmd/gf/v2/internal/consts" + "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" + "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" ) type generateServiceFilesInput struct { diff --git a/cmd/gf/internal/cmd/genservice/genservice_generate_template.go b/cmd/gf/internal/cmd/genservice/genservice_generate_template.go index 664ce699eea..5947908d9ec 100644 --- a/cmd/gf/internal/cmd/genservice/genservice_generate_template.go +++ b/cmd/gf/internal/cmd/genservice/genservice_generate_template.go @@ -10,11 +10,12 @@ import ( "bytes" "fmt" - "github.com/gogf/gf/cmd/gf/v2/internal/consts" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" + + "github.com/gogf/gf/cmd/gf/v2/internal/consts" ) func (c CGenService) generatePackageImports(generatedContent *bytes.Buffer, packageName string, imports []string) { diff --git a/cmd/gf/internal/cmd/testdata/genservice/logic/article/article.go b/cmd/gf/internal/cmd/testdata/genservice/logic/article/article.go index 57b6a31a6e0..9ee049fab47 100644 --- a/cmd/gf/internal/cmd/testdata/genservice/logic/article/article.go +++ b/cmd/gf/internal/cmd/testdata/genservice/logic/article/article.go @@ -11,8 +11,9 @@ import ( "go/ast" t "time" - "github.com/gogf/gf/cmd/gf/v2/internal/cmd/testdata/genservice/service" gdbalias "github.com/gogf/gf/v2/database/gdb" + + "github.com/gogf/gf/cmd/gf/v2/internal/cmd/testdata/genservice/service" ) type sArticle struct { diff --git a/cmd/gf/internal/cmd/testdata/genservice/logic/article/article_extra.go b/cmd/gf/internal/cmd/testdata/genservice/logic/article/article_extra.go index 165747407d2..3d9c3d0fa22 100644 --- a/cmd/gf/internal/cmd/testdata/genservice/logic/article/article_extra.go +++ b/cmd/gf/internal/cmd/testdata/genservice/logic/article/article_extra.go @@ -14,12 +14,13 @@ package article import ( "context" - // This is a random comment - gdbas "github.com/gogf/gf/v2/database/gdb" /** * */ _ "github.com/gogf/gf/v2/os/gfile" + + // This is a random comment + gdbas "github.com/gogf/gf/v2/database/gdb" ) // T1 random comment diff --git a/cmd/gf/internal/cmd/testdata/issue/3835/logic/issue3835/issue3835.go b/cmd/gf/internal/cmd/testdata/issue/3835/logic/issue3835/issue3835.go index 888b5a994c7..f54e54b3afa 100644 --- a/cmd/gf/internal/cmd/testdata/issue/3835/logic/issue3835/issue3835.go +++ b/cmd/gf/internal/cmd/testdata/issue/3835/logic/issue3835/issue3835.go @@ -4,6 +4,7 @@ import ( "context" "github.com/gogf/gf/cmd/gf/v2/internal/cmd/testdata/issue/3835/service" + "github.com/gogf/gf/contrib/drivers/mysql/v2" ) diff --git a/cmd/gf/internal/utility/utils/utils_test.go b/cmd/gf/internal/utility/utils/utils_test.go index 8fbbfc1dc44..c7c30fc2914 100644 --- a/cmd/gf/internal/utility/utils/utils_test.go +++ b/cmd/gf/internal/utility/utils/utils_test.go @@ -10,8 +10,9 @@ import ( "fmt" "testing" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" "github.com/gogf/gf/v2/test/gtest" + + "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" ) func Test_GetModPath(t *testing.T) { diff --git a/cmd/gf/main.go b/cmd/gf/main.go index 358c7d4590a..9021f656fd8 100644 --- a/cmd/gf/main.go +++ b/cmd/gf/main.go @@ -7,10 +7,11 @@ package main import ( - "github.com/gogf/gf/cmd/gf/v2/gfcmd" - "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/cmd/gf/v2/gfcmd" + "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" ) func main() { diff --git a/container/garray/garray_z_example_normal_any_test.go b/container/garray/garray_z_example_normal_any_test.go index 5457757197c..a115fcacf8e 100644 --- a/container/garray/garray_z_example_normal_any_test.go +++ b/container/garray/garray_z_example_normal_any_test.go @@ -9,10 +9,9 @@ package garray_test import ( "fmt" - "github.com/gogf/gf/v2/internal/empty" - "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/empty" ) func ExampleNew() { diff --git a/container/garray/garray_z_example_normal_int_test.go b/container/garray/garray_z_example_normal_int_test.go index 867a8ea6faa..f60345540ec 100644 --- a/container/garray/garray_z_example_normal_int_test.go +++ b/container/garray/garray_z_example_normal_int_test.go @@ -9,10 +9,9 @@ package garray_test import ( "fmt" - "github.com/gogf/gf/v2/internal/empty" - "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/container/garray/garray_z_example_normal_str_test.go b/container/garray/garray_z_example_normal_str_test.go index bb721c71df7..a4daab3f2bb 100644 --- a/container/garray/garray_z_example_normal_str_test.go +++ b/container/garray/garray_z_example_normal_str_test.go @@ -10,10 +10,9 @@ import ( "fmt" "strings" - "github.com/gogf/gf/v2/internal/empty" - "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" diff --git a/container/garray/garray_z_example_sorted_str_test.go b/container/garray/garray_z_example_sorted_str_test.go index 466e52caaec..bbd3a1aee0a 100644 --- a/container/garray/garray_z_example_sorted_str_test.go +++ b/container/garray/garray_z_example_sorted_str_test.go @@ -9,10 +9,9 @@ package garray_test import ( "fmt" - "github.com/gogf/gf/v2/internal/empty" - "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/container/garray/garray_z_unit_normal_any_test.go b/container/garray/garray_z_unit_normal_any_test.go index be381c9d403..5cce7794981 100644 --- a/container/garray/garray_z_unit_normal_any_test.go +++ b/container/garray/garray_z_unit_normal_any_test.go @@ -12,10 +12,9 @@ import ( "testing" "time" - "github.com/gogf/gf/v2/internal/empty" - "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" diff --git a/container/garray/garray_z_unit_normal_int_test.go b/container/garray/garray_z_unit_normal_int_test.go index 9d7dd814a49..d3f0a3d5c29 100644 --- a/container/garray/garray_z_unit_normal_int_test.go +++ b/container/garray/garray_z_unit_normal_int_test.go @@ -12,10 +12,9 @@ import ( "testing" "time" - "github.com/gogf/gf/v2/internal/empty" - "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" diff --git a/container/garray/garray_z_unit_normal_str_test.go b/container/garray/garray_z_unit_normal_str_test.go index f71ec473d03..23a43c39b67 100644 --- a/container/garray/garray_z_unit_normal_str_test.go +++ b/container/garray/garray_z_unit_normal_str_test.go @@ -13,10 +13,9 @@ import ( "testing" "time" - "github.com/gogf/gf/v2/internal/empty" - "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" diff --git a/container/garray/garray_z_unit_sorted_any_test.go b/container/garray/garray_z_unit_sorted_any_test.go index 3be78342edc..70cf53dd39e 100644 --- a/container/garray/garray_z_unit_sorted_any_test.go +++ b/container/garray/garray_z_unit_sorted_any_test.go @@ -13,10 +13,9 @@ import ( "testing" "time" - "github.com/gogf/gf/v2/internal/empty" - "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" diff --git a/container/garray/garray_z_unit_sorted_int_test.go b/container/garray/garray_z_unit_sorted_int_test.go index 65c921611f0..a4ebf4fe96e 100644 --- a/container/garray/garray_z_unit_sorted_int_test.go +++ b/container/garray/garray_z_unit_sorted_int_test.go @@ -12,10 +12,9 @@ import ( "testing" "time" - "github.com/gogf/gf/v2/internal/empty" - "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/gconv" diff --git a/container/garray/garray_z_unit_sorted_str_test.go b/container/garray/garray_z_unit_sorted_str_test.go index 458f9043a1f..d1fef5c992a 100644 --- a/container/garray/garray_z_unit_sorted_str_test.go +++ b/container/garray/garray_z_unit_sorted_str_test.go @@ -12,10 +12,9 @@ import ( "testing" "time" - "github.com/gogf/gf/v2/internal/empty" - "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" diff --git a/container/gmap/gmap_hash_any_any_map.go b/container/gmap/gmap_hash_any_any_map.go index 5ff0fad7acf..1cf02d139e0 100644 --- a/container/gmap/gmap_hash_any_any_map.go +++ b/container/gmap/gmap_hash_any_any_map.go @@ -7,13 +7,14 @@ package gmap import ( + "reflect" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/internal/deepcopy" "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" "github.com/gogf/gf/v2/util/gconv" - "reflect" ) // AnyAnyMap wraps map type `map[interface{}]interface{}` and provides more map features. diff --git a/container/gmap/gmap_hash_int_any_map.go b/container/gmap/gmap_hash_int_any_map.go index 016fb6c97db..b2d43eca7b4 100644 --- a/container/gmap/gmap_hash_int_any_map.go +++ b/container/gmap/gmap_hash_int_any_map.go @@ -8,13 +8,14 @@ package gmap import ( + "reflect" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/internal/deepcopy" "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" "github.com/gogf/gf/v2/util/gconv" - "reflect" ) // IntAnyMap implements map[int]interface{} with RWMutex that has switch. diff --git a/container/gtree/gtree_avltree.go b/container/gtree/gtree_avltree.go index ac8a51a8694..0d21c131eaf 100644 --- a/container/gtree/gtree_avltree.go +++ b/container/gtree/gtree_avltree.go @@ -10,6 +10,7 @@ import ( "fmt" "github.com/emirpasic/gods/trees/avltree" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/internal/rwmutex" "github.com/gogf/gf/v2/text/gstr" diff --git a/container/gtree/gtree_btree.go b/container/gtree/gtree_btree.go index 59f45053351..1ae03a13270 100644 --- a/container/gtree/gtree_btree.go +++ b/container/gtree/gtree_btree.go @@ -10,6 +10,7 @@ import ( "fmt" "github.com/emirpasic/gods/trees/btree" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/internal/rwmutex" "github.com/gogf/gf/v2/text/gstr" diff --git a/container/gtree/gtree_redblacktree.go b/container/gtree/gtree_redblacktree.go index c5a6bddf826..a94dc585e9d 100644 --- a/container/gtree/gtree_redblacktree.go +++ b/container/gtree/gtree_redblacktree.go @@ -10,6 +10,7 @@ import ( "fmt" "github.com/emirpasic/gods/trees/redblacktree" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/internal/rwmutex" diff --git a/contrib/config/consul/consul_test.go b/contrib/config/consul/consul_test.go index 8b14dda86e0..27fff6cab38 100644 --- a/contrib/config/consul/consul_test.go +++ b/contrib/config/consul/consul_test.go @@ -10,15 +10,15 @@ import ( "testing" "time" - consul "github.com/gogf/gf/contrib/config/consul/v2" + "github.com/hashicorp/consul/api" + "github.com/hashicorp/go-cleanhttp" + "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/hashicorp/consul/api" - "github.com/hashicorp/go-cleanhttp" - "github.com/gogf/gf/v2/frame/g" + consul "github.com/gogf/gf/contrib/config/consul/v2" ) func TestConsul(t *testing.T) { diff --git a/contrib/config/kubecm/kubecm_test.go b/contrib/config/kubecm/kubecm_test.go index 6b3dc173adb..d0e0ff435e8 100644 --- a/contrib/config/kubecm/kubecm_test.go +++ b/contrib/config/kubecm/kubecm_test.go @@ -13,13 +13,14 @@ import ( kubeMetaV1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/client-go/kubernetes" - "github.com/gogf/gf/contrib/config/kubecm/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/os/gfile" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/guid" + + "github.com/gogf/gf/contrib/config/kubecm/v2" ) const ( diff --git a/contrib/config/nacos/nacos_test.go b/contrib/config/nacos/nacos_test.go index 30b65a3d6d7..4adcfdaa6a9 100644 --- a/contrib/config/nacos/nacos_test.go +++ b/contrib/config/nacos/nacos_test.go @@ -12,11 +12,12 @@ import ( "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/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/gogf/gf/contrib/config/nacos/v2" ) var ( diff --git a/contrib/drivers/clickhouse/clickhouse_z_unit_issue_test.go b/contrib/drivers/clickhouse/clickhouse_z_unit_issue_test.go index 050f7785095..78fc2fa3234 100644 --- a/contrib/drivers/clickhouse/clickhouse_z_unit_issue_test.go +++ b/contrib/drivers/clickhouse/clickhouse_z_unit_issue_test.go @@ -7,9 +7,10 @@ package clickhouse import ( - "github.com/shopspring/decimal" "testing" + "github.com/shopspring/decimal" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" diff --git a/contrib/drivers/dm/dm_convert.go b/contrib/drivers/dm/dm_convert.go index 3bbc8164712..f17909d29c7 100644 --- a/contrib/drivers/dm/dm_convert.go +++ b/contrib/drivers/dm/dm_convert.go @@ -8,7 +8,6 @@ package dm import ( "context" - "time" "github.com/gogf/gf/v2/os/gtime" diff --git a/contrib/drivers/dm/dm_do_filter.go b/contrib/drivers/dm/dm_do_filter.go index 2a91e3734ad..8f574aef0e5 100644 --- a/contrib/drivers/dm/dm_do_filter.go +++ b/contrib/drivers/dm/dm_do_filter.go @@ -8,7 +8,6 @@ package dm import ( "context" - "strings" "github.com/gogf/gf/v2/database/gdb" diff --git a/contrib/drivers/dm/dm_open.go b/contrib/drivers/dm/dm_open.go index 8c51b5ff123..ebc789b7909 100644 --- a/contrib/drivers/dm/dm_open.go +++ b/contrib/drivers/dm/dm_open.go @@ -9,7 +9,6 @@ package dm import ( "database/sql" "fmt" - "net/url" "strings" diff --git a/contrib/drivers/dm/dm_table_fields.go b/contrib/drivers/dm/dm_table_fields.go index f2c715870c6..892973d37c1 100644 --- a/contrib/drivers/dm/dm_table_fields.go +++ b/contrib/drivers/dm/dm_table_fields.go @@ -9,7 +9,6 @@ package dm import ( "context" "fmt" - "strings" "github.com/gogf/gf/v2/database/gdb" diff --git a/contrib/drivers/mssql/mssql_z_unit_model_test.go b/contrib/drivers/mssql/mssql_z_unit_model_test.go index 7435e84cc24..e9eac7428b7 100644 --- a/contrib/drivers/mssql/mssql_z_unit_model_test.go +++ b/contrib/drivers/mssql/mssql_z_unit_model_test.go @@ -12,14 +12,13 @@ import ( "testing" "time" - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/guid" "github.com/gogf/gf/v2/util/gutil" ) diff --git a/contrib/drivers/mysql/mysql_z_unit_feature_with_test.go b/contrib/drivers/mysql/mysql_z_unit_feature_with_test.go index f71a3d378b5..64a49199111 100644 --- a/contrib/drivers/mysql/mysql_z_unit_feature_with_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_feature_with_test.go @@ -10,10 +10,9 @@ import ( "fmt" "testing" - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gmeta" diff --git a/contrib/drivers/oracle/oracle_do_insert.go b/contrib/drivers/oracle/oracle_do_insert.go index 381597d3533..cf6a9b14bbb 100644 --- a/contrib/drivers/oracle/oracle_do_insert.go +++ b/contrib/drivers/oracle/oracle_do_insert.go @@ -13,11 +13,10 @@ import ( "strings" "github.com/gogf/gf/v2/container/gset" - "github.com/gogf/gf/v2/text/gstr" - "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" ) diff --git a/contrib/drivers/oracle/oracle_z_unit_basic_test.go b/contrib/drivers/oracle/oracle_z_unit_basic_test.go index d54a13c43b2..83b926bfc30 100644 --- a/contrib/drivers/oracle/oracle_z_unit_basic_test.go +++ b/contrib/drivers/oracle/oracle_z_unit_basic_test.go @@ -12,11 +12,10 @@ import ( "testing" "github.com/gogf/gf/v2/database/gdb" - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" ) func Test_Tables(t *testing.T) { diff --git a/contrib/drivers/pgsql/pgsql_convert.go b/contrib/drivers/pgsql/pgsql_convert.go index 8ccd6e54fe0..a657bee7647 100644 --- a/contrib/drivers/pgsql/pgsql_convert.go +++ b/contrib/drivers/pgsql/pgsql_convert.go @@ -8,10 +8,11 @@ package pgsql import ( "context" - "github.com/lib/pq" "reflect" "strings" + "github.com/lib/pq" + "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/text/gregex" diff --git a/contrib/drivers/pgsql/pgsql_do_filter.go b/contrib/drivers/pgsql/pgsql_do_filter.go index a595d908ab6..a04ed9a08d3 100644 --- a/contrib/drivers/pgsql/pgsql_do_filter.go +++ b/contrib/drivers/pgsql/pgsql_do_filter.go @@ -9,6 +9,7 @@ package pgsql import ( "context" "fmt" + "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" diff --git a/contrib/drivers/pgsql/pgsql_do_insert.go b/contrib/drivers/pgsql/pgsql_do_insert.go index 15a102cdc58..ec24edde302 100644 --- a/contrib/drivers/pgsql/pgsql_do_insert.go +++ b/contrib/drivers/pgsql/pgsql_do_insert.go @@ -9,6 +9,7 @@ package pgsql import ( "context" "database/sql" + "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" diff --git a/contrib/drivers/pgsql/pgsql_z_unit_init_test.go b/contrib/drivers/pgsql/pgsql_z_unit_init_test.go index 023efdee1c4..e317d30009a 100644 --- a/contrib/drivers/pgsql/pgsql_z_unit_init_test.go +++ b/contrib/drivers/pgsql/pgsql_z_unit_init_test.go @@ -7,11 +7,11 @@ package pgsql_test import ( - _ "github.com/gogf/gf/contrib/drivers/pgsql/v2" - "context" "fmt" + _ "github.com/gogf/gf/contrib/drivers/pgsql/v2" + "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" diff --git a/contrib/drivers/pgsql/pgsql_z_unit_issue_test.go b/contrib/drivers/pgsql/pgsql_z_unit_issue_test.go index b329cdfdfa8..47122c461f8 100644 --- a/contrib/drivers/pgsql/pgsql_z_unit_issue_test.go +++ b/contrib/drivers/pgsql/pgsql_z_unit_issue_test.go @@ -11,7 +11,6 @@ import ( "testing" "github.com/gogf/gf/v2/database/gdb" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" diff --git a/contrib/metric/otelmetric/otelmetric_z_unit_http_test.go b/contrib/metric/otelmetric/otelmetric_z_unit_http_test.go index 36a644f0d8e..325a9a8ab88 100644 --- a/contrib/metric/otelmetric/otelmetric_z_unit_http_test.go +++ b/contrib/metric/otelmetric/otelmetric_z_unit_http_test.go @@ -14,7 +14,6 @@ import ( "github.com/prometheus/client_golang/prometheus/promhttp" "go.opentelemetry.io/otel/exporters/prometheus" - "github.com/gogf/gf/contrib/metric/otelmetric/v2" "github.com/gogf/gf/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" @@ -24,6 +23,8 @@ import ( "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/guid" + + "github.com/gogf/gf/contrib/metric/otelmetric/v2" ) func Test_HTTP_Server(t *testing.T) { diff --git a/contrib/metric/otelmetric/otelmetric_z_unit_test.go b/contrib/metric/otelmetric/otelmetric_z_unit_test.go index 9b6b78fe6f6..54c08a20ed3 100644 --- a/contrib/metric/otelmetric/otelmetric_z_unit_test.go +++ b/contrib/metric/otelmetric/otelmetric_z_unit_test.go @@ -13,12 +13,13 @@ import ( "go.opentelemetry.io/otel/sdk/metric" "go.opentelemetry.io/otel/sdk/metric/metricdata" - "github.com/gogf/gf/contrib/metric/otelmetric/v2" "github.com/gogf/gf/v2/encoding/gjson" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gmetric" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" + + "github.com/gogf/gf/contrib/metric/otelmetric/v2" ) func Test_Basic(t *testing.T) { diff --git a/contrib/nosql/redis/redis_z_group_set_test.go b/contrib/nosql/redis/redis_z_group_set_test.go index b843ab0a8b3..94bf4060842 100644 --- a/contrib/nosql/redis/redis_z_group_set_test.go +++ b/contrib/nosql/redis/redis_z_group_set_test.go @@ -7,9 +7,10 @@ package redis_test import ( + "testing" + "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/guid" - "testing" ) func Test_GroupSet_SAdd(t *testing.T) { diff --git a/contrib/nosql/redis/redis_z_unit_config_test.go b/contrib/nosql/redis/redis_z_unit_config_test.go index b11d07d51e5..e14c3f7102b 100644 --- a/contrib/nosql/redis/redis_z_unit_config_test.go +++ b/contrib/nosql/redis/redis_z_unit_config_test.go @@ -7,10 +7,10 @@ package redis_test import ( - "github.com/gogf/gf/v2/container/gvar" "testing" "time" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/database/gredis" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" diff --git a/contrib/nosql/redis/redis_z_unit_gcache_adapter_test.go b/contrib/nosql/redis/redis_z_unit_gcache_adapter_test.go index e780f51b466..73530963884 100644 --- a/contrib/nosql/redis/redis_z_unit_gcache_adapter_test.go +++ b/contrib/nosql/redis/redis_z_unit_gcache_adapter_test.go @@ -8,11 +8,11 @@ package redis_test import ( "context" - "github.com/gogf/gf/v2/frame/g" "testing" "time" "github.com/gogf/gf/v2/database/gredis" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gcache" "github.com/gogf/gf/v2/test/gtest" ) diff --git a/contrib/registry/etcd/etcd_z_test.go b/contrib/registry/etcd/etcd_z_test.go index 5dc3910a74d..c4a8194db17 100644 --- a/contrib/registry/etcd/etcd_z_test.go +++ b/contrib/registry/etcd/etcd_z_test.go @@ -9,11 +9,12 @@ package etcd_test import ( "testing" - "github.com/gogf/gf/contrib/registry/etcd/v2" "github.com/gogf/gf/v2/net/gsvc" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/guid" + + "github.com/gogf/gf/contrib/registry/etcd/v2" ) func TestRegistry(t *testing.T) { diff --git a/contrib/registry/file/file_z_basic_test.go b/contrib/registry/file/file_z_basic_test.go index 7fc7827fb92..61bd22aa6c6 100644 --- a/contrib/registry/file/file_z_basic_test.go +++ b/contrib/registry/file/file_z_basic_test.go @@ -9,12 +9,13 @@ package file_test import ( "testing" - "github.com/gogf/gf/contrib/registry/file/v2" "github.com/gogf/gf/v2/net/gsvc" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/guid" + + "github.com/gogf/gf/contrib/registry/file/v2" ) func TestRegistry(t *testing.T) { diff --git a/contrib/registry/file/file_z_http_test.go b/contrib/registry/file/file_z_http_test.go index 5edfd53c388..a1eac283b44 100644 --- a/contrib/registry/file/file_z_http_test.go +++ b/contrib/registry/file/file_z_http_test.go @@ -11,7 +11,6 @@ import ( "testing" "time" - "github.com/gogf/gf/contrib/registry/file/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/gsvc" @@ -20,6 +19,8 @@ import ( "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/guid" + + "github.com/gogf/gf/contrib/registry/file/v2" ) var ctx = gctx.GetInitCtx() diff --git a/contrib/registry/nacos/nacos.go b/contrib/registry/nacos/nacos.go index 600ebe635ee..799db2a5d40 100644 --- a/contrib/registry/nacos/nacos.go +++ b/contrib/registry/nacos/nacos.go @@ -10,6 +10,11 @@ package nacos import ( "context" + "github.com/nacos-group/nacos-sdk-go/v2/clients" + "github.com/nacos-group/nacos-sdk-go/v2/clients/naming_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/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" @@ -17,10 +22,6 @@ import ( "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" - "github.com/nacos-group/nacos-sdk-go/v2/clients" - "github.com/nacos-group/nacos-sdk-go/v2/clients/naming_client" - "github.com/nacos-group/nacos-sdk-go/v2/common/constant" - "github.com/nacos-group/nacos-sdk-go/v2/vo" ) const ( diff --git a/contrib/registry/nacos/nacos_discovery.go b/contrib/registry/nacos/nacos_discovery.go index 6e38585db7c..d9d1eecd9df 100644 --- a/contrib/registry/nacos/nacos_discovery.go +++ b/contrib/registry/nacos/nacos_discovery.go @@ -9,12 +9,13 @@ package nacos import ( "context" + "github.com/nacos-group/nacos-sdk-go/v2/model" + "github.com/nacos-group/nacos-sdk-go/v2/vo" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/net/gsvc" "github.com/gogf/gf/v2/text/gstr" - "github.com/nacos-group/nacos-sdk-go/v2/model" - "github.com/nacos-group/nacos-sdk-go/v2/vo" ) // Search searches and returns services with specified condition. diff --git a/contrib/registry/nacos/nacos_register.go b/contrib/registry/nacos/nacos_register.go index afc950c609e..0b94c97ceca 100644 --- a/contrib/registry/nacos/nacos_register.go +++ b/contrib/registry/nacos/nacos_register.go @@ -9,9 +9,10 @@ package nacos import ( "context" + "github.com/nacos-group/nacos-sdk-go/v2/vo" + "github.com/gogf/gf/v2/net/gsvc" "github.com/gogf/gf/v2/util/gconv" - "github.com/nacos-group/nacos-sdk-go/v2/vo" ) // Register registers `service` to Registry. diff --git a/contrib/registry/nacos/nacos_service.go b/contrib/registry/nacos/nacos_service.go index 8ac5f5ce1e0..ee2208c7583 100644 --- a/contrib/registry/nacos/nacos_service.go +++ b/contrib/registry/nacos/nacos_service.go @@ -9,10 +9,11 @@ package nacos import ( "fmt" + "github.com/nacos-group/nacos-sdk-go/v2/model" + "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/net/gsvc" "github.com/gogf/gf/v2/text/gstr" - "github.com/nacos-group/nacos-sdk-go/v2/model" ) // NewServiceFromInstance new one service from instance diff --git a/contrib/registry/nacos/nacos_watcher.go b/contrib/registry/nacos/nacos_watcher.go index c9454d1648e..fe34441f7d3 100644 --- a/contrib/registry/nacos/nacos_watcher.go +++ b/contrib/registry/nacos/nacos_watcher.go @@ -9,10 +9,11 @@ package nacos import ( "context" + "github.com/nacos-group/nacos-sdk-go/v2/model" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/net/gsvc" - "github.com/nacos-group/nacos-sdk-go/v2/model" ) // Watcher used to mange service event such as update. diff --git a/contrib/registry/nacos/nacos_z_test.go b/contrib/registry/nacos/nacos_z_test.go index 0470c4abbe1..f610384929e 100644 --- a/contrib/registry/nacos/nacos_z_test.go +++ b/contrib/registry/nacos/nacos_z_test.go @@ -12,13 +12,15 @@ import ( "testing" "time" - "github.com/gogf/gf/contrib/registry/nacos/v2" + "github.com/nacos-group/nacos-sdk-go/v2/common/constant" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gsvc" "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/gogf/gf/contrib/registry/nacos/v2" ) const ( diff --git a/contrib/registry/zookeeper/zookeeper.go b/contrib/registry/zookeeper/zookeeper.go index b3279185557..be4b59c8cf5 100644 --- a/contrib/registry/zookeeper/zookeeper.go +++ b/contrib/registry/zookeeper/zookeeper.go @@ -8,9 +8,10 @@ package zookeeper import ( + "time" + "github.com/go-zookeeper/zk" "golang.org/x/sync/singleflight" - "time" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/net/gsvc" diff --git a/contrib/registry/zookeeper/zookeeper_registrar.go b/contrib/registry/zookeeper/zookeeper_registrar.go index 26273a5b2a7..5a67ff0b11b 100644 --- a/contrib/registry/zookeeper/zookeeper_registrar.go +++ b/contrib/registry/zookeeper/zookeeper_registrar.go @@ -8,12 +8,13 @@ package zookeeper import ( "context" - "github.com/go-zookeeper/zk" - "github.com/gogf/gf/v2/errors/gerror" "path" "strings" "time" + "github.com/go-zookeeper/zk" + + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/net/gsvc" ) diff --git a/contrib/registry/zookeeper/zookeeper_watcher.go b/contrib/registry/zookeeper/zookeeper_watcher.go index 1ee710a17e0..5efea6f57ef 100644 --- a/contrib/registry/zookeeper/zookeeper_watcher.go +++ b/contrib/registry/zookeeper/zookeeper_watcher.go @@ -9,11 +9,12 @@ package zookeeper import ( "context" "errors" - "github.com/go-zookeeper/zk" - "golang.org/x/sync/singleflight" "path" "strings" + "github.com/go-zookeeper/zk" + "golang.org/x/sync/singleflight" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/net/gsvc" ) diff --git a/contrib/rpc/grpcx/grpcx_interceptor_client.go b/contrib/rpc/grpcx/grpcx_interceptor_client.go index d1418234931..bc185d7d1b5 100644 --- a/contrib/rpc/grpcx/grpcx_interceptor_client.go +++ b/contrib/rpc/grpcx/grpcx_interceptor_client.go @@ -12,9 +12,10 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/status" - "github.com/gogf/gf/contrib/rpc/grpcx/v2/internal/tracing" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" + + "github.com/gogf/gf/contrib/rpc/grpcx/v2/internal/tracing" ) // UnaryError handles the error types converting between grpc and gerror. diff --git a/contrib/rpc/grpcx/grpcx_interceptor_server.go b/contrib/rpc/grpcx/grpcx_interceptor_server.go index 29b922b2938..0d968f6a867 100644 --- a/contrib/rpc/grpcx/grpcx_interceptor_server.go +++ b/contrib/rpc/grpcx/grpcx_interceptor_server.go @@ -8,17 +8,18 @@ package grpcx import ( "context" - "google.golang.org/protobuf/proto" "google.golang.org/grpc" "google.golang.org/grpc/codes" "google.golang.org/grpc/status" + "google.golang.org/protobuf/proto" - "github.com/gogf/gf/contrib/rpc/grpcx/v2/internal/tracing" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/util/gutil" + + "github.com/gogf/gf/contrib/rpc/grpcx/v2/internal/tracing" ) // ChainUnary returns a ServerOption that specifies the chained interceptor diff --git a/contrib/rpc/grpcx/grpcx_registry_file.go b/contrib/rpc/grpcx/grpcx_registry_file.go index 4605b94e853..5e2fef9a733 100644 --- a/contrib/rpc/grpcx/grpcx_registry_file.go +++ b/contrib/rpc/grpcx/grpcx_registry_file.go @@ -7,12 +7,12 @@ package grpcx import ( - "github.com/gogf/gf/contrib/registry/file/v2" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gsvc" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gfile" + + "github.com/gogf/gf/contrib/registry/file/v2" ) // autoLoadAndRegisterFileRegistry checks and registers ETCD service as default service registry diff --git a/contrib/rpc/grpcx/grpcx_unit_z_ctx_test.go b/contrib/rpc/grpcx/grpcx_unit_z_ctx_test.go index cacf4e294c8..c673d13beef 100644 --- a/contrib/rpc/grpcx/grpcx_unit_z_ctx_test.go +++ b/contrib/rpc/grpcx/grpcx_unit_z_ctx_test.go @@ -12,9 +12,10 @@ import ( "google.golang.org/grpc/metadata" - "github.com/gogf/gf/contrib/rpc/grpcx/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" + + "github.com/gogf/gf/contrib/rpc/grpcx/v2" ) func Test_Ctx_Basic(t *testing.T) { diff --git a/contrib/rpc/grpcx/grpcx_unit_z_grpc_server_basic_test.go b/contrib/rpc/grpcx/grpcx_unit_z_grpc_server_basic_test.go index f3ffb137b8d..12cec2a3b36 100644 --- a/contrib/rpc/grpcx/grpcx_unit_z_grpc_server_basic_test.go +++ b/contrib/rpc/grpcx/grpcx_unit_z_grpc_server_basic_test.go @@ -11,14 +11,15 @@ import ( "testing" "time" - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - "github.com/gogf/gf/contrib/rpc/grpcx/v2/testdata/controller" - "github.com/gogf/gf/contrib/rpc/grpcx/v2/testdata/protobuf" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gipv4" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/guid" + + "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "github.com/gogf/gf/contrib/rpc/grpcx/v2/testdata/controller" + "github.com/gogf/gf/contrib/rpc/grpcx/v2/testdata/protobuf" ) func Test_Grpcx_Grpc_Server_Basic(t *testing.T) { diff --git a/contrib/rpc/grpcx/grpcx_unit_z_issue_test.go b/contrib/rpc/grpcx/grpcx_unit_z_issue_test.go index 980ab54d75b..531d0b28451 100644 --- a/contrib/rpc/grpcx/grpcx_unit_z_issue_test.go +++ b/contrib/rpc/grpcx/grpcx_unit_z_issue_test.go @@ -9,16 +9,18 @@ package grpcx_test import ( "context" "fmt" - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" "testing" "time" - "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "google.golang.org/grpc" + "google.golang.org/grpc/credentials/insecure" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/guid" + + "github.com/gogf/gf/contrib/rpc/grpcx/v2" ) var ctx = context.Background() diff --git a/contrib/rpc/grpcx/internal/balancer/balancer_builder.go b/contrib/rpc/grpcx/internal/balancer/balancer_builder.go index 6e2de321046..83cb5f5aaa2 100644 --- a/contrib/rpc/grpcx/internal/balancer/balancer_builder.go +++ b/contrib/rpc/grpcx/internal/balancer/balancer_builder.go @@ -8,6 +8,7 @@ package balancer import ( "context" + "google.golang.org/grpc/balancer" "google.golang.org/grpc/balancer/base" diff --git a/contrib/rpc/grpcx/internal/tracing/tracing_interceptor_client.go b/contrib/rpc/grpcx/internal/tracing/tracing_interceptor_client.go index a244eeb0d5b..b688446f730 100644 --- a/contrib/rpc/grpcx/internal/tracing/tracing_interceptor_client.go +++ b/contrib/rpc/grpcx/internal/tracing/tracing_interceptor_client.go @@ -18,10 +18,11 @@ import ( "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" - "github.com/gogf/gf/contrib/rpc/grpcx/v2/internal/grpcctx" "github.com/gogf/gf/v2" "github.com/gogf/gf/v2/net/gtrace" "github.com/gogf/gf/v2/util/gconv" + + "github.com/gogf/gf/contrib/rpc/grpcx/v2/internal/grpcctx" ) // UnaryClientInterceptor returns a grpc.UnaryClientInterceptor suitable diff --git a/contrib/rpc/grpcx/internal/tracing/tracing_interceptor_server.go b/contrib/rpc/grpcx/internal/tracing/tracing_interceptor_server.go index fe77c60209f..7395d5cf052 100644 --- a/contrib/rpc/grpcx/internal/tracing/tracing_interceptor_server.go +++ b/contrib/rpc/grpcx/internal/tracing/tracing_interceptor_server.go @@ -19,10 +19,11 @@ import ( "google.golang.org/grpc/metadata" "google.golang.org/grpc/status" - "github.com/gogf/gf/contrib/rpc/grpcx/v2/internal/grpcctx" "github.com/gogf/gf/v2" "github.com/gogf/gf/v2/net/gtrace" "github.com/gogf/gf/v2/util/gconv" + + "github.com/gogf/gf/contrib/rpc/grpcx/v2/internal/grpcctx" ) // UnaryServerInterceptor returns a grpc.UnaryServerInterceptor suitable diff --git a/contrib/sdk/httpclient/httpclient_z_unit_feature_handler_test.go b/contrib/sdk/httpclient/httpclient_z_unit_feature_handler_test.go index 6561f9e79b7..2babecd8801 100644 --- a/contrib/sdk/httpclient/httpclient_z_unit_feature_handler_test.go +++ b/contrib/sdk/httpclient/httpclient_z_unit_feature_handler_test.go @@ -12,7 +12,6 @@ import ( "testing" "time" - "github.com/gogf/gf/contrib/sdk/httpclient/v2" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" @@ -21,6 +20,8 @@ import ( "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/guid" + + "github.com/gogf/gf/contrib/sdk/httpclient/v2" ) func Test_HttpClient_With_Default_Handler(t *testing.T) { diff --git a/database/gdb/gdb_core_underlying.go b/database/gdb/gdb_core_underlying.go index 166f5785b68..d8c1171ca58 100644 --- a/database/gdb/gdb_core_underlying.go +++ b/database/gdb/gdb_core_underlying.go @@ -16,14 +16,13 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/trace" - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2" "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/util/gconv" "github.com/gogf/gf/v2/util/guid" ) diff --git a/debug/gdebug/gdebug_grid.go b/debug/gdebug/gdebug_grid.go index f43023d87cf..4d1aa8faad7 100644 --- a/debug/gdebug/gdebug_grid.go +++ b/debug/gdebug/gdebug_grid.go @@ -12,10 +12,8 @@ import ( "strconv" ) -var ( - // gridRegex is the regular expression object for parsing goroutine id from stack information. - gridRegex = regexp.MustCompile(`^\w+\s+(\d+)\s+`) -) +// gridRegex is the regular expression object for parsing goroutine id from stack information. +var gridRegex = regexp.MustCompile(`^\w+\s+(\d+)\s+`) // GoroutineId retrieves and returns the current goroutine id from stack information. // Be very aware that, it is with low performance as it uses runtime.Stack function. diff --git a/encoding/gcharset/gcharset.go b/encoding/gcharset/gcharset.go index 35c2e736636..5bb6a5ac008 100644 --- a/encoding/gcharset/gcharset.go +++ b/encoding/gcharset/gcharset.go @@ -33,15 +33,13 @@ import ( "github.com/gogf/gf/v2/internal/intlog" ) -var ( - // Alias for charsets. - charsetAlias = map[string]string{ - "HZGB2312": "HZ-GB-2312", - "hzgb2312": "HZ-GB-2312", - "GB2312": "HZ-GB-2312", - "gb2312": "HZ-GB-2312", - } -) +// Alias for charsets. +var charsetAlias = map[string]string{ + "HZGB2312": "HZ-GB-2312", + "hzgb2312": "HZ-GB-2312", + "GB2312": "HZ-GB-2312", + "gb2312": "HZ-GB-2312", +} // Supported returns whether charset `charset` is supported. func Supported(charset string) bool { diff --git a/encoding/ghtml/ghtml.go b/encoding/ghtml/ghtml.go index 34fa027aa78..d027fb192de 100644 --- a/encoding/ghtml/ghtml.go +++ b/encoding/ghtml/ghtml.go @@ -12,9 +12,10 @@ import ( "reflect" "strings" + strip "github.com/grokify/html-strip-tags-go" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" - strip "github.com/grokify/html-strip-tags-go" ) // StripTags strips HTML tags from content, and returns only text. diff --git a/encoding/gurl/url.go b/encoding/gurl/url.go index b4ee072c8a7..e519f348137 100644 --- a/encoding/gurl/url.go +++ b/encoding/gurl/url.go @@ -61,7 +61,7 @@ func ParseURL(str string, component int) (map[string]string, error) { if component == -1 { component = 1 | 2 | 4 | 8 | 16 | 32 | 64 | 128 } - var components = make(map[string]string) + components := make(map[string]string) if (component & 1) == 1 { components["scheme"] = u.Scheme } diff --git a/errors/gerror/gerror_error.go b/errors/gerror/gerror_error.go index 4824f9bb244..18a1811848c 100644 --- a/errors/gerror/gerror_error.go +++ b/errors/gerror/gerror_error.go @@ -28,10 +28,8 @@ const ( stackFilterKeyLocal = "/errors/gerror/gerror" ) -var ( - // goRootForFilter is used for stack filtering in development environment purpose. - goRootForFilter = runtime.GOROOT() -) +// goRootForFilter is used for stack filtering in development environment purpose. +var goRootForFilter = runtime.GOROOT() func init() { if goRootForFilter != "" { diff --git a/errors/gerror/gerror_error_stack.go b/errors/gerror/gerror_error_stack.go index 741daaa291e..553abd5a8bf 100644 --- a/errors/gerror/gerror_error_stack.go +++ b/errors/gerror/gerror_error_stack.go @@ -101,7 +101,7 @@ func filterLinesOfStackInfos(infos []*stackInfo) { // formatStackInfos formats and returns error stack information as string. func formatStackInfos(infos []*stackInfo) string { - var buffer = bytes.NewBuffer(nil) + buffer := bytes.NewBuffer(nil) for i, info := range infos { buffer.WriteString(fmt.Sprintf("%d. %s\n", i+1, info.Message)) if info.Lines != nil && info.Lines.Len() > 0 { diff --git a/example/balancer/http/client/client.go b/example/balancer/http/client/client.go index 895a3bc57cf..38f9ea0e137 100644 --- a/example/balancer/http/client/client.go +++ b/example/balancer/http/client/client.go @@ -7,11 +7,12 @@ package main import ( - "github.com/gogf/gf/contrib/registry/etcd/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gsel" "github.com/gogf/gf/v2/net/gsvc" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/registry/etcd/v2" ) func main() { diff --git a/example/balancer/http/server/server.go b/example/balancer/http/server/server.go index 3e577244177..fa157d36ee3 100644 --- a/example/balancer/http/server/server.go +++ b/example/balancer/http/server/server.go @@ -7,10 +7,11 @@ package main import ( - "github.com/gogf/gf/contrib/registry/etcd/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/gsvc" + + "github.com/gogf/gf/contrib/registry/etcd/v2" ) func main() { diff --git a/example/balancer/polaris/client/client.go b/example/balancer/polaris/client/client.go index 34a0c7ecd2c..d40fd3c719a 100644 --- a/example/balancer/polaris/client/client.go +++ b/example/balancer/polaris/client/client.go @@ -15,11 +15,12 @@ import ( "github.com/polarismesh/polaris-go/api" "github.com/polarismesh/polaris-go/pkg/config" - "github.com/gogf/gf/contrib/registry/polaris/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gsel" "github.com/gogf/gf/v2/net/gsvc" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/registry/polaris/v2" ) func main() { diff --git a/example/balancer/polaris/server/server.go b/example/balancer/polaris/server/server.go index 0de9af46392..6be2619ab21 100644 --- a/example/balancer/polaris/server/server.go +++ b/example/balancer/polaris/server/server.go @@ -13,10 +13,11 @@ import ( "github.com/polarismesh/polaris-go/api" "github.com/polarismesh/polaris-go/pkg/config" - "github.com/gogf/gf/contrib/registry/polaris/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/gsvc" + + "github.com/gogf/gf/contrib/registry/polaris/v2" ) func main() { diff --git a/example/config/apollo/boot/boot.go b/example/config/apollo/boot/boot.go index a7584e91319..73428dce3fc 100644 --- a/example/config/apollo/boot/boot.go +++ b/example/config/apollo/boot/boot.go @@ -7,9 +7,10 @@ package boot import ( - "github.com/gogf/gf/contrib/config/apollo/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/config/apollo/v2" ) func init() { diff --git a/example/config/consul/boot/boot.go b/example/config/consul/boot/boot.go index 7b090a8bd6e..996173bacf6 100644 --- a/example/config/consul/boot/boot.go +++ b/example/config/consul/boot/boot.go @@ -7,13 +7,13 @@ package boot import ( - consul "github.com/gogf/gf/contrib/config/consul/v2" - "github.com/hashicorp/consul/api" "github.com/hashicorp/go-cleanhttp" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" + + consul "github.com/gogf/gf/contrib/config/consul/v2" ) func init() { diff --git a/example/config/kubecm/boot_in_pod/boot.go b/example/config/kubecm/boot_in_pod/boot.go index da0c2e3d6ef..0836454424c 100644 --- a/example/config/kubecm/boot_in_pod/boot.go +++ b/example/config/kubecm/boot_in_pod/boot.go @@ -7,9 +7,10 @@ package boot import ( - "github.com/gogf/gf/contrib/config/kubecm/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/config/kubecm/v2" ) const ( diff --git a/example/config/kubecm/boot_out_pod/boot.go b/example/config/kubecm/boot_out_pod/boot.go index 468bdc27007..1be0210f581 100644 --- a/example/config/kubecm/boot_out_pod/boot.go +++ b/example/config/kubecm/boot_out_pod/boot.go @@ -9,9 +9,10 @@ package boot import ( "k8s.io/client-go/kubernetes" - "github.com/gogf/gf/contrib/config/kubecm/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/config/kubecm/v2" ) const ( diff --git a/example/config/nacos/boot/boot.go b/example/config/nacos/boot/boot.go index 6e657565a8e..f6e764540dc 100644 --- a/example/config/nacos/boot/boot.go +++ b/example/config/nacos/boot/boot.go @@ -10,9 +10,10 @@ import ( "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/frame/g" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/config/nacos/v2" ) func init() { diff --git a/example/config/polaris/boot/boot.go b/example/config/polaris/boot/boot.go index 09e5e45fd6c..405d902fd7a 100644 --- a/example/config/polaris/boot/boot.go +++ b/example/config/polaris/boot/boot.go @@ -7,9 +7,10 @@ package boot import ( - "github.com/gogf/gf/contrib/config/polaris/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/config/polaris/v2" ) func init() { diff --git a/example/database/mysql/driver-encrypt-decrypt-password/main.go b/example/database/mysql/driver-encrypt-decrypt-password/main.go index 421372d5f14..419eb6397c8 100644 --- a/example/database/mysql/driver-encrypt-decrypt-password/main.go +++ b/example/database/mysql/driver-encrypt-decrypt-password/main.go @@ -12,10 +12,11 @@ import ( "database/sql" "fmt" - "github.com/gogf/gf/contrib/drivers/mysql/v2" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/encoding/gbase64" "github.com/gogf/gf/v2/frame/g" + + "github.com/gogf/gf/contrib/drivers/mysql/v2" ) const ( diff --git a/example/metric/basic/main.go b/example/metric/basic/main.go index d31c696dd25..dd77a6aa867 100644 --- a/example/metric/basic/main.go +++ b/example/metric/basic/main.go @@ -11,10 +11,11 @@ import ( "go.opentelemetry.io/otel/exporters/prometheus" - "github.com/gogf/gf/contrib/metric/otelmetric/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gmetric" + + "github.com/gogf/gf/contrib/metric/otelmetric/v2" ) var ( diff --git a/example/metric/callback/main.go b/example/metric/callback/main.go index 3cc4021000c..f64931f04f9 100644 --- a/example/metric/callback/main.go +++ b/example/metric/callback/main.go @@ -11,10 +11,11 @@ import ( "go.opentelemetry.io/otel/exporters/prometheus" - "github.com/gogf/gf/contrib/metric/otelmetric/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gmetric" + + "github.com/gogf/gf/contrib/metric/otelmetric/v2" ) var ( diff --git a/example/metric/dynamic_attributes/main.go b/example/metric/dynamic_attributes/main.go index 291cf396942..6c0661e380b 100644 --- a/example/metric/dynamic_attributes/main.go +++ b/example/metric/dynamic_attributes/main.go @@ -11,10 +11,11 @@ import ( "go.opentelemetry.io/otel/exporters/prometheus" - "github.com/gogf/gf/contrib/metric/otelmetric/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gmetric" + + "github.com/gogf/gf/contrib/metric/otelmetric/v2" ) var ( diff --git a/example/metric/global_attributes/main.go b/example/metric/global_attributes/main.go index 53149d7b1ea..f57de3396fb 100644 --- a/example/metric/global_attributes/main.go +++ b/example/metric/global_attributes/main.go @@ -11,10 +11,11 @@ import ( "go.opentelemetry.io/otel/exporters/prometheus" - "github.com/gogf/gf/contrib/metric/otelmetric/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gmetric" + + "github.com/gogf/gf/contrib/metric/otelmetric/v2" ) const ( diff --git a/example/metric/http_client/main.go b/example/metric/http_client/main.go index 08830920443..4c61c640e3f 100644 --- a/example/metric/http_client/main.go +++ b/example/metric/http_client/main.go @@ -9,9 +9,10 @@ package main import ( "go.opentelemetry.io/otel/exporters/prometheus" - "github.com/gogf/gf/contrib/metric/otelmetric/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/metric/otelmetric/v2" ) func main() { diff --git a/example/metric/http_server/main.go b/example/metric/http_server/main.go index be86932923b..be3879506c1 100644 --- a/example/metric/http_server/main.go +++ b/example/metric/http_server/main.go @@ -11,10 +11,11 @@ import ( "go.opentelemetry.io/otel/exporters/prometheus" - "github.com/gogf/gf/contrib/metric/otelmetric/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/metric/otelmetric/v2" ) func main() { diff --git a/example/metric/meter_attributes/main.go b/example/metric/meter_attributes/main.go index 1ef26cd8ada..ad029d1f8d3 100644 --- a/example/metric/meter_attributes/main.go +++ b/example/metric/meter_attributes/main.go @@ -11,10 +11,11 @@ import ( "go.opentelemetry.io/otel/exporters/prometheus" - "github.com/gogf/gf/contrib/metric/otelmetric/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gmetric" + + "github.com/gogf/gf/contrib/metric/otelmetric/v2" ) const ( diff --git a/example/nosql/redis/adapter/main.go b/example/nosql/redis/adapter/main.go index 96b7cc827ab..490317efc76 100644 --- a/example/nosql/redis/adapter/main.go +++ b/example/nosql/redis/adapter/main.go @@ -4,12 +4,12 @@ import ( "context" "fmt" - "github.com/gogf/gf/contrib/nosql/redis/v2" - "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/database/gredis" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/nosql/redis/v2" ) var ( diff --git a/example/registry/etcd/grpc/client/client.go b/example/registry/etcd/grpc/client/client.go index 17293ac61ba..0ff7266c0c7 100644 --- a/example/registry/etcd/grpc/client/client.go +++ b/example/registry/etcd/grpc/client/client.go @@ -7,11 +7,13 @@ package main import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gctx" + "github.com/gogf/gf/contrib/registry/etcd/v2" "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "github.com/gogf/gf/example/registry/etcd/grpc/protobuf" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" ) func main() { diff --git a/example/registry/etcd/grpc/controller/helloworld.go b/example/registry/etcd/grpc/controller/helloworld.go index 86aa46c9ab8..c112a004e1f 100644 --- a/example/registry/etcd/grpc/controller/helloworld.go +++ b/example/registry/etcd/grpc/controller/helloworld.go @@ -10,6 +10,7 @@ import ( "context" "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "github.com/gogf/gf/example/registry/etcd/grpc/protobuf" ) diff --git a/example/registry/etcd/grpc/server/server.go b/example/registry/etcd/grpc/server/server.go index 6fdb2124b2e..d3a893dffd4 100644 --- a/example/registry/etcd/grpc/server/server.go +++ b/example/registry/etcd/grpc/server/server.go @@ -9,6 +9,7 @@ package main import ( "github.com/gogf/gf/contrib/registry/etcd/v2" "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "github.com/gogf/gf/example/registry/etcd/grpc/controller" ) diff --git a/example/registry/etcd/http/client/client.go b/example/registry/etcd/http/client/client.go index cc9f2cb800d..b0f260fc860 100644 --- a/example/registry/etcd/http/client/client.go +++ b/example/registry/etcd/http/client/client.go @@ -7,10 +7,11 @@ package main import ( - "github.com/gogf/gf/contrib/registry/etcd/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gsvc" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/registry/etcd/v2" ) func main() { diff --git a/example/registry/etcd/http/server/server.go b/example/registry/etcd/http/server/server.go index 3e577244177..fa157d36ee3 100644 --- a/example/registry/etcd/http/server/server.go +++ b/example/registry/etcd/http/server/server.go @@ -7,10 +7,11 @@ package main import ( - "github.com/gogf/gf/contrib/registry/etcd/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/gsvc" + + "github.com/gogf/gf/contrib/registry/etcd/v2" ) func main() { diff --git a/example/registry/file/client/client.go b/example/registry/file/client/client.go index ca63e2ad3d6..d6357593991 100644 --- a/example/registry/file/client/client.go +++ b/example/registry/file/client/client.go @@ -9,11 +9,12 @@ package main import ( "time" - "github.com/gogf/gf/contrib/registry/file/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gsvc" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gfile" + + "github.com/gogf/gf/contrib/registry/file/v2" ) func main() { diff --git a/example/registry/file/server/server.go b/example/registry/file/server/server.go index ef68159bd53..6da9a374025 100644 --- a/example/registry/file/server/server.go +++ b/example/registry/file/server/server.go @@ -7,11 +7,12 @@ package main import ( - "github.com/gogf/gf/contrib/registry/file/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/gsvc" "github.com/gogf/gf/v2/os/gfile" + + "github.com/gogf/gf/contrib/registry/file/v2" ) func main() { diff --git a/example/registry/nacos/grpc/client/client.go b/example/registry/nacos/grpc/client/client.go index d9f86ffa61a..f41329e9628 100644 --- a/example/registry/nacos/grpc/client/client.go +++ b/example/registry/nacos/grpc/client/client.go @@ -7,11 +7,13 @@ package main import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gctx" + "github.com/gogf/gf/contrib/registry/nacos/v2" "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "github.com/gogf/gf/example/registry/etcd/grpc/protobuf" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" ) func main() { diff --git a/example/registry/nacos/grpc/controller/helloworld.go b/example/registry/nacos/grpc/controller/helloworld.go index 86aa46c9ab8..c112a004e1f 100644 --- a/example/registry/nacos/grpc/controller/helloworld.go +++ b/example/registry/nacos/grpc/controller/helloworld.go @@ -10,6 +10,7 @@ import ( "context" "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "github.com/gogf/gf/example/registry/etcd/grpc/protobuf" ) diff --git a/example/registry/nacos/grpc/server/server.go b/example/registry/nacos/grpc/server/server.go index aa2940e2d52..cab827b28ac 100644 --- a/example/registry/nacos/grpc/server/server.go +++ b/example/registry/nacos/grpc/server/server.go @@ -9,6 +9,7 @@ package main import ( "github.com/gogf/gf/contrib/registry/nacos/v2" "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "github.com/gogf/gf/example/registry/etcd/grpc/controller" ) diff --git a/example/registry/nacos/http/client/client.go b/example/registry/nacos/http/client/client.go index 96e4ed4aa91..f2bf8635ce1 100644 --- a/example/registry/nacos/http/client/client.go +++ b/example/registry/nacos/http/client/client.go @@ -7,10 +7,11 @@ package main import ( - "github.com/gogf/gf/contrib/registry/nacos/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gsvc" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/registry/nacos/v2" ) func main() { diff --git a/example/registry/nacos/http/server/server.go b/example/registry/nacos/http/server/server.go index b2a2c6118d2..a7abece7617 100644 --- a/example/registry/nacos/http/server/server.go +++ b/example/registry/nacos/http/server/server.go @@ -7,10 +7,11 @@ package main import ( - "github.com/gogf/gf/contrib/registry/nacos/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/gsvc" + + "github.com/gogf/gf/contrib/registry/nacos/v2" ) func main() { diff --git a/example/registry/polaris/client/client.go b/example/registry/polaris/client/client.go index fb73bc93e8f..183e1a6b4a9 100644 --- a/example/registry/polaris/client/client.go +++ b/example/registry/polaris/client/client.go @@ -14,10 +14,11 @@ import ( "github.com/polarismesh/polaris-go/api" "github.com/polarismesh/polaris-go/pkg/config" - "github.com/gogf/gf/contrib/registry/polaris/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gsvc" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/registry/polaris/v2" ) func main() { diff --git a/example/registry/polaris/server/server.go b/example/registry/polaris/server/server.go index c6d9794f3e8..5a15ebb1bfd 100644 --- a/example/registry/polaris/server/server.go +++ b/example/registry/polaris/server/server.go @@ -12,10 +12,11 @@ import ( "github.com/polarismesh/polaris-go/api" "github.com/polarismesh/polaris-go/pkg/config" - "github.com/gogf/gf/contrib/registry/polaris/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/gsvc" + + "github.com/gogf/gf/contrib/registry/polaris/v2" ) func main() { diff --git a/example/rpc/grpcx/balancer/client/client.go b/example/rpc/grpcx/balancer/client/client.go index 5a3ba518cb0..99d78534147 100644 --- a/example/rpc/grpcx/balancer/client/client.go +++ b/example/rpc/grpcx/balancer/client/client.go @@ -9,10 +9,12 @@ package main import ( "context" - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - "github.com/gogf/gf/example/rpc/grpcx/balancer/protobuf" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/rpc/grpcx/v2" + + "github.com/gogf/gf/example/rpc/grpcx/balancer/protobuf" ) func main() { diff --git a/example/rpc/grpcx/balancer/controller/helloworld.go b/example/rpc/grpcx/balancer/controller/helloworld.go index e30161523fe..0dc0bbad1bf 100644 --- a/example/rpc/grpcx/balancer/controller/helloworld.go +++ b/example/rpc/grpcx/balancer/controller/helloworld.go @@ -10,6 +10,7 @@ import ( "context" "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "github.com/gogf/gf/example/rpc/grpcx/balancer/protobuf" ) diff --git a/example/rpc/grpcx/balancer/server/server.go b/example/rpc/grpcx/balancer/server/server.go index 0a938c59949..df1c276d1dc 100644 --- a/example/rpc/grpcx/balancer/server/server.go +++ b/example/rpc/grpcx/balancer/server/server.go @@ -8,6 +8,7 @@ package main import ( "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "github.com/gogf/gf/example/rpc/grpcx/balancer/controller" ) diff --git a/example/rpc/grpcx/basic/client/client.go b/example/rpc/grpcx/basic/client/client.go index f2779bf8691..e224d601aa1 100644 --- a/example/rpc/grpcx/basic/client/client.go +++ b/example/rpc/grpcx/basic/client/client.go @@ -7,10 +7,12 @@ package main import ( - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - "github.com/gogf/gf/example/rpc/grpcx/basic/protobuf" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/rpc/grpcx/v2" + + "github.com/gogf/gf/example/rpc/grpcx/basic/protobuf" ) func main() { diff --git a/example/rpc/grpcx/basic/controller/helloworld.go b/example/rpc/grpcx/basic/controller/helloworld.go index 4441e5fd0a2..10b5e900f80 100644 --- a/example/rpc/grpcx/basic/controller/helloworld.go +++ b/example/rpc/grpcx/basic/controller/helloworld.go @@ -10,6 +10,7 @@ import ( "context" "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "github.com/gogf/gf/example/rpc/grpcx/basic/protobuf" ) diff --git a/example/rpc/grpcx/basic/server/server.go b/example/rpc/grpcx/basic/server/server.go index 5afdeb44c5f..524ee1b4ee8 100644 --- a/example/rpc/grpcx/basic/server/server.go +++ b/example/rpc/grpcx/basic/server/server.go @@ -8,6 +8,7 @@ package main import ( "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "github.com/gogf/gf/example/rpc/grpcx/basic/controller" ) diff --git a/example/rpc/grpcx/ctx/client/client.go b/example/rpc/grpcx/ctx/client/client.go index 1ce67432966..2a50869080b 100644 --- a/example/rpc/grpcx/ctx/client/client.go +++ b/example/rpc/grpcx/ctx/client/client.go @@ -7,10 +7,12 @@ package main import ( - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - "github.com/gogf/gf/example/rpc/grpcx/ctx/protobuf" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/rpc/grpcx/v2" + + "github.com/gogf/gf/example/rpc/grpcx/ctx/protobuf" ) func main() { diff --git a/example/rpc/grpcx/ctx/controller/helloworld.go b/example/rpc/grpcx/ctx/controller/helloworld.go index 03a3240b8a5..839f0b8e563 100644 --- a/example/rpc/grpcx/ctx/controller/helloworld.go +++ b/example/rpc/grpcx/ctx/controller/helloworld.go @@ -9,9 +9,11 @@ package controller import ( "context" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "github.com/gogf/gf/example/rpc/grpcx/ctx/protobuf" - "github.com/gogf/gf/v2/frame/g" ) type Controller struct { diff --git a/example/rpc/grpcx/ctx/server/server.go b/example/rpc/grpcx/ctx/server/server.go index 83aa82af8c3..401e2319dbf 100644 --- a/example/rpc/grpcx/ctx/server/server.go +++ b/example/rpc/grpcx/ctx/server/server.go @@ -8,6 +8,7 @@ package main import ( "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "github.com/gogf/gf/example/rpc/grpcx/ctx/controller" ) diff --git a/example/rpc/grpcx/rawgrpc/client/client.go b/example/rpc/grpcx/rawgrpc/client/client.go index b9557d48319..e240d52afdb 100644 --- a/example/rpc/grpcx/rawgrpc/client/client.go +++ b/example/rpc/grpcx/rawgrpc/client/client.go @@ -13,14 +13,15 @@ import ( "google.golang.org/grpc" "google.golang.org/grpc/credentials/insecure" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/gsvc" + "github.com/gogf/gf/v2/os/gctx" + "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/contrib/registry/file/v2" "github.com/gogf/gf/contrib/rpc/grpcx/v2" - "github.com/gogf/gf/v2/os/gfile" pb "github.com/gogf/gf/example/rpc/grpcx/rawgrpc/helloworld" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gsvc" - "github.com/gogf/gf/v2/os/gctx" ) func main() { diff --git a/example/rpc/grpcx/rawgrpc/server/server.go b/example/rpc/grpcx/rawgrpc/server/server.go index 20edb56a68f..3000a6aa995 100644 --- a/example/rpc/grpcx/rawgrpc/server/server.go +++ b/example/rpc/grpcx/rawgrpc/server/server.go @@ -13,14 +13,16 @@ import ( "google.golang.org/grpc" - "github.com/gogf/gf/contrib/registry/file/v2" - "github.com/gogf/gf/example/rpc/grpcx/rawgrpc/helloworld" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gipv4" "github.com/gogf/gf/v2/net/gsvc" "github.com/gogf/gf/v2/net/gtcp" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gfile" + + "github.com/gogf/gf/contrib/registry/file/v2" + + "github.com/gogf/gf/example/rpc/grpcx/rawgrpc/helloworld" ) type GreetingServer struct { diff --git a/example/rpc/grpcx/resolver/client/client.go b/example/rpc/grpcx/resolver/client/client.go index ae2fefc4f9a..3623852f58d 100644 --- a/example/rpc/grpcx/resolver/client/client.go +++ b/example/rpc/grpcx/resolver/client/client.go @@ -7,11 +7,13 @@ package main import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gctx" + "github.com/gogf/gf/contrib/registry/etcd/v2" "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "github.com/gogf/gf/example/rpc/grpcx/resolver/protobuf" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" ) func main() { diff --git a/example/rpc/grpcx/resolver/controller/helloworld.go b/example/rpc/grpcx/resolver/controller/helloworld.go index 797a4580a84..08bb90fc2d8 100644 --- a/example/rpc/grpcx/resolver/controller/helloworld.go +++ b/example/rpc/grpcx/resolver/controller/helloworld.go @@ -10,6 +10,7 @@ import ( "context" "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "github.com/gogf/gf/example/rpc/grpcx/resolver/protobuf" ) diff --git a/example/rpc/grpcx/resolver/server/server.go b/example/rpc/grpcx/resolver/server/server.go index 7d8f1beb62f..dc1fe080b12 100644 --- a/example/rpc/grpcx/resolver/server/server.go +++ b/example/rpc/grpcx/resolver/server/server.go @@ -9,6 +9,7 @@ package main import ( "github.com/gogf/gf/contrib/registry/etcd/v2" "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "github.com/gogf/gf/example/rpc/grpcx/resolver/controller" ) diff --git a/example/trace/grpc-with-db/client/client.go b/example/trace/grpc-with-db/client/client.go index 22823eca91e..f5a286ba3a3 100644 --- a/example/trace/grpc-with-db/client/client.go +++ b/example/trace/grpc-with-db/client/client.go @@ -7,13 +7,15 @@ package main import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/gtrace" + "github.com/gogf/gf/v2/os/gctx" + "github.com/gogf/gf/contrib/registry/etcd/v2" "github.com/gogf/gf/contrib/rpc/grpcx/v2" "github.com/gogf/gf/contrib/trace/otlpgrpc/v2" + "github.com/gogf/gf/example/trace/grpc-with-db/protobuf/user" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gtrace" - "github.com/gogf/gf/v2/os/gctx" ) const ( diff --git a/example/trace/grpc-with-db/server/server.go b/example/trace/grpc-with-db/server/server.go index 6ef4d3a3ccf..3c11655f2a8 100644 --- a/example/trace/grpc-with-db/server/server.go +++ b/example/trace/grpc-with-db/server/server.go @@ -7,21 +7,23 @@ package main import ( - _ "github.com/gogf/gf/contrib/drivers/mysql/v2" - _ "github.com/gogf/gf/contrib/nosql/redis/v2" - "github.com/gogf/gf/contrib/registry/etcd/v2" - "github.com/gogf/gf/contrib/trace/otlpgrpc/v2" - "github.com/gogf/gf/example/trace/grpc-with-db/protobuf/user" - "context" "fmt" "time" - "github.com/gogf/gf/contrib/rpc/grpcx/v2" + _ "github.com/gogf/gf/contrib/drivers/mysql/v2" + _ "github.com/gogf/gf/contrib/nosql/redis/v2" + "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gcache" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/registry/etcd/v2" + "github.com/gogf/gf/contrib/rpc/grpcx/v2" + "github.com/gogf/gf/contrib/trace/otlpgrpc/v2" + + "github.com/gogf/gf/example/trace/grpc-with-db/protobuf/user" ) // Controller is the gRPC controller for user management. diff --git a/example/trace/http-with-db/client/client.go b/example/trace/http-with-db/client/client.go index 24afdcc701a..393ed3e95de 100644 --- a/example/trace/http-with-db/client/client.go +++ b/example/trace/http-with-db/client/client.go @@ -7,12 +7,13 @@ package main import ( - "github.com/gogf/gf/contrib/trace/otlphttp/v2" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/gtrace" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/trace/otlphttp/v2" ) const ( diff --git a/example/trace/http-with-db/server/server.go b/example/trace/http-with-db/server/server.go index fd31dba167e..ce467e10904 100644 --- a/example/trace/http-with-db/server/server.go +++ b/example/trace/http-with-db/server/server.go @@ -12,12 +12,14 @@ import ( "time" _ "github.com/gogf/gf/contrib/drivers/mysql/v2" - "github.com/gogf/gf/contrib/trace/otlphttp/v2" + "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/os/gcache" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/trace/otlphttp/v2" ) type cTrace struct{} diff --git a/example/trace/http/client/client.go b/example/trace/http/client/client.go index d092260758c..8dd74683011 100644 --- a/example/trace/http/client/client.go +++ b/example/trace/http/client/client.go @@ -7,10 +7,11 @@ package main import ( - "github.com/gogf/gf/contrib/trace/otlphttp/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gtrace" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/trace/otlphttp/v2" ) const ( diff --git a/example/trace/http/server/server.go b/example/trace/http/server/server.go index 2616df9cd42..de3114eac0b 100644 --- a/example/trace/http/server/server.go +++ b/example/trace/http/server/server.go @@ -7,11 +7,12 @@ package main import ( - "github.com/gogf/gf/contrib/trace/otlphttp/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/gtrace" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/trace/otlphttp/v2" ) const ( diff --git a/example/trace/inprocess-grpc/main.go b/example/trace/inprocess-grpc/main.go index bf8052ab683..1e084b16c8f 100644 --- a/example/trace/inprocess-grpc/main.go +++ b/example/trace/inprocess-grpc/main.go @@ -9,11 +9,12 @@ package main import ( "context" - "github.com/gogf/gf/contrib/trace/otlpgrpc/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gtrace" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/util/gutil" + + "github.com/gogf/gf/contrib/trace/otlpgrpc/v2" ) const ( diff --git a/example/trace/inprocess/main.go b/example/trace/inprocess/main.go index 3e603e037ca..c7e7ffbda9c 100644 --- a/example/trace/inprocess/main.go +++ b/example/trace/inprocess/main.go @@ -9,11 +9,12 @@ package main import ( "context" - "github.com/gogf/gf/contrib/trace/otlphttp/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gtrace" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/util/gutil" + + "github.com/gogf/gf/contrib/trace/otlphttp/v2" ) const ( diff --git a/example/trace/otlp/grpc/main.go b/example/trace/otlp/grpc/main.go index 8703d04b9cb..a20e63dba7b 100644 --- a/example/trace/otlp/grpc/main.go +++ b/example/trace/otlp/grpc/main.go @@ -7,11 +7,11 @@ package main import ( - "github.com/gogf/gf/contrib/trace/otlpgrpc/v2" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gtrace" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/trace/otlpgrpc/v2" ) const ( diff --git a/example/trace/otlp/http/main.go b/example/trace/otlp/http/main.go index 4994f882e91..aa1454ebaf5 100644 --- a/example/trace/otlp/http/main.go +++ b/example/trace/otlp/http/main.go @@ -7,10 +7,11 @@ package main import ( - "github.com/gogf/gf/contrib/trace/otlphttp/v2" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/gtrace" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/trace/otlphttp/v2" ) const ( diff --git a/example/trace/provider/grpc/main.go b/example/trace/provider/grpc/main.go index 7d5606f1d92..40a9a5aaad9 100644 --- a/example/trace/provider/grpc/main.go +++ b/example/trace/provider/grpc/main.go @@ -18,10 +18,10 @@ import ( semconv "go.opentelemetry.io/otel/semconv/v1.24.0" "google.golang.org/grpc/encoding/gzip" - "github.com/gogf/gf/example/trace/provider/internal" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/example/trace/provider/internal" ) func main() { diff --git a/example/trace/provider/http/main.go b/example/trace/provider/http/main.go index 6f66c7eb9f1..c6f63a6350f 100644 --- a/example/trace/provider/http/main.go +++ b/example/trace/provider/http/main.go @@ -16,9 +16,10 @@ import ( "go.opentelemetry.io/otel/sdk/trace" semconv "go.opentelemetry.io/otel/semconv/v1.24.0" - "github.com/gogf/gf/example/trace/provider/internal" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/example/trace/provider/internal" ) func main() { diff --git a/i18n/gi18n/gi18n_z_unit_test.go b/i18n/gi18n/gi18n_z_unit_test.go index af44d226bf7..2a1d672a4f0 100644 --- a/i18n/gi18n/gi18n_z_unit_test.go +++ b/i18n/gi18n/gi18n_z_unit_test.go @@ -7,17 +7,15 @@ package gi18n_test import ( - "time" - - "github.com/gogf/gf/v2/encoding/gbase64" - "github.com/gogf/gf/v2/os/gctx" - "context" "testing" + "time" "github.com/gogf/gf/v2/debug/gdebug" + "github.com/gogf/gf/v2/encoding/gbase64" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/i18n/gi18n" + "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gres" "github.com/gogf/gf/v2/os/gtime" diff --git a/internal/errors/errors.go b/internal/errors/errors.go index 8ab919c12cb..b1f83aa5e53 100644 --- a/internal/errors/errors.go +++ b/internal/errors/errors.go @@ -31,11 +31,9 @@ const ( StackModeDetail StackMode = "detail" ) -var ( - // stackModeConfigured is the configured error stack mode variable. - // It is brief stack mode in default. - stackModeConfigured = StackModeBrief -) +// stackModeConfigured is the configured error stack mode variable. +// It is brief stack mode in default. +var stackModeConfigured = StackModeBrief func init() { // Deprecated. diff --git a/internal/utils/utils_debug.go b/internal/utils/utils_debug.go index 5584341b847..9b26e78b83d 100644 --- a/internal/utils/utils_debug.go +++ b/internal/utils/utils_debug.go @@ -15,10 +15,8 @@ const ( commandEnvKeyForDebugKey = "gf.debug" ) -var ( - // isDebugEnabled marks whether GoFrame debug mode is enabled. - isDebugEnabled = false -) +// isDebugEnabled marks whether GoFrame debug mode is enabled. +var isDebugEnabled = false func init() { // Debugging configured. diff --git a/internal/utils/utils_is.go b/internal/utils/utils_is.go index e7fa2e3388f..01fe759ee7f 100644 --- a/internal/utils/utils_is.go +++ b/internal/utils/utils_is.go @@ -85,11 +85,11 @@ func IsMap(value interface{}) bool { // IsStruct checks whether `value` is type of struct. func IsStruct(value interface{}) bool { - var reflectType = reflect.TypeOf(value) + reflectType := reflect.TypeOf(value) if reflectType == nil { return false } - var reflectKind = reflectType.Kind() + reflectKind := reflectType.Kind() for reflectKind == reflect.Ptr { reflectType = reflectType.Elem() reflectKind = reflectType.Kind() diff --git a/internal/utils/utils_str.go b/internal/utils/utils_str.go index 9f1089d509e..01d47819070 100644 --- a/internal/utils/utils_str.go +++ b/internal/utils/utils_str.go @@ -11,20 +11,18 @@ import ( "strings" ) -var ( - // DefaultTrimChars are the characters which are stripped by Trim* functions in default. - DefaultTrimChars = string([]byte{ - '\t', // Tab. - '\v', // Vertical tab. - '\n', // New line (line feed). - '\r', // Carriage return. - '\f', // New page. - ' ', // Ordinary space. - 0x00, // NUL-byte. - 0x85, // Delete. - 0xA0, // Non-breaking space. - }) -) +// DefaultTrimChars are the characters which are stripped by Trim* functions in default. +var DefaultTrimChars = string([]byte{ + '\t', // Tab. + '\v', // Vertical tab. + '\n', // New line (line feed). + '\r', // Carriage return. + '\f', // New page. + ' ', // Ordinary space. + 0x00, // NUL-byte. + 0x85, // Delete. + 0xA0, // Non-breaking space. +}) // IsLetterUpper checks whether the given byte b is in upper case. func IsLetterUpper(b byte) bool { @@ -101,7 +99,7 @@ func ReplaceByMap(origin string, replaces map[string]string) string { // RemoveSymbols removes all symbols from string and lefts only numbers and letters. func RemoveSymbols(s string) string { - var b = make([]rune, 0, len(s)) + b := make([]rune, 0, len(s)) for _, c := range s { if c > 127 { b = append(b, c) diff --git a/net/ghttp/ghttp_z_unit_feature_https_test.go b/net/ghttp/ghttp_z_unit_feature_https_test.go index 35c269982da..fe728d2f10b 100644 --- a/net/ghttp/ghttp_z_unit_feature_https_test.go +++ b/net/ghttp/ghttp_z_unit_feature_https_test.go @@ -7,12 +7,12 @@ package ghttp_test import ( - _ "github.com/gogf/gf/v2/net/ghttp/testdata/https/packed" - "fmt" "testing" "time" + _ "github.com/gogf/gf/v2/net/ghttp/testdata/https/packed" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/net/gtcp" diff --git a/net/ghttp/ghttp_z_unit_feature_pprof_test.go b/net/ghttp/ghttp_z_unit_feature_pprof_test.go index d6b355e7e77..ca8d428cbc1 100644 --- a/net/ghttp/ghttp_z_unit_feature_pprof_test.go +++ b/net/ghttp/ghttp_z_unit_feature_pprof_test.go @@ -13,9 +13,10 @@ import ( "testing" "time" + . "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" - . "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/guid" ) diff --git a/net/ghttp/ghttp_z_unit_feature_request_file_test.go b/net/ghttp/ghttp_z_unit_feature_request_file_test.go index 9d354461718..f2318f3c2de 100644 --- a/net/ghttp/ghttp_z_unit_feature_request_file_test.go +++ b/net/ghttp/ghttp_z_unit_feature_request_file_test.go @@ -13,9 +13,8 @@ import ( "testing" "time" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/net/ghttp" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gtime" diff --git a/net/ghttp/ghttp_z_unit_feature_response_test.go b/net/ghttp/ghttp_z_unit_feature_response_test.go index c0e2b565bba..6615baada73 100644 --- a/net/ghttp/ghttp_z_unit_feature_response_test.go +++ b/net/ghttp/ghttp_z_unit_feature_response_test.go @@ -14,11 +14,10 @@ import ( "time" "github.com/gogf/gf/v2/encoding/gxml" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/os/gview" - "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/os/gview" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/util/guid" ) diff --git a/net/gtrace/gtrace.go b/net/gtrace/gtrace.go index 15f6e128e55..d1e72273bf7 100644 --- a/net/gtrace/gtrace.go +++ b/net/gtrace/gtrace.go @@ -15,7 +15,7 @@ import ( "go.opentelemetry.io/otel" "go.opentelemetry.io/otel/attribute" "go.opentelemetry.io/otel/propagation" - semconv "go.opentelemetry.io/otel/semconv/v1.18.0" + semconv "go.opentelemetry.io/otel/semconv/v1.24.0" "go.opentelemetry.io/otel/trace" "github.com/gogf/gf/v2/container/gmap" diff --git a/net/gtrace/gtrace_content.go b/net/gtrace/gtrace_content.go index ccb82601c17..7d596426aeb 100644 --- a/net/gtrace/gtrace_content.go +++ b/net/gtrace/gtrace_content.go @@ -11,7 +11,6 @@ import ( "strings" "github.com/gogf/gf/v2/encoding/gcompress" - "github.com/gogf/gf/v2/text/gstr" ) diff --git a/net/gtrace/gtrace_z_unit_test.go b/net/gtrace/gtrace_z_unit_test.go index 700c587dc75..604fd7f6e79 100644 --- a/net/gtrace/gtrace_z_unit_test.go +++ b/net/gtrace/gtrace_z_unit_test.go @@ -13,7 +13,6 @@ import ( "testing" "github.com/gogf/gf/v2/encoding/gcompress" - "github.com/gogf/gf/v2/net/gtrace" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" diff --git a/os/gcache/gcache_adapter_memory_lru.go b/os/gcache/gcache_adapter_memory_lru.go index 318bb2171f3..cf7f71c438d 100644 --- a/os/gcache/gcache_adapter_memory_lru.go +++ b/os/gcache/gcache_adapter_memory_lru.go @@ -7,9 +7,10 @@ package gcache import ( + "sync" + "github.com/gogf/gf/v2/container/glist" "github.com/gogf/gf/v2/container/gmap" - "sync" ) // memoryLru holds LRU info. diff --git a/os/gcache/gcache_cache.go b/os/gcache/gcache_cache.go index 7cae6c7c8c5..939227731e1 100644 --- a/os/gcache/gcache_cache.go +++ b/os/gcache/gcache_cache.go @@ -8,6 +8,7 @@ package gcache import ( "context" + "github.com/gogf/gf/v2/util/gconv" ) diff --git a/os/gfsnotify/gfsnotify_watcher_loop.go b/os/gfsnotify/gfsnotify_watcher_loop.go index dca551fdf6a..dc12d576389 100644 --- a/os/gfsnotify/gfsnotify_watcher_loop.go +++ b/os/gfsnotify/gfsnotify_watcher_loop.go @@ -8,10 +8,10 @@ package gfsnotify import ( "context" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/container/glist" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" ) diff --git a/os/gres/gres_z_unit_test.go b/os/gres/gres_z_unit_test.go index 3f6cd416952..4b065373058 100644 --- a/os/gres/gres_z_unit_test.go +++ b/os/gres/gres_z_unit_test.go @@ -7,11 +7,11 @@ package gres_test import ( - _ "github.com/gogf/gf/v2/os/gres/testdata/data" - "strings" "testing" + _ "github.com/gogf/gf/v2/os/gres/testdata/data" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gres" diff --git a/os/gstructs/gstructs_field.go b/os/gstructs/gstructs_field.go index 639291fd25c..5fc234242f3 100644 --- a/os/gstructs/gstructs_field.go +++ b/os/gstructs/gstructs_field.go @@ -50,9 +50,7 @@ func (f *Field) TagStr() string { // TagMap returns all the tag of the field along with its value string as map. func (f *Field) TagMap() map[string]string { - var ( - data = ParseTag(f.TagStr()) - ) + data := ParseTag(f.TagStr()) for k, v := range data { data[k] = utils.StripSlashes(gtag.Parse(v)) } diff --git a/os/gstructs/gstructs_field_tag.go b/os/gstructs/gstructs_field_tag.go index c08d98c0f7f..fa7211515d6 100644 --- a/os/gstructs/gstructs_field_tag.go +++ b/os/gstructs/gstructs_field_tag.go @@ -98,7 +98,7 @@ func (f *Field) TagIn() string { // TagPriorityName checks and returns tag name that matches the name item in `gtag.StructTagPriority`. // It or else returns attribute field Name if it doesn't have a tag name by `gtag.StructsTagPriority`. func (f *Field) TagPriorityName() string { - var name = f.Name() + name := f.Name() for _, tagName := range gtag.StructTagPriority { if tagValue := f.Tag(tagName); tagValue != "" { name = tagValue diff --git a/os/gtime/gtime.go b/os/gtime/gtime.go index ec71dcbddbb..f09ed0eff19 100644 --- a/os/gtime/gtime.go +++ b/os/gtime/gtime.go @@ -377,9 +377,7 @@ func ParseTimeFromContent(content string, format ...string) *Time { // // Very note that it supports unit "d" more than function time.ParseDuration. func ParseDuration(s string) (duration time.Duration, err error) { - var ( - num int64 - ) + var num int64 if utils.IsNumeric(s) { num, err = strconv.ParseInt(s, 10, 64) if err != nil { diff --git a/os/gtimer/gtimer_entry.go b/os/gtimer/gtimer_entry.go index fd76688989d..791b4401cb1 100644 --- a/os/gtimer/gtimer_entry.go +++ b/os/gtimer/gtimer_entry.go @@ -9,9 +9,8 @@ package gtimer import ( "context" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" ) diff --git a/util/grand/grand_buffer.go b/util/grand/grand_buffer.go index 4f527babc3b..75d1fb72408 100644 --- a/util/grand/grand_buffer.go +++ b/util/grand/grand_buffer.go @@ -18,11 +18,9 @@ const ( bufferChanSize = 10000 ) -var ( - // bufferChan is the buffer for random bytes, - // every item storing 4 bytes. - bufferChan = make(chan []byte, bufferChanSize) -) +// bufferChan is the buffer for random bytes, +// every item storing 4 bytes. +var bufferChan = make(chan []byte, bufferChanSize) func init() { go asyncProducingRandomBufferBytesLoop() diff --git a/util/gtag/gtag_enums.go b/util/gtag/gtag_enums.go index 2c9d65c3a01..10a4dbe973c 100644 --- a/util/gtag/gtag_enums.go +++ b/util/gtag/gtag_enums.go @@ -10,10 +10,8 @@ import ( "github.com/gogf/gf/v2/internal/json" ) -var ( - // Type name => enums json. - enumsMap = make(map[string]json.RawMessage) -) +// Type name => enums json. +var enumsMap = make(map[string]json.RawMessage) // SetGlobalEnums sets the global enums into package. // Note that this operation is not concurrent safety. diff --git a/util/gutil/gutil_z_example_test.go b/util/gutil/gutil_z_example_test.go index b885e06c739..aeb54922589 100644 --- a/util/gutil/gutil_z_example_test.go +++ b/util/gutil/gutil_z_example_test.go @@ -8,6 +8,7 @@ package gutil_test import ( "fmt" + "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/util/gutil" ) From e18331aa2c1ac37d9c5ae6380a0722972fbf7264 Mon Sep 17 00:00:00 2001 From: houseme Date: Sat, 7 Dec 2024 14:19:36 +0800 Subject: [PATCH 036/102] docs(cmd/gen): improve comments for command `gen dao` (#4007) --- .github/workflows/ci-main.sh | 2 +- .github/workflows/ci-main.yml | 2 +- .../generated_user/dao/internal/table_user.go | 22 ++++++------ .../gendao/generated_user/dao/table_user.go | 12 +++---- .../dao/internal/table_user.go | 22 ++++++------ .../dao/table_user.go | 12 +++---- .../dao/internal/table_user.go | 22 ++++++------ .../generated_user_sqlite3/dao/table_user.go | 12 +++---- .../dao/internal/table_user.go | 22 ++++++------ .../dao/table_user.go | 12 +++---- .../internal/cmd/testdata/gendao/go.mod.txt | 10 +++--- .../issue/2572/dao/internal/user_3.go | 22 ++++++------ .../issue/2572/dao/internal/user_4.go | 22 ++++++------ .../cmd/testdata/issue/2572/dao/user_3.go | 12 +++---- .../cmd/testdata/issue/2572/dao/user_4.go | 12 +++---- .../issue/2616/dao/internal/user_1.go | 22 ++++++------ .../issue/2616/dao/internal/user_2.go | 22 ++++++------ .../issue/2616/dao/internal/user_3.go | 22 ++++++------ .../issue/2616/dao/internal/user_4.go | 22 ++++++------ .../cmd/testdata/issue/2616/dao/user_1.go | 12 +++---- .../cmd/testdata/issue/2616/dao/user_2.go | 12 +++---- .../cmd/testdata/issue/2616/dao/user_3.go | 12 +++---- .../cmd/testdata/issue/2616/dao/user_4.go | 12 +++---- .../issue/3749/dao/internal/table_user.go | 22 ++++++------ .../cmd/testdata/issue/3749/dao/table_user.go | 12 +++---- .../consts/consts_gen_dao_template_dao.go | 34 +++++++++---------- 26 files changed, 211 insertions(+), 211 deletions(-) diff --git a/.github/workflows/ci-main.sh b/.github/workflows/ci-main.sh index 85078dc885e..39d094c9d8e 100644 --- a/.github/workflows/ci-main.sh +++ b/.github/workflows/ci-main.sh @@ -49,7 +49,7 @@ for file in `find . -name go.mod`; do # package example needs golang >= v1.20 if [ "example" = $(basename $dirpath) ]; then - if ! go version|grep -qE "go1.[2-9][0-9]"; then + if ! go version|grep -qE "go1.[2-9][1-9]"; then echo "ignore example as go version: $(go version)" continue 1 fi diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index 8daf6bf2ea0..c5c73440092 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -225,7 +225,7 @@ jobs: - name: Install Protoc uses: arduino/setup-protoc@v2 with: - version: "23.x" + version: "29.x" repo-token: ${{ secrets.GITHUB_TOKEN }} - name: Install the protocol compiler plugins for Go diff --git a/cmd/gf/internal/cmd/testdata/gendao/generated_user/dao/internal/table_user.go b/cmd/gf/internal/cmd/testdata/gendao/generated_user/dao/internal/table_user.go index f883408e46e..68d96fb0619 100644 --- a/cmd/gf/internal/cmd/testdata/gendao/generated_user/dao/internal/table_user.go +++ b/cmd/gf/internal/cmd/testdata/gendao/generated_user/dao/internal/table_user.go @@ -11,14 +11,14 @@ import ( "github.com/gogf/gf/v2/frame/g" ) -// TableUserDao is the data access object for table table_user. +// TableUserDao is the data access object for the table table_user. type TableUserDao struct { table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of current DAO. + group string // group is the database configuration group name of the current DAO. columns TableUserColumns // columns contains all the column names of Table for convenient usage. } -// TableUserColumns defines and stores column names for table table_user. +// TableUserColumns defines and stores column names for the table table_user. type TableUserColumns struct { Id string // User ID Passport string // User Passport @@ -29,7 +29,7 @@ type TableUserColumns struct { UpdateAt string // Updated Time } -// tableUserColumns holds the columns for table table_user. +// tableUserColumns holds the columns for the table table_user. var tableUserColumns = TableUserColumns{ Id: "id", Passport: "passport", @@ -49,36 +49,36 @@ func NewTableUserDao() *TableUserDao { } } -// DB retrieves and returns the underlying raw database management object of current DAO. +// DB retrieves and returns the underlying raw database management object of the current DAO. func (dao *TableUserDao) DB() gdb.DB { return g.DB(dao.group) } -// Table returns the table name of current dao. +// Table returns the table name of the current DAO. func (dao *TableUserDao) Table() string { return dao.table } -// Columns returns all column names of current dao. +// Columns returns all column names of the current DAO. func (dao *TableUserDao) Columns() TableUserColumns { return dao.columns } -// Group returns the configuration group name of database of current dao. +// Group returns the database configuration group name of the current DAO. func (dao *TableUserDao) Group() string { return dao.group } -// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *TableUserDao) Ctx(ctx context.Context) *gdb.Model { return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. -// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It rolls back the transaction and returns the error if function f returns a non-nil error. // It commits the transaction and returns nil if function f returns nil. // -// Note that, you should not Commit or Rollback the transaction in function f +// Note: Do not commit or roll back the transaction in function f, // as it is automatically handled by this function. func (dao *TableUserDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { return dao.Ctx(ctx).Transaction(ctx, f) diff --git a/cmd/gf/internal/cmd/testdata/gendao/generated_user/dao/table_user.go b/cmd/gf/internal/cmd/testdata/gendao/generated_user/dao/table_user.go index 9bc9cff6f7d..28d2d47973d 100644 --- a/cmd/gf/internal/cmd/testdata/gendao/generated_user/dao/table_user.go +++ b/cmd/gf/internal/cmd/testdata/gendao/generated_user/dao/table_user.go @@ -1,5 +1,5 @@ // ================================================================================= -// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // ================================================================================= package dao @@ -8,20 +8,20 @@ import ( "for-gendao-test/pkg/dao/internal" ) -// internalTableUserDao is internal type for wrapping internal DAO implements. +// internalTableUserDao is an internal type for wrapping the internal DAO implementation. type internalTableUserDao = *internal.TableUserDao -// tableUserDao is the data access object for table table_user. -// You can define custom methods on it to extend its functionality as you wish. +// tableUserDao is the data access object for the table table_user. +// You can define custom methods on it to extend its functionality as needed. type tableUserDao struct { internalTableUserDao } var ( - // TableUser is globally public accessible object for table table_user operations. + // TableUser is a globally accessible object for table table_user operations. TableUser = tableUserDao{ internal.NewTableUserDao(), } ) -// Fill with you ideas below. +// Add your custom methods and functionality below. diff --git a/cmd/gf/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/internal/table_user.go b/cmd/gf/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/internal/table_user.go index f883408e46e..68d96fb0619 100644 --- a/cmd/gf/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/internal/table_user.go +++ b/cmd/gf/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/internal/table_user.go @@ -11,14 +11,14 @@ import ( "github.com/gogf/gf/v2/frame/g" ) -// TableUserDao is the data access object for table table_user. +// TableUserDao is the data access object for the table table_user. type TableUserDao struct { table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of current DAO. + group string // group is the database configuration group name of the current DAO. columns TableUserColumns // columns contains all the column names of Table for convenient usage. } -// TableUserColumns defines and stores column names for table table_user. +// TableUserColumns defines and stores column names for the table table_user. type TableUserColumns struct { Id string // User ID Passport string // User Passport @@ -29,7 +29,7 @@ type TableUserColumns struct { UpdateAt string // Updated Time } -// tableUserColumns holds the columns for table table_user. +// tableUserColumns holds the columns for the table table_user. var tableUserColumns = TableUserColumns{ Id: "id", Passport: "passport", @@ -49,36 +49,36 @@ func NewTableUserDao() *TableUserDao { } } -// DB retrieves and returns the underlying raw database management object of current DAO. +// DB retrieves and returns the underlying raw database management object of the current DAO. func (dao *TableUserDao) DB() gdb.DB { return g.DB(dao.group) } -// Table returns the table name of current dao. +// Table returns the table name of the current DAO. func (dao *TableUserDao) Table() string { return dao.table } -// Columns returns all column names of current dao. +// Columns returns all column names of the current DAO. func (dao *TableUserDao) Columns() TableUserColumns { return dao.columns } -// Group returns the configuration group name of database of current dao. +// Group returns the database configuration group name of the current DAO. func (dao *TableUserDao) Group() string { return dao.group } -// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *TableUserDao) Ctx(ctx context.Context) *gdb.Model { return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. -// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It rolls back the transaction and returns the error if function f returns a non-nil error. // It commits the transaction and returns nil if function f returns nil. // -// Note that, you should not Commit or Rollback the transaction in function f +// Note: Do not commit or roll back the transaction in function f, // as it is automatically handled by this function. func (dao *TableUserDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { return dao.Ctx(ctx).Transaction(ctx, f) diff --git a/cmd/gf/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/table_user.go b/cmd/gf/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/table_user.go index 9bc9cff6f7d..28d2d47973d 100644 --- a/cmd/gf/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/table_user.go +++ b/cmd/gf/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/table_user.go @@ -1,5 +1,5 @@ // ================================================================================= -// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // ================================================================================= package dao @@ -8,20 +8,20 @@ import ( "for-gendao-test/pkg/dao/internal" ) -// internalTableUserDao is internal type for wrapping internal DAO implements. +// internalTableUserDao is an internal type for wrapping the internal DAO implementation. type internalTableUserDao = *internal.TableUserDao -// tableUserDao is the data access object for table table_user. -// You can define custom methods on it to extend its functionality as you wish. +// tableUserDao is the data access object for the table table_user. +// You can define custom methods on it to extend its functionality as needed. type tableUserDao struct { internalTableUserDao } var ( - // TableUser is globally public accessible object for table table_user operations. + // TableUser is a globally accessible object for table table_user operations. TableUser = tableUserDao{ internal.NewTableUserDao(), } ) -// Fill with you ideas below. +// Add your custom methods and functionality below. diff --git a/cmd/gf/internal/cmd/testdata/gendao/generated_user_sqlite3/dao/internal/table_user.go b/cmd/gf/internal/cmd/testdata/gendao/generated_user_sqlite3/dao/internal/table_user.go index 3c84716f2d6..8484c101957 100644 --- a/cmd/gf/internal/cmd/testdata/gendao/generated_user_sqlite3/dao/internal/table_user.go +++ b/cmd/gf/internal/cmd/testdata/gendao/generated_user_sqlite3/dao/internal/table_user.go @@ -11,14 +11,14 @@ import ( "github.com/gogf/gf/v2/frame/g" ) -// TableUserDao is the data access object for table table_user. +// TableUserDao is the data access object for the table table_user. type TableUserDao struct { table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of current DAO. + group string // group is the database configuration group name of the current DAO. columns TableUserColumns // columns contains all the column names of Table for convenient usage. } -// TableUserColumns defines and stores column names for table table_user. +// TableUserColumns defines and stores column names for the table table_user. type TableUserColumns struct { Id string // Passport string // @@ -28,7 +28,7 @@ type TableUserColumns struct { UpdatedAt string // } -// tableUserColumns holds the columns for table table_user. +// tableUserColumns holds the columns for the table table_user. var tableUserColumns = TableUserColumns{ Id: "id", Passport: "passport", @@ -47,36 +47,36 @@ func NewTableUserDao() *TableUserDao { } } -// DB retrieves and returns the underlying raw database management object of current DAO. +// DB retrieves and returns the underlying raw database management object of the current DAO. func (dao *TableUserDao) DB() gdb.DB { return g.DB(dao.group) } -// Table returns the table name of current dao. +// Table returns the table name of the current DAO. func (dao *TableUserDao) Table() string { return dao.table } -// Columns returns all column names of current dao. +// Columns returns all column names of the current DAO. func (dao *TableUserDao) Columns() TableUserColumns { return dao.columns } -// Group returns the configuration group name of database of current dao. +// Group returns the database configuration group name of the current DAO. func (dao *TableUserDao) Group() string { return dao.group } -// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *TableUserDao) Ctx(ctx context.Context) *gdb.Model { return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. -// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It rolls back the transaction and returns the error if function f returns a non-nil error. // It commits the transaction and returns nil if function f returns nil. // -// Note that, you should not Commit or Rollback the transaction in function f +// Note: Do not commit or roll back the transaction in function f, // as it is automatically handled by this function. func (dao *TableUserDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { return dao.Ctx(ctx).Transaction(ctx, f) diff --git a/cmd/gf/internal/cmd/testdata/gendao/generated_user_sqlite3/dao/table_user.go b/cmd/gf/internal/cmd/testdata/gendao/generated_user_sqlite3/dao/table_user.go index 9bc9cff6f7d..28d2d47973d 100644 --- a/cmd/gf/internal/cmd/testdata/gendao/generated_user_sqlite3/dao/table_user.go +++ b/cmd/gf/internal/cmd/testdata/gendao/generated_user_sqlite3/dao/table_user.go @@ -1,5 +1,5 @@ // ================================================================================= -// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // ================================================================================= package dao @@ -8,20 +8,20 @@ import ( "for-gendao-test/pkg/dao/internal" ) -// internalTableUserDao is internal type for wrapping internal DAO implements. +// internalTableUserDao is an internal type for wrapping the internal DAO implementation. type internalTableUserDao = *internal.TableUserDao -// tableUserDao is the data access object for table table_user. -// You can define custom methods on it to extend its functionality as you wish. +// tableUserDao is the data access object for the table table_user. +// You can define custom methods on it to extend its functionality as needed. type tableUserDao struct { internalTableUserDao } var ( - // TableUser is globally public accessible object for table table_user operations. + // TableUser is a globally accessible object for table table_user operations. TableUser = tableUserDao{ internal.NewTableUserDao(), } ) -// Fill with you ideas below. +// Add your custom methods and functionality below. diff --git a/cmd/gf/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/internal/table_user.go b/cmd/gf/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/internal/table_user.go index f883408e46e..68d96fb0619 100644 --- a/cmd/gf/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/internal/table_user.go +++ b/cmd/gf/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/internal/table_user.go @@ -11,14 +11,14 @@ import ( "github.com/gogf/gf/v2/frame/g" ) -// TableUserDao is the data access object for table table_user. +// TableUserDao is the data access object for the table table_user. type TableUserDao struct { table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of current DAO. + group string // group is the database configuration group name of the current DAO. columns TableUserColumns // columns contains all the column names of Table for convenient usage. } -// TableUserColumns defines and stores column names for table table_user. +// TableUserColumns defines and stores column names for the table table_user. type TableUserColumns struct { Id string // User ID Passport string // User Passport @@ -29,7 +29,7 @@ type TableUserColumns struct { UpdateAt string // Updated Time } -// tableUserColumns holds the columns for table table_user. +// tableUserColumns holds the columns for the table table_user. var tableUserColumns = TableUserColumns{ Id: "id", Passport: "passport", @@ -49,36 +49,36 @@ func NewTableUserDao() *TableUserDao { } } -// DB retrieves and returns the underlying raw database management object of current DAO. +// DB retrieves and returns the underlying raw database management object of the current DAO. func (dao *TableUserDao) DB() gdb.DB { return g.DB(dao.group) } -// Table returns the table name of current dao. +// Table returns the table name of the current DAO. func (dao *TableUserDao) Table() string { return dao.table } -// Columns returns all column names of current dao. +// Columns returns all column names of the current DAO. func (dao *TableUserDao) Columns() TableUserColumns { return dao.columns } -// Group returns the configuration group name of database of current dao. +// Group returns the database configuration group name of the current DAO. func (dao *TableUserDao) Group() string { return dao.group } -// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *TableUserDao) Ctx(ctx context.Context) *gdb.Model { return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. -// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It rolls back the transaction and returns the error if function f returns a non-nil error. // It commits the transaction and returns nil if function f returns nil. // -// Note that, you should not Commit or Rollback the transaction in function f +// Note: Do not commit or roll back the transaction in function f, // as it is automatically handled by this function. func (dao *TableUserDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { return dao.Ctx(ctx).Transaction(ctx, f) diff --git a/cmd/gf/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/table_user.go b/cmd/gf/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/table_user.go index 9bc9cff6f7d..28d2d47973d 100644 --- a/cmd/gf/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/table_user.go +++ b/cmd/gf/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/table_user.go @@ -1,5 +1,5 @@ // ================================================================================= -// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // ================================================================================= package dao @@ -8,20 +8,20 @@ import ( "for-gendao-test/pkg/dao/internal" ) -// internalTableUserDao is internal type for wrapping internal DAO implements. +// internalTableUserDao is an internal type for wrapping the internal DAO implementation. type internalTableUserDao = *internal.TableUserDao -// tableUserDao is the data access object for table table_user. -// You can define custom methods on it to extend its functionality as you wish. +// tableUserDao is the data access object for the table table_user. +// You can define custom methods on it to extend its functionality as needed. type tableUserDao struct { internalTableUserDao } var ( - // TableUser is globally public accessible object for table table_user operations. + // TableUser is a globally accessible object for table table_user operations. TableUser = tableUserDao{ internal.NewTableUserDao(), } ) -// Fill with you ideas below. +// Add your custom methods and functionality below. diff --git a/cmd/gf/internal/cmd/testdata/gendao/go.mod.txt b/cmd/gf/internal/cmd/testdata/gendao/go.mod.txt index c1213050b56..ca87c963168 100644 --- a/cmd/gf/internal/cmd/testdata/gendao/go.mod.txt +++ b/cmd/gf/internal/cmd/testdata/gendao/go.mod.txt @@ -1,9 +1,9 @@ module for-gendao-test/pkg -go 1.18 +go 1.20 require ( - github.com/gogf/gf/v2 v2.5.3 + github.com/gogf/gf/v2 v2.8.1 github.com/shopspring/decimal v1.3.1 ) @@ -22,9 +22,9 @@ require ( github.com/mattn/go-runewidth v0.0.15 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/rivo/uniseg v0.4.4 // indirect - go.opentelemetry.io/otel v1.14.0 // indirect - go.opentelemetry.io/otel/sdk v1.14.0 // indirect - go.opentelemetry.io/otel/trace v1.14.0 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/sdk v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.24.0 // indirect golang.org/x/net v0.17.0 // indirect golang.org/x/sys v0.13.0 // indirect golang.org/x/text v0.13.0 // indirect diff --git a/cmd/gf/internal/cmd/testdata/issue/2572/dao/internal/user_3.go b/cmd/gf/internal/cmd/testdata/issue/2572/dao/internal/user_3.go index db59440164d..58c955a88c6 100644 --- a/cmd/gf/internal/cmd/testdata/issue/2572/dao/internal/user_3.go +++ b/cmd/gf/internal/cmd/testdata/issue/2572/dao/internal/user_3.go @@ -11,14 +11,14 @@ import ( "github.com/gogf/gf/v2/frame/g" ) -// User3Dao is the data access object for table user3. +// User3Dao is the data access object for the table user3. type User3Dao struct { table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of current DAO. + group string // group is the database configuration group name of the current DAO. columns User3Columns // columns contains all the column names of Table for convenient usage. } -// User3Columns defines and stores column names for table user3. +// User3Columns defines and stores column names for the table user3. type User3Columns struct { Id string // User ID Passport string // User Passport @@ -29,7 +29,7 @@ type User3Columns struct { UpdateAt string // Updated Time } -// user3Columns holds the columns for table user3. +// user3Columns holds the columns for the table user3. var user3Columns = User3Columns{ Id: "id", Passport: "passport", @@ -49,36 +49,36 @@ func NewUser3Dao() *User3Dao { } } -// DB retrieves and returns the underlying raw database management object of current DAO. +// DB retrieves and returns the underlying raw database management object of the current DAO. func (dao *User3Dao) DB() gdb.DB { return g.DB(dao.group) } -// Table returns the table name of current dao. +// Table returns the table name of the current DAO. func (dao *User3Dao) Table() string { return dao.table } -// Columns returns all column names of current dao. +// Columns returns all column names of the current DAO. func (dao *User3Dao) Columns() User3Columns { return dao.columns } -// Group returns the configuration group name of database of current dao. +// Group returns the database configuration group name of the current DAO. func (dao *User3Dao) Group() string { return dao.group } -// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *User3Dao) Ctx(ctx context.Context) *gdb.Model { return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. -// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It rolls back the transaction and returns the error if function f returns a non-nil error. // It commits the transaction and returns nil if function f returns nil. // -// Note that, you should not Commit or Rollback the transaction in function f +// Note: Do not commit or roll back the transaction in function f, // as it is automatically handled by this function. func (dao *User3Dao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { return dao.Ctx(ctx).Transaction(ctx, f) diff --git a/cmd/gf/internal/cmd/testdata/issue/2572/dao/internal/user_4.go b/cmd/gf/internal/cmd/testdata/issue/2572/dao/internal/user_4.go index 0488034d842..6cff3565047 100644 --- a/cmd/gf/internal/cmd/testdata/issue/2572/dao/internal/user_4.go +++ b/cmd/gf/internal/cmd/testdata/issue/2572/dao/internal/user_4.go @@ -11,14 +11,14 @@ import ( "github.com/gogf/gf/v2/frame/g" ) -// User4Dao is the data access object for table user4. +// User4Dao is the data access object for the table user4. type User4Dao struct { table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of current DAO. + group string // group is the database configuration group name of the current DAO. columns User4Columns // columns contains all the column names of Table for convenient usage. } -// User4Columns defines and stores column names for table user4. +// User4Columns defines and stores column names for the table user4. type User4Columns struct { Id string // User ID Passport string // User Passport @@ -29,7 +29,7 @@ type User4Columns struct { UpdateAt string // Updated Time } -// user4Columns holds the columns for table user4. +// user4Columns holds the columns for the table user4. var user4Columns = User4Columns{ Id: "id", Passport: "passport", @@ -49,36 +49,36 @@ func NewUser4Dao() *User4Dao { } } -// DB retrieves and returns the underlying raw database management object of current DAO. +// DB retrieves and returns the underlying raw database management object of the current DAO. func (dao *User4Dao) DB() gdb.DB { return g.DB(dao.group) } -// Table returns the table name of current dao. +// Table returns the table name of the current DAO. func (dao *User4Dao) Table() string { return dao.table } -// Columns returns all column names of current dao. +// Columns returns all column names of the current DAO. func (dao *User4Dao) Columns() User4Columns { return dao.columns } -// Group returns the configuration group name of database of current dao. +// Group returns the database configuration group name of the current DAO. func (dao *User4Dao) Group() string { return dao.group } -// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *User4Dao) Ctx(ctx context.Context) *gdb.Model { return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. -// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It rolls back the transaction and returns the error if function f returns a non-nil error. // It commits the transaction and returns nil if function f returns nil. // -// Note that, you should not Commit or Rollback the transaction in function f +// Note: Do not commit or roll back the transaction in function f, // as it is automatically handled by this function. func (dao *User4Dao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { return dao.Ctx(ctx).Transaction(ctx, f) diff --git a/cmd/gf/internal/cmd/testdata/issue/2572/dao/user_3.go b/cmd/gf/internal/cmd/testdata/issue/2572/dao/user_3.go index 375276e4823..41b681d9f36 100644 --- a/cmd/gf/internal/cmd/testdata/issue/2572/dao/user_3.go +++ b/cmd/gf/internal/cmd/testdata/issue/2572/dao/user_3.go @@ -1,5 +1,5 @@ // ================================================================================= -// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // ================================================================================= package dao @@ -8,20 +8,20 @@ import ( "/internal" ) -// internalUser3Dao is internal type for wrapping internal DAO implements. +// internalUser3Dao is an internal type for wrapping the internal DAO implementation. type internalUser3Dao = *internal.User3Dao -// user3Dao is the data access object for table user3. -// You can define custom methods on it to extend its functionality as you wish. +// user3Dao is the data access object for the table user3. +// You can define custom methods on it to extend its functionality as needed. type user3Dao struct { internalUser3Dao } var ( - // User3 is globally public accessible object for table user3 operations. + // User3 is a globally accessible object for table user3 operations. User3 = user3Dao{ internal.NewUser3Dao(), } ) -// Fill with you ideas below. +// Add your custom methods and functionality below. diff --git a/cmd/gf/internal/cmd/testdata/issue/2572/dao/user_4.go b/cmd/gf/internal/cmd/testdata/issue/2572/dao/user_4.go index 7d023591979..29b6947907e 100644 --- a/cmd/gf/internal/cmd/testdata/issue/2572/dao/user_4.go +++ b/cmd/gf/internal/cmd/testdata/issue/2572/dao/user_4.go @@ -1,5 +1,5 @@ // ================================================================================= -// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // ================================================================================= package dao @@ -8,20 +8,20 @@ import ( "/internal" ) -// internalUser4Dao is internal type for wrapping internal DAO implements. +// internalUser4Dao is an internal type for wrapping the internal DAO implementation. type internalUser4Dao = *internal.User4Dao -// user4Dao is the data access object for table user4. -// You can define custom methods on it to extend its functionality as you wish. +// user4Dao is the data access object for the table user4. +// You can define custom methods on it to extend its functionality as needed. type user4Dao struct { internalUser4Dao } var ( - // User4 is globally public accessible object for table user4 operations. + // User4 is a globally accessible object for table user4 operations. User4 = user4Dao{ internal.NewUser4Dao(), } ) -// Fill with you ideas below. +// Add your custom methods and functionality below. diff --git a/cmd/gf/internal/cmd/testdata/issue/2616/dao/internal/user_1.go b/cmd/gf/internal/cmd/testdata/issue/2616/dao/internal/user_1.go index 9988251832e..4951b4fda5b 100644 --- a/cmd/gf/internal/cmd/testdata/issue/2616/dao/internal/user_1.go +++ b/cmd/gf/internal/cmd/testdata/issue/2616/dao/internal/user_1.go @@ -11,14 +11,14 @@ import ( "github.com/gogf/gf/v2/frame/g" ) -// User1Dao is the data access object for table user1. +// User1Dao is the data access object for the table user1. type User1Dao struct { table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of current DAO. + group string // group is the database configuration group name of the current DAO. columns User1Columns // columns contains all the column names of Table for convenient usage. } -// User1Columns defines and stores column names for table user1. +// User1Columns defines and stores column names for the table user1. type User1Columns struct { Id string // User ID Passport string // User Passport @@ -29,7 +29,7 @@ type User1Columns struct { UpdateAt string // Updated Time } -// user1Columns holds the columns for table user1. +// user1Columns holds the columns for the table user1. var user1Columns = User1Columns{ Id: "id", Passport: "passport", @@ -49,36 +49,36 @@ func NewUser1Dao() *User1Dao { } } -// DB retrieves and returns the underlying raw database management object of current DAO. +// DB retrieves and returns the underlying raw database management object of the current DAO. func (dao *User1Dao) DB() gdb.DB { return g.DB(dao.group) } -// Table returns the table name of current dao. +// Table returns the table name of the current DAO. func (dao *User1Dao) Table() string { return dao.table } -// Columns returns all column names of current dao. +// Columns returns all column names of the current DAO. func (dao *User1Dao) Columns() User1Columns { return dao.columns } -// Group returns the configuration group name of database of current dao. +// Group returns the database configuration group name of the current DAO. func (dao *User1Dao) Group() string { return dao.group } -// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *User1Dao) Ctx(ctx context.Context) *gdb.Model { return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. -// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It rolls back the transaction and returns the error if function f returns a non-nil error. // It commits the transaction and returns nil if function f returns nil. // -// Note that, you should not Commit or Rollback the transaction in function f +// Note: Do not commit or roll back the transaction in function f, // as it is automatically handled by this function. func (dao *User1Dao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { return dao.Ctx(ctx).Transaction(ctx, f) diff --git a/cmd/gf/internal/cmd/testdata/issue/2616/dao/internal/user_2.go b/cmd/gf/internal/cmd/testdata/issue/2616/dao/internal/user_2.go index 7e9cf2fa9ac..65c04197f58 100644 --- a/cmd/gf/internal/cmd/testdata/issue/2616/dao/internal/user_2.go +++ b/cmd/gf/internal/cmd/testdata/issue/2616/dao/internal/user_2.go @@ -11,14 +11,14 @@ import ( "github.com/gogf/gf/v2/frame/g" ) -// User2Dao is the data access object for table user2. +// User2Dao is the data access object for the table user2. type User2Dao struct { table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of current DAO. + group string // group is the database configuration group name of the current DAO. columns User2Columns // columns contains all the column names of Table for convenient usage. } -// User2Columns defines and stores column names for table user2. +// User2Columns defines and stores column names for the table user2. type User2Columns struct { Id string // User ID Passport string // User Passport @@ -29,7 +29,7 @@ type User2Columns struct { UpdateAt string // Updated Time } -// user2Columns holds the columns for table user2. +// user2Columns holds the columns for the table user2. var user2Columns = User2Columns{ Id: "id", Passport: "passport", @@ -49,36 +49,36 @@ func NewUser2Dao() *User2Dao { } } -// DB retrieves and returns the underlying raw database management object of current DAO. +// DB retrieves and returns the underlying raw database management object of the current DAO. func (dao *User2Dao) DB() gdb.DB { return g.DB(dao.group) } -// Table returns the table name of current dao. +// Table returns the table name of the current DAO. func (dao *User2Dao) Table() string { return dao.table } -// Columns returns all column names of current dao. +// Columns returns all column names of the current DAO. func (dao *User2Dao) Columns() User2Columns { return dao.columns } -// Group returns the configuration group name of database of current dao. +// Group returns the database configuration group name of the current DAO. func (dao *User2Dao) Group() string { return dao.group } -// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *User2Dao) Ctx(ctx context.Context) *gdb.Model { return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. -// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It rolls back the transaction and returns the error if function f returns a non-nil error. // It commits the transaction and returns nil if function f returns nil. // -// Note that, you should not Commit or Rollback the transaction in function f +// Note: Do not commit or roll back the transaction in function f, // as it is automatically handled by this function. func (dao *User2Dao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { return dao.Ctx(ctx).Transaction(ctx, f) diff --git a/cmd/gf/internal/cmd/testdata/issue/2616/dao/internal/user_3.go b/cmd/gf/internal/cmd/testdata/issue/2616/dao/internal/user_3.go index db59440164d..58c955a88c6 100644 --- a/cmd/gf/internal/cmd/testdata/issue/2616/dao/internal/user_3.go +++ b/cmd/gf/internal/cmd/testdata/issue/2616/dao/internal/user_3.go @@ -11,14 +11,14 @@ import ( "github.com/gogf/gf/v2/frame/g" ) -// User3Dao is the data access object for table user3. +// User3Dao is the data access object for the table user3. type User3Dao struct { table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of current DAO. + group string // group is the database configuration group name of the current DAO. columns User3Columns // columns contains all the column names of Table for convenient usage. } -// User3Columns defines and stores column names for table user3. +// User3Columns defines and stores column names for the table user3. type User3Columns struct { Id string // User ID Passport string // User Passport @@ -29,7 +29,7 @@ type User3Columns struct { UpdateAt string // Updated Time } -// user3Columns holds the columns for table user3. +// user3Columns holds the columns for the table user3. var user3Columns = User3Columns{ Id: "id", Passport: "passport", @@ -49,36 +49,36 @@ func NewUser3Dao() *User3Dao { } } -// DB retrieves and returns the underlying raw database management object of current DAO. +// DB retrieves and returns the underlying raw database management object of the current DAO. func (dao *User3Dao) DB() gdb.DB { return g.DB(dao.group) } -// Table returns the table name of current dao. +// Table returns the table name of the current DAO. func (dao *User3Dao) Table() string { return dao.table } -// Columns returns all column names of current dao. +// Columns returns all column names of the current DAO. func (dao *User3Dao) Columns() User3Columns { return dao.columns } -// Group returns the configuration group name of database of current dao. +// Group returns the database configuration group name of the current DAO. func (dao *User3Dao) Group() string { return dao.group } -// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *User3Dao) Ctx(ctx context.Context) *gdb.Model { return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. -// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It rolls back the transaction and returns the error if function f returns a non-nil error. // It commits the transaction and returns nil if function f returns nil. // -// Note that, you should not Commit or Rollback the transaction in function f +// Note: Do not commit or roll back the transaction in function f, // as it is automatically handled by this function. func (dao *User3Dao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { return dao.Ctx(ctx).Transaction(ctx, f) diff --git a/cmd/gf/internal/cmd/testdata/issue/2616/dao/internal/user_4.go b/cmd/gf/internal/cmd/testdata/issue/2616/dao/internal/user_4.go index 0488034d842..6cff3565047 100644 --- a/cmd/gf/internal/cmd/testdata/issue/2616/dao/internal/user_4.go +++ b/cmd/gf/internal/cmd/testdata/issue/2616/dao/internal/user_4.go @@ -11,14 +11,14 @@ import ( "github.com/gogf/gf/v2/frame/g" ) -// User4Dao is the data access object for table user4. +// User4Dao is the data access object for the table user4. type User4Dao struct { table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of current DAO. + group string // group is the database configuration group name of the current DAO. columns User4Columns // columns contains all the column names of Table for convenient usage. } -// User4Columns defines and stores column names for table user4. +// User4Columns defines and stores column names for the table user4. type User4Columns struct { Id string // User ID Passport string // User Passport @@ -29,7 +29,7 @@ type User4Columns struct { UpdateAt string // Updated Time } -// user4Columns holds the columns for table user4. +// user4Columns holds the columns for the table user4. var user4Columns = User4Columns{ Id: "id", Passport: "passport", @@ -49,36 +49,36 @@ func NewUser4Dao() *User4Dao { } } -// DB retrieves and returns the underlying raw database management object of current DAO. +// DB retrieves and returns the underlying raw database management object of the current DAO. func (dao *User4Dao) DB() gdb.DB { return g.DB(dao.group) } -// Table returns the table name of current dao. +// Table returns the table name of the current DAO. func (dao *User4Dao) Table() string { return dao.table } -// Columns returns all column names of current dao. +// Columns returns all column names of the current DAO. func (dao *User4Dao) Columns() User4Columns { return dao.columns } -// Group returns the configuration group name of database of current dao. +// Group returns the database configuration group name of the current DAO. func (dao *User4Dao) Group() string { return dao.group } -// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *User4Dao) Ctx(ctx context.Context) *gdb.Model { return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. -// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It rolls back the transaction and returns the error if function f returns a non-nil error. // It commits the transaction and returns nil if function f returns nil. // -// Note that, you should not Commit or Rollback the transaction in function f +// Note: Do not commit or roll back the transaction in function f, // as it is automatically handled by this function. func (dao *User4Dao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { return dao.Ctx(ctx).Transaction(ctx, f) diff --git a/cmd/gf/internal/cmd/testdata/issue/2616/dao/user_1.go b/cmd/gf/internal/cmd/testdata/issue/2616/dao/user_1.go index 69af67a98bb..4c46f1a6941 100644 --- a/cmd/gf/internal/cmd/testdata/issue/2616/dao/user_1.go +++ b/cmd/gf/internal/cmd/testdata/issue/2616/dao/user_1.go @@ -1,5 +1,5 @@ // ================================================================================= -// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // ================================================================================= // I am not overwritten. @@ -10,20 +10,20 @@ import ( "/internal" ) -// internalUser1Dao is internal type for wrapping internal DAO implements. +// internalUser1Dao is an internal type for wrapping the internal DAO implementation. type internalUser1Dao = *internal.User1Dao -// user1Dao is the data access object for table user1. -// You can define custom methods on it to extend its functionality as you wish. +// user1Dao is the data access object for the table user1. +// You can define custom methods on it to extend its functionality as needed. type user1Dao struct { internalUser1Dao } var ( - // User1 is globally public accessible object for table user1 operations. + // User1 is a globally accessible object for table user1 operations. User1 = user1Dao{ internal.NewUser1Dao(), } ) -// Fill with you ideas below. +// Add your custom methods and functionality below. diff --git a/cmd/gf/internal/cmd/testdata/issue/2616/dao/user_2.go b/cmd/gf/internal/cmd/testdata/issue/2616/dao/user_2.go index 895d406cb3d..692ed1b9614 100644 --- a/cmd/gf/internal/cmd/testdata/issue/2616/dao/user_2.go +++ b/cmd/gf/internal/cmd/testdata/issue/2616/dao/user_2.go @@ -1,5 +1,5 @@ // ================================================================================= -// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // ================================================================================= // I am not overwritten. @@ -10,20 +10,20 @@ import ( "/internal" ) -// internalUser2Dao is internal type for wrapping internal DAO implements. +// internalUser2Dao is an internal type for wrapping the internal DAO implementation. type internalUser2Dao = *internal.User2Dao -// user2Dao is the data access object for table user2. -// You can define custom methods on it to extend its functionality as you wish. +// user2Dao is the data access object for the table user2. +// You can define custom methods on it to extend its functionality as needed. type user2Dao struct { internalUser2Dao } var ( - // User2 is globally public accessible object for table user2 operations. + // User2 is a globally accessible object for table user2 operations. User2 = user2Dao{ internal.NewUser2Dao(), } ) -// Fill with you ideas below. +// Add your custom methods and functionality below. diff --git a/cmd/gf/internal/cmd/testdata/issue/2616/dao/user_3.go b/cmd/gf/internal/cmd/testdata/issue/2616/dao/user_3.go index 375276e4823..41b681d9f36 100644 --- a/cmd/gf/internal/cmd/testdata/issue/2616/dao/user_3.go +++ b/cmd/gf/internal/cmd/testdata/issue/2616/dao/user_3.go @@ -1,5 +1,5 @@ // ================================================================================= -// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // ================================================================================= package dao @@ -8,20 +8,20 @@ import ( "/internal" ) -// internalUser3Dao is internal type for wrapping internal DAO implements. +// internalUser3Dao is an internal type for wrapping the internal DAO implementation. type internalUser3Dao = *internal.User3Dao -// user3Dao is the data access object for table user3. -// You can define custom methods on it to extend its functionality as you wish. +// user3Dao is the data access object for the table user3. +// You can define custom methods on it to extend its functionality as needed. type user3Dao struct { internalUser3Dao } var ( - // User3 is globally public accessible object for table user3 operations. + // User3 is a globally accessible object for table user3 operations. User3 = user3Dao{ internal.NewUser3Dao(), } ) -// Fill with you ideas below. +// Add your custom methods and functionality below. diff --git a/cmd/gf/internal/cmd/testdata/issue/2616/dao/user_4.go b/cmd/gf/internal/cmd/testdata/issue/2616/dao/user_4.go index 7d023591979..29b6947907e 100644 --- a/cmd/gf/internal/cmd/testdata/issue/2616/dao/user_4.go +++ b/cmd/gf/internal/cmd/testdata/issue/2616/dao/user_4.go @@ -1,5 +1,5 @@ // ================================================================================= -// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // ================================================================================= package dao @@ -8,20 +8,20 @@ import ( "/internal" ) -// internalUser4Dao is internal type for wrapping internal DAO implements. +// internalUser4Dao is an internal type for wrapping the internal DAO implementation. type internalUser4Dao = *internal.User4Dao -// user4Dao is the data access object for table user4. -// You can define custom methods on it to extend its functionality as you wish. +// user4Dao is the data access object for the table user4. +// You can define custom methods on it to extend its functionality as needed. type user4Dao struct { internalUser4Dao } var ( - // User4 is globally public accessible object for table user4 operations. + // User4 is a globally accessible object for table user4 operations. User4 = user4Dao{ internal.NewUser4Dao(), } ) -// Fill with you ideas below. +// Add your custom methods and functionality below. diff --git a/cmd/gf/internal/cmd/testdata/issue/3749/dao/internal/table_user.go b/cmd/gf/internal/cmd/testdata/issue/3749/dao/internal/table_user.go index 871b7d65748..bb7bf30a875 100644 --- a/cmd/gf/internal/cmd/testdata/issue/3749/dao/internal/table_user.go +++ b/cmd/gf/internal/cmd/testdata/issue/3749/dao/internal/table_user.go @@ -11,14 +11,14 @@ import ( "github.com/gogf/gf/v2/frame/g" ) -// TableUserDao is the data access object for table table_user. +// TableUserDao is the data access object for the table table_user. type TableUserDao struct { table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of current DAO. + group string // group is the database configuration group name of the current DAO. columns TableUserColumns // columns contains all the column names of Table for convenient usage. } -// TableUserColumns defines and stores column names for table table_user. +// TableUserColumns defines and stores column names for the table table_user. type TableUserColumns struct { Id string // User ID ParentId string // @@ -29,7 +29,7 @@ type TableUserColumns struct { UpdateAt string // Updated Time } -// tableUserColumns holds the columns for table table_user. +// tableUserColumns holds the columns for the table table_user. var tableUserColumns = TableUserColumns{ Id: "Id", ParentId: "parentId", @@ -49,36 +49,36 @@ func NewTableUserDao() *TableUserDao { } } -// DB retrieves and returns the underlying raw database management object of current DAO. +// DB retrieves and returns the underlying raw database management object of the current DAO. func (dao *TableUserDao) DB() gdb.DB { return g.DB(dao.group) } -// Table returns the table name of current dao. +// Table returns the table name of the current DAO. func (dao *TableUserDao) Table() string { return dao.table } -// Columns returns all column names of current dao. +// Columns returns all column names of the current DAO. func (dao *TableUserDao) Columns() TableUserColumns { return dao.columns } -// Group returns the configuration group name of database of current dao. +// Group returns the database configuration group name of the current DAO. func (dao *TableUserDao) Group() string { return dao.group } -// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *TableUserDao) Ctx(ctx context.Context) *gdb.Model { return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. -// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It rolls back the transaction and returns the error if function f returns a non-nil error. // It commits the transaction and returns nil if function f returns nil. // -// Note that, you should not Commit or Rollback the transaction in function f +// Note: Do not commit or roll back the transaction in function f, // as it is automatically handled by this function. func (dao *TableUserDao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { return dao.Ctx(ctx).Transaction(ctx, f) diff --git a/cmd/gf/internal/cmd/testdata/issue/3749/dao/table_user.go b/cmd/gf/internal/cmd/testdata/issue/3749/dao/table_user.go index 9bc9cff6f7d..28d2d47973d 100644 --- a/cmd/gf/internal/cmd/testdata/issue/3749/dao/table_user.go +++ b/cmd/gf/internal/cmd/testdata/issue/3749/dao/table_user.go @@ -1,5 +1,5 @@ // ================================================================================= -// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // ================================================================================= package dao @@ -8,20 +8,20 @@ import ( "for-gendao-test/pkg/dao/internal" ) -// internalTableUserDao is internal type for wrapping internal DAO implements. +// internalTableUserDao is an internal type for wrapping the internal DAO implementation. type internalTableUserDao = *internal.TableUserDao -// tableUserDao is the data access object for table table_user. -// You can define custom methods on it to extend its functionality as you wish. +// tableUserDao is the data access object for the table table_user. +// You can define custom methods on it to extend its functionality as needed. type tableUserDao struct { internalTableUserDao } var ( - // TableUser is globally public accessible object for table table_user operations. + // TableUser is a globally accessible object for table table_user operations. TableUser = tableUserDao{ internal.NewTableUserDao(), } ) -// Fill with you ideas below. +// Add your custom methods and functionality below. diff --git a/cmd/gf/internal/consts/consts_gen_dao_template_dao.go b/cmd/gf/internal/consts/consts_gen_dao_template_dao.go index 5af47e4931f..c1e20fbe770 100644 --- a/cmd/gf/internal/consts/consts_gen_dao_template_dao.go +++ b/cmd/gf/internal/consts/consts_gen_dao_template_dao.go @@ -8,7 +8,7 @@ package consts const TemplateGenDaoIndexContent = ` // ================================================================================= -// This is auto-generated by GoFrame CLI tool only once. Fill this file as you wish. +// This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // ================================================================================= package {TplPackageName} @@ -17,23 +17,23 @@ import ( "{TplImportPrefix}/internal" ) -// internal{TplTableNameCamelCase}Dao is internal type for wrapping internal DAO implements. +// internal{TplTableNameCamelCase}Dao is an internal type for wrapping the internal DAO implementation. type internal{TplTableNameCamelCase}Dao = *internal.{TplTableNameCamelCase}Dao -// {TplTableNameCamelLowerCase}Dao is the data access object for table {TplTableName}. -// You can define custom methods on it to extend its functionality as you wish. +// {TplTableNameCamelLowerCase}Dao is the data access object for the table {TplTableName}. +// You can define custom methods on it to extend its functionality as needed. type {TplTableNameCamelLowerCase}Dao struct { internal{TplTableNameCamelCase}Dao } var ( - // {TplTableNameCamelCase} is globally public accessible object for table {TplTableName} operations. + // {TplTableNameCamelCase} is a globally accessible object for table {TplTableName} operations. {TplTableNameCamelCase} = {TplTableNameCamelLowerCase}Dao{ internal.New{TplTableNameCamelCase}Dao(), } ) -// Fill with you ideas below. +// Add your custom methods and functionality below. ` @@ -51,19 +51,19 @@ import ( "github.com/gogf/gf/v2/frame/g" ) -// {TplTableNameCamelCase}Dao is the data access object for table {TplTableName}. +// {TplTableNameCamelCase}Dao is the data access object for the table {TplTableName}. type {TplTableNameCamelCase}Dao struct { table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of current DAO. + group string // group is the database configuration group name of the current DAO. columns {TplTableNameCamelCase}Columns // columns contains all the column names of Table for convenient usage. } -// {TplTableNameCamelCase}Columns defines and stores column names for table {TplTableName}. +// {TplTableNameCamelCase}Columns defines and stores column names for the table {TplTableName}. type {TplTableNameCamelCase}Columns struct { {TplColumnDefine} } -// {TplTableNameCamelLowerCase}Columns holds the columns for table {TplTableName}. +// {TplTableNameCamelLowerCase}Columns holds the columns for the table {TplTableName}. var {TplTableNameCamelLowerCase}Columns = {TplTableNameCamelCase}Columns{ {TplColumnNames} } @@ -77,36 +77,36 @@ func New{TplTableNameCamelCase}Dao() *{TplTableNameCamelCase}Dao { } } -// DB retrieves and returns the underlying raw database management object of current DAO. +// DB retrieves and returns the underlying raw database management object of the current DAO. func (dao *{TplTableNameCamelCase}Dao) DB() gdb.DB { return g.DB(dao.group) } -// Table returns the table name of current dao. +// Table returns the table name of the current DAO. func (dao *{TplTableNameCamelCase}Dao) Table() string { return dao.table } -// Columns returns all column names of current dao. +// Columns returns all column names of the current DAO. func (dao *{TplTableNameCamelCase}Dao) Columns() {TplTableNameCamelCase}Columns { return dao.columns } -// Group returns the configuration group name of database of current dao. +// Group returns the database configuration group name of the current DAO. func (dao *{TplTableNameCamelCase}Dao) Group() string { return dao.group } -// Ctx creates and returns the Model for current DAO, It automatically sets the context for current operation. +// Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *{TplTableNameCamelCase}Dao) Ctx(ctx context.Context) *gdb.Model { return dao.DB().Model(dao.table).Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. -// It rollbacks the transaction and returns the error from function f if it returns non-nil error. +// It rolls back the transaction and returns the error if function f returns a non-nil error. // It commits the transaction and returns nil if function f returns nil. // -// Note that, you should not Commit or Rollback the transaction in function f +// Note: Do not commit or roll back the transaction in function f, // as it is automatically handled by this function. func (dao *{TplTableNameCamelCase}Dao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { return dao.Ctx(ctx).Transaction(ctx, f) From 3cffa4d5d608e7622282a197a416ebb205f9cd63 Mon Sep 17 00:00:00 2001 From: TIANYU HU <70132033+huty1998@users.noreply.github.com> Date: Mon, 9 Dec 2024 09:22:52 +0800 Subject: [PATCH 037/102] fix(database/gdb): CRUD typos (#4017) --- database/gdb/gdb.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/database/gdb/gdb.go b/database/gdb/gdb.go index a8c2a2bdf22..18de920a7e0 100644 --- a/database/gdb/gdb.go +++ b/database/gdb/gdb.go @@ -90,7 +90,7 @@ type DB interface { Prepare(ctx context.Context, sql string, execOnMaster ...bool) (*Stmt, error) // =========================================================================== - // Common APIs for CURD. + // Common APIs for CRUD. // =========================================================================== // Insert inserts one or multiple records into table. @@ -124,7 +124,7 @@ type DB interface { Delete(ctx context.Context, table string, condition interface{}, args ...interface{}) (sql.Result, error) // =========================================================================== - // Internal APIs for CURD, which can be overwritten by custom CURD implements. + // Internal APIs for CRUD, which can be overwritten by custom CRUD implements. // =========================================================================== // DoSelect executes a SELECT query using the given link and returns the result. @@ -434,7 +434,7 @@ type TX interface { GetCount(sql string, args ...interface{}) (int64, error) // =========================================================================== - // CURD. + // CRUD. // =========================================================================== // Insert inserts one or multiple records into table. From 5e475901658b80fe9cc5a8e757832841293c3c48 Mon Sep 17 00:00:00 2001 From: John Guo Date: Mon, 9 Dec 2024 09:24:48 +0800 Subject: [PATCH 038/102] feat(database/gdb): add `WhereExists/WhereNotExists` (#4015) --- .../drivers/mysql/mysql_z_unit_model_test.go | 1061 +------------- .../mysql/mysql_z_unit_model_where_test.go | 1244 +++++++++++++++++ database/gdb/gdb_model_builder_where.go | 10 + database/gdb/gdb_model_where.go | 10 + 4 files changed, 1280 insertions(+), 1045 deletions(-) create mode 100644 contrib/drivers/mysql/mysql_z_unit_model_where_test.go diff --git a/contrib/drivers/mysql/mysql_z_unit_model_test.go b/contrib/drivers/mysql/mysql_z_unit_model_test.go index 5f3033b36d0..9be10ff1313 100644 --- a/contrib/drivers/mysql/mysql_z_unit_model_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_model_test.go @@ -17,7 +17,6 @@ import ( "time" "github.com/gogf/gf/v2/container/garray" - "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/encoding/gjson" @@ -28,7 +27,6 @@ import ( "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/guid" - "github.com/gogf/gf/v2/util/gutil" ) func Test_Model_Insert(t *testing.T) { @@ -1366,591 +1364,6 @@ func Test_Model_Data(t *testing.T) { }) } -func Test_Model_Where(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - // string - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where("id=? and nickname=?", 3, "name_3").One() - t.AssertNil(err) - t.AssertGT(len(result), 0) - t.Assert(result["id"].Int(), 3) - }) - - // slice - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where(g.Slice{"id", 3}).One() - t.AssertNil(err) - t.AssertGT(len(result), 0) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where(g.Slice{"id", 3, "nickname", "name_3"}).One() - t.AssertNil(err) - t.AssertGT(len(result), 0) - t.Assert(result["id"].Int(), 3) - }) - - // slice parameter - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where("id=? and nickname=?", g.Slice{3, "name_3"}).One() - t.AssertNil(err) - t.AssertGT(len(result), 0) - t.Assert(result["id"].Int(), 3) - }) - // map like - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where(g.Map{ - "passport like": "user_1%", - }).Order("id asc").All() - t.AssertNil(err) - t.Assert(len(result), 2) - t.Assert(result[0].GMap().Get("id"), 1) - t.Assert(result[1].GMap().Get("id"), 10) - }) - // map + slice parameter - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where(g.Map{ - "id": g.Slice{1, 2, 3}, - "passport": g.Slice{"user_2", "user_3"}, - }).Where("id=? and nickname=?", g.Slice{3, "name_3"}).One() - t.AssertNil(err) - t.AssertGT(len(result), 0) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where("id=3", g.Slice{}).One() - t.AssertNil(err) - t.AssertGT(len(result), 0) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where("id=?", g.Slice{3}).One() - t.AssertNil(err) - t.AssertGT(len(result), 0) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where("id", 3).One() - t.AssertNil(err) - t.AssertGT(len(result), 0) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where("id", 3).Where("nickname", "name_3").One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where("id", 3).Where("nickname", "name_3").One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where("id", 30).WhereOr("nickname", "name_3").One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where("id", 30).WhereOr("nickname", "name_3").Where("id>?", 1).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where("id", 30).WhereOr("nickname", "name_3").Where("id>", 1).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - // slice - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where("id=? AND nickname=?", g.Slice{3, "name_3"}...).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where("id=? AND nickname=?", g.Slice{3, "name_3"}).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where("passport like ? and nickname like ?", g.Slice{"user_3", "name_3"}).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - // map - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where(g.Map{"id": 3, "nickname": "name_3"}).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - // map key operator - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where(g.Map{"id>": 1, "id<": 3}).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 2) - }) - - // gmap.Map - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where(gmap.NewFrom(g.MapAnyAny{"id": 3, "nickname": "name_3"})).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - // gmap.Map key operator - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where(gmap.NewFrom(g.MapAnyAny{"id>": 1, "id<": 3})).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 2) - }) - - // list map - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where(gmap.NewListMapFrom(g.MapAnyAny{"id": 3, "nickname": "name_3"})).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - // list map key operator - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where(gmap.NewListMapFrom(g.MapAnyAny{"id>": 1, "id<": 3})).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 2) - }) - - // tree map - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where(gmap.NewTreeMapFrom(gutil.ComparatorString, g.MapAnyAny{"id": 3, "nickname": "name_3"})).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - // tree map key operator - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where(gmap.NewTreeMapFrom(gutil.ComparatorString, g.MapAnyAny{"id>": 1, "id<": 3})).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 2) - }) - - // complicated where 1 - gtest.C(t, func(t *gtest.T) { - // db.SetDebug(true) - conditions := g.Map{ - "nickname like ?": "%name%", - "id between ? and ?": g.Slice{1, 3}, - "id > 0": nil, - "create_time > 0": nil, - "id": g.Slice{1, 2, 3}, - } - result, err := db.Model(table).Where(conditions).Order("id asc").All() - t.AssertNil(err) - t.Assert(len(result), 3) - t.Assert(result[0]["id"].Int(), 1) - }) - // complicated where 2 - gtest.C(t, func(t *gtest.T) { - // db.SetDebug(true) - conditions := g.Map{ - "nickname like ?": "%name%", - "id between ? and ?": g.Slice{1, 3}, - "id >= ?": 1, - "create_time > ?": 0, - "id in(?)": g.Slice{1, 2, 3}, - } - result, err := db.Model(table).Where(conditions).Order("id asc").All() - t.AssertNil(err) - t.Assert(len(result), 3) - t.Assert(result[0]["id"].Int(), 1) - }) - // struct, automatic mapping and filtering. - gtest.C(t, func(t *gtest.T) { - type User struct { - Id int - Nickname string - } - result, err := db.Model(table).Where(User{3, "name_3"}).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - - result, err = db.Model(table).Where(&User{3, "name_3"}).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - // slice single - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where("id IN(?)", g.Slice{1, 3}).Order("id ASC").All() - t.AssertNil(err) - t.Assert(len(result), 2) - t.Assert(result[0]["id"].Int(), 1) - t.Assert(result[1]["id"].Int(), 3) - }) - // slice + string - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where("nickname=? AND id IN(?)", "name_3", g.Slice{1, 3}).Order("id ASC").All() - t.AssertNil(err) - t.Assert(len(result), 1) - t.Assert(result[0]["id"].Int(), 3) - }) - // slice + map - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where(g.Map{ - "id": g.Slice{1, 3}, - "nickname": "name_3", - }).Order("id ASC").All() - t.AssertNil(err) - t.Assert(len(result), 1) - t.Assert(result[0]["id"].Int(), 3) - }) - // slice + struct - gtest.C(t, func(t *gtest.T) { - type User struct { - Ids []int `json:"id"` - Nickname string `gconv:"nickname"` - } - result, err := db.Model(table).Where(User{ - Ids: []int{1, 3}, - Nickname: "name_3", - }).Order("id ASC").All() - t.AssertNil(err) - t.Assert(len(result), 1) - t.Assert(result[0]["id"].Int(), 3) - }) -} - -func Test_Model_Where_ISNULL_1(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - // db.SetDebug(true) - result, err := db.Model(table).Data("nickname", nil).Where("id", 2).Update() - t.AssertNil(err) - n, _ := result.RowsAffected() - t.Assert(n, 1) - - one, err := db.Model(table).Where("nickname", nil).One() - t.AssertNil(err) - t.Assert(one.IsEmpty(), false) - t.Assert(one["id"], 2) - }) -} - -func Test_Model_Where_ISNULL_2(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - // complicated one. - gtest.C(t, func(t *gtest.T) { - // db.SetDebug(true) - conditions := g.Map{ - "nickname like ?": "%name%", - "id between ? and ?": g.Slice{1, 3}, - "id > 0": nil, - "create_time > 0": nil, - "id": g.Slice{1, 2, 3}, - } - result, err := db.Model(table).Where(conditions).Order("id asc").All() - t.AssertNil(err) - t.Assert(len(result), 3) - t.Assert(result[0]["id"].Int(), 1) - }) -} - -func Test_Model_Where_OmitEmpty(t *testing.T) { - table := createInitTable() - defer dropTable(table) - gtest.C(t, func(t *gtest.T) { - conditions := g.Map{ - "id < 4": "", - } - result, err := db.Model(table).Where(conditions).Order("id desc").All() - t.AssertNil(err) - t.Assert(len(result), 3) - t.Assert(result[0]["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - conditions := g.Map{ - "id < 4": "", - } - result, err := db.Model(table).Where(conditions).OmitEmpty().Order("id desc").All() - t.AssertNil(err) - t.Assert(len(result), 10) - t.Assert(result[0]["id"].Int(), 10) - }) -} - -func Test_Model_Where_GTime(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where("create_time>?", gtime.NewFromStr("2010-09-01")).All() - t.AssertNil(err) - t.Assert(len(result), 10) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where("create_time>?", *gtime.NewFromStr("2010-09-01")).All() - t.AssertNil(err) - t.Assert(len(result), 10) - }) -} - -func Test_Model_WherePri(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - // primary key - gtest.C(t, func(t *gtest.T) { - one, err := db.Model(table).WherePri(3).One() - t.AssertNil(err) - t.AssertNE(one, nil) - t.Assert(one["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - all, err := db.Model(table).WherePri(g.Slice{3, 9}).Order("id asc").All() - t.AssertNil(err) - t.Assert(len(all), 2) - t.Assert(all[0]["id"].Int(), 3) - t.Assert(all[1]["id"].Int(), 9) - }) - - // string - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri("id=? and nickname=?", 3, "name_3").One() - t.AssertNil(err) - t.AssertGT(len(result), 0) - t.Assert(result["id"].Int(), 3) - }) - // slice parameter - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri("id=? and nickname=?", g.Slice{3, "name_3"}).One() - t.AssertNil(err) - t.AssertGT(len(result), 0) - t.Assert(result["id"].Int(), 3) - }) - // map like - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri(g.Map{ - "passport like": "user_1%", - }).Order("id asc").All() - t.AssertNil(err) - t.Assert(len(result), 2) - t.Assert(result[0].GMap().Get("id"), 1) - t.Assert(result[1].GMap().Get("id"), 10) - }) - // map + slice parameter - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri(g.Map{ - "id": g.Slice{1, 2, 3}, - "passport": g.Slice{"user_2", "user_3"}, - }).Where("id=? and nickname=?", g.Slice{3, "name_3"}).One() - t.AssertNil(err) - t.AssertGT(len(result), 0) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri(g.Map{ - "id": g.Slice{1, 2, 3}, - "passport": g.Slice{"user_2", "user_3"}, - }).WhereOr("nickname=?", g.Slice{"name_4"}).Where("id", 3).One() - t.AssertNil(err) - t.AssertGT(len(result), 0) - t.Assert(result["id"].Int(), 2) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri("id=3", g.Slice{}).One() - t.AssertNil(err) - t.AssertGT(len(result), 0) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri("id=?", g.Slice{3}).One() - t.AssertNil(err) - t.AssertGT(len(result), 0) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri("id", 3).One() - t.AssertNil(err) - t.AssertGT(len(result), 0) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri("id", 3).WherePri("nickname", "name_3").One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri("id", 3).Where("nickname", "name_3").One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri("id", 30).WhereOr("nickname", "name_3").One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri("id", 30).WhereOr("nickname", "name_3").Where("id>?", 1).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri("id", 30).WhereOr("nickname", "name_3").Where("id>", 1).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - // slice - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri("id=? AND nickname=?", g.Slice{3, "name_3"}...).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri("id=? AND nickname=?", g.Slice{3, "name_3"}).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri("passport like ? and nickname like ?", g.Slice{"user_3", "name_3"}).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - // map - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri(g.Map{"id": 3, "nickname": "name_3"}).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - // map key operator - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri(g.Map{"id>": 1, "id<": 3}).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 2) - }) - - // gmap.Map - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri(gmap.NewFrom(g.MapAnyAny{"id": 3, "nickname": "name_3"})).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - // gmap.Map key operator - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri(gmap.NewFrom(g.MapAnyAny{"id>": 1, "id<": 3})).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 2) - }) - - // list map - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri(gmap.NewListMapFrom(g.MapAnyAny{"id": 3, "nickname": "name_3"})).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - // list map key operator - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri(gmap.NewListMapFrom(g.MapAnyAny{"id>": 1, "id<": 3})).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 2) - }) - - // tree map - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri(gmap.NewTreeMapFrom(gutil.ComparatorString, g.MapAnyAny{"id": 3, "nickname": "name_3"})).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - // tree map key operator - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri(gmap.NewTreeMapFrom(gutil.ComparatorString, g.MapAnyAny{"id>": 1, "id<": 3})).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 2) - }) - - // complicated where 1 - gtest.C(t, func(t *gtest.T) { - // db.SetDebug(true) - conditions := g.Map{ - "nickname like ?": "%name%", - "id between ? and ?": g.Slice{1, 3}, - "id > 0": nil, - "create_time > 0": nil, - "id": g.Slice{1, 2, 3}, - } - result, err := db.Model(table).WherePri(conditions).Order("id asc").All() - t.AssertNil(err) - t.Assert(len(result), 3) - t.Assert(result[0]["id"].Int(), 1) - }) - // complicated where 2 - gtest.C(t, func(t *gtest.T) { - // db.SetDebug(true) - conditions := g.Map{ - "nickname like ?": "%name%", - "id between ? and ?": g.Slice{1, 3}, - "id >= ?": 1, - "create_time > ?": 0, - "id in(?)": g.Slice{1, 2, 3}, - } - result, err := db.Model(table).WherePri(conditions).Order("id asc").All() - t.AssertNil(err) - t.Assert(len(result), 3) - t.Assert(result[0]["id"].Int(), 1) - }) - // struct - gtest.C(t, func(t *gtest.T) { - type User struct { - Id int `json:"id"` - Nickname string `gconv:"nickname"` - } - result, err := db.Model(table).WherePri(User{3, "name_3"}).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - - result, err = db.Model(table).WherePri(&User{3, "name_3"}).One() - t.AssertNil(err) - t.Assert(result["id"].Int(), 3) - }) - // slice single - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri("id IN(?)", g.Slice{1, 3}).Order("id ASC").All() - t.AssertNil(err) - t.Assert(len(result), 2) - t.Assert(result[0]["id"].Int(), 1) - t.Assert(result[1]["id"].Int(), 3) - }) - // slice + string - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri("nickname=? AND id IN(?)", "name_3", g.Slice{1, 3}).Order("id ASC").All() - t.AssertNil(err) - t.Assert(len(result), 1) - t.Assert(result[0]["id"].Int(), 3) - }) - // slice + map - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WherePri(g.Map{ - "id": g.Slice{1, 3}, - "nickname": "name_3", - }).Order("id ASC").All() - t.AssertNil(err) - t.Assert(len(result), 1) - t.Assert(result[0]["id"].Int(), 3) - }) - // slice + struct - gtest.C(t, func(t *gtest.T) { - type User struct { - Ids []int `json:"id"` - Nickname string `gconv:"nickname"` - } - result, err := db.Model(table).WherePri(User{ - Ids: []int{1, 3}, - Nickname: "name_3", - }).Order("id ASC").All() - t.AssertNil(err) - t.Assert(len(result), 1) - t.Assert(result[0]["id"].Int(), 3) - }) -} - func Test_Model_Delete(t *testing.T) { table := createInitTable() defer dropTable(table) @@ -2265,79 +1678,29 @@ func Test_Model_OmitNil(t *testing.T) { ) ENGINE=InnoDB DEFAULT CHARSET=utf8; `, table)); err != nil { gtest.Error(err) - } - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - _, err := db.Model(table).OmitNil().Data(g.Map{ - "id": 1, - "name": nil, - }).Save() - t.AssertNE(err, nil) - }) - gtest.C(t, func(t *gtest.T) { - _, err := db.Model(table).OmitNil().Data(g.Map{ - "id": 1, - "name": "", - }).Save() - t.AssertNil(err) - }) - gtest.C(t, func(t *gtest.T) { - _, err := db.Model(table).OmitNilWhere().Data(g.Map{ - "id": 1, - "name": "", - }).Save() - t.AssertNil(err) - }) -} - -func Test_Model_Option_Where(t *testing.T) { - gtest.C(t, func(t *gtest.T) { - table := createInitTable() - defer dropTable(table) - r, err := db.Model(table).OmitEmpty().Data("nickname", 1).Where(g.Map{"id": 0, "passport": ""}).Where(1).Update() - t.AssertNil(err) - n, _ := r.RowsAffected() - t.Assert(n, TableSize) - }) - - gtest.C(t, func(t *gtest.T) { - table := createInitTable() - defer dropTable(table) - r, err := db.Model(table).OmitEmpty().Data("nickname", 1).Where(g.Map{"id": 1, "passport": ""}).Update() - t.AssertNil(err) - n, _ := r.RowsAffected() - t.Assert(n, 1) + } + defer dropTable(table) - v, err := db.Model(table).Where("id", 1).Fields("nickname").Value() - t.AssertNil(err) - t.Assert(v.String(), "1") + gtest.C(t, func(t *gtest.T) { + _, err := db.Model(table).OmitNil().Data(g.Map{ + "id": 1, + "name": nil, + }).Save() + t.AssertNE(err, nil) }) -} - -func Test_Model_Where_MultiSliceArguments(t *testing.T) { - table := createInitTable() - defer dropTable(table) gtest.C(t, func(t *gtest.T) { - r, err := db.Model(table).Where(g.Map{ - "id": g.Slice{1, 2, 3, 4}, - "passport": g.Slice{"user_2", "user_3", "user_4"}, - "nickname": g.Slice{"name_2", "name_4"}, - "id >= 4": nil, - }).All() + _, err := db.Model(table).OmitNil().Data(g.Map{ + "id": 1, + "name": "", + }).Save() t.AssertNil(err) - t.Assert(len(r), 1) - t.Assert(r[0]["id"], 4) }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).Where(g.Map{ - "id": g.Slice{1, 2, 3}, - "passport": g.Slice{"user_2", "user_3"}, - }).WhereOr("nickname=?", g.Slice{"name_4"}).Where("id", 3).One() + _, err := db.Model(table).OmitNilWhere().Data(g.Map{ + "id": 1, + "name": "", + }).Save() t.AssertNil(err) - t.AssertGT(len(result), 0) - t.Assert(result["id"].Int(), 2) }) } @@ -3260,315 +2623,6 @@ func Test_Model_Fields_Map_Struct(t *testing.T) { }) } -func Test_Model_WhereIn(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereIn("id", g.Slice{1, 2, 3, 4}).WhereIn("id", g.Slice{3, 4, 5}).OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), 2) - t.Assert(result[0]["id"], 3) - t.Assert(result[1]["id"], 4) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereIn("id", g.Slice{}).OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), 0) - }) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).OmitEmptyWhere().WhereIn("id", g.Slice{}).OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), TableSize) - }) -} - -func Test_Model_WhereNotIn(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereNotIn("id", g.Slice{1, 2, 3, 4}).WhereNotIn("id", g.Slice{3, 4, 5}).OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), 5) - t.Assert(result[0]["id"], 6) - t.Assert(result[1]["id"], 7) - }) -} - -func Test_Model_WhereOrIn(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereOrIn("id", g.Slice{1, 2, 3, 4}).WhereOrIn("id", g.Slice{3, 4, 5}).OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), 5) - t.Assert(result[0]["id"], 1) - t.Assert(result[4]["id"], 5) - }) -} - -func Test_Model_WhereOrNotIn(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereOrNotIn("id", g.Slice{1, 2, 3, 4}).WhereOrNotIn("id", g.Slice{3, 4, 5}).OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), 8) - t.Assert(result[0]["id"], 1) - t.Assert(result[4]["id"], 7) - }) -} - -func Test_Model_WhereBetween(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereBetween("id", 1, 4).WhereBetween("id", 3, 5).OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), 2) - t.Assert(result[0]["id"], 3) - t.Assert(result[1]["id"], 4) - }) -} - -func Test_Model_WhereNotBetween(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereNotBetween("id", 2, 8).WhereNotBetween("id", 3, 100).OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), 1) - t.Assert(result[0]["id"], 1) - }) -} - -func Test_Model_WhereOrBetween(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereOrBetween("id", 1, 4).WhereOrBetween("id", 3, 5).OrderDesc("id").All() - t.AssertNil(err) - t.Assert(len(result), 5) - t.Assert(result[0]["id"], 5) - t.Assert(result[4]["id"], 1) - }) -} - -func Test_Model_WhereOrNotBetween(t *testing.T) { - table := createInitTable() - defer dropTable(table) - // db.SetDebug(true) - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereOrNotBetween("id", 1, 4).WhereOrNotBetween("id", 3, 5).OrderDesc("id").All() - t.AssertNil(err) - t.Assert(len(result), 8) - t.Assert(result[0]["id"], 10) - t.Assert(result[4]["id"], 6) - }) -} - -func Test_Model_WhereLike(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereLike("nickname", "name%").OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), TableSize) - t.Assert(result[0]["id"], 1) - t.Assert(result[TableSize-1]["id"], TableSize) - }) -} - -func Test_Model_WhereNotLike(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereNotLike("nickname", "name%").OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), 0) - }) -} - -func Test_Model_WhereOrLike(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereOrLike("nickname", "namexxx%").WhereOrLike("nickname", "name%").OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), TableSize) - t.Assert(result[0]["id"], 1) - t.Assert(result[TableSize-1]["id"], TableSize) - }) -} - -func Test_Model_WhereOrNotLike(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereOrNotLike("nickname", "namexxx%").WhereOrNotLike("nickname", "name%").OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), TableSize) - t.Assert(result[0]["id"], 1) - t.Assert(result[TableSize-1]["id"], TableSize) - }) -} - -func Test_Model_WhereNull(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereNull("nickname").WhereNull("passport").OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), 0) - }) -} - -func Test_Model_WhereNotNull(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereNotNull("nickname").WhereNotNull("passport").OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), TableSize) - t.Assert(result[0]["id"], 1) - t.Assert(result[TableSize-1]["id"], TableSize) - }) -} - -func Test_Model_WhereOrNull(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereOrNull("nickname").WhereOrNull("passport").OrderAsc("id").OrderRandom().All() - t.AssertNil(err) - t.Assert(len(result), 0) - }) -} - -func Test_Model_WhereOrNotNull(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereOrNotNull("nickname").WhereOrNotNull("passport").OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), TableSize) - t.Assert(result[0]["id"], 1) - t.Assert(result[TableSize-1]["id"], TableSize) - }) -} - -func Test_Model_WhereLT(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereLT("id", 3).OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), 2) - t.Assert(result[0]["id"], 1) - }) -} - -func Test_Model_WhereLTE(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereLTE("id", 3).OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), 3) - t.Assert(result[0]["id"], 1) - }) -} - -func Test_Model_WhereGT(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereGT("id", 8).OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), 2) - t.Assert(result[0]["id"], 9) - }) -} - -func Test_Model_WhereGTE(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereGTE("id", 8).OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), 3) - t.Assert(result[0]["id"], 8) - }) -} - -func Test_Model_WhereOrLT(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereLT("id", 3).WhereOrLT("id", 4).OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), 3) - t.Assert(result[0]["id"], 1) - t.Assert(result[2]["id"], 3) - }) -} - -func Test_Model_WhereOrLTE(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereLTE("id", 3).WhereOrLTE("id", 4).OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), 4) - t.Assert(result[0]["id"], 1) - t.Assert(result[3]["id"], 4) - }) -} - -func Test_Model_WhereOrGT(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereGT("id", 8).WhereOrGT("id", 7).OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), 3) - t.Assert(result[0]["id"], 8) - }) -} - -func Test_Model_WhereOrGTE(t *testing.T) { - table := createInitTable() - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - result, err := db.Model(table).WhereGTE("id", 8).WhereOrGTE("id", 7).OrderAsc("id").All() - t.AssertNil(err) - t.Assert(len(result), 4) - t.Assert(result[0]["id"], 7) - }) -} - func Test_Model_Min_Max_Avg_Sum(t *testing.T) { table := createInitTable() defer dropTable(table) @@ -4270,89 +3324,6 @@ func Test_Model_Fields_AutoFilterInJoinStatement(t *testing.T) { }) } -func Test_Model_WherePrefix(t *testing.T) { - var ( - table1 = gtime.TimestampNanoStr() + "_table1" - table2 = gtime.TimestampNanoStr() + "_table2" - ) - createInitTable(table1) - defer dropTable(table1) - createInitTable(table2) - defer dropTable(table2) - - gtest.C(t, func(t *gtest.T) { - r, err := db.Model(table1). - FieldsPrefix(table1, "*"). - LeftJoinOnField(table2, "id"). - WherePrefix(table2, g.Map{ - "id": g.Slice{1, 2}, - }). - Order("id asc").All() - t.AssertNil(err) - t.Assert(len(r), 2) - t.Assert(r[0]["id"], "1") - t.Assert(r[1]["id"], "2") - }) -} - -func Test_Model_WhereOrPrefix(t *testing.T) { - var ( - table1 = gtime.TimestampNanoStr() + "_table1" - table2 = gtime.TimestampNanoStr() + "_table2" - ) - createInitTable(table1) - defer dropTable(table1) - createInitTable(table2) - defer dropTable(table2) - - gtest.C(t, func(t *gtest.T) { - r, err := db.Model(table1). - FieldsPrefix(table1, "*"). - LeftJoinOnField(table2, "id"). - WhereOrPrefix(table1, g.Map{ - "id": g.Slice{1, 2}, - }). - WhereOrPrefix(table2, g.Map{ - "id": g.Slice{8, 9}, - }). - Order("id asc").All() - t.AssertNil(err) - t.Assert(len(r), 4) - t.Assert(r[0]["id"], "1") - t.Assert(r[1]["id"], "2") - t.Assert(r[2]["id"], "8") - t.Assert(r[3]["id"], "9") - }) -} - -func Test_Model_WherePrefixLike(t *testing.T) { - var ( - table1 = gtime.TimestampNanoStr() + "_table1" - table2 = gtime.TimestampNanoStr() + "_table2" - ) - createInitTable(table1) - defer dropTable(table1) - createInitTable(table2) - defer dropTable(table2) - - gtest.C(t, func(t *gtest.T) { - r, err := db.Model(table1). - FieldsPrefix(table1, "*"). - LeftJoinOnField(table2, "id"). - WherePrefix(table1, g.Map{ - "id": g.Slice{1, 2, 3}, - }). - WherePrefix(table2, g.Map{ - "id": g.Slice{3, 4, 5}, - }). - WherePrefixLike(table2, "nickname", "name%"). - Order("id asc").All() - t.AssertNil(err) - t.Assert(len(r), 1) - t.Assert(r[0]["id"], "3") - }) -} - // https://github.com/gogf/gf/issues/1159 func Test_ScanList_NoRecreate_PtrAttribute(t *testing.T) { gtest.C(t, func(t *gtest.T) { diff --git a/contrib/drivers/mysql/mysql_z_unit_model_where_test.go b/contrib/drivers/mysql/mysql_z_unit_model_where_test.go new file mode 100644 index 00000000000..c0007c6885a --- /dev/null +++ b/contrib/drivers/mysql/mysql_z_unit_model_where_test.go @@ -0,0 +1,1244 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package mysql_test + +import ( + "fmt" + "testing" + + "github.com/gogf/gf/v2/container/gmap" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gutil" +) + +func Test_Model_Where(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + // string + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where("id=? and nickname=?", 3, "name_3").One() + t.AssertNil(err) + t.AssertGT(len(result), 0) + t.Assert(result["id"].Int(), 3) + }) + + // slice + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where(g.Slice{"id", 3}).One() + t.AssertNil(err) + t.AssertGT(len(result), 0) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where(g.Slice{"id", 3, "nickname", "name_3"}).One() + t.AssertNil(err) + t.AssertGT(len(result), 0) + t.Assert(result["id"].Int(), 3) + }) + + // slice parameter + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where("id=? and nickname=?", g.Slice{3, "name_3"}).One() + t.AssertNil(err) + t.AssertGT(len(result), 0) + t.Assert(result["id"].Int(), 3) + }) + // map like + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where(g.Map{ + "passport like": "user_1%", + }).Order("id asc").All() + t.AssertNil(err) + t.Assert(len(result), 2) + t.Assert(result[0].GMap().Get("id"), 1) + t.Assert(result[1].GMap().Get("id"), 10) + }) + // map + slice parameter + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where(g.Map{ + "id": g.Slice{1, 2, 3}, + "passport": g.Slice{"user_2", "user_3"}, + }).Where("id=? and nickname=?", g.Slice{3, "name_3"}).One() + t.AssertNil(err) + t.AssertGT(len(result), 0) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where(g.Map{ + "id": g.Slice{1, 2, 3}, + "passport": g.Slice{"user_2", "user_3"}, + }).WhereOr("nickname=?", g.Slice{"name_4"}).Where("id", 3).One() + t.AssertNil(err) + t.AssertGT(len(result), 0) + t.Assert(result["id"].Int(), 2) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where("id=3", g.Slice{}).One() + t.AssertNil(err) + t.AssertGT(len(result), 0) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where("id=?", g.Slice{3}).One() + t.AssertNil(err) + t.AssertGT(len(result), 0) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where("id", 3).One() + t.AssertNil(err) + t.AssertGT(len(result), 0) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where("id", 3).Where("nickname", "name_3").One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where("id", 3).Where("nickname", "name_3").One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where("id", 30).WhereOr("nickname", "name_3").One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where("id", 30).WhereOr("nickname", "name_3").Where("id>?", 1).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where("id", 30).WhereOr("nickname", "name_3").Where("id>", 1).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + // slice + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where("id=? AND nickname=?", g.Slice{3, "name_3"}...).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where("id=? AND nickname=?", g.Slice{3, "name_3"}).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where("passport like ? and nickname like ?", g.Slice{"user_3", "name_3"}).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + // map + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where(g.Map{"id": 3, "nickname": "name_3"}).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + // map key operator + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where(g.Map{"id>": 1, "id<": 3}).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 2) + }) + + // gmap.Map + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where(gmap.NewFrom(g.MapAnyAny{"id": 3, "nickname": "name_3"})).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + // gmap.Map key operator + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where(gmap.NewFrom(g.MapAnyAny{"id>": 1, "id<": 3})).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 2) + }) + + // list map + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where(gmap.NewListMapFrom(g.MapAnyAny{"id": 3, "nickname": "name_3"})).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + // list map key operator + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where(gmap.NewListMapFrom(g.MapAnyAny{"id>": 1, "id<": 3})).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 2) + }) + + // tree map + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where(gmap.NewTreeMapFrom(gutil.ComparatorString, g.MapAnyAny{"id": 3, "nickname": "name_3"})).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + // tree map key operator + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where(gmap.NewTreeMapFrom(gutil.ComparatorString, g.MapAnyAny{"id>": 1, "id<": 3})).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 2) + }) + + // complicated where 1 + gtest.C(t, func(t *gtest.T) { + // db.SetDebug(true) + conditions := g.Map{ + "nickname like ?": "%name%", + "id between ? and ?": g.Slice{1, 3}, + "id > 0": nil, + "create_time > 0": nil, + "id": g.Slice{1, 2, 3}, + } + result, err := db.Model(table).Where(conditions).Order("id asc").All() + t.AssertNil(err) + t.Assert(len(result), 3) + t.Assert(result[0]["id"].Int(), 1) + }) + // complicated where 2 + gtest.C(t, func(t *gtest.T) { + // db.SetDebug(true) + conditions := g.Map{ + "nickname like ?": "%name%", + "id between ? and ?": g.Slice{1, 3}, + "id >= ?": 1, + "create_time > ?": 0, + "id in(?)": g.Slice{1, 2, 3}, + } + result, err := db.Model(table).Where(conditions).Order("id asc").All() + t.AssertNil(err) + t.Assert(len(result), 3) + t.Assert(result[0]["id"].Int(), 1) + }) + // struct, automatic mapping and filtering. + gtest.C(t, func(t *gtest.T) { + type User struct { + Id int + Nickname string + } + result, err := db.Model(table).Where(User{3, "name_3"}).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + + result, err = db.Model(table).Where(&User{3, "name_3"}).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + // slice single + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where("id IN(?)", g.Slice{1, 3}).Order("id ASC").All() + t.AssertNil(err) + t.Assert(len(result), 2) + t.Assert(result[0]["id"].Int(), 1) + t.Assert(result[1]["id"].Int(), 3) + }) + // slice + string + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where("nickname=? AND id IN(?)", "name_3", g.Slice{1, 3}).Order("id ASC").All() + t.AssertNil(err) + t.Assert(len(result), 1) + t.Assert(result[0]["id"].Int(), 3) + }) + // slice + map + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where(g.Map{ + "id": g.Slice{1, 3}, + "nickname": "name_3", + }).Order("id ASC").All() + t.AssertNil(err) + t.Assert(len(result), 1) + t.Assert(result[0]["id"].Int(), 3) + }) + // slice + struct + gtest.C(t, func(t *gtest.T) { + type User struct { + Ids []int `json:"id"` + Nickname string `gconv:"nickname"` + } + result, err := db.Model(table).Where(User{ + Ids: []int{1, 3}, + Nickname: "name_3", + }).Order("id ASC").All() + t.AssertNil(err) + t.Assert(len(result), 1) + t.Assert(result[0]["id"].Int(), 3) + }) +} + +func Test_Model_Option_Where(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + table := createInitTable() + defer dropTable(table) + r, err := db.Model(table).OmitEmpty().Data("nickname", 1).Where(g.Map{"id": 0, "passport": ""}).Where(1).Update() + t.AssertNil(err) + n, _ := r.RowsAffected() + t.Assert(n, TableSize) + }) + + gtest.C(t, func(t *gtest.T) { + table := createInitTable() + defer dropTable(table) + r, err := db.Model(table).OmitEmpty().Data("nickname", 1).Where(g.Map{"id": 1, "passport": ""}).Update() + t.AssertNil(err) + n, _ := r.RowsAffected() + t.Assert(n, 1) + + v, err := db.Model(table).Where("id", 1).Fields("nickname").Value() + t.AssertNil(err) + t.Assert(v.String(), "1") + }) +} + +func Test_Model_Where_MultiSliceArguments(t *testing.T) { + table := createInitTable() + defer dropTable(table) + gtest.C(t, func(t *gtest.T) { + r, err := db.Model(table).Where(g.Map{ + "id": g.Slice{1, 2, 3, 4}, + "passport": g.Slice{"user_2", "user_3", "user_4"}, + "nickname": g.Slice{"name_2", "name_4"}, + "id >= 4": nil, + }).All() + t.AssertNil(err) + t.Assert(len(r), 1) + t.Assert(r[0]["id"], 4) + }) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where(g.Map{ + "id": g.Slice{1, 2, 3}, + "passport": g.Slice{"user_2", "user_3"}, + }).WhereOr("nickname=?", g.Slice{"name_4"}).Where("id", 3).One() + t.AssertNil(err) + t.AssertGT(len(result), 0) + t.Assert(result["id"].Int(), 2) + }) +} + +func Test_Model_Where_ISNULL_1(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + // db.SetDebug(true) + result, err := db.Model(table).Data("nickname", nil).Where("id", 2).Update() + t.AssertNil(err) + n, _ := result.RowsAffected() + t.Assert(n, 1) + + one, err := db.Model(table).Where("nickname", nil).One() + t.AssertNil(err) + t.Assert(one.IsEmpty(), false) + t.Assert(one["id"], 2) + }) +} + +func Test_Model_Where_ISNULL_2(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + // complicated one. + gtest.C(t, func(t *gtest.T) { + // db.SetDebug(true) + conditions := g.Map{ + "nickname like ?": "%name%", + "id between ? and ?": g.Slice{1, 3}, + "id > 0": nil, + "create_time > 0": nil, + "id": g.Slice{1, 2, 3}, + } + result, err := db.Model(table).Where(conditions).Order("id asc").All() + t.AssertNil(err) + t.Assert(len(result), 3) + t.Assert(result[0]["id"].Int(), 1) + }) +} + +func Test_Model_Where_OmitEmpty(t *testing.T) { + table := createInitTable() + defer dropTable(table) + gtest.C(t, func(t *gtest.T) { + conditions := g.Map{ + "id < 4": "", + } + result, err := db.Model(table).Where(conditions).Order("id desc").All() + t.AssertNil(err) + t.Assert(len(result), 3) + t.Assert(result[0]["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + conditions := g.Map{ + "id < 4": "", + } + result, err := db.Model(table).Where(conditions).OmitEmpty().Order("id desc").All() + t.AssertNil(err) + t.Assert(len(result), 10) + t.Assert(result[0]["id"].Int(), 10) + }) +} + +func Test_Model_Where_GTime(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where("create_time>?", gtime.NewFromStr("2010-09-01")).All() + t.AssertNil(err) + t.Assert(len(result), 10) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Where("create_time>?", *gtime.NewFromStr("2010-09-01")).All() + t.AssertNil(err) + t.Assert(len(result), 10) + }) +} + +func Test_Model_WherePri(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + // primary key + gtest.C(t, func(t *gtest.T) { + one, err := db.Model(table).WherePri(3).One() + t.AssertNil(err) + t.AssertNE(one, nil) + t.Assert(one["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + all, err := db.Model(table).WherePri(g.Slice{3, 9}).Order("id asc").All() + t.AssertNil(err) + t.Assert(len(all), 2) + t.Assert(all[0]["id"].Int(), 3) + t.Assert(all[1]["id"].Int(), 9) + }) + + // string + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri("id=? and nickname=?", 3, "name_3").One() + t.AssertNil(err) + t.AssertGT(len(result), 0) + t.Assert(result["id"].Int(), 3) + }) + // slice parameter + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri("id=? and nickname=?", g.Slice{3, "name_3"}).One() + t.AssertNil(err) + t.AssertGT(len(result), 0) + t.Assert(result["id"].Int(), 3) + }) + // map like + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri(g.Map{ + "passport like": "user_1%", + }).Order("id asc").All() + t.AssertNil(err) + t.Assert(len(result), 2) + t.Assert(result[0].GMap().Get("id"), 1) + t.Assert(result[1].GMap().Get("id"), 10) + }) + // map + slice parameter + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri(g.Map{ + "id": g.Slice{1, 2, 3}, + "passport": g.Slice{"user_2", "user_3"}, + }).Where("id=? and nickname=?", g.Slice{3, "name_3"}).One() + t.AssertNil(err) + t.AssertGT(len(result), 0) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri(g.Map{ + "id": g.Slice{1, 2, 3}, + "passport": g.Slice{"user_2", "user_3"}, + }).WhereOr("nickname=?", g.Slice{"name_4"}).Where("id", 3).One() + t.AssertNil(err) + t.AssertGT(len(result), 0) + t.Assert(result["id"].Int(), 2) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri("id=3", g.Slice{}).One() + t.AssertNil(err) + t.AssertGT(len(result), 0) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri("id=?", g.Slice{3}).One() + t.AssertNil(err) + t.AssertGT(len(result), 0) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri("id", 3).One() + t.AssertNil(err) + t.AssertGT(len(result), 0) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri("id", 3).WherePri("nickname", "name_3").One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri("id", 3).Where("nickname", "name_3").One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri("id", 30).WhereOr("nickname", "name_3").One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri("id", 30).WhereOr("nickname", "name_3").Where("id>?", 1).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri("id", 30).WhereOr("nickname", "name_3").Where("id>", 1).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + // slice + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri("id=? AND nickname=?", g.Slice{3, "name_3"}...).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri("id=? AND nickname=?", g.Slice{3, "name_3"}).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri("passport like ? and nickname like ?", g.Slice{"user_3", "name_3"}).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + // map + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri(g.Map{"id": 3, "nickname": "name_3"}).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + // map key operator + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri(g.Map{"id>": 1, "id<": 3}).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 2) + }) + + // gmap.Map + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri(gmap.NewFrom(g.MapAnyAny{"id": 3, "nickname": "name_3"})).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + // gmap.Map key operator + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri(gmap.NewFrom(g.MapAnyAny{"id>": 1, "id<": 3})).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 2) + }) + + // list map + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri(gmap.NewListMapFrom(g.MapAnyAny{"id": 3, "nickname": "name_3"})).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + // list map key operator + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri(gmap.NewListMapFrom(g.MapAnyAny{"id>": 1, "id<": 3})).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 2) + }) + + // tree map + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri(gmap.NewTreeMapFrom(gutil.ComparatorString, g.MapAnyAny{"id": 3, "nickname": "name_3"})).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + // tree map key operator + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri(gmap.NewTreeMapFrom(gutil.ComparatorString, g.MapAnyAny{"id>": 1, "id<": 3})).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 2) + }) + + // complicated where 1 + gtest.C(t, func(t *gtest.T) { + // db.SetDebug(true) + conditions := g.Map{ + "nickname like ?": "%name%", + "id between ? and ?": g.Slice{1, 3}, + "id > 0": nil, + "create_time > 0": nil, + "id": g.Slice{1, 2, 3}, + } + result, err := db.Model(table).WherePri(conditions).Order("id asc").All() + t.AssertNil(err) + t.Assert(len(result), 3) + t.Assert(result[0]["id"].Int(), 1) + }) + // complicated where 2 + gtest.C(t, func(t *gtest.T) { + // db.SetDebug(true) + conditions := g.Map{ + "nickname like ?": "%name%", + "id between ? and ?": g.Slice{1, 3}, + "id >= ?": 1, + "create_time > ?": 0, + "id in(?)": g.Slice{1, 2, 3}, + } + result, err := db.Model(table).WherePri(conditions).Order("id asc").All() + t.AssertNil(err) + t.Assert(len(result), 3) + t.Assert(result[0]["id"].Int(), 1) + }) + // struct + gtest.C(t, func(t *gtest.T) { + type User struct { + Id int `json:"id"` + Nickname string `gconv:"nickname"` + } + result, err := db.Model(table).WherePri(User{3, "name_3"}).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + + result, err = db.Model(table).WherePri(&User{3, "name_3"}).One() + t.AssertNil(err) + t.Assert(result["id"].Int(), 3) + }) + // slice single + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri("id IN(?)", g.Slice{1, 3}).Order("id ASC").All() + t.AssertNil(err) + t.Assert(len(result), 2) + t.Assert(result[0]["id"].Int(), 1) + t.Assert(result[1]["id"].Int(), 3) + }) + // slice + string + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri("nickname=? AND id IN(?)", "name_3", g.Slice{1, 3}).Order("id ASC").All() + t.AssertNil(err) + t.Assert(len(result), 1) + t.Assert(result[0]["id"].Int(), 3) + }) + // slice + map + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WherePri(g.Map{ + "id": g.Slice{1, 3}, + "nickname": "name_3", + }).Order("id ASC").All() + t.AssertNil(err) + t.Assert(len(result), 1) + t.Assert(result[0]["id"].Int(), 3) + }) + // slice + struct + gtest.C(t, func(t *gtest.T) { + type User struct { + Ids []int `json:"id"` + Nickname string `gconv:"nickname"` + } + result, err := db.Model(table).WherePri(User{ + Ids: []int{1, 3}, + Nickname: "name_3", + }).Order("id ASC").All() + t.AssertNil(err) + t.Assert(len(result), 1) + t.Assert(result[0]["id"].Int(), 3) + }) +} + +func Test_Model_WhereIn(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereIn("id", g.Slice{1, 2, 3, 4}).WhereIn("id", g.Slice{3, 4, 5}).OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 2) + t.Assert(result[0]["id"], 3) + t.Assert(result[1]["id"], 4) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereIn("id", g.Slice{}).OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 0) + }) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).OmitEmptyWhere().WhereIn("id", g.Slice{}).OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), TableSize) + }) +} + +func Test_Model_WhereNotIn(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereNotIn("id", g.Slice{1, 2, 3, 4}).WhereNotIn("id", g.Slice{3, 4, 5}).OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 5) + t.Assert(result[0]["id"], 6) + t.Assert(result[1]["id"], 7) + }) +} + +func Test_Model_WhereOrIn(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereOrIn("id", g.Slice{1, 2, 3, 4}).WhereOrIn("id", g.Slice{3, 4, 5}).OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 5) + t.Assert(result[0]["id"], 1) + t.Assert(result[4]["id"], 5) + }) +} + +func Test_Model_WhereOrNotIn(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereOrNotIn("id", g.Slice{1, 2, 3, 4}).WhereOrNotIn("id", g.Slice{3, 4, 5}).OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 8) + t.Assert(result[0]["id"], 1) + t.Assert(result[4]["id"], 7) + }) +} + +func Test_Model_WhereBetween(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereBetween("id", 1, 4).WhereBetween("id", 3, 5).OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 2) + t.Assert(result[0]["id"], 3) + t.Assert(result[1]["id"], 4) + }) +} + +func Test_Model_WhereNotBetween(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereNotBetween("id", 2, 8).WhereNotBetween("id", 3, 100).OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 1) + t.Assert(result[0]["id"], 1) + }) +} + +func Test_Model_WhereOrBetween(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereOrBetween("id", 1, 4).WhereOrBetween("id", 3, 5).OrderDesc("id").All() + t.AssertNil(err) + t.Assert(len(result), 5) + t.Assert(result[0]["id"], 5) + t.Assert(result[4]["id"], 1) + }) +} + +func Test_Model_WhereOrNotBetween(t *testing.T) { + table := createInitTable() + defer dropTable(table) + // db.SetDebug(true) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereOrNotBetween("id", 1, 4).WhereOrNotBetween("id", 3, 5).OrderDesc("id").All() + t.AssertNil(err) + t.Assert(len(result), 8) + t.Assert(result[0]["id"], 10) + t.Assert(result[4]["id"], 6) + }) +} + +func Test_Model_WhereLike(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereLike("nickname", "name%").OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), TableSize) + t.Assert(result[0]["id"], 1) + t.Assert(result[TableSize-1]["id"], TableSize) + }) +} + +func Test_Model_WhereNotLike(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereNotLike("nickname", "name%").OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 0) + }) +} + +func Test_Model_WhereOrLike(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereOrLike("nickname", "namexxx%").WhereOrLike("nickname", "name%").OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), TableSize) + t.Assert(result[0]["id"], 1) + t.Assert(result[TableSize-1]["id"], TableSize) + }) +} + +func Test_Model_WhereOrNotLike(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereOrNotLike("nickname", "namexxx%").WhereOrNotLike("nickname", "name%").OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), TableSize) + t.Assert(result[0]["id"], 1) + t.Assert(result[TableSize-1]["id"], TableSize) + }) +} + +func Test_Model_WhereNull(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereNull("nickname").WhereNull("passport").OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 0) + }) +} + +func Test_Model_WhereNotNull(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereNotNull("nickname").WhereNotNull("passport").OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), TableSize) + t.Assert(result[0]["id"], 1) + t.Assert(result[TableSize-1]["id"], TableSize) + }) +} + +func Test_Model_WhereOrNull(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereOrNull("nickname").WhereOrNull("passport").OrderAsc("id").OrderRandom().All() + t.AssertNil(err) + t.Assert(len(result), 0) + }) +} + +func Test_Model_WhereOrNotNull(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereOrNotNull("nickname").WhereOrNotNull("passport").OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), TableSize) + t.Assert(result[0]["id"], 1) + t.Assert(result[TableSize-1]["id"], TableSize) + }) +} + +func Test_Model_WhereLT(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereLT("id", 3).OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 2) + t.Assert(result[0]["id"], 1) + }) +} + +func Test_Model_WhereLTE(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereLTE("id", 3).OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 3) + t.Assert(result[0]["id"], 1) + }) +} + +func Test_Model_WhereGT(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereGT("id", 8).OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 2) + t.Assert(result[0]["id"], 9) + }) +} + +func Test_Model_WhereGTE(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereGTE("id", 8).OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 3) + t.Assert(result[0]["id"], 8) + }) +} + +func Test_Model_WhereOrLT(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereLT("id", 3).WhereOrLT("id", 4).OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 3) + t.Assert(result[0]["id"], 1) + t.Assert(result[2]["id"], 3) + }) +} + +func Test_Model_WhereOrLTE(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereLTE("id", 3).WhereOrLTE("id", 4).OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 4) + t.Assert(result[0]["id"], 1) + t.Assert(result[3]["id"], 4) + }) +} + +func Test_Model_WhereOrGT(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereGT("id", 8).WhereOrGT("id", 7).OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 3) + t.Assert(result[0]["id"], 8) + }) +} + +func Test_Model_WhereOrGTE(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).WhereGTE("id", 8).WhereOrGTE("id", 7).OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 4) + t.Assert(result[0]["id"], 7) + }) +} + +func Test_Model_WherePrefix(t *testing.T) { + var ( + table1 = gtime.TimestampNanoStr() + "_table1" + table2 = gtime.TimestampNanoStr() + "_table2" + ) + createInitTable(table1) + defer dropTable(table1) + createInitTable(table2) + defer dropTable(table2) + + gtest.C(t, func(t *gtest.T) { + r, err := db.Model(table1). + FieldsPrefix(table1, "*"). + LeftJoinOnField(table2, "id"). + WherePrefix(table2, g.Map{ + "id": g.Slice{1, 2}, + }). + Order("id asc").All() + t.AssertNil(err) + t.Assert(len(r), 2) + t.Assert(r[0]["id"], "1") + t.Assert(r[1]["id"], "2") + }) +} + +func Test_Model_WhereOrPrefix(t *testing.T) { + var ( + table1 = gtime.TimestampNanoStr() + "_table1" + table2 = gtime.TimestampNanoStr() + "_table2" + ) + createInitTable(table1) + defer dropTable(table1) + createInitTable(table2) + defer dropTable(table2) + + gtest.C(t, func(t *gtest.T) { + r, err := db.Model(table1). + FieldsPrefix(table1, "*"). + LeftJoinOnField(table2, "id"). + WhereOrPrefix(table1, g.Map{ + "id": g.Slice{1, 2}, + }). + WhereOrPrefix(table2, g.Map{ + "id": g.Slice{8, 9}, + }). + Order("id asc").All() + t.AssertNil(err) + t.Assert(len(r), 4) + t.Assert(r[0]["id"], "1") + t.Assert(r[1]["id"], "2") + t.Assert(r[2]["id"], "8") + t.Assert(r[3]["id"], "9") + }) +} + +func Test_Model_WherePrefixLike(t *testing.T) { + var ( + table1 = gtime.TimestampNanoStr() + "_table1" + table2 = gtime.TimestampNanoStr() + "_table2" + ) + createInitTable(table1) + defer dropTable(table1) + createInitTable(table2) + defer dropTable(table2) + + gtest.C(t, func(t *gtest.T) { + r, err := db.Model(table1). + FieldsPrefix(table1, "*"). + LeftJoinOnField(table2, "id"). + WherePrefix(table1, g.Map{ + "id": g.Slice{1, 2, 3}, + }). + WherePrefix(table2, g.Map{ + "id": g.Slice{3, 4, 5}, + }). + WherePrefixLike(table2, "nickname", "name%"). + Order("id asc").All() + t.AssertNil(err) + t.Assert(len(r), 1) + t.Assert(r[0]["id"], "3") + }) +} + +func Test_Model_WhereExists(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + // Create another table for exists subquery + table2 := "table2_" + gtime.TimestampNanoStr() + sqlCreate := fmt.Sprintf(` +CREATE TABLE %s ( + id int(10) unsigned NOT NULL AUTO_INCREMENT, + uid int(10) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `, table2) + if _, err := db.Exec(ctx, sqlCreate); err != nil { + t.AssertNil(err) + } + defer dropTable(table2) + + // Insert test data + _, err := db.Model(table2).Insert(g.List{ + {"uid": 1}, + {"uid": 2}, + }) + t.AssertNil(err) + + // Test WhereExists with subquery + subQuery1 := db.Model(table2). + Fields("id"). + Where("uid = ?", db.Raw("user.id")) + + r, err := db.Model(table + " as user"). + WhereExists(subQuery1). + Order("id asc"). + All() + t.AssertNil(err) + t.Assert(len(r), 2) + t.Assert(r[0]["id"].Int(), 1) + t.Assert(r[1]["id"].Int(), 2) + + // Test WhereNotExists + r, err = db.Model(table + " as user"). + WhereNotExists(subQuery1). + Order("id asc"). + All() + t.AssertNil(err) + t.Assert(len(r), 8) + t.Assert(r[0]["id"].Int(), 3) + + // Test WhereExists with empty result + subQuery2 := db.Model(table2). + Fields("id"). + Where("uid = -1") + r, err = db.Model(table). + WhereExists(subQuery2). + All() + t.AssertNil(err) + t.Assert(len(r), 0) + + // Test WhereNotExists with all results + r, err = db.Model(table). + WhereNotExists(subQuery2). + All() + t.AssertNil(err) + t.Assert(len(r), 10) + + // Test combination of Where and WhereExists + r, err = db.Model(table+" as user"). + Where("id>?", 3). + WhereExists(subQuery1). + Order("id asc"). + All() + t.AssertNil(err) + t.Assert(len(r), 0) + + // Test WhereExists with complex subquery + subQuery3 := db.Model(table2). + Fields("id"). + Where("uid = ?", db.Raw("user.id")). + Where("id > ?", 0) + r, err = db.Model(table + " as user"). + WhereExists(subQuery3). + Order("id asc"). + All() + t.AssertNil(err) + t.Assert(len(r), 2) + t.Assert(r[0]["id"].Int(), 1) + t.Assert(r[1]["id"].Int(), 2) + + // Test WhereExists with Fields + r, err = db.Model(table + " as user"). + Fields("id,passport"). + WhereExists(subQuery1). + Order("id asc"). + All() + t.AssertNil(err) + t.Assert(len(r), 2) + t.Assert(r[0]["id"].Int(), 1) + t.Assert(r[0]["passport"].String(), "user_1") + + // Test WhereExists with Group + r, err = db.Model(table + " as user"). + WhereExists(subQuery1). + Group("id"). + Order("id asc"). + All() + t.AssertNil(err) + t.Assert(len(r), 2) + t.Assert(r[0]["id"].Int(), 1) + t.Assert(r[1]["id"].Int(), 2) + + // Test WhereExists with Having + r, err = db.Model(table+" as user"). + WhereExists(subQuery1). + Group("id"). + Having("id > ?", 1). + Order("id asc"). + All() + t.AssertNil(err) + t.Assert(len(r), 1) + t.Assert(r[0]["id"].Int(), 2) + }) +} + +func Test_Model_WhereNotExists(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + // Create another table for exists subquery + table2 := "table2_" + gtime.TimestampNanoStr() + sqlCreate := fmt.Sprintf(` +CREATE TABLE %s ( + id int(10) unsigned NOT NULL AUTO_INCREMENT, + uid int(10) unsigned NOT NULL DEFAULT '0', + PRIMARY KEY (id) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + `, table2) + if _, err := db.Exec(ctx, sqlCreate); err != nil { + t.AssertNil(err) + } + defer dropTable(table2) + + // Insert test data + _, err := db.Model(table2).Insert(g.List{ + {"uid": 1}, + {"uid": 2}, + }) + t.AssertNil(err) + + // Test WhereNotExists with subquery + subQuery1 := db.Model(table2). + Fields("id"). + Where("uid = ?", db.Raw("user.id")) + + r, err := db.Model(table + " as user"). + WhereNotExists(subQuery1). + Order("id asc"). + All() + t.AssertNil(err) + t.Assert(len(r), 8) // Should be 8 because records with id 1 and 2 exist in table2 + t.Assert(r[0]["id"].Int(), 3) // First record should be id 3 + t.Assert(r[1]["id"].Int(), 4) // Second record should be id 4 + + // Test WhereNotExists with empty subquery + subQuery2 := db.Model(table2). + Fields("id"). + Where("uid = -1") // This condition will return no results + r, err = db.Model(table + " as user"). + WhereNotExists(subQuery2). + Order("id asc"). + All() + t.AssertNil(err) + t.Assert(len(r), 10) // Should return all records when subquery is empty + + // Test WhereNotExists with complex condition + subQuery3 := db.Model(table2). + Fields("id"). + Where("uid = ?", db.Raw("user.id")). + Where("id > ?", 1) + r, err = db.Model(table + " as user"). + WhereNotExists(subQuery3). + Order("id asc"). + All() + t.AssertNil(err) + t.Assert(len(r), 9) // Should only exclude the record with id 2 + t.Assert(r[0]["id"].Int(), 1) // Should include id 1 + }) +} diff --git a/database/gdb/gdb_model_builder_where.go b/database/gdb/gdb_model_builder_where.go index 4ae43f856a8..7b695b96b64 100644 --- a/database/gdb/gdb_model_builder_where.go +++ b/database/gdb/gdb_model_builder_where.go @@ -159,3 +159,13 @@ func (b *WhereBuilder) WhereNotNull(columns ...string) *WhereBuilder { } return builder } + +// WhereExists builds `EXISTS (subQuery)` statement. +func (b *WhereBuilder) WhereExists(subQuery *Model) *WhereBuilder { + return b.Wheref(`EXISTS (?)`, subQuery) +} + +// WhereNotExists builds `NOT EXISTS (subQuery)` statement. +func (b *WhereBuilder) WhereNotExists(subQuery *Model) *WhereBuilder { + return b.Wheref(`NOT EXISTS (?)`, subQuery) +} diff --git a/database/gdb/gdb_model_where.go b/database/gdb/gdb_model_where.go index 96ea722b6b3..067a9bcadb9 100644 --- a/database/gdb/gdb_model_where.go +++ b/database/gdb/gdb_model_where.go @@ -117,3 +117,13 @@ func (m *Model) WhereNotIn(column string, in interface{}) *Model { func (m *Model) WhereNotNull(columns ...string) *Model { return m.callWhereBuilder(m.whereBuilder.WhereNotNull(columns...)) } + +// WhereExists builds `EXISTS (subQuery)` statement. +func (m *Model) WhereExists(subQuery *Model) *Model { + return m.callWhereBuilder(m.whereBuilder.WhereExists(subQuery)) +} + +// WhereNotExists builds `NOT EXISTS (subQuery)` statement. +func (m *Model) WhereNotExists(subQuery *Model) *Model { + return m.callWhereBuilder(m.whereBuilder.WhereNotExists(subQuery)) +} From 80e73da41600215be272202e079b2bfd46c34084 Mon Sep 17 00:00:00 2001 From: John Guo Date: Mon, 9 Dec 2024 23:11:56 +0800 Subject: [PATCH 039/102] feat(errors/gerror): add `As` support (#4002) --- errors/gerror/gerror_api_stack.go | 17 +++++++ errors/gerror/gerror_z_unit_test.go | 69 +++++++++++++++++++++++++++++ os/gcron/gcron_z_unit_test.go | 2 +- 3 files changed, 87 insertions(+), 1 deletion(-) diff --git a/errors/gerror/gerror_api_stack.go b/errors/gerror/gerror_api_stack.go index b8c5f269c90..f773681047c 100644 --- a/errors/gerror/gerror_api_stack.go +++ b/errors/gerror/gerror_api_stack.go @@ -98,6 +98,23 @@ func Is(err, target error) bool { return errors.Is(err, target) } +// As finds the first error in err's chain that matches target, and if so, sets +// target to that error value and returns true. +// +// The chain consists of err itself followed by the sequence of errors obtained by +// repeatedly calling Unwrap. +// +// An error matches target if the error's concrete value is assignable to the value +// pointed to by target, or if the error has a method As(interface{}) bool such that +// As(target) returns true. In the latter case, the As method is responsible for +// setting target. +// +// As will panic if target is not a non-nil pointer to either a type that implements +// error, or to any interface type. As returns false if err is nil. +func As(err error, target any) bool { + return errors.As(err, target) +} + // HasError performs as Is. // This function is designed and implemented early before errors.Is of go stdlib. // Deprecated: use Is instead. diff --git a/errors/gerror/gerror_z_unit_test.go b/errors/gerror/gerror_z_unit_test.go index 29da031372b..83acc183774 100644 --- a/errors/gerror/gerror_z_unit_test.go +++ b/errors/gerror/gerror_z_unit_test.go @@ -17,6 +17,22 @@ import ( "github.com/gogf/gf/v2/test/gtest" ) +// customError is used to test As function +type customError struct { + Message string +} + +func (e *customError) Error() string { + return e.Message +} + +// anotherError is used to test As function with different error type +type anotherError struct{} + +func (e *anotherError) Error() string { + return "another error" +} + func nilError() error { return nil } @@ -472,3 +488,56 @@ func Test_NewOption(t *testing.T) { }), gerror.New("NewOptionError")) }) } + +func Test_As(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var myerr = &customError{Message: "custom error"} + + // Test with nil error + var targetErr *customError + t.Assert(gerror.As(nil, &targetErr), false) + t.Assert(targetErr, nil) + + // Test with standard error + err1 := errors.New("standard error") + t.Assert(gerror.As(err1, &targetErr), false) + t.Assert(targetErr, nil) + + // Test with custom error type + err2 := myerr + t.Assert(gerror.As(err2, &targetErr), true) + t.Assert(targetErr.Message, "custom error") + + // Test with wrapped error + err3 := gerror.Wrap(myerr, "wrapped") + targetErr = nil + t.Assert(gerror.As(err3, &targetErr), true) + t.Assert(targetErr.Message, "custom error") + + // Test with deeply wrapped error + err4 := gerror.Wrap(gerror.Wrap(gerror.Wrap(myerr, "wrap3"), "wrap2"), "wrap1") + targetErr = nil + t.Assert(gerror.As(err4, &targetErr), true) + t.Assert(targetErr.Message, "custom error") + + // Test with different error type + var otherErr *anotherError + t.Assert(gerror.As(err4, &otherErr), false) + t.Assert(otherErr, nil) + + // Test with non-pointer target + defer func() { + t.Assert(recover() != nil, true) + }() + var nonPtr customError + gerror.As(err4, nonPtr) + }) + + gtest.C(t, func(t *gtest.T) { + // Test with nil target + defer func() { + t.Assert(recover() != nil, true) + }() + gerror.As(errors.New("error"), nil) + }) +} diff --git a/os/gcron/gcron_z_unit_test.go b/os/gcron/gcron_z_unit_test.go index 1f92a3d8e5f..1f162d56097 100644 --- a/os/gcron/gcron_z_unit_test.go +++ b/os/gcron/gcron_z_unit_test.go @@ -133,7 +133,7 @@ func doTestCronAddFixedPattern(t *testing.T) { array.Append(1) }) t.AssertNil(err) - time.Sleep(3000 * time.Millisecond) + time.Sleep(3500 * time.Millisecond) g.Log().Debug(ctx, `current time`) t.Assert(array.Len(), 1) }) From bae78fbf5bf5f816e38dc39415b2e9d79fcd875b Mon Sep 17 00:00:00 2001 From: John Guo Date: Mon, 9 Dec 2024 23:12:09 +0800 Subject: [PATCH 040/102] feat(net/ghttp): add middleware `MiddlewareGzip` for compressing response content using gzip (#4008) --- net/ghttp/ghttp_middleware_gzip.go | 76 ++++++++++++++ .../ghttp_z_unit_middleware_gzip_test.go | 98 +++++++++++++++++++ 2 files changed, 174 insertions(+) create mode 100644 net/ghttp/ghttp_middleware_gzip.go create mode 100644 net/ghttp/ghttp_z_unit_middleware_gzip_test.go diff --git a/net/ghttp/ghttp_middleware_gzip.go b/net/ghttp/ghttp_middleware_gzip.go new file mode 100644 index 00000000000..6599baeb461 --- /dev/null +++ b/net/ghttp/ghttp_middleware_gzip.go @@ -0,0 +1,76 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package ghttp + +import ( + "bytes" + "compress/gzip" + "net/http" + "strings" +) + +// MiddlewareGzip is a middleware that compresses HTTP response using gzip compression. +// Note that it does not compress responses if: +// 1. The response is already compressed (Content-Encoding header is set) +// 2. The client does not accept gzip compression +// 3. The response body length is too small (less than 1KB) +// +// To disable compression for specific routes, you can use the group middleware: +// +// group.Group("/api", func(group *ghttp.RouterGroup) { +// group.Middleware(ghttp.MiddlewareGzip) // Enable GZIP for /api routes +// }) +func MiddlewareGzip(r *Request) { + // Skip compression if client doesn't accept gzip + if !acceptsGzip(r.Request) { + r.Middleware.Next() + return + } + + // Execute the next handlers first + r.Middleware.Next() + + // Skip if already compressed or empty response + if r.Response.Header().Get("Content-Encoding") != "" { + return + } + + // Get the response buffer and check its length + buffer := r.Response.Buffer() + if len(buffer) < 1024 { + return + } + + // Try to compress the response + var ( + compressed bytes.Buffer + logger = r.Server.Logger() + ctx = r.Context() + ) + gzipWriter := gzip.NewWriter(&compressed) + if _, err := gzipWriter.Write(buffer); err != nil { + logger.Warningf(ctx, "gzip compression failed: %+v", err) + return + } + if err := gzipWriter.Close(); err != nil { + logger.Warningf(ctx, "gzip writer close failed: %+v", err) + return + } + + // Clear the original buffer and set headers + r.Response.ClearBuffer() + r.Response.Header().Set("Content-Encoding", "gzip") + r.Response.Header().Del("Content-Length") + + // Write the compressed data + r.Response.Write(compressed.Bytes()) +} + +// acceptsGzip returns true if the client accepts gzip compression. +func acceptsGzip(r *http.Request) bool { + return strings.Contains(r.Header.Get("Accept-Encoding"), "gzip") +} diff --git a/net/ghttp/ghttp_z_unit_middleware_gzip_test.go b/net/ghttp/ghttp_z_unit_middleware_gzip_test.go new file mode 100644 index 00000000000..7bacfe4bd75 --- /dev/null +++ b/net/ghttp/ghttp_z_unit_middleware_gzip_test.go @@ -0,0 +1,98 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package ghttp_test + +import ( + "compress/gzip" + "fmt" + "io" + "strings" + "testing" + "time" + + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/guid" +) + +func Test_Middleware_Gzip(t *testing.T) { + s := g.Server(guid.S()) + // Routes with GZIP enabled + s.Group("/", func(group *ghttp.RouterGroup) { + group.Middleware(ghttp.MiddlewareGzip) + group.ALL("/", func(r *ghttp.Request) { + r.Response.Write(strings.Repeat("Hello World! ", 1000)) + }) + group.ALL("/small", func(r *ghttp.Request) { + r.Response.Write("Small response") + }) + }) + + // Routes without GZIP + s.Group("/no-gzip", func(group *ghttp.RouterGroup) { + group.ALL("/", func(r *ghttp.Request) { + r.Response.Write(strings.Repeat("Hello World! ", 1000)) + }) + }) + + s.SetDumpRouterMap(false) + s.Start() + defer s.Shutdown() + time.Sleep(100 * time.Millisecond) + + gtest.C(t, func(t *gtest.T) { + client := g.Client() + client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) + + // Test 1: Route with GZIP, client supports GZIP + resp, err := client.Header(map[string]string{ + "Accept-Encoding": "gzip", + }).Get(ctx, "/") + t.AssertNil(err) + t.Assert(resp.Header.Get("Content-Encoding"), "gzip") + + reader, err := gzip.NewReader(resp.Body) + t.AssertNil(err) + defer reader.Close() + + content, err := io.ReadAll(reader) + t.AssertNil(err) + expected := strings.Repeat("Hello World! ", 1000) + t.Assert(len(content), len(expected)) + t.Assert(string(content), expected) + + // Test 2: Route with GZIP, client doesn't support GZIP + resp, err = client.Header(map[string]string{}).Get(ctx, "/") + t.AssertNil(err) + t.Assert(resp.Header.Get("Content-Encoding"), "") + content, err = io.ReadAll(resp.Body) + t.AssertNil(err) + t.Assert(len(content), len(expected)) + t.Assert(string(content), expected) + + // Test 3: Route with GZIP, response too small + resp, err = client.Header(map[string]string{ + "Accept-Encoding": "gzip", + }).Get(ctx, "/small") + t.AssertNil(err) + t.Assert(resp.Header.Get("Content-Encoding"), "") + content, err = io.ReadAll(resp.Body) + t.AssertNil(err) + t.Assert(string(content), "Small response") + + // Test 4: Route without GZIP + resp, err = client.Header(map[string]string{ + "Accept-Encoding": "gzip", + }).Get(ctx, "/no-gzip/") + t.AssertNil(err) + t.Assert(resp.Header.Get("Content-Encoding"), "") + content, err = io.ReadAll(resp.Body) + t.AssertNil(err) + t.Assert(string(content), expected) + }) +} From 13bc192e36052f5c4ab6627f503159a6b8e2c8b2 Mon Sep 17 00:00:00 2001 From: John Guo Date: Mon, 9 Dec 2024 23:12:20 +0800 Subject: [PATCH 041/102] feat(database/gdb): add sharding feature for schema and table (#4014) --- ...ysql_z_unit_feature_model_sharding_test.go | 231 +++++++++++++++++- database/gdb/gdb_model.go | 2 + database/gdb/gdb_model_delete.go | 2 + database/gdb/gdb_model_hook.go | 49 ++++ database/gdb/gdb_model_insert.go | 1 + database/gdb/gdb_model_select.go | 1 + database/gdb/gdb_model_sharding.go | 161 ++++++++++++ database/gdb/gdb_model_update.go | 1 + database/gdb/gdb_model_utility.go | 35 ++- 9 files changed, 476 insertions(+), 7 deletions(-) create mode 100644 database/gdb/gdb_model_sharding.go diff --git a/contrib/drivers/mysql/mysql_z_unit_feature_model_sharding_test.go b/contrib/drivers/mysql/mysql_z_unit_feature_model_sharding_test.go index e8b50e91d25..5ace95336f4 100644 --- a/contrib/drivers/mysql/mysql_z_unit_feature_model_sharding_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_feature_model_sharding_test.go @@ -18,7 +18,234 @@ import ( "github.com/gogf/gf/v2/test/gtest" ) -func Test_Model_Sharding_Table(t *testing.T) { +const ( + TestDbNameSh0 = "test_0" + TestDbNameSh1 = "test_1" + TestTableName = "user" +) + +type ShardingUser struct { + Id int + Name string +} + +// createShardingDatabase creates test databases and tables for sharding +func createShardingDatabase(t *gtest.T) { + // Create databases + dbs := []string{TestDbNameSh0, TestDbNameSh1} + for _, dbName := range dbs { + sql := fmt.Sprintf("CREATE DATABASE IF NOT EXISTS `%s`", dbName) + _, err := db.Exec(ctx, sql) + t.AssertNil(err) + + // Switch to the database + sql = fmt.Sprintf("USE `%s`", dbName) + _, err = db.Exec(ctx, sql) + t.AssertNil(err) + + // Create tables + tables := []string{"user_0", "user_1", "user_2", "user_3"} + for _, table := range tables { + sql := fmt.Sprintf(` + CREATE TABLE IF NOT EXISTS %s ( + id int(11) NOT NULL, + name varchar(255) NOT NULL, + PRIMARY KEY (id) + ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; + `, table) + _, err := db.Exec(ctx, sql) + t.AssertNil(err) + } + } +} + +// dropShardingDatabase drops test databases +func dropShardingDatabase(t *gtest.T) { + dbs := []string{TestDbNameSh0, TestDbNameSh1} + for _, dbName := range dbs { + sql := fmt.Sprintf("DROP DATABASE IF EXISTS `%s`", dbName) + _, err := db.Exec(ctx, sql) + t.AssertNil(err) + } +} + +func Test_Sharding_Basic(t *testing.T) { + return + gtest.C(t, func(t *gtest.T) { + var ( + tablePrefix = "user_" + schemaPrefix = "test_" + ) + + // Create test databases and tables + createShardingDatabase(t) + defer dropShardingDatabase(t) + + // Create sharding configuration + shardingConfig := gdb.ShardingConfig{ + Table: gdb.ShardingTableConfig{ + Enable: true, + Prefix: tablePrefix, + Rule: &gdb.DefaultShardingRule{ + TableCount: 4, + }, + }, + Schema: gdb.ShardingSchemaConfig{ + Enable: true, + Prefix: schemaPrefix, + Rule: &gdb.DefaultShardingRule{ + SchemaCount: 2, + }, + }, + } + + // Prepare test data + user := ShardingUser{ + Id: 1, + Name: "John", + } + + model := db.Model(TestTableName). + Sharding(shardingConfig). + ShardingValue(user.Id). + Safe() + + // Test Insert + _, err := model.Data(user).Insert() + t.AssertNil(err) + + // Test Select + var result ShardingUser + err = model.Where("id", user.Id).Scan(&result) + t.AssertNil(err) + t.Assert(result.Id, user.Id) + t.Assert(result.Name, user.Name) + + // Test Update + _, err = model.Data(g.Map{"name": "John Doe"}). + Where("id", user.Id). + Update() + t.AssertNil(err) + + // Verify Update + err = model.Where("id", user.Id).Scan(&result) + t.AssertNil(err) + t.Assert(result.Name, "John Doe") + + // Test Delete + _, err = model.Where("id", user.Id).Delete() + t.AssertNil(err) + + // Verify Delete + count, err := model.Where("id", user.Id).Count() + t.AssertNil(err) + t.Assert(count, 0) + }) +} + +// Test_Sharding_Error tests error cases +func Test_Sharding_Error(t *testing.T) { + return + gtest.C(t, func(t *gtest.T) { + // Create test databases and tables + createShardingDatabase(t) + defer dropShardingDatabase(t) + + // Test missing sharding value + model := db.Model(TestTableName). + Sharding(gdb.ShardingConfig{ + Table: gdb.ShardingTableConfig{ + Enable: true, + Prefix: "user_", + Rule: &gdb.DefaultShardingRule{TableCount: 4}, + }, + }).Safe() + + _, err := model.Insert(g.Map{"id": 1, "name": "test"}) + t.AssertNE(err, nil) + t.Assert(err.Error(), "sharding value is required when sharding feature enabled") + + // Test missing sharding rule + model = db.Model(TestTableName). + Sharding(gdb.ShardingConfig{ + Table: gdb.ShardingTableConfig{ + Enable: true, + Prefix: "user_", + }, + }). + ShardingValue(1) + + _, err = model.Insert(g.Map{"id": 1, "name": "test"}) + t.AssertNE(err, nil) + t.Assert(err.Error(), "sharding rule is required when sharding feature enabled") + }) +} + +// Test_Sharding_Complex tests complex sharding scenarios +func Test_Sharding_Complex(t *testing.T) { + return + gtest.C(t, func(t *gtest.T) { + // Create test databases and tables + createShardingDatabase(t) + defer dropShardingDatabase(t) + + shardingConfig := gdb.ShardingConfig{ + Table: gdb.ShardingTableConfig{ + Enable: true, + Prefix: "user_", + Rule: &gdb.DefaultShardingRule{TableCount: 4}, + }, + Schema: gdb.ShardingSchemaConfig{ + Enable: true, + Prefix: "test_", + Rule: &gdb.DefaultShardingRule{SchemaCount: 2}, + }, + } + + users := []ShardingUser{ + {Id: 1, Name: "User1"}, + {Id: 2, Name: "User2"}, + {Id: 3, Name: "User3"}, + } + + for _, user := range users { + model := db.Model(TestTableName). + Sharding(shardingConfig). + ShardingValue(user.Id). + Safe() + + _, err := model.Data(user).Insert() + t.AssertNil(err) + } + + // Test batch query + for _, user := range users { + model := db.Model(TestTableName). + Sharding(shardingConfig). + ShardingValue(user.Id). + Safe() + + var result ShardingUser + err := model.Where("id", user.Id).Scan(&result) + t.AssertNil(err) + t.Assert(result.Id, user.Id) + t.Assert(result.Name, user.Name) + } + + // Clean up + for _, user := range users { + model := db.Model(TestTableName). + Sharding(shardingConfig). + ShardingValue(user.Id). + Safe() + + _, err := model.Where("id", user.Id).Delete() + t.AssertNil(err) + } + }) +} + +func Test_Model_Sharding_Table_Using_Hook(t *testing.T) { var ( table1 = gtime.TimestampNanoStr() + "_table1" table2 = gtime.TimestampNanoStr() + "_table2" @@ -127,7 +354,7 @@ func Test_Model_Sharding_Table(t *testing.T) { }) } -func Test_Model_Sharding_Schema(t *testing.T) { +func Test_Model_Sharding_Schema_Using_Hook(t *testing.T) { var ( table = gtime.TimestampNanoStr() + "_table" ) diff --git a/database/gdb/gdb_model.go b/database/gdb/gdb_model.go index beaa515008a..dc67fef7dfc 100644 --- a/database/gdb/gdb_model.go +++ b/database/gdb/gdb_model.go @@ -53,6 +53,8 @@ type Model struct { onConflict interface{} // onConflict is used for conflict keys on Upsert clause. tableAliasMap map[string]string // Table alias to true table name, usually used in join statements. softTimeOption SoftTimeOption // SoftTimeOption is the option to customize soft time feature for Model. + shardingConfig ShardingConfig // ShardingConfig for database/table sharding feature. + shardingValue any // Sharding value for sharding feature. } // ModelHandler is a function that handles given Model and returns a new Model that is custom modified. diff --git a/database/gdb/gdb_model_delete.go b/database/gdb/gdb_model_delete.go index b6a32c52424..25b417be59e 100644 --- a/database/gdb/gdb_model_delete.go +++ b/database/gdb/gdb_model_delete.go @@ -64,6 +64,7 @@ func (m *Model) Delete(where ...interface{}) (result sql.Result, err error) { }, Model: m, Table: m.tables, + Schema: m.schema, Data: dataHolder, Condition: conditionStr, Args: append([]interface{}{dataValue}, conditionArgs...), @@ -80,6 +81,7 @@ func (m *Model) Delete(where ...interface{}) (result sql.Result, err error) { }, Model: m, Table: m.tables, + Schema: m.schema, Condition: conditionStr, Args: conditionArgs, } diff --git a/database/gdb/gdb_model_hook.go b/database/gdb/gdb_model_hook.go index 3428990a73c..7c88428f7dc 100644 --- a/database/gdb/gdb_model_hook.go +++ b/database/gdb/gdb_model_hook.go @@ -122,6 +122,17 @@ func (h *HookSelectInput) Next(ctx context.Context) (result Result, err error) { if h.originalSchemaName.IsNil() { h.originalSchemaName = gvar.New(h.Schema) } + + // Sharding feature. + h.Schema, err = h.Model.getActualSchema(ctx, h.Schema) + if err != nil { + return nil, err + } + h.Table, err = h.Model.getActualTable(ctx, h.Table) + if err != nil { + return nil, err + } + // Custom hook handler call. if h.handler != nil && !h.handlerCalled { h.handlerCalled = true @@ -161,11 +172,23 @@ func (h *HookInsertInput) Next(ctx context.Context) (result sql.Result, err erro h.originalSchemaName = gvar.New(h.Schema) } + // Sharding feature. + h.Schema, err = h.Model.getActualSchema(ctx, h.Schema) + if err != nil { + return nil, err + } + h.Table, err = h.Model.getActualTable(ctx, h.Table) + if err != nil { + return nil, err + } + if h.handler != nil && !h.handlerCalled { h.handlerCalled = true return h.handler(ctx, h) } + // No need to handle table change. + // Schema change. if h.Schema != "" && h.Schema != h.originalSchemaName.String() { h.link, err = h.Model.db.GetCore().MasterLink(h.Schema) @@ -185,6 +208,16 @@ func (h *HookUpdateInput) Next(ctx context.Context) (result sql.Result, err erro h.originalSchemaName = gvar.New(h.Schema) } + // Sharding feature. + h.Schema, err = h.Model.getActualSchema(ctx, h.Schema) + if err != nil { + return nil, err + } + h.Table, err = h.Model.getActualTable(ctx, h.Table) + if err != nil { + return nil, err + } + if h.handler != nil && !h.handlerCalled { h.handlerCalled = true if gstr.HasPrefix(h.Condition, whereKeyInCondition) { @@ -196,6 +229,9 @@ func (h *HookUpdateInput) Next(ctx context.Context) (result sql.Result, err erro if h.removedWhere { h.Condition = whereKeyInCondition + h.Condition } + + // No need to handle table change. + // Schema change. if h.Schema != "" && h.Schema != h.originalSchemaName.String() { h.link, err = h.Model.db.GetCore().MasterLink(h.Schema) @@ -215,6 +251,16 @@ func (h *HookDeleteInput) Next(ctx context.Context) (result sql.Result, err erro h.originalSchemaName = gvar.New(h.Schema) } + // Sharding feature. + h.Schema, err = h.Model.getActualSchema(ctx, h.Schema) + if err != nil { + return nil, err + } + h.Table, err = h.Model.getActualTable(ctx, h.Table) + if err != nil { + return nil, err + } + if h.handler != nil && !h.handlerCalled { h.handlerCalled = true if gstr.HasPrefix(h.Condition, whereKeyInCondition) { @@ -226,6 +272,9 @@ func (h *HookDeleteInput) Next(ctx context.Context) (result sql.Result, err erro if h.removedWhere { h.Condition = whereKeyInCondition + h.Condition } + + // No need to handle table change. + // Schema change. if h.Schema != "" && h.Schema != h.originalSchemaName.String() { h.link, err = h.Model.db.GetCore().MasterLink(h.Schema) diff --git a/database/gdb/gdb_model_insert.go b/database/gdb/gdb_model_insert.go index fad1728acaa..efb65df06c2 100644 --- a/database/gdb/gdb_model_insert.go +++ b/database/gdb/gdb_model_insert.go @@ -335,6 +335,7 @@ func (m *Model) doInsertWithOption(ctx context.Context, insertOption InsertOptio }, Model: m, Table: m.tables, + Schema: m.schema, Data: list, Option: doInsertOption, } diff --git a/database/gdb/gdb_model_select.go b/database/gdb/gdb_model_select.go index 8c6433abf02..cc7a08148e4 100644 --- a/database/gdb/gdb_model_select.go +++ b/database/gdb/gdb_model_select.go @@ -684,6 +684,7 @@ func (m *Model) doGetAllBySql( }, Model: m, Table: m.tables, + Schema: m.schema, Sql: sql, Args: m.mergeArguments(args), SelectType: selectType, diff --git a/database/gdb/gdb_model_sharding.go b/database/gdb/gdb_model_sharding.go new file mode 100644 index 00000000000..384f32bef36 --- /dev/null +++ b/database/gdb/gdb_model_sharding.go @@ -0,0 +1,161 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package gdb + +import ( + "context" + "fmt" + "hash/fnv" + "reflect" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/util/gconv" +) + +// ShardingConfig defines the configuration for database/table sharding. +type ShardingConfig struct { + // Table sharding configuration + Table ShardingTableConfig + // Schema sharding configuration + Schema ShardingSchemaConfig +} + +// ShardingSchemaConfig defines the configuration for database sharding. +type ShardingSchemaConfig struct { + // Enable schema sharding + Enable bool + // Schema rule prefix, e.g., "db_" + Prefix string + // ShardingRule defines how to route data to different database nodes + Rule ShardingRule +} + +// ShardingTableConfig defines the configuration for table sharding +type ShardingTableConfig struct { + // Enable table sharding + Enable bool + // Table rule prefix, e.g., "user_" + Prefix string + // ShardingRule defines how to route data to different tables + Rule ShardingRule +} + +// ShardingRule defines the interface for sharding rules +type ShardingRule interface { + // SchemaName returns the target schema name based on sharding value. + SchemaName(ctx context.Context, config ShardingSchemaConfig, value any) (string, error) + // TableName returns the target table name based on sharding value. + TableName(ctx context.Context, config ShardingTableConfig, value any) (string, error) +} + +// DefaultShardingRule implements a simple modulo-based sharding rule +type DefaultShardingRule struct { + // Number of schema count. + SchemaCount int + // Number of tables per schema. + TableCount int +} + +// Sharding creates a sharding model with given sharding configuration. +func (m *Model) Sharding(config ShardingConfig) *Model { + model := m.getModel() + model.shardingConfig = config + return model +} + +// ShardingValue sets the sharding value for routing +func (m *Model) ShardingValue(value any) *Model { + model := m.getModel() + model.shardingValue = value + return model +} + +// getActualSchema returns the actual schema based on sharding configuration. +// TODO it does not support schemas in different database config node. +func (m *Model) getActualSchema(ctx context.Context, defaultSchema string) (string, error) { + if !m.shardingConfig.Schema.Enable { + return defaultSchema, nil + } + if m.shardingValue == nil { + return defaultSchema, gerror.NewCode( + gcode.CodeInvalidParameter, "sharding value is required when sharding feature enabled", + ) + } + if m.shardingConfig.Schema.Rule == nil { + return defaultSchema, gerror.NewCode( + gcode.CodeInvalidParameter, "sharding rule is required when sharding feature enabled", + ) + } + return m.shardingConfig.Schema.Rule.SchemaName(ctx, m.shardingConfig.Schema, m.shardingValue) +} + +// getActualTable returns the actual table name based on sharding configuration +func (m *Model) getActualTable(ctx context.Context, defaultTable string) (string, error) { + if !m.shardingConfig.Table.Enable { + return defaultTable, nil + } + if m.shardingValue == nil { + return defaultTable, gerror.NewCode( + gcode.CodeInvalidParameter, "sharding value is required when sharding feature enabled", + ) + } + if m.shardingConfig.Table.Rule == nil { + return defaultTable, gerror.NewCode( + gcode.CodeInvalidParameter, "sharding rule is required when sharding feature enabled", + ) + } + return m.shardingConfig.Table.Rule.TableName(ctx, m.shardingConfig.Table, m.shardingValue) +} + +// SchemaName implements the default database sharding strategy +func (r *DefaultShardingRule) SchemaName(ctx context.Context, config ShardingSchemaConfig, value any) (string, error) { + if r.SchemaCount == 0 { + return "", gerror.NewCode( + gcode.CodeInvalidParameter, "schema count should not be 0 using DefaultShardingRule when schema sharding enabled", + ) + } + hashValue, err := getHashValue(value) + if err != nil { + return "", err + } + nodeIndex := hashValue % uint64(r.SchemaCount) + return fmt.Sprintf("%s%d", config.Prefix, nodeIndex), nil +} + +// TableName implements the default table sharding strategy +func (r *DefaultShardingRule) TableName(ctx context.Context, config ShardingTableConfig, value any) (string, error) { + if r.TableCount == 0 { + return "", gerror.NewCode( + gcode.CodeInvalidParameter, "table count should not be 0 using DefaultShardingRule when table sharding enabled", + ) + } + hashValue, err := getHashValue(value) + if err != nil { + return "", err + } + tableIndex := hashValue % uint64(r.TableCount) + return fmt.Sprintf("%s%d", config.Prefix, tableIndex), nil +} + +// getHashValue converts sharding value to uint64 hash +func getHashValue(value any) (uint64, error) { + var rv = reflect.ValueOf(value) + switch rv.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, + reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, + reflect.Float32, reflect.Float64: + return gconv.Uint64(value), nil + default: + h := fnv.New64a() + _, err := h.Write(gconv.Bytes(value)) + if err != nil { + return 0, gerror.WrapCode(gcode.CodeInternalError, err) + } + return h.Sum64(), nil + } +} diff --git a/database/gdb/gdb_model_update.go b/database/gdb/gdb_model_update.go index 44c04d8e67d..c253ab96d28 100644 --- a/database/gdb/gdb_model_update.go +++ b/database/gdb/gdb_model_update.go @@ -105,6 +105,7 @@ func (m *Model) Update(dataAndWhere ...interface{}) (result sql.Result, err erro }, Model: m, Table: m.tables, + Schema: m.schema, Data: newData, Condition: conditionStr, Args: m.mergeArguments(conditionArgs), diff --git a/database/gdb/gdb_model_utility.go b/database/gdb/gdb_model_utility.go index 79fe878ac63..3532396230e 100644 --- a/database/gdb/gdb_model_utility.go +++ b/database/gdb/gdb_model_utility.go @@ -33,10 +33,20 @@ func (m *Model) QuoteWord(s string) string { // Also see DriverMysql.TableFields. func (m *Model) TableFields(tableStr string, schema ...string) (fields map[string]*TableField, err error) { var ( - table = m.db.GetCore().guessPrimaryTableName(tableStr) + ctx = m.GetCtx() + usedTable = m.db.GetCore().guessPrimaryTableName(tableStr) usedSchema = gutil.GetOrDefaultStr(m.schema, schema...) ) - return m.db.TableFields(m.GetCtx(), table, usedSchema) + // Sharding feature. + usedSchema, err = m.getActualSchema(ctx, usedSchema) + if err != nil { + return nil, err + } + usedTable, err = m.getActualTable(ctx, usedTable) + if err != nil { + return nil, err + } + return m.db.TableFields(ctx, usedTable, usedSchema) } // getModel creates and returns a cloned model of current model if `safe` is true, or else it returns @@ -143,9 +153,24 @@ func (m *Model) filterDataForInsertOrUpdate(data interface{}) (interface{}, erro // doMappingAndFilterForInsertOrUpdateDataMap does the filter features for map. // Note that, it does not filter list item, which is also type of map, for "omit empty" feature. func (m *Model) doMappingAndFilterForInsertOrUpdateDataMap(data Map, allowOmitEmpty bool) (Map, error) { - var err error - data, err = m.db.GetCore().mappingAndFilterData( - m.GetCtx(), m.schema, m.tablesInit, data, m.filter, + var ( + err error + ctx = m.GetCtx() + core = m.db.GetCore() + schema = m.schema + table = m.tablesInit + ) + // Sharding feature. + schema, err = m.getActualSchema(ctx, schema) + if err != nil { + return nil, err + } + table, err = m.getActualTable(ctx, table) + if err != nil { + return nil, err + } + data, err = core.mappingAndFilterData( + ctx, schema, table, data, m.filter, ) if err != nil { return nil, err From 2e788be1d3a4d05d90050bbab655917e0e459cbb Mon Sep 17 00:00:00 2001 From: John Guo Date: Mon, 9 Dec 2024 23:12:29 +0800 Subject: [PATCH 042/102] feat(contrib/registry/consul): add consul registry support (#4016) --- .github/workflows/consul/docker-compose.yml | 4 +- .github/workflows/golangci-lint.yml | 40 +- .golangci.yml | 2 +- contrib/registry/consul/README.MD | 104 ++++ contrib/registry/consul/consul.go | 199 ++++++++ contrib/registry/consul/consul_discovery.go | 91 ++++ contrib/registry/consul/consul_test.go | 445 ++++++++++++++++++ contrib/registry/consul/consul_watcher.go | 209 ++++++++ contrib/registry/consul/go.mod | 46 ++ contrib/registry/consul/go.sum | 255 ++++++++++ example/go.mod | 4 +- example/go.sum | 8 +- example/registry/consul/grpc/client/client.go | 39 ++ .../consul/grpc/controller/helloworld.go | 28 ++ .../consul/grpc/protobuf/helloworld.pb.go | 217 +++++++++ .../consul/grpc/protobuf/helloworld.proto | 24 + .../grpc/protobuf/helloworld_grpc.pb.go | 107 +++++ .../registry/consul/grpc/server/config.yaml | 8 + example/registry/consul/grpc/server/server.go | 30 ++ example/registry/consul/http/client/client.go | 29 ++ example/registry/consul/http/server/server.go | 32 ++ 21 files changed, 1911 insertions(+), 10 deletions(-) create mode 100644 contrib/registry/consul/README.MD create mode 100644 contrib/registry/consul/consul.go create mode 100644 contrib/registry/consul/consul_discovery.go create mode 100644 contrib/registry/consul/consul_test.go create mode 100644 contrib/registry/consul/consul_watcher.go create mode 100644 contrib/registry/consul/go.mod create mode 100644 contrib/registry/consul/go.sum create mode 100644 example/registry/consul/grpc/client/client.go create mode 100644 example/registry/consul/grpc/controller/helloworld.go create mode 100644 example/registry/consul/grpc/protobuf/helloworld.pb.go create mode 100644 example/registry/consul/grpc/protobuf/helloworld.proto create mode 100644 example/registry/consul/grpc/protobuf/helloworld_grpc.pb.go create mode 100644 example/registry/consul/grpc/server/config.yaml create mode 100644 example/registry/consul/grpc/server/server.go create mode 100644 example/registry/consul/http/client/client.go create mode 100644 example/registry/consul/http/server/server.go diff --git a/.github/workflows/consul/docker-compose.yml b/.github/workflows/consul/docker-compose.yml index 607c884a50a..6bbb9cf9347 100644 --- a/.github/workflows/consul/docker-compose.yml +++ b/.github/workflows/consul/docker-compose.yml @@ -3,7 +3,7 @@ version: '3.7' services: consul-server: - image: loads/consul:1.15 + image: consul:1.15 container_name: consul-server restart: always volumes: @@ -17,7 +17,7 @@ services: command: "agent" consul-client: - image: loads/consul:1.15 + image: consul:1.15 container_name: consul-client restart: always volumes: diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 567a5239a94..4850913f105 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -14,6 +14,7 @@ on: - feature/** - enhance/** - fix/** + - feat/** pull_request: branches: - master @@ -22,12 +23,13 @@ on: - feature/** - enhance/** - fix/** + - feat/** jobs: golangci: strategy: matrix: - go-version: [ '1.20','1.21.4','1.22','1.23' ] + go-version: [ 'stable' ] name: golangci-lint runs-on: ubuntu-latest steps: @@ -42,4 +44,38 @@ jobs: with: # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. version: v1.62.2 - args: --timeout 3m0s \ No newline at end of file + only-new-issues: true + github-token: ${{ secrets.GITHUB_TOKEN }} + args: --timeout 3m0s --fix + - name: Install gci + run: go install github.com/daixiang0/gci@latest + - name: Run gci + run: | + gci write --custom-order \ + --skip-generated \ + --skip-vendor \ + -s standard \ + -s blank \ + -s default \ + -s dot \ + -s "prefix(github.com/gogf/gf/v2)" \ + -s "prefix(github.com/gogf/gf/cmd)" \ + -s "prefix(github.com/gogf/gf/contrib)" \ + -s "prefix(github.com/gogf/gf/example)" \ + ./ + - name: Check for changes + id: check_changes + run: | + if [[ -n "$(git status --porcelain)" ]]; then + echo "HAS_CHANGES=true" >> $GITHUB_ENV + else + echo "HAS_CHANGES=false" >> $GITHUB_ENV + fi + - name: Commit and push changes + if: env.HAS_CHANGES == 'true' + run: | + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + git add . + git commit -m "Apply gci import order changes" + git push \ No newline at end of file diff --git a/.golangci.yml b/.golangci.yml index 0ee2b141e5c..a2b04ea7735 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -125,7 +125,7 @@ linters-settings: custom-order: true # Drops lexical ordering for custom sections. # Default: false - no-lex-order: true + no-lex-order: false # https://golangci-lint.run/usage/linters/#revive # https://github.com/mgechev/revive/blob/master/RULES_DESCRIPTIONS.md revive: diff --git a/contrib/registry/consul/README.MD b/contrib/registry/consul/README.MD new file mode 100644 index 00000000000..85da78adec6 --- /dev/null +++ b/contrib/registry/consul/README.MD @@ -0,0 +1,104 @@ +# GoFrame Consul Registry + +Use `consul` as service registration and discovery management. + +## Installation +```bash +go get -u github.com/gogf/gf/contrib/registry/consul/v2 +``` +suggested using `go.mod`: +```bash +require github.com/gogf/gf/contrib/registry/consul/v2 latest +``` + +## Example + +### HTTP Server +```go +package main + +import ( + "context" + + "github.com/gogf/gf/contrib/registry/consul/v2" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/net/gsvc" +) + +func main() { + registry, err := consul.New(consul.WithAddress("127.0.0.1:8500")) + if err != nil { + g.Log().Fatal(context.Background(), err) + } + gsvc.SetRegistry(registry) + + s := g.Server("hello.svc") + s.BindHandler("/", func(r *ghttp.Request) { + g.Log().Info(r.Context(), "request received") + r.Response.Write("Hello world") + }) + s.Run() +} +``` + +### HTTP Client +```go +package main + +import ( + "context" + "fmt" + "time" + + "github.com/gogf/gf/contrib/registry/consul/v2" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/gsel" + "github.com/gogf/gf/v2/net/gsvc" + "github.com/gogf/gf/v2/os/gctx" +) + +func main() { + registry, err := consul.New(consul.WithAddress("127.0.0.1:8500")) + if err != nil { + g.Log().Fatal(context.Background(), err) + } + gsvc.SetRegistry(registry) + gsel.SetBuilder(gsel.NewBuilderRoundRobin()) + + client := g.Client() + for i := 0; i < 100; i++ { + res, err := client.Get(gctx.New(), "http://hello.svc/") + if err != nil { + panic(err) + } + fmt.Println(res.ReadAllString()) + res.Close() + time.Sleep(time.Second) + } +} +``` + +## Configuration Options + +The registry supports the following configuration options: + +- `WithAddress(address string)`: Sets the Consul server address (default: "127.0.0.1:8500") +- `WithToken(token string)`: Sets the ACL token for Consul authentication + +## Features + +- Service registration with TTL health check +- Service discovery with health status filtering +- Service metadata support +- Watch support for service changes +- Consul ACL token support + +## Requirements + +- Go 1.18 or higher +- Consul 1.0 or higher + +## License + +`GoFrame Consul` is licensed under the [MIT License](../../../LICENSE), 100% free and open-source, forever. diff --git a/contrib/registry/consul/consul.go b/contrib/registry/consul/consul.go new file mode 100644 index 00000000000..7968e2ee404 --- /dev/null +++ b/contrib/registry/consul/consul.go @@ -0,0 +1,199 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +// Package consul implements service Registry and Discovery using consul. +package consul + +import ( + "context" + "encoding/json" + "fmt" + "sync" + "time" + + "github.com/hashicorp/consul/api" + + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/net/gsvc" +) + +const ( + // DefaultTTL is the default TTL for service registration + DefaultTTL = 20 * time.Second + + // DefaultHealthCheckInterval is the default interval for health check + DefaultHealthCheckInterval = 10 * time.Second +) + +var ( + _ gsvc.Registry = (*Registry)(nil) +) + +// Registry implements gsvc.Registry interface using consul. +type Registry struct { + client *api.Client // Consul client + address string // Consul address + options map[string]string // Additional options + mu sync.RWMutex // Mutex for thread safety +} + +// Option is the configuration option type for registry. +type Option func(r *Registry) + +// WithAddress sets the address for consul client. +func WithAddress(address string) Option { + return func(r *Registry) { + r.mu.Lock() + r.address = address + r.mu.Unlock() + } +} + +// WithToken sets the ACL token for consul client. +func WithToken(token string) Option { + return func(r *Registry) { + r.mu.Lock() + r.options["token"] = token + r.mu.Unlock() + } +} + +// New creates and returns a new Registry. +func New(opts ...Option) (gsvc.Registry, error) { + r := &Registry{ + address: "127.0.0.1:8500", + options: make(map[string]string), + } + + // Apply options + for _, opt := range opts { + opt(r) + } + + // Create consul config + config := api.DefaultConfig() + r.mu.RLock() + config.Address = r.address + if token, ok := r.options["token"]; ok { + config.Token = token + } + r.mu.RUnlock() + + // Create consul client + client, err := api.NewClient(config) + if err != nil { + return nil, err + } + r.client = client + + return r, nil +} + +// Register registers a service to consul. +func (r *Registry) Register(ctx context.Context, service gsvc.Service) (gsvc.Service, error) { + metadata := service.GetMetadata() + if metadata == nil { + metadata = make(map[string]interface{}) + } + + // Convert metadata to string map + meta := make(map[string]string) + if len(metadata) > 0 { + metadataBytes, err := json.Marshal(metadata) + if err != nil { + return nil, gerror.Wrap(err, "failed to marshal metadata") + } + meta["metadata"] = string(metadataBytes) + } + + // Add version to meta + meta["version"] = service.GetVersion() + + endpoints := service.GetEndpoints() + if len(endpoints) == 0 { + return nil, gerror.New("no endpoints found in service") + } + + // Create service ID + serviceID := fmt.Sprintf("%s-%s-%s:%d", service.GetName(), service.GetVersion(), endpoints[0].Host(), endpoints[0].Port()) + + // Create registration + reg := &api.AgentServiceRegistration{ + ID: serviceID, + Name: service.GetName(), + Tags: []string{service.GetVersion()}, + Meta: meta, + Address: endpoints[0].Host(), + Port: endpoints[0].Port(), + } + + // Add health check + checkID := fmt.Sprintf("service:%s", serviceID) + reg.Check = &api.AgentServiceCheck{ + CheckID: checkID, + TTL: DefaultTTL.String(), + DeregisterCriticalServiceAfter: "1m", + } + + // Register service + if err := r.client.Agent().ServiceRegister(reg); err != nil { + return nil, gerror.Wrap(err, "failed to register service") + } + + // Start TTL health check + if err := r.client.Agent().PassTTL(checkID, ""); err != nil { + // Try to deregister service if health check fails + _ = r.client.Agent().ServiceDeregister(serviceID) + return nil, gerror.Wrap(err, "failed to pass TTL health check") + } + + // Start TTL health check goroutine + go r.ttlHealthCheck(serviceID) + + return service, nil +} + +// Deregister deregisters a service from consul. +func (r *Registry) Deregister(ctx context.Context, service gsvc.Service) error { + endpoints := service.GetEndpoints() + if len(endpoints) == 0 { + return gerror.New("no endpoints found in service") + } + + // Create service ID + serviceID := fmt.Sprintf("%s-%s-%s:%d", service.GetName(), service.GetVersion(), endpoints[0].Host(), endpoints[0].Port()) + + return r.client.Agent().ServiceDeregister(serviceID) +} + +// ttlHealthCheck maintains the TTL health check for a service +func (r *Registry) ttlHealthCheck(serviceID string) { + ticker := time.NewTicker(DefaultHealthCheckInterval) + defer ticker.Stop() + + checkID := fmt.Sprintf("service:%s", serviceID) + for range ticker.C { + if err := r.client.Agent().PassTTL(checkID, ""); err != nil { + return + } + } +} + +// GetAddress returns the consul address +func (r *Registry) GetAddress() string { + r.mu.RLock() + defer r.mu.RUnlock() + return r.address +} + +// Watch creates and returns a watcher for specified service. +func (r *Registry) Watch(ctx context.Context, key string) (gsvc.Watcher, error) { + watcher, err := newWatcher(r, key) + if err != nil { + return nil, err + } + return watcher, nil +} diff --git a/contrib/registry/consul/consul_discovery.go b/contrib/registry/consul/consul_discovery.go new file mode 100644 index 00000000000..10fb237e581 --- /dev/null +++ b/contrib/registry/consul/consul_discovery.go @@ -0,0 +1,91 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package consul + +import ( + "context" + "encoding/json" + "fmt" + "time" + + "github.com/hashicorp/consul/api" + + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/net/gsvc" +) + +// Search searches and returns services with specified condition. +func (r *Registry) Search(ctx context.Context, in gsvc.SearchInput) ([]gsvc.Service, error) { + // Get services from consul + services, _, err := r.client.Health().Service(in.Name, "", true, &api.QueryOptions{ + WaitTime: time.Second * 3, + }) + if err != nil { + return nil, gerror.Wrap(err, "failed to get services from consul") + } + + var result []gsvc.Service + for _, service := range services { + if service.Checks.AggregatedStatus() != api.HealthPassing { + continue + } + + // Parse metadata + var metadata map[string]interface{} + if metaStr, ok := service.Service.Meta["metadata"]; ok && metaStr != "" { + if err = json.Unmarshal([]byte(metaStr), &metadata); err != nil { + return nil, gerror.Wrap(err, "failed to unmarshal service metadata") + } + } + + // Skip if version doesn't match + if in.Version != "" { + if len(service.Service.Tags) == 0 || service.Service.Tags[0] != in.Version { + continue + } + } + + // Skip if metadata doesn't match + if len(in.Metadata) > 0 { + if metadata == nil { + continue + } + match := true + for k, v := range in.Metadata { + if mv, ok := metadata[k]; !ok || mv != v { + match = false + break + } + } + if !match { + continue + } + } + + // Get version from tags + version := "" + if len(service.Service.Tags) > 0 { + version = service.Service.Tags[0] + } + + // Create service instance + localService := &gsvc.LocalService{ + Head: "", + Deployment: "", + Namespace: "", + Name: service.Service.Service, + Version: version, + Endpoints: []gsvc.Endpoint{ + gsvc.NewEndpoint(fmt.Sprintf("%s:%d", service.Service.Address, service.Service.Port)), + }, + Metadata: metadata, + } + result = append(result, localService) + } + + return result, nil +} diff --git a/contrib/registry/consul/consul_test.go b/contrib/registry/consul/consul_test.go new file mode 100644 index 00000000000..912f9bd9a0f --- /dev/null +++ b/contrib/registry/consul/consul_test.go @@ -0,0 +1,445 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package consul + +import ( + "context" + "fmt" + "testing" + "time" + + "github.com/gogf/gf/v2/net/gsvc" + "github.com/gogf/gf/v2/test/gtest" +) + +const ( + testServiceName = "test-service" + testServiceVersion = "1.0.0" + testServiceAddress = "127.0.0.1" + testServicePort = 8000 +) + +func createTestService() gsvc.Service { + return &gsvc.LocalService{ + Name: testServiceName, + Version: testServiceVersion, + Metadata: map[string]interface{}{ + "region": "cn-east-1", + "zone": "a", + }, + Endpoints: []gsvc.Endpoint{ + gsvc.NewEndpoint(fmt.Sprintf("%s:%d", testServiceAddress, testServicePort)), + }, + } +} + +func Test_Registry_Basic(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + // Create registry + registry, err := New() + t.AssertNil(err) + t.Assert(registry != nil, true) + + // Test invalid service + invalidService := &gsvc.LocalService{ + Name: testServiceName, + Version: testServiceVersion, + } + _, err = registry.Register(context.Background(), invalidService) + t.AssertNE(err, nil) // Should fail due to no endpoints + + // Create service with invalid metadata + serviceWithInvalidMeta := &gsvc.LocalService{ + Name: testServiceName, + Version: testServiceVersion, + Metadata: map[string]interface{}{ + "invalid": make(chan int), // This will fail JSON marshaling + }, + Endpoints: []gsvc.Endpoint{ + gsvc.NewEndpoint(fmt.Sprintf("%s:%d", testServiceAddress, testServicePort)), + }, + } + _, err = registry.Register(context.Background(), serviceWithInvalidMeta) + t.AssertNE(err, nil) // Should fail due to invalid metadata + + // Create service + service := createTestService() + + // Register service + ctx := context.Background() + registeredService, err := registry.Register(ctx, service) + t.AssertNil(err) + t.Assert(registeredService != nil, true) + + // Wait for service to be registered + time.Sleep(2 * time.Second) + + // Search service + services, err := registry.Search(ctx, gsvc.SearchInput{ + Name: testServiceName, + Version: testServiceVersion, + }) + t.AssertNil(err) + t.Assert(len(services), 1) + + // Test service properties + foundService := services[0] + t.Assert(foundService.GetName(), testServiceName) + t.Assert(foundService.GetVersion(), testServiceVersion) + t.Assert(len(foundService.GetEndpoints()), 1) + + endpoint := foundService.GetEndpoints()[0] + t.Assert(endpoint.Host(), testServiceAddress) + t.Assert(endpoint.Port(), testServicePort) + + metadata := foundService.GetMetadata() + t.Assert(metadata != nil, true) + t.Assert(metadata["region"], "cn-east-1") + t.Assert(metadata["zone"], "a") + + // Search with invalid metadata + servicesWithInvalidMeta, err := registry.Search(ctx, gsvc.SearchInput{ + Name: testServiceName, + Version: testServiceVersion, + Metadata: map[string]interface{}{"nonexistent": "value"}, + }) + t.AssertNil(err) + t.Assert(len(servicesWithInvalidMeta), 0) + + // Test deregister with invalid service + err = registry.Deregister(ctx, invalidService) + t.AssertNE(err, nil) // Should fail due to no endpoints + + // Deregister service + err = registry.Deregister(ctx, service) + t.AssertNil(err) + + // Wait for service to be deregistered + time.Sleep(2 * time.Second) + + // Verify service is deregistered + deregisteredServices, err := registry.Search(ctx, gsvc.SearchInput{ + Name: testServiceName, + Version: testServiceVersion, + }) + t.AssertNil(err) + t.Assert(len(deregisteredServices), 0) + }) +} + +func Test_Registry_Watch(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + // Create registry + registry, err := New() + t.AssertNil(err) + + // Create service + service := createTestService() + + // Register service first + ctx := context.Background() + _, err = registry.Register(ctx, service) + t.AssertNil(err) + defer registry.Deregister(ctx, service) + + // Wait for service to be registered + time.Sleep(time.Second) + + // Create watcher after service is registered + watcher, err := registry.Watch(ctx, testServiceName) + t.AssertNil(err) + t.Assert(watcher != nil, true) + defer watcher.Close() + + // Wait for initial service query + time.Sleep(time.Second) + + // Should receive initial service list + services, err := watcher.Proceed() + t.AssertNil(err) + t.Assert(len(services), 1) + t.Assert(services[0].GetName(), testServiceName) + t.Assert(services[0].GetVersion(), testServiceVersion) + + // Test closing watcher + err = watcher.Close() + t.AssertNil(err) + + // Test watch with invalid service name + watcher, err = registry.Watch(ctx, "nonexistent-service") + t.AssertNil(err) + defer watcher.Close() + + // Wait for initial query + time.Sleep(time.Second) + + // Should receive empty service list for non-existent service + services, err = watcher.Proceed() + t.AssertNil(err) + t.Assert(len(services), 0) + + // Test watch after service deregistration + watcher, err = registry.Watch(ctx, testServiceName) + t.AssertNil(err) + defer watcher.Close() + + // Wait for initial query + time.Sleep(time.Second) + + err = registry.Deregister(ctx, service) + t.AssertNil(err) + + // Wait for service to be deregistered + time.Sleep(time.Second) + + // Should receive empty service list after deregistration + services, err = watcher.Proceed() + t.AssertNil(err) + t.Assert(len(services), 0) + }) +} + +func Test_Registry_MultipleServices(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + // Create registry + registry, err := New() + t.AssertNil(err) + + // Create multiple services + service1 := &gsvc.LocalService{ + Name: testServiceName, + Version: "1.0.0", + Metadata: map[string]interface{}{ + "region": "us-east-1", + }, + Endpoints: []gsvc.Endpoint{ + gsvc.NewEndpoint("127.0.0.1:8001"), + }, + } + + service2 := &gsvc.LocalService{ + Name: testServiceName, + Version: "2.0.0", + Metadata: map[string]interface{}{ + "region": "us-west-1", + }, + Endpoints: []gsvc.Endpoint{ + gsvc.NewEndpoint("127.0.0.1:8002"), + }, + } + + // Register services + ctx := context.Background() + _, err = registry.Register(ctx, service1) + t.AssertNil(err) + defer registry.Deregister(ctx, service1) + + _, err = registry.Register(ctx, service2) + t.AssertNil(err) + defer registry.Deregister(ctx, service2) + + // Wait for services to be registered + time.Sleep(2 * time.Second) + + // Search all services without version filter + allServices, err := registry.Search(ctx, gsvc.SearchInput{ + Name: testServiceName, + }) + t.AssertNil(err) + t.Assert(len(allServices), 2) + + // Test search with different versions + services1, err := registry.Search(ctx, gsvc.SearchInput{ + Name: testServiceName, + Version: "1.0.0", + }) + t.AssertNil(err) + t.Assert(len(services1), 1) + t.Assert(services1[0].GetVersion(), "1.0.0") + + services2, err := registry.Search(ctx, gsvc.SearchInput{ + Name: testServiceName, + Version: "2.0.0", + }) + t.AssertNil(err) + t.Assert(len(services2), 1) + t.Assert(services2[0].GetVersion(), "2.0.0") + + // Test search with metadata + servicesEast, err := registry.Search(ctx, gsvc.SearchInput{ + Name: testServiceName, + Metadata: map[string]interface{}{ + "region": "us-east-1", + }, + }) + t.AssertNil(err) + t.Assert(len(servicesEast), 1) + t.Assert(servicesEast[0].GetMetadata()["region"], "us-east-1") + + // Watch both services + watcher, err := registry.Watch(ctx, testServiceName) + t.AssertNil(err) + defer watcher.Close() + + // Wait for initial query + time.Sleep(time.Second) + + // Should receive updates for both services + services, err := watcher.Proceed() + t.AssertNil(err) + t.Assert(len(services), 2) + + // Verify services are sorted by version + t.Assert(services[0].GetVersion() < services[1].GetVersion(), true) + }) +} + +func Test_Registry_Options(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + // Test with custom address + registry1, err := New(WithAddress("localhost:8500")) + t.AssertNil(err) + t.Assert(registry1.(*Registry).GetAddress(), "localhost:8500") + + // Test with token + registry2, err := New(WithAddress("localhost:8500"), WithToken("test-token")) + t.AssertNil(err) + t.Assert(registry2.(*Registry).options["token"], "test-token") + + // Test with invalid address (should still create registry but fail on operations) + registry3, err := New(WithAddress("invalid:99999")) + t.AssertNil(err) + _, err = registry3.Register(context.Background(), createTestService()) + t.AssertNE(err, nil) + }) +} + +func Test_Registry_MultipleServicesMetadataFiltering(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + // Create registry + registry, err := New() + t.AssertNil(err) + + // Create multiple services + service1 := &gsvc.LocalService{ + Name: testServiceName, + Version: "1.0.0", + Metadata: map[string]interface{}{ + "region": "us-east-1", + "env": "dev", + }, + Endpoints: []gsvc.Endpoint{ + gsvc.NewEndpoint("127.0.0.1:8001"), + }, + } + + service2 := &gsvc.LocalService{ + Name: testServiceName, + Version: "2.0.0", + Metadata: map[string]interface{}{ + "region": "us-west-1", + "env": "prod", + }, + Endpoints: []gsvc.Endpoint{ + gsvc.NewEndpoint("127.0.0.1:8002"), + }, + } + + // Register services + ctx := context.Background() + _, err = registry.Register(ctx, service1) + t.AssertNil(err) + defer registry.Deregister(ctx, service1) + + _, err = registry.Register(ctx, service2) + t.AssertNil(err) + defer registry.Deregister(ctx, service2) + + time.Sleep(time.Second) // Wait for services to be registered + + // Test search with metadata filtering + servicesDev, err := registry.Search(ctx, gsvc.SearchInput{ + Name: testServiceName, + Metadata: map[string]interface{}{ + "env": "dev", + }, + }) + t.AssertNil(err) + t.Assert(len(servicesDev), 1) + t.Assert(servicesDev[0].GetMetadata()["env"], "dev") + + servicesProd, err := registry.Search(ctx, gsvc.SearchInput{ + Name: testServiceName, + Metadata: map[string]interface{}{ + "env": "prod", + }, + }) + t.AssertNil(err) + t.Assert(len(servicesProd), 1) + t.Assert(servicesProd[0].GetMetadata()["env"], "prod") + }) +} + +func Test_Registry_MultipleServicesVersionFiltering(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + // Create registry + registry, err := New() + t.AssertNil(err) + + // Create multiple services + service1 := &gsvc.LocalService{ + Name: testServiceName, + Version: "1.0.0", + Metadata: map[string]interface{}{ + "region": "us-east-1", + }, + Endpoints: []gsvc.Endpoint{ + gsvc.NewEndpoint("127.0.0.1:8001"), + }, + } + + service2 := &gsvc.LocalService{ + Name: testServiceName, + Version: "2.0.0", + Metadata: map[string]interface{}{ + "region": "us-west-1", + }, + Endpoints: []gsvc.Endpoint{ + gsvc.NewEndpoint("127.0.0.1:8002"), + }, + } + + // Register services + ctx := context.Background() + _, err = registry.Register(ctx, service1) + t.AssertNil(err) + defer registry.Deregister(ctx, service1) + + _, err = registry.Register(ctx, service2) + t.AssertNil(err) + defer registry.Deregister(ctx, service2) + + time.Sleep(time.Second) // Wait for services to be registered + + // Test search with version filtering + services, err := registry.Search(ctx, gsvc.SearchInput{ + Name: testServiceName, + Version: "1.0.0", + }) + t.AssertNil(err) + t.Assert(len(services), 1) + t.Assert(services[0].GetVersion(), "1.0.0") + + services, err = registry.Search(ctx, gsvc.SearchInput{ + Name: testServiceName, + Version: "2.0.0", + }) + t.AssertNil(err) + t.Assert(len(services), 1) + t.Assert(services[0].GetVersion(), "2.0.0") + }) +} diff --git a/contrib/registry/consul/consul_watcher.go b/contrib/registry/consul/consul_watcher.go new file mode 100644 index 00000000000..865b6e28c41 --- /dev/null +++ b/contrib/registry/consul/consul_watcher.go @@ -0,0 +1,209 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package consul + +import ( + "encoding/json" + "fmt" + "sort" + "sync" + + "github.com/hashicorp/consul/api" + "github.com/hashicorp/consul/api/watch" + + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/net/gsvc" +) + +// Watcher watches the service changes. +type Watcher struct { + registry *Registry // The registry instance + key string // The service name to watch + closeChan chan struct{} // Channel for closing + eventChan chan struct{} // Channel for notifying changes + mu sync.RWMutex // Mutex for thread safety + plan *watch.Plan // The watch plan + services []gsvc.Service // Current services +} + +// New creates and returns a new watcher. +func newWatcher(registry *Registry, key string) (*Watcher, error) { + w := &Watcher{ + registry: registry, + key: key, + closeChan: make(chan struct{}), + eventChan: make(chan struct{}, 1), + } + + // Start watching + go w.watch() + + return w, nil +} + +// watch starts the watching process. +func (w *Watcher) watch() { + // Get initial service list + initServices, err := w.Services() + if err != nil { + return + } + + // Set initial services + w.mu.Lock() + w.services = initServices + w.mu.Unlock() + + // Create watch plan + plan, err := watch.Parse(map[string]interface{}{ + "type": "service", + "service": w.key, + }) + if err != nil { + return + } + + w.mu.Lock() + w.plan = plan + w.mu.Unlock() + + // Set handler + plan.Handler = func(idx uint64, data interface{}) { + // Check if watcher is closed + select { + case <-w.closeChan: + return + default: + } + + // Get current services + services, _ := w.Services() + + // Update services + w.mu.Lock() + w.services = services + w.mu.Unlock() + + // Notify changes + select { + case w.eventChan <- struct{}{}: + default: + } + } + + // Start watching + go func() { + defer func() { + w.mu.Lock() + if w.plan != nil { + w.plan.Stop() + w.plan = nil + } + w.mu.Unlock() + }() + + if err = plan.Run(w.registry.GetAddress()); err != nil { + return + } + }() + + // Wait for close signal + <-w.closeChan +} + +// Proceed returns current services and waits for the next service change. +func (w *Watcher) Proceed() ([]gsvc.Service, error) { + // Check if watcher is closed + select { + case <-w.closeChan: + return nil, gerror.New("watcher closed") + default: + } + + w.mu.RLock() + services := w.services + w.mu.RUnlock() + + // Wait for changes + select { + case <-w.closeChan: + return nil, gerror.New("watcher closed") + case <-w.eventChan: + w.mu.RLock() + services = w.services + w.mu.RUnlock() + return services, nil + } +} + +// Close closes the watcher. +func (w *Watcher) Close() error { + w.mu.Lock() + defer w.mu.Unlock() + + select { + case <-w.closeChan: + return nil + default: + close(w.closeChan) + if w.plan != nil { + w.plan.Stop() + w.plan = nil + } + return nil + } +} + +// Services returns current services from the watcher. +func (w *Watcher) Services() ([]gsvc.Service, error) { + // Query services directly from Consul + entries, _, err := w.registry.client.Health().Service(w.key, "", true, &api.QueryOptions{}) + if err != nil { + return nil, err + } + // Convert entries to services + var services []gsvc.Service + for _, entry := range entries { + if entry.Checks.AggregatedStatus() == api.HealthPassing { + metadata := make(map[string]interface{}) + if entry.Service.Meta != nil { + if metaStr, ok := entry.Service.Meta["metadata"]; ok { + if err := json.Unmarshal([]byte(metaStr), &metadata); err != nil { + return nil, gerror.Wrap(err, "failed to unmarshal metadata") + } + } + } + + // Get version from metadata or tags + version := "" + if v, ok := entry.Service.Meta["version"]; ok { + version = v + } else if len(entry.Service.Tags) > 0 { + version = entry.Service.Tags[0] + } + + // Create service instance + service := &gsvc.LocalService{ + Name: entry.Service.Service, + Version: version, + Metadata: metadata, + Endpoints: []gsvc.Endpoint{ + gsvc.NewEndpoint(fmt.Sprintf("%s:%d", entry.Service.Address, entry.Service.Port)), + }, + } + services = append(services, service) + } + } + + // Sort services by version + if len(services) > 0 { + sort.Slice(services, func(i, j int) bool { + return services[i].GetVersion() < services[j].GetVersion() + }) + } + return services, nil +} diff --git a/contrib/registry/consul/go.mod b/contrib/registry/consul/go.mod new file mode 100644 index 00000000000..2bf364b61d5 --- /dev/null +++ b/contrib/registry/consul/go.mod @@ -0,0 +1,46 @@ +module github.com/gogf/gf/contrib/registry/consul/v2 + +go 1.18 + +require ( + github.com/gogf/gf/v2 v2.8.1 + github.com/hashicorp/consul/api v1.26.1 +) + +require ( + github.com/BurntSushi/toml v1.4.0 // indirect + 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/fsnotify/fsnotify v1.7.0 // indirect + github.com/go-logr/logr v1.4.2 // indirect + github.com/go-logr/stdr v1.2.2 // indirect + github.com/gorilla/websocket v1.5.3 // indirect + github.com/grokify/html-strip-tags-go v0.1.0 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect + github.com/hashicorp/go-cleanhttp v0.5.2 // indirect + github.com/hashicorp/go-hclog v1.5.0 // indirect + github.com/hashicorp/go-immutable-radix v1.3.1 // indirect + github.com/hashicorp/go-multierror v1.1.1 // indirect + 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/mattn/go-colorable v0.1.13 // indirect + github.com/mattn/go-isatty v0.0.20 // indirect + github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/mitchellh/go-homedir v1.1.0 // indirect + github.com/mitchellh/mapstructure v1.5.0 // indirect + github.com/olekukonko/tablewriter v0.0.5 // indirect + github.com/rivo/uniseg v0.4.7 // indirect + go.opentelemetry.io/otel v1.24.0 // indirect + go.opentelemetry.io/otel/metric v1.24.0 // indirect + 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/net v0.27.0 // indirect + golang.org/x/sys v0.22.0 // indirect + golang.org/x/text v0.16.0 // indirect + gopkg.in/yaml.v3 v3.0.1 // indirect +) diff --git a/contrib/registry/consul/go.sum b/contrib/registry/consul/go.sum new file mode 100644 index 00000000000..1e5a596416a --- /dev/null +++ b/contrib/registry/consul/go.sum @@ -0,0 +1,255 @@ +github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= +github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= +github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= +github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= +github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= +github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= +github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA= +github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= +github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= +github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= +github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= +github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= +github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= +github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= +github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= +github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= +github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= +github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= +github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= +github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= +github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= +github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= +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/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= +github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= +github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= +github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= +github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= +github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= +github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= +github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= +github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= +github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= +github.com/gogf/gf/v2 v2.8.1 h1:1oVQg3G5OgCats4qWFTH3pHLe92nfUQeUDta05tUs1g= +github.com/gogf/gf/v2 v2.8.1/go.mod h1:6iYuZZ+A0ZcH8+4MDS/P0SvTPCvKzRvyAsY1kbkJYJc= +github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= +github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= +github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= +github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= +github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= +github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= +github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= +github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= +github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= +github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= +github.com/hashicorp/consul/api v1.26.1 h1:5oSXOO5fboPZeW5SN+TdGFP/BILDgBm19OrPZ/pICIM= +github.com/hashicorp/consul/api v1.26.1/go.mod h1:B4sQTeaSO16NtynqrAdwOlahJ7IUDZM9cj2420xYL8A= +github.com/hashicorp/consul/sdk v0.15.0 h1:2qK9nDrr4tiJKRoxPGhm6B7xJjLVIQqkjiab2M4aKjU= +github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= +github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= +github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= +github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= +github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= +github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= +github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= +github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= +github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= +github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI= +github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= +github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= +github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= +github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= +github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= +github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= +github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= +github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= +github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc= +github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= +github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= +github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI= +github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= +github.com/hashicorp/golang-lru v0.5.4 h1:YDjusn29QI/Das2iO9M0BHnIbxPeyuCHsjMW+lJfyTc= +github.com/hashicorp/golang-lru v0.5.4/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= +github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= +github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= +github.com/hashicorp/memberlist v0.5.0 h1:EtYPN8DpAURiapus508I4n9CzHs2W+8NZGbmmR/prTM= +github.com/hashicorp/memberlist v0.5.0/go.mod h1:yvyXLpo0QaGE59Y7hDTsTzDD25JYBZ4mHgHUZ8lrOI0= +github.com/hashicorp/serf v0.10.1 h1:Z1H2J60yRKvfDYAOZLd2MU0ND4AH/WDz7xYHDWQsIPY= +github.com/hashicorp/serf v0.10.1/go.mod h1:yL2t6BqATOLGc5HF7qbFkTfXoPIY0WZdWHfEvMqbG+4= +github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= +github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= +github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= +github.com/kr/pretty v0.1.0 h1:L/CwN0zerZDmRFUapSPitk6f+Q3+0za1rQkzVuMiMFI= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +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/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= +github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= +github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= +github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= +github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= +github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= +github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= +github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= +github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= +github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= +github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= +github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= +github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= +github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= +github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= +github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= +github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= +github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= +github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= +github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= +github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= +github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= +github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= +github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= +github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= +github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= +github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= +github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= +github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= +github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= +github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= +github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= +github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= +github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= +github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= +github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= +github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= +github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= +github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= +github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= +github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= +github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= +github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= +github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= +github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= +github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= +github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= +github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= +github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= +github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= +github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= +github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= +go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= +go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= +go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= +go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= +go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= +go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= +go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= +golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= +golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= +golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63 h1:m64FZMko/V45gv0bNmrNYoDEq8U5YUhetc9cBWKS1TQ= +golang.org/x/exp v0.0.0-20230817173708-d852ddb80c63/go.mod h1:0v4NqG35kSWCMzLaMeX+IQrlSnVE/bqGSyC2cz/9Le8= +golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= +golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= +golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= +golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= +golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= +golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= +golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +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/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= +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/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= +golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= +gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15 h1:YR8cESwS4TdDjEe65xsg0ogRM/Nc3DYOhEAlW+xobZo= +gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= +gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= +gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/example/go.mod b/example/go.mod index 0841ae83936..ae0ca68ed45 100644 --- a/example/go.mod +++ b/example/go.mod @@ -11,6 +11,7 @@ require ( github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.2 github.com/gogf/gf/contrib/metric/otelmetric/v2 v2.8.2 github.com/gogf/gf/contrib/nosql/redis/v2 v2.8.2 + github.com/gogf/gf/contrib/registry/consul/v2 v2.8.2 github.com/gogf/gf/contrib/registry/etcd/v2 v2.8.2 github.com/gogf/gf/contrib/registry/file/v2 v2.8.2 github.com/gogf/gf/contrib/registry/nacos/v2 v2.8.2 @@ -19,7 +20,7 @@ require ( github.com/gogf/gf/contrib/trace/otlpgrpc/v2 v2.8.2 github.com/gogf/gf/contrib/trace/otlphttp/v2 v2.8.2 github.com/gogf/gf/v2 v2.8.2 - github.com/hashicorp/consul/api v1.24.0 + github.com/hashicorp/consul/api v1.26.1 github.com/hashicorp/go-cleanhttp v0.5.2 github.com/nacos-group/nacos-sdk-go/v2 v2.2.7 github.com/polarismesh/polaris-go v1.5.8 @@ -168,6 +169,7 @@ replace ( github.com/gogf/gf/contrib/drivers/mysql/v2 => ../contrib/drivers/mysql/ github.com/gogf/gf/contrib/metric/otelmetric/v2 => ../contrib/metric/otelmetric github.com/gogf/gf/contrib/nosql/redis/v2 => ../contrib/nosql/redis/ + github.com/gogf/gf/contrib/registry/consul/v2 => ../contrib/registry/consul/ github.com/gogf/gf/contrib/registry/etcd/v2 => ../contrib/registry/etcd/ github.com/gogf/gf/contrib/registry/file/v2 => ../contrib/registry/file/ github.com/gogf/gf/contrib/registry/nacos/v2 => ../contrib/registry/nacos/ diff --git a/example/go.sum b/example/go.sum index ccada6a1c8a..c8a2be1087b 100644 --- a/example/go.sum +++ b/example/go.sum @@ -445,11 +445,11 @@ github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFb github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys= github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I= github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= -github.com/hashicorp/consul/api v1.24.0 h1:u2XyStA2j0jnCiVUU7Qyrt8idjRn4ORhK6DlvZ3bWhA= -github.com/hashicorp/consul/api v1.24.0/go.mod h1:NZJGRFYruc/80wYowkPFCp1LbGmJC9L8izrwfyVx/Wg= +github.com/hashicorp/consul/api v1.26.1 h1:5oSXOO5fboPZeW5SN+TdGFP/BILDgBm19OrPZ/pICIM= +github.com/hashicorp/consul/api v1.26.1/go.mod h1:B4sQTeaSO16NtynqrAdwOlahJ7IUDZM9cj2420xYL8A= github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/consul/sdk v0.14.1 h1:ZiwE2bKb+zro68sWzZ1SgHF3kRMBZ94TwOCFRF4ylPs= -github.com/hashicorp/consul/sdk v0.14.1/go.mod h1:vFt03juSzocLRFo59NkeQHHmQa6+g7oU0pfzdI1mUhg= +github.com/hashicorp/consul/sdk v0.15.0 h1:2qK9nDrr4tiJKRoxPGhm6B7xJjLVIQqkjiab2M4aKjU= +github.com/hashicorp/consul/sdk v0.15.0/go.mod h1:r/OmRRPbHOe0yxNahLw7G9x5WG17E1BIECMtCjcPSNo= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= diff --git a/example/registry/consul/grpc/client/client.go b/example/registry/consul/grpc/client/client.go new file mode 100644 index 00000000000..9799c3d62e0 --- /dev/null +++ b/example/registry/consul/grpc/client/client.go @@ -0,0 +1,39 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package main + +import ( + "context" + + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/registry/consul/v2" + "github.com/gogf/gf/contrib/rpc/grpcx/v2" + + "github.com/gogf/gf/example/registry/consul/grpc/protobuf" +) + +func main() { + registry, err := consul.New(consul.WithAddress("127.0.0.1:8500")) + if err != nil { + g.Log().Fatal(context.Background(), err) + } + grpcx.Resolver.Register(registry) + + var ( + ctx = gctx.New() + conn = grpcx.Client.MustNewGrpcClientConn("demo") + client = protobuf.NewGreeterClient(conn) + ) + res, err := client.SayHello(ctx, &protobuf.HelloRequest{Name: "World"}) + if err != nil { + g.Log().Error(ctx, err) + return + } + g.Log().Debug(ctx, "Response:", res.Message) +} diff --git a/example/registry/consul/grpc/controller/helloworld.go b/example/registry/consul/grpc/controller/helloworld.go new file mode 100644 index 00000000000..b6f849cd79b --- /dev/null +++ b/example/registry/consul/grpc/controller/helloworld.go @@ -0,0 +1,28 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package controller + +import ( + "context" + + "github.com/gogf/gf/contrib/rpc/grpcx/v2" + + "github.com/gogf/gf/example/registry/consul/grpc/protobuf" +) + +type Controller struct { + protobuf.UnimplementedGreeterServer +} + +func Register(s *grpcx.GrpcServer) { + protobuf.RegisterGreeterServer(s.Server, &Controller{}) +} + +// SayHello implements helloworld.GreeterServer +func (s *Controller) SayHello(ctx context.Context, in *protobuf.HelloRequest) (*protobuf.HelloReply, error) { + return &protobuf.HelloReply{Message: "Hello " + in.GetName()}, nil +} diff --git a/example/registry/consul/grpc/protobuf/helloworld.pb.go b/example/registry/consul/grpc/protobuf/helloworld.pb.go new file mode 100644 index 00000000000..8af3b213b5f --- /dev/null +++ b/example/registry/consul/grpc/protobuf/helloworld.pb.go @@ -0,0 +1,217 @@ +// protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. *.proto + +// Code generated by protoc-gen-go. DO NOT EDIT. +// versions: +// protoc-gen-go v1.28.1 +// protoc v3.21.12 +// source: helloworld.proto + +package protobuf + +import ( + protoreflect "google.golang.org/protobuf/reflect/protoreflect" + protoimpl "google.golang.org/protobuf/runtime/protoimpl" + reflect "reflect" + sync "sync" +) + +const ( + // Verify that this generated code is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) + // Verify that runtime/protoimpl is sufficiently up-to-date. + _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) +) + +// The request message containing the user's name. +type HelloRequest struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` +} + +func (x *HelloRequest) Reset() { + *x = HelloRequest{} + if protoimpl.UnsafeEnabled { + mi := &file_helloworld_proto_msgTypes[0] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HelloRequest) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HelloRequest) ProtoMessage() {} + +func (x *HelloRequest) ProtoReflect() protoreflect.Message { + mi := &file_helloworld_proto_msgTypes[0] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead. +func (*HelloRequest) Descriptor() ([]byte, []int) { + return file_helloworld_proto_rawDescGZIP(), []int{0} +} + +func (x *HelloRequest) GetName() string { + if x != nil { + return x.Name + } + return "" +} + +// The response message containing the greetings +type HelloReply struct { + state protoimpl.MessageState + sizeCache protoimpl.SizeCache + unknownFields protoimpl.UnknownFields + + Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` +} + +func (x *HelloReply) Reset() { + *x = HelloReply{} + if protoimpl.UnsafeEnabled { + mi := &file_helloworld_proto_msgTypes[1] + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + ms.StoreMessageInfo(mi) + } +} + +func (x *HelloReply) String() string { + return protoimpl.X.MessageStringOf(x) +} + +func (*HelloReply) ProtoMessage() {} + +func (x *HelloReply) ProtoReflect() protoreflect.Message { + mi := &file_helloworld_proto_msgTypes[1] + if protoimpl.UnsafeEnabled && x != nil { + ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) + if ms.LoadMessageInfo() == nil { + ms.StoreMessageInfo(mi) + } + return ms + } + return mi.MessageOf(x) +} + +// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead. +func (*HelloReply) Descriptor() ([]byte, []int) { + return file_helloworld_proto_rawDescGZIP(), []int{1} +} + +func (x *HelloReply) GetMessage() string { + if x != nil { + return x.Message + } + return "" +} + +var File_helloworld_proto protoreflect.FileDescriptor + +var file_helloworld_proto_rawDesc = []byte{ + 0x0a, 0x10, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x70, 0x72, 0x6f, + 0x74, 0x6f, 0x12, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, 0x22, 0x0a, 0x0c, + 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, + 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, + 0x22, 0x26, 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, + 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, + 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x45, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, + 0x74, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, + 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, + 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, + 0x75, 0x66, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, + 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, + 0x67, 0x66, 0x2f, 0x67, 0x66, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, + 0x6c, 0x65, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x70, 0x72, + 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, +} + +var ( + file_helloworld_proto_rawDescOnce sync.Once + file_helloworld_proto_rawDescData = file_helloworld_proto_rawDesc +) + +func file_helloworld_proto_rawDescGZIP() []byte { + file_helloworld_proto_rawDescOnce.Do(func() { + file_helloworld_proto_rawDescData = protoimpl.X.CompressGZIP(file_helloworld_proto_rawDescData) + }) + return file_helloworld_proto_rawDescData +} + +var file_helloworld_proto_msgTypes = make([]protoimpl.MessageInfo, 2) +var file_helloworld_proto_goTypes = []interface{}{ + (*HelloRequest)(nil), // 0: protobuf.HelloRequest + (*HelloReply)(nil), // 1: protobuf.HelloReply +} +var file_helloworld_proto_depIdxs = []int32{ + 0, // 0: protobuf.Greeter.SayHello:input_type -> protobuf.HelloRequest + 1, // 1: protobuf.Greeter.SayHello:output_type -> protobuf.HelloReply + 1, // [1:2] is the sub-list for method output_type + 0, // [0:1] is the sub-list for method input_type + 0, // [0:0] is the sub-list for extension type_name + 0, // [0:0] is the sub-list for extension extendee + 0, // [0:0] is the sub-list for field type_name +} + +func init() { file_helloworld_proto_init() } +func file_helloworld_proto_init() { + if File_helloworld_proto != nil { + return + } + if !protoimpl.UnsafeEnabled { + file_helloworld_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HelloRequest); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + file_helloworld_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { + switch v := v.(*HelloReply); i { + case 0: + return &v.state + case 1: + return &v.sizeCache + case 2: + return &v.unknownFields + default: + return nil + } + } + } + type x struct{} + out := protoimpl.TypeBuilder{ + File: protoimpl.DescBuilder{ + GoPackagePath: reflect.TypeOf(x{}).PkgPath(), + RawDescriptor: file_helloworld_proto_rawDesc, + NumEnums: 0, + NumMessages: 2, + NumExtensions: 0, + NumServices: 1, + }, + GoTypes: file_helloworld_proto_goTypes, + DependencyIndexes: file_helloworld_proto_depIdxs, + MessageInfos: file_helloworld_proto_msgTypes, + }.Build() + File_helloworld_proto = out.File + file_helloworld_proto_rawDesc = nil + file_helloworld_proto_goTypes = nil + file_helloworld_proto_depIdxs = nil +} diff --git a/example/registry/consul/grpc/protobuf/helloworld.proto b/example/registry/consul/grpc/protobuf/helloworld.proto new file mode 100644 index 00000000000..9f4f4864fc8 --- /dev/null +++ b/example/registry/consul/grpc/protobuf/helloworld.proto @@ -0,0 +1,24 @@ +// protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. *.proto + +syntax = "proto3"; + +package protobuf; + +option go_package = "github.com/gogf/gf/grpc/example/helloworld/protobuf"; + + +// The greeting service definition. +service Greeter { + // Sends a greeting + rpc SayHello (HelloRequest) returns (HelloReply) {} +} + +// The request message containing the user's name. +message HelloRequest { + string name = 1; +} + +// The response message containing the greetings +message HelloReply { + string message = 1; +} diff --git a/example/registry/consul/grpc/protobuf/helloworld_grpc.pb.go b/example/registry/consul/grpc/protobuf/helloworld_grpc.pb.go new file mode 100644 index 00000000000..af29539f4ee --- /dev/null +++ b/example/registry/consul/grpc/protobuf/helloworld_grpc.pb.go @@ -0,0 +1,107 @@ +// Code generated by protoc-gen-go-grpc. DO NOT EDIT. +// versions: +// - protoc-gen-go-grpc v1.2.0 +// - protoc v3.21.12 +// source: helloworld.proto + +package protobuf + +import ( + context "context" + grpc "google.golang.org/grpc" + codes "google.golang.org/grpc/codes" + status "google.golang.org/grpc/status" +) + +// This is a compile-time assertion to ensure that this generated file +// is compatible with the grpc package it is being compiled against. +// Requires gRPC-Go v1.32.0 or later. +const _ = grpc.SupportPackageIsVersion7 + +// GreeterClient is the client API for Greeter service. +// +// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. +type GreeterClient interface { + // Sends a greeting + SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) +} + +type greeterClient struct { + cc grpc.ClientConnInterface +} + +func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { + return &greeterClient{cc} +} + +func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { + out := new(HelloReply) + err := c.cc.Invoke(ctx, "/protobuf.Greeter/SayHello", in, out, opts...) + if err != nil { + return nil, err + } + return out, nil +} + +// GreeterServer is the server API for Greeter service. +// All implementations must embed UnimplementedGreeterServer +// for forward compatibility +type GreeterServer interface { + // Sends a greeting + SayHello(context.Context, *HelloRequest) (*HelloReply, error) + mustEmbedUnimplementedGreeterServer() +} + +// UnimplementedGreeterServer must be embedded to have forward compatible implementations. +type UnimplementedGreeterServer struct { +} + +func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { + return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") +} +func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {} + +// UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service. +// Use of this interface is not recommended, as added methods to GreeterServer will +// result in compilation errors. +type UnsafeGreeterServer interface { + mustEmbedUnimplementedGreeterServer() +} + +func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) { + s.RegisterService(&Greeter_ServiceDesc, srv) +} + +func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { + in := new(HelloRequest) + if err := dec(in); err != nil { + return nil, err + } + if interceptor == nil { + return srv.(GreeterServer).SayHello(ctx, in) + } + info := &grpc.UnaryServerInfo{ + Server: srv, + FullMethod: "/protobuf.Greeter/SayHello", + } + handler := func(ctx context.Context, req interface{}) (interface{}, error) { + return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) + } + return interceptor(ctx, in, info, handler) +} + +// Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service. +// It's only intended for direct use with grpc.RegisterService, +// and not to be introspected or modified (even as a copy) +var Greeter_ServiceDesc = grpc.ServiceDesc{ + ServiceName: "protobuf.Greeter", + HandlerType: (*GreeterServer)(nil), + Methods: []grpc.MethodDesc{ + { + MethodName: "SayHello", + Handler: _Greeter_SayHello_Handler, + }, + }, + Streams: []grpc.StreamDesc{}, + Metadata: "helloworld.proto", +} diff --git a/example/registry/consul/grpc/server/config.yaml b/example/registry/consul/grpc/server/config.yaml new file mode 100644 index 00000000000..071b62623ed --- /dev/null +++ b/example/registry/consul/grpc/server/config.yaml @@ -0,0 +1,8 @@ +grpc: + name: "demo" + logPath: "./log" + logStdout: true + errorLogEnabled: true + accessLogEnabled: true + errorStack: true + diff --git a/example/registry/consul/grpc/server/server.go b/example/registry/consul/grpc/server/server.go new file mode 100644 index 00000000000..ef26a750a7a --- /dev/null +++ b/example/registry/consul/grpc/server/server.go @@ -0,0 +1,30 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package main + +import ( + "context" + + "github.com/gogf/gf/v2/frame/g" + + "github.com/gogf/gf/contrib/registry/consul/v2" + "github.com/gogf/gf/contrib/rpc/grpcx/v2" + + "github.com/gogf/gf/example/registry/consul/grpc/controller" +) + +func main() { + registry, err := consul.New(consul.WithAddress("127.0.0.1:8500")) + if err != nil { + g.Log().Fatal(context.Background(), err) + } + grpcx.Resolver.Register(registry) + + s := grpcx.Server.New() + controller.Register(s) + s.Run() +} diff --git a/example/registry/consul/http/client/client.go b/example/registry/consul/http/client/client.go new file mode 100644 index 00000000000..9a948bc03f9 --- /dev/null +++ b/example/registry/consul/http/client/client.go @@ -0,0 +1,29 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package main + +import ( + "context" + + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/gsvc" + "github.com/gogf/gf/v2/os/gctx" + + "github.com/gogf/gf/contrib/registry/consul/v2" +) + +func main() { + registry, err := consul.New(consul.WithAddress("127.0.0.1:8500")) + if err != nil { + g.Log().Fatal(context.Background(), err) + } + gsvc.SetRegistry(registry) + + ctx := gctx.New() + res := g.Client().GetContent(ctx, `http://hello.svc/`) + g.Log().Info(ctx, res) +} diff --git a/example/registry/consul/http/server/server.go b/example/registry/consul/http/server/server.go new file mode 100644 index 00000000000..badc5ce64e1 --- /dev/null +++ b/example/registry/consul/http/server/server.go @@ -0,0 +1,32 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package main + +import ( + "context" + + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/net/ghttp" + "github.com/gogf/gf/v2/net/gsvc" + + "github.com/gogf/gf/contrib/registry/consul/v2" +) + +func main() { + registry, err := consul.New(consul.WithAddress("127.0.0.1:8500")) + if err != nil { + g.Log().Fatal(context.Background(), err) + } + gsvc.SetRegistry(registry) + + s := g.Server(`hello.svc`) + s.BindHandler("/", func(r *ghttp.Request) { + g.Log().Info(r.Context(), `request received`) + r.Response.Write(`Hello world`) + }) + s.Run() +} From 38bffc77e26be24f31f318a301624c44df69bf98 Mon Sep 17 00:00:00 2001 From: John Guo Date: Tue, 10 Dec 2024 09:52:48 +0800 Subject: [PATCH 043/102] fix(net/ghttp): occasional ci failed by unit testing cases using `gctp.GetFreePort` (#3982) --- .github/workflows/golangci-lint.yml | 10 - net/ghttp/ghttp.go | 64 +-- net/ghttp/ghttp_server.go | 44 +- net/ghttp/ghttp_server_admin.go | 2 +- net/ghttp/ghttp_server_admin_process.go | 4 +- net/ghttp/ghttp_server_config.go | 2 + net/ghttp/ghttp_server_graceful.go | 273 +------------ ...tp_z_unit_feature_custom_listeners_test.go | 43 +- net/ghttp/ghttp_z_unit_feature_https_test.go | 13 +- net/ghttp/internal/graceful/graceful.go | 378 ++++++++++++++++++ 10 files changed, 472 insertions(+), 361 deletions(-) create mode 100644 net/ghttp/internal/graceful/graceful.go diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 4850913f105..70b6679c274 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -15,15 +15,6 @@ on: - enhance/** - fix/** - feat/** - pull_request: - branches: - - master - - develop - - personal/** - - feature/** - - enhance/** - - fix/** - - feat/** jobs: golangci: @@ -64,7 +55,6 @@ jobs: -s "prefix(github.com/gogf/gf/example)" \ ./ - name: Check for changes - id: check_changes run: | if [[ -n "$(git status --porcelain)" ]]; then echo "HAS_CHANGES=true" >> $GITHUB_ENV diff --git a/net/ghttp/ghttp.go b/net/ghttp/ghttp.go index b01d27c8b12..32353319460 100644 --- a/net/ghttp/ghttp.go +++ b/net/ghttp/ghttp.go @@ -19,6 +19,7 @@ import ( "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/net/ghttp/internal/graceful" "github.com/gogf/gf/v2/net/goai" "github.com/gogf/gf/v2/net/gsvc" "github.com/gogf/gf/v2/os/gcache" @@ -34,7 +35,7 @@ type ( instance string // Instance name of current HTTP server. config ServerConfig // Server configuration. plugins []Plugin // Plugin array to extend server functionality. - servers []*gracefulServer // Underlying http.Server array. + servers []*graceful.Server // Underlying http.Server array. serverCount *gtype.Int // Underlying http.Server number for internal usage. closeChan chan struct{} // Used for underlying server closing event notification. serveTree map[string]interface{} // The route maps tree. @@ -69,7 +70,7 @@ type ( Method string // Handler method name. Route string // Route URI. Priority int // Just for reference. - IsServiceHandler bool // Is service handler. + IsServiceHandler bool // Is a service handler. } // HandlerFunc is request handler function. @@ -127,42 +128,41 @@ type ( const ( // FreePortAddress marks the server listens using random free port. - FreePortAddress = ":0" + FreePortAddress = graceful.FreePortAddress ) const ( - HeaderXUrlPath = "x-url-path" // Used for custom route handler, which does not change URL.Path. - HookBeforeServe HookName = "HOOK_BEFORE_SERVE" // Hook handler before route handler/file serving. - HookAfterServe HookName = "HOOK_AFTER_SERVE" // Hook handler after route handler/file serving. - HookBeforeOutput HookName = "HOOK_BEFORE_OUTPUT" // Hook handler before response output. - HookAfterOutput HookName = "HOOK_AFTER_OUTPUT" // Hook handler after response output. - ServerStatusStopped ServerStatus = 0 - ServerStatusRunning ServerStatus = 1 - DefaultServerName = "default" - DefaultDomainName = "default" - HandlerTypeHandler HandlerType = "handler" - HandlerTypeObject HandlerType = "object" - HandlerTypeMiddleware HandlerType = "middleware" - HandlerTypeHook HandlerType = "hook" + HeaderXUrlPath = "x-url-path" // Used for custom route handler, which does not change URL.Path. + HookBeforeServe HookName = "HOOK_BEFORE_SERVE" // Hook handler before route handler/file serving. + HookAfterServe HookName = "HOOK_AFTER_SERVE" // Hook handler after route handler/file serving. + HookBeforeOutput HookName = "HOOK_BEFORE_OUTPUT" // Hook handler before response output. + HookAfterOutput HookName = "HOOK_AFTER_OUTPUT" // Hook handler after response output. + DefaultServerName = "default" + DefaultDomainName = "default" + HandlerTypeHandler HandlerType = "handler" + HandlerTypeObject HandlerType = "object" + HandlerTypeMiddleware HandlerType = "middleware" + HandlerTypeHook HandlerType = "hook" + ServerStatusStopped = graceful.ServerStatusStopped + ServerStatusRunning = graceful.ServerStatusRunning ) const ( - supportedHttpMethods = "GET,PUT,POST,DELETE,PATCH,HEAD,CONNECT,OPTIONS,TRACE" - defaultMethod = "ALL" - routeCacheDuration = time.Hour - ctxKeyForRequest gctx.StrKey = "gHttpRequestObject" - contentTypeXml = "text/xml" - contentTypeHtml = "text/html" - contentTypeJson = "application/json" - contentTypeJavascript = "application/javascript" - swaggerUIPackedPath = "/goframe/swaggerui" - responseHeaderTraceID = "Trace-ID" - responseHeaderContentLength = "Content-Length" - specialMethodNameInit = "Init" - specialMethodNameShut = "Shut" - specialMethodNameIndex = "Index" - defaultEndpointPort = 80 - noPrintInternalRoute = "internalMiddlewareServerTracing" + supportedHttpMethods = "GET,PUT,POST,DELETE,PATCH,HEAD,CONNECT,OPTIONS,TRACE" + defaultMethod = "ALL" + routeCacheDuration = time.Hour + ctxKeyForRequest gctx.StrKey = "gHttpRequestObject" + contentTypeXml = "text/xml" + contentTypeHtml = "text/html" + contentTypeJson = "application/json" + contentTypeJavascript = "application/javascript" + swaggerUIPackedPath = "/goframe/swaggerui" + responseHeaderTraceID = "Trace-ID" + specialMethodNameInit = "Init" + specialMethodNameShut = "Shut" + specialMethodNameIndex = "Index" + defaultEndpointPort = 80 + noPrintInternalRoute = "internalMiddlewareServerTracing" ) const ( diff --git a/net/ghttp/ghttp_server.go b/net/ghttp/ghttp_server.go index 80976ee97e9..11a8502853f 100644 --- a/net/ghttp/ghttp_server.go +++ b/net/ghttp/ghttp_server.go @@ -26,6 +26,7 @@ import ( "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/internal/intlog" + "github.com/gogf/gf/v2/net/ghttp/internal/graceful" "github.com/gogf/gf/v2/net/ghttp/internal/swaggerui" "github.com/gogf/gf/v2/net/goai" "github.com/gogf/gf/v2/net/gsvc" @@ -97,7 +98,7 @@ func GetServer(name ...interface{}) *Server { s := &Server{ instance: serverName, plugins: make([]Plugin, 0), - servers: make([]*gracefulServer, 0), + servers: make([]*graceful.Server, 0), closeChan: make(chan struct{}, 10000), serverCount: gtype.NewInt(), statusHandlerMap: make(map[string][]HandlerFunc), @@ -535,9 +536,9 @@ func (s *Server) startServer(fdMap listenerFdMap) { if fd > 0 { s.servers = append(s.servers, s.newGracefulServer(itemFunc, fd)) } else { - s.servers = append(s.servers, s.newGracefulServer(itemFunc)) + s.servers = append(s.servers, s.newGracefulServer(itemFunc, 0)) } - s.servers[len(s.servers)-1].isHttps = true + s.servers[len(s.servers)-1].SetIsHttps(true) } } // HTTP @@ -570,7 +571,7 @@ func (s *Server) startServer(fdMap listenerFdMap) { if fd > 0 { s.servers = append(s.servers, s.newGracefulServer(itemFunc, fd)) } else { - s.servers = append(s.servers, s.newGracefulServer(itemFunc)) + s.servers = append(s.servers, s.newGracefulServer(itemFunc, 0)) } } // Start listening asynchronously. @@ -583,11 +584,11 @@ func (s *Server) startServer(fdMap listenerFdMap) { wg.Wait() } -func (s *Server) startGracefulServer(ctx context.Context, wg *sync.WaitGroup, server *gracefulServer) { +func (s *Server) startGracefulServer(ctx context.Context, wg *sync.WaitGroup, server *graceful.Server) { s.serverCount.Add(1) var err error // Create listener. - if server.isHttps { + if server.IsHttps() { err = server.CreateListenerTLS( s.config.HTTPSCertPath, s.config.HTTPSKeyPath, s.config.TLSConfig, ) @@ -621,7 +622,7 @@ func (s *Server) Status() ServerStatus { } // If any underlying server is running, the server status is running. for _, v := range s.servers { - if v.status.Val() == ServerStatusRunning { + if v.Status() == ServerStatusRunning { return ServerStatusRunning } } @@ -636,8 +637,8 @@ func (s *Server) getListenerFdMap() map[string]string { "http": "", } for _, v := range s.servers { - str := v.address + "#" + gconv.String(v.Fd()) + "," - if v.isHttps { + str := v.GetAddress() + "#" + gconv.String(v.Fd()) + "," + if v.IsHttps() { if len(m["https"]) > 0 { m["https"] += "," } @@ -653,12 +654,29 @@ func (s *Server) getListenerFdMap() map[string]string { } // GetListenedPort retrieves and returns one port which is listened by current server. +// It returns the normal HTTP port in most priority if both HTTP and HTTPS are enabled. func (s *Server) GetListenedPort() int { - ports := s.GetListenedPorts() - if len(ports) > 0 { - return ports[0] + for _, server := range s.servers { + if !server.IsHttps() { + return server.GetListenedPort() + } + } + for _, server := range s.servers { + if server.IsHttps() { + return server.GetListenedPort() + } + } + return -1 +} + +// GetListenedHTTPSPort retrieves and returns one port which is listened using TLS by current server. +func (s *Server) GetListenedHTTPSPort() int { + for _, server := range s.servers { + if server.IsHttps() { + return server.GetListenedPort() + } } - return 0 + return -1 } // GetListenedPorts retrieves and returns the ports which are listened by current server. diff --git a/net/ghttp/ghttp_server_admin.go b/net/ghttp/ghttp_server_admin.go index 109cacb138e..58f63575dec 100644 --- a/net/ghttp/ghttp_server_admin.go +++ b/net/ghttp/ghttp_server_admin.go @@ -95,7 +95,7 @@ func (s *Server) Shutdown() error { // Only shut down current servers. // It may have multiple underlying http servers. for _, v := range s.servers { - v.shutdown(ctx) + v.Shutdown(ctx) } return nil } diff --git a/net/ghttp/ghttp_server_admin_process.go b/net/ghttp/ghttp_server_admin_process.go index 31313f6aa4f..93dcecf1114 100644 --- a/net/ghttp/ghttp_server_admin_process.go +++ b/net/ghttp/ghttp_server_admin_process.go @@ -268,7 +268,7 @@ func shutdownWebServersGracefully(ctx context.Context, signal os.Signal) { server := v.(*Server) server.doServiceDeregister() for _, s := range server.servers { - s.shutdown(ctx) + s.Shutdown(ctx) } } }) @@ -279,7 +279,7 @@ func forceCloseWebServers(ctx context.Context) { serverMapping.RLockFunc(func(m map[string]interface{}) { for _, v := range m { for _, s := range v.(*Server).servers { - s.close(ctx) + s.Close(ctx) } } }) diff --git a/net/ghttp/ghttp_server_config.go b/net/ghttp/ghttp_server_config.go index 219b1f4ca81..450f9bb05fb 100644 --- a/net/ghttp/ghttp_server_config.go +++ b/net/ghttp/ghttp_server_config.go @@ -399,6 +399,7 @@ func (s *Server) SetAddr(address string) { } // SetPort sets the listening ports for the server. +// It uses random port if the port is 0. // The listening ports can be multiple like: SetPort(80, 8080). func (s *Server) SetPort(port ...int) { if len(port) > 0 { @@ -418,6 +419,7 @@ func (s *Server) SetHTTPSAddr(address string) { } // SetHTTPSPort sets the HTTPS listening ports for the server. +// It uses random port if the port is 0. // The listening ports can be multiple like: SetHTTPSPort(443, 500). func (s *Server) SetHTTPSPort(port ...int) { if len(port) > 0 { diff --git a/net/ghttp/ghttp_server_graceful.go b/net/ghttp/ghttp_server_graceful.go index a86475378d0..611ba74e71b 100644 --- a/net/ghttp/ghttp_server_graceful.go +++ b/net/ghttp/ghttp_server_graceful.go @@ -6,269 +6,24 @@ package ghttp -import ( - "context" - "crypto/tls" - "fmt" - "log" - "net" - "net/http" - "os" - "strconv" - "sync" - "time" - - "github.com/gogf/gf/v2/container/gtype" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/os/gproc" - "github.com/gogf/gf/v2/os/gres" - "github.com/gogf/gf/v2/text/gstr" -) - -// gracefulServer wraps the net/http.Server with graceful reload/restart feature. -type gracefulServer struct { - server *Server // Belonged server. - fd uintptr // File descriptor for passing to the child process when graceful reload. - address string // Listening address like:":80", ":8080". - httpServer *http.Server // Underlying http.Server. - rawListener net.Listener // Underlying net.Listener. - rawLnMu sync.RWMutex // Concurrent safety mutex for `rawListener`. - listener net.Listener // Wrapped net.Listener. - isHttps bool // Is HTTPS. - status *gtype.Int // Status of current server. Using `gtype` to ensure concurrent safety. -} +import "github.com/gogf/gf/v2/net/ghttp/internal/graceful" // newGracefulServer creates and returns a graceful http server with a given address. // The optional parameter `fd` specifies the file descriptor which is passed from parent server. -func (s *Server) newGracefulServer(address string, fd ...int) *gracefulServer { - // Change port to address like: 80 -> :80 - if gstr.IsNumeric(address) { - address = ":" + address - } - gs := &gracefulServer{ - server: s, - address: address, - httpServer: s.newHttpServer(address), - status: gtype.NewInt(), - } - if len(fd) > 0 && fd[0] > 0 { - gs.fd = uintptr(fd[0]) - } - if s.config.Listeners != nil { - addrArray := gstr.SplitAndTrim(address, ":") - addrPort, err := strconv.Atoi(addrArray[len(addrArray)-1]) - if err == nil { - for _, v := range s.config.Listeners { - if listenerPort := (v.Addr().(*net.TCPAddr)).Port; listenerPort == addrPort { - gs.rawListener = v - break - } - } - } - } - return gs -} - -// newHttpServer creates and returns an underlying http.Server with a given address. -func (s *Server) newHttpServer(address string) *http.Server { - server := &http.Server{ - Addr: address, - Handler: http.HandlerFunc(s.config.Handler), - ReadTimeout: s.config.ReadTimeout, - WriteTimeout: s.config.WriteTimeout, - IdleTimeout: s.config.IdleTimeout, - MaxHeaderBytes: s.config.MaxHeaderBytes, - ErrorLog: log.New(&errorLogger{logger: s.config.Logger}, "", 0), - } - server.SetKeepAlivesEnabled(s.config.KeepAlive) - return server -} - -// Fd retrieves and returns the file descriptor of the current server. -// It is available ony in *nix like operating systems like linux, unix, darwin. -func (s *gracefulServer) Fd() uintptr { - if ln := s.getRawListener(); ln != nil { - file, err := ln.(*net.TCPListener).File() - if err == nil { - return file.Fd() - } - } - return 0 -} - -// CreateListener creates listener on configured address. -func (s *gracefulServer) CreateListener() error { - ln, err := s.getNetListener() - if err != nil { - return err - } - s.listener = ln - s.setRawListener(ln) - return nil -} - -// CreateListenerTLS creates listener on configured address with HTTPS. -// The parameter `certFile` and `keyFile` specify the necessary certification and key files for HTTPS. -// The optional parameter `tlsConfig` specifies the custom TLS configuration. -func (s *gracefulServer) CreateListenerTLS(certFile, keyFile string, tlsConfig ...*tls.Config) error { - var config *tls.Config - if len(tlsConfig) > 0 && tlsConfig[0] != nil { - config = tlsConfig[0] - } else if s.httpServer.TLSConfig != nil { - config = s.httpServer.TLSConfig - } else { - config = &tls.Config{} - } - if config.NextProtos == nil { - config.NextProtos = []string{"http/1.1"} - } - var err error - if len(config.Certificates) == 0 { - config.Certificates = make([]tls.Certificate, 1) - if gres.Contains(certFile) { - config.Certificates[0], err = tls.X509KeyPair( - gres.GetContent(certFile), - gres.GetContent(keyFile), - ) - } else { - config.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile) - } - } - if err != nil { - return gerror.Wrapf(err, `open certFile "%s" and keyFile "%s" failed`, certFile, keyFile) - } - ln, err := s.getNetListener() - if err != nil { - return err - } - - s.listener = tls.NewListener(ln, config) - s.setRawListener(ln) - return nil -} - -// Serve starts the serving with blocking way. -func (s *gracefulServer) Serve(ctx context.Context) error { - if s.rawListener == nil { - return gerror.NewCode(gcode.CodeInvalidOperation, `call CreateListener/CreateListenerTLS before Serve`) - } - - action := "started" - if s.fd != 0 { - action = "reloaded" - } - s.server.Logger().Infof( - ctx, - `pid[%d]: %s server %s listening on [%s]`, - gproc.Pid(), s.getProto(), action, s.GetListenedAddress(), - ) - s.status.Set(ServerStatusRunning) - err := s.httpServer.Serve(s.listener) - s.status.Set(ServerStatusStopped) - return err -} - -// GetListenedAddress retrieves and returns the address string which are listened by current server. -func (s *gracefulServer) GetListenedAddress() string { - if !gstr.Contains(s.address, FreePortAddress) { - return s.address - } - var ( - address = s.address - listenedPort = s.GetListenedPort() - ) - address = gstr.Replace(address, FreePortAddress, fmt.Sprintf(`:%d`, listenedPort)) - return address -} - -// GetListenedPort retrieves and returns one port which is listened to by current server. -// Note that this method is only available if the server is listening on one port. -func (s *gracefulServer) GetListenedPort() int { - if ln := s.getRawListener(); ln != nil { - return ln.Addr().(*net.TCPAddr).Port - } - return -1 -} - -// getProto retrieves and returns the proto string of current server. -func (s *gracefulServer) getProto() string { - proto := "http" - if s.isHttps { - proto = "https" - } - return proto -} - -// getNetListener retrieves and returns the wrapped net.Listener. -func (s *gracefulServer) getNetListener() (net.Listener, error) { - if s.rawListener != nil { - return s.rawListener, nil - } +func (s *Server) newGracefulServer(address string, fd int) *graceful.Server { var ( - ln net.Listener - err error - ) - if s.fd > 0 { - f := os.NewFile(s.fd, "") - ln, err = net.FileListener(f) - if err != nil { - err = gerror.Wrap(err, "net.FileListener failed") - return nil, err + loggerWriter = &errorLogger{logger: s.config.Logger} + serverConfig = graceful.ServerConfig{ + Listeners: s.config.Listeners, + Handler: s.config.Handler, + ReadTimeout: s.config.ReadTimeout, + WriteTimeout: s.config.WriteTimeout, + IdleTimeout: s.config.IdleTimeout, + GracefulShutdownTimeout: s.config.GracefulTimeout, + MaxHeaderBytes: s.config.MaxHeaderBytes, + KeepAlive: s.config.KeepAlive, + Logger: s.config.Logger, } - } else { - ln, err = net.Listen("tcp", s.httpServer.Addr) - if err != nil { - err = gerror.Wrapf(err, `net.Listen address "%s" failed`, s.httpServer.Addr) - } - } - return ln, err -} - -// shutdown shuts down the server gracefully. -func (s *gracefulServer) shutdown(ctx context.Context) { - if s.status.Val() == ServerStatusStopped { - return - } - timeoutCtx, cancelFunc := context.WithTimeout( - ctx, - time.Duration(s.server.config.GracefulShutdownTimeout)*time.Second, ) - defer cancelFunc() - if err := s.httpServer.Shutdown(timeoutCtx); err != nil { - s.server.Logger().Errorf( - ctx, - "%d: %s server [%s] shutdown error: %v", - gproc.Pid(), s.getProto(), s.address, err, - ) - } -} - -// setRawListener sets `rawListener` with given net.Listener. -func (s *gracefulServer) setRawListener(ln net.Listener) { - s.rawLnMu.Lock() - defer s.rawLnMu.Unlock() - s.rawListener = ln -} - -// setRawListener returns the `rawListener` of current server. -func (s *gracefulServer) getRawListener() net.Listener { - s.rawLnMu.RLock() - defer s.rawLnMu.RUnlock() - return s.rawListener -} - -// close shuts down the server forcibly. -// for graceful shutdown, please use gracefulServer.shutdown. -func (s *gracefulServer) close(ctx context.Context) { - if s.status.Val() == ServerStatusStopped { - return - } - if err := s.httpServer.Close(); err != nil { - s.server.Logger().Errorf( - ctx, - "%d: %s server [%s] closed error: %v", - gproc.Pid(), s.getProto(), s.address, err, - ) - } + return graceful.New(address, fd, loggerWriter, serverConfig) } diff --git a/net/ghttp/ghttp_z_unit_feature_custom_listeners_test.go b/net/ghttp/ghttp_z_unit_feature_custom_listeners_test.go index 69b568f9d75..292df268733 100644 --- a/net/ghttp/ghttp_z_unit_feature_custom_listeners_test.go +++ b/net/ghttp/ghttp_z_unit_feature_custom_listeners_test.go @@ -14,26 +14,13 @@ import ( "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/net/gtcp" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/guid" ) func Test_SetSingleCustomListener(t *testing.T) { - var ( - p1 int - ln1 net.Listener - ) - for i := 0; i < 1000; i++ { - p1, _ = gtcp.GetFreePort() - if ln1 == nil { - ln1, _ = net.Listen("tcp", fmt.Sprintf(":%d", p1)) - } - if ln1 != nil { - break - } - } + ln1, _ := net.Listen("tcp", ":0") s := g.Server(guid.S()) s.Group("/", func(group *ghttp.RouterGroup) { group.GET("/test", func(r *ghttp.Request) { @@ -60,25 +47,8 @@ func Test_SetSingleCustomListener(t *testing.T) { } func Test_SetMultipleCustomListeners(t *testing.T) { - var ( - p1 int - p2 int - ln1 net.Listener - ln2 net.Listener - ) - for i := 0; i < 1000; i++ { - p1, _ = gtcp.GetFreePort() - p2, _ = gtcp.GetFreePort() - if ln1 == nil { - ln1, _ = net.Listen("tcp", fmt.Sprintf(":%d", p1)) - } - if ln2 == nil { - ln2, _ = net.Listen("tcp", fmt.Sprintf(":%d", p2)) - } - if ln1 != nil && ln2 != nil { - break - } - } + ln1, _ := net.Listen("tcp", ":0") + ln2, _ := net.Listen("tcp", ":0") s := g.Server(guid.S()) s.Group("/", func(group *ghttp.RouterGroup) { group.GET("/test", func(r *ghttp.Request) { @@ -95,15 +65,18 @@ func Test_SetMultipleCustomListeners(t *testing.T) { time.Sleep(100 * time.Millisecond) gtest.C(t, func(t *gtest.T) { + ports := s.GetListenedPorts() + t.Assert(len(ports), 2) + c := g.Client() - c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", p1)) + c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", ports[0])) t.Assert( gstr.Trim(c.GetContent(ctx, "/test")), "test", ) - c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", p2)) + c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", ports[1])) t.Assert( gstr.Trim(c.GetContent(ctx, "/test")), diff --git a/net/ghttp/ghttp_z_unit_feature_https_test.go b/net/ghttp/ghttp_z_unit_feature_https_test.go index fe728d2f10b..06b54fe0d01 100644 --- a/net/ghttp/ghttp_z_unit_feature_https_test.go +++ b/net/ghttp/ghttp_z_unit_feature_https_test.go @@ -15,7 +15,6 @@ import ( "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/net/gtcp" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" @@ -90,10 +89,6 @@ func Test_HTTPS_Resource(t *testing.T) { } func Test_HTTPS_HTTP_Basic(t *testing.T) { - var ( - portHttp, _ = gtcp.GetFreePort() - portHttps, _ = gtcp.GetFreePort() - ) s := g.Server(gtime.TimestampNanoStr()) s.Group("/", func(group *ghttp.RouterGroup) { group.GET("/test", func(r *ghttp.Request) { @@ -104,8 +99,8 @@ func Test_HTTPS_HTTP_Basic(t *testing.T) { gtest.DataPath("https", "files", "server.crt"), gtest.DataPath("https", "files", "server.key"), ) - s.SetPort(portHttp) - s.SetHTTPSPort(portHttps) + s.SetPort(0) + s.SetHTTPSPort(0) s.SetDumpRouterMap(false) s.Start() defer s.Shutdown() @@ -115,14 +110,14 @@ func Test_HTTPS_HTTP_Basic(t *testing.T) { // HTTP gtest.C(t, func(t *gtest.T) { c := g.Client() - c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", portHttp)) + c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) t.Assert(c.GetContent(ctx, "/"), "Not Found") t.Assert(c.GetContent(ctx, "/test"), "test") }) // HTTPS gtest.C(t, func(t *gtest.T) { c := g.Client() - c.SetPrefix(fmt.Sprintf("https://127.0.0.1:%d", portHttps)) + c.SetPrefix(fmt.Sprintf("https://127.0.0.1:%d", s.GetListenedHTTPSPort())) t.Assert(c.GetContent(ctx, "/"), "Not Found") t.Assert(c.GetContent(ctx, "/test"), "test") }) diff --git a/net/ghttp/internal/graceful/graceful.go b/net/ghttp/internal/graceful/graceful.go new file mode 100644 index 00000000000..126e4c42ea0 --- /dev/null +++ b/net/ghttp/internal/graceful/graceful.go @@ -0,0 +1,378 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +// Package graceful implements graceful reload/restart features for HTTP servers. +// It provides the ability to gracefully shutdown or restart HTTP servers without +// interrupting existing connections. This is particularly useful for zero-downtime +// deployments and maintenance operations. +// +// The package wraps the standard net/http.Server and provides additional functionality +// for graceful server management, including: +// - Graceful server shutdown with timeout +// - Support for both HTTP and HTTPS servers +// - File descriptor inheritance for server reload/restart +// - Connection management during shutdown +package graceful + +import ( + "context" + "crypto/tls" + "fmt" + "io" + "log" + "net" + "net/http" + "os" + "strconv" + "sync" + "time" + + "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/os/glog" + "github.com/gogf/gf/v2/os/gproc" + "github.com/gogf/gf/v2/os/gres" + "github.com/gogf/gf/v2/text/gstr" +) + +// ServerStatus is the server status enum type. +type ServerStatus = int + +const ( + // FreePortAddress marks the server listens using random free port. + FreePortAddress = ":0" + // ServerStatusStopped indicates the server is stopped. + ServerStatusStopped ServerStatus = 0 + // ServerStatusRunning indicates the server is running. + ServerStatusRunning ServerStatus = 1 +) + +// Server wraps the net/http.Server with graceful reload/restart feature. +type Server struct { + fd uintptr // File descriptor for passing to the child process when graceful reload. + address string // Listening address like ":80", ":8080". + httpServer *http.Server // Underlying http.Server. + rawListener net.Listener // Underlying net.Listener. + rawLnMu sync.RWMutex // Concurrent safety mutex for rawListener. + listener net.Listener // Wrapped net.Listener with TLS support if necessary. + isHttps bool // Whether server is running in HTTPS mode. + status *gtype.Int // Server status using gtype for concurrent safety. + config ServerConfig // Server configuration. +} + +// ServerConfig is the graceful Server configuration manager. +type ServerConfig struct { + // Listeners specifies the custom listeners. + Listeners []net.Listener `json:"listeners"` + + // Handler the handler for HTTP request. + Handler func(w http.ResponseWriter, r *http.Request) `json:"-"` + + // ReadTimeout is the maximum duration for reading the entire + // request, including the body. + // + // Because ReadTimeout does not let Handlers make per-request + // decisions on each request body's acceptable deadline or + // upload rate, most users will prefer to use + // ReadHeaderTimeout. It is valid to use them both. + ReadTimeout time.Duration `json:"readTimeout"` + + // WriteTimeout is the maximum duration before timing out + // writes of the response. It is reset whenever a new + // request's header is read. Like ReadTimeout, it does not + // let Handlers make decisions on a per-request basis. + WriteTimeout time.Duration `json:"writeTimeout"` + + // IdleTimeout is the maximum amount of time to wait for the + // next request when keep-alive are enabled. If IdleTimeout + // is zero, the value of ReadTimeout is used. If both are + // zero, there is no timeout. + IdleTimeout time.Duration `json:"idleTimeout"` + + // GracefulShutdownTimeout set the maximum survival time (seconds) before stopping the server. + GracefulShutdownTimeout int `json:"gracefulShutdownTimeout"` + + // MaxHeaderBytes controls the maximum number of bytes the + // server will read parsing the request header's keys and + // values, including the request line. It does not limit the + // size of the request body. + // + // It can be configured in configuration file using string like: 1m, 10m, 500kb etc. + // It's 10240 bytes in default. + MaxHeaderBytes int `json:"maxHeaderBytes"` + + // KeepAlive enables HTTP keep-alive. + KeepAlive bool `json:"keepAlive"` + + // Logger specifies the logger for server. + Logger *glog.Logger `json:"logger"` +} + +// New creates and returns a graceful http server with a given address. +// The optional parameter `fd` specifies the file descriptor which is passed from parent server. +func New( + address string, + fd int, + loggerWriter io.Writer, + config ServerConfig, +) *Server { + // Change port to address like: 80 -> :80 + if gstr.IsNumeric(address) { + address = ":" + address + } + gs := &Server{ + address: address, + httpServer: newHttpServer(address, loggerWriter, config), + status: gtype.NewInt(), + config: config, + } + if fd != 0 { + gs.fd = uintptr(fd) + } + if len(config.Listeners) > 0 { + addrArray := gstr.SplitAndTrim(address, ":") + addrPort, err := strconv.Atoi(addrArray[len(addrArray)-1]) + if err == nil { + for _, v := range config.Listeners { + if listenerPort := (v.Addr().(*net.TCPAddr)).Port; listenerPort == addrPort { + gs.rawListener = v + break + } + } + } + } + return gs +} + +// newHttpServer creates and returns an underlying http.Server with a given address. +func newHttpServer( + address string, + loggerWriter io.Writer, + config ServerConfig, +) *http.Server { + server := &http.Server{ + Addr: address, + Handler: http.HandlerFunc(config.Handler), + ReadTimeout: config.ReadTimeout, + WriteTimeout: config.WriteTimeout, + IdleTimeout: config.IdleTimeout, + MaxHeaderBytes: config.MaxHeaderBytes, + ErrorLog: log.New(loggerWriter, "", 0), + } + server.SetKeepAlivesEnabled(config.KeepAlive) + return server +} + +// Fd retrieves and returns the file descriptor of the current server. +// It is available ony in *nix like operating systems like linux, unix, darwin. +func (s *Server) Fd() uintptr { + if ln := s.getRawListener(); ln != nil { + file, err := ln.(*net.TCPListener).File() + if err == nil { + return file.Fd() + } + } + return 0 +} + +// CreateListener creates listener on configured address. +func (s *Server) CreateListener() error { + ln, err := s.getNetListener() + if err != nil { + return err + } + s.listener = ln + s.setRawListener(ln) + return nil +} + +// IsHttps returns whether the server is running in HTTPS mode. +func (s *Server) IsHttps() bool { + return s.isHttps +} + +// GetAddress returns the server's configured address. +func (s *Server) GetAddress() string { + return s.address +} + +// SetIsHttps sets the HTTPS mode for the server. +// The parameter isHttps determines whether to enable HTTPS mode. +func (s *Server) SetIsHttps(isHttps bool) { + s.isHttps = isHttps +} + +// CreateListenerTLS creates listener on configured address with HTTPS. +// The parameter `certFile` and `keyFile` specify the necessary certification and key files for HTTPS. +// The optional parameter `tlsConfig` specifies the custom TLS configuration. +func (s *Server) CreateListenerTLS(certFile, keyFile string, tlsConfig ...*tls.Config) error { + var config *tls.Config + if len(tlsConfig) > 0 && tlsConfig[0] != nil { + config = tlsConfig[0] + } else if s.httpServer.TLSConfig != nil { + config = s.httpServer.TLSConfig + } else { + config = &tls.Config{} + } + if config.NextProtos == nil { + config.NextProtos = []string{"http/1.1"} + } + var err error + if len(config.Certificates) == 0 { + config.Certificates = make([]tls.Certificate, 1) + if gres.Contains(certFile) { + config.Certificates[0], err = tls.X509KeyPair( + gres.GetContent(certFile), + gres.GetContent(keyFile), + ) + } else { + config.Certificates[0], err = tls.LoadX509KeyPair(certFile, keyFile) + } + } + if err != nil { + return gerror.Wrapf(err, `open certFile "%s" and keyFile "%s" failed`, certFile, keyFile) + } + ln, err := s.getNetListener() + if err != nil { + return err + } + + s.listener = tls.NewListener(ln, config) + s.setRawListener(ln) + return nil +} + +// Serve starts the serving with blocking way. +func (s *Server) Serve(ctx context.Context) error { + if s.rawListener == nil { + return gerror.NewCode(gcode.CodeInvalidOperation, `call CreateListener/CreateListenerTLS before Serve`) + } + + var action = "started" + if s.fd != 0 { + action = "reloaded" + } + s.config.Logger.Infof( + ctx, + `pid[%d]: %s server %s listening on [%s]`, + gproc.Pid(), s.getProto(), action, s.GetListenedAddress(), + ) + s.status.Set(ServerStatusRunning) + err := s.httpServer.Serve(s.listener) + s.status.Set(ServerStatusStopped) + return err +} + +// GetListenedAddress retrieves and returns the address string which are listened by current server. +func (s *Server) GetListenedAddress() string { + if !gstr.Contains(s.address, FreePortAddress) { + return s.address + } + var ( + address = s.address + listenedPort = s.GetListenedPort() + ) + address = gstr.Replace(address, FreePortAddress, fmt.Sprintf(`:%d`, listenedPort)) + return address +} + +// GetListenedPort retrieves and returns one port which is listened to by current server. +// Note that this method is only available if the server is listening on one port. +func (s *Server) GetListenedPort() int { + if ln := s.getRawListener(); ln != nil { + return ln.Addr().(*net.TCPAddr).Port + } + return -1 +} + +// Status returns the current status of the server. +// It returns either ServerStatusStopped or ServerStatusRunning. +func (s *Server) Status() ServerStatus { + return s.status.Val() +} + +// getProto retrieves and returns the proto string of current server. +func (s *Server) getProto() string { + proto := "http" + if s.isHttps { + proto = "https" + } + return proto +} + +// getNetListener retrieves and returns the wrapped net.Listener. +func (s *Server) getNetListener() (net.Listener, error) { + if s.rawListener != nil { + return s.rawListener, nil + } + var ( + ln net.Listener + err error + ) + if s.fd > 0 { + f := os.NewFile(s.fd, "") + ln, err = net.FileListener(f) + if err != nil { + err = gerror.Wrap(err, "net.FileListener failed") + return nil, err + } + } else { + ln, err = net.Listen("tcp", s.httpServer.Addr) + if err != nil { + err = gerror.Wrapf(err, `net.Listen address "%s" failed`, s.httpServer.Addr) + } + } + return ln, err +} + +// Shutdown shuts down the server gracefully. +func (s *Server) Shutdown(ctx context.Context) { + if s.status.Val() == ServerStatusStopped { + return + } + timeoutCtx, cancelFunc := context.WithTimeout( + ctx, + time.Duration(s.config.GracefulShutdownTimeout)*time.Second, + ) + defer cancelFunc() + if err := s.httpServer.Shutdown(timeoutCtx); err != nil { + s.config.Logger.Errorf( + ctx, + "%d: %s server [%s] shutdown error: %v", + gproc.Pid(), s.getProto(), s.address, err, + ) + } +} + +// setRawListener sets `rawListener` with given net.Listener. +func (s *Server) setRawListener(ln net.Listener) { + s.rawLnMu.Lock() + defer s.rawLnMu.Unlock() + s.rawListener = ln +} + +// getRawListener returns the `rawListener` of current server. +func (s *Server) getRawListener() net.Listener { + s.rawLnMu.RLock() + defer s.rawLnMu.RUnlock() + return s.rawListener +} + +// Close shuts down the server forcibly. +// for graceful shutdown, please use Server.shutdown. +func (s *Server) Close(ctx context.Context) { + if s.status.Val() == ServerStatusStopped { + return + } + if err := s.httpServer.Close(); err != nil { + s.config.Logger.Errorf( + ctx, + "%d: %s server [%s] closed error: %v", + gproc.Pid(), s.getProto(), s.address, err, + ) + } +} From 69969b17237c6887bf0dcb650c597c3071cdb653 Mon Sep 17 00:00:00 2001 From: John Guo Date: Tue, 10 Dec 2024 20:59:44 +0800 Subject: [PATCH 044/102] fix(contrib/registry/etcd): remove default configuration of `AutoSyncInterval` (#4027) --- contrib/registry/etcd/etcd.go | 5 ----- 1 file changed, 5 deletions(-) diff --git a/contrib/registry/etcd/etcd.go b/contrib/registry/etcd/etcd.go index fac43a9e46d..0e95f87aafc 100644 --- a/contrib/registry/etcd/etcd.go +++ b/contrib/registry/etcd/etcd.go @@ -55,10 +55,6 @@ const ( // DefaultDialTimeout is the timeout for failing to establish a connection. DefaultDialTimeout = time.Second * 5 - - // DefaultAutoSyncInterval is the interval to update endpoints with its latest members. - // 0 disables auto-sync. By default auto-sync is disabled. - DefaultAutoSyncInterval = time.Second ) // New creates and returns a new etcd registry. @@ -98,7 +94,6 @@ func New(address string, option ...Option) gsvc.Registry { } cfg.DialTimeout = DefaultDialTimeout - cfg.AutoSyncInterval = DefaultAutoSyncInterval var usedOption Option if len(option) > 0 { From b7c74c9a350af6446cabd6546a12163cf8bdeb4e Mon Sep 17 00:00:00 2001 From: John Guo Date: Wed, 11 Dec 2024 09:58:26 +0800 Subject: [PATCH 045/102] fix(contrib/drivers/pgsql): add unix socket connection support (#4028) --- LICENSE | 2 +- contrib/drivers/clickhouse/clickhouse_open.go | 45 +++----- .../clickhouse/clickhouse_z_unit_test.go | 2 +- contrib/drivers/mssql/mssql_open.go | 61 ++++++----- contrib/drivers/mysql/mysql_open.go | 48 ++++----- contrib/drivers/oracle/oracle_open.go | 32 ++---- contrib/drivers/pgsql/pgsql_open.go | 79 +++++++------- contrib/drivers/sqlite/sqlite_open.go | 10 +- .../drivers/sqlite/sqlite_z_unit_core_test.go | 2 +- contrib/drivers/sqlitecgo/sqlitecgo_open.go | 9 +- .../sqlitecgo/sqlitecgo_z_unit_core_test.go | 2 +- database/gdb/gdb.go | 9 +- database/gdb/gdb_core_config.go | 101 +++++++++++------- database/gdb/gdb_z_mysql_internal_test.go | 42 +++++--- frame/gins/gins_database.go | 8 +- 15 files changed, 224 insertions(+), 228 deletions(-) diff --git a/LICENSE b/LICENSE index 0c20e2aaa87..953bd19acbe 100644 --- a/LICENSE +++ b/LICENSE @@ -1,6 +1,6 @@ MIT License -Copyright (c) 2017 john@goframe.org https://goframe.org +Copyright (c) 2017 GoFrame Team https://goframe.org Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal diff --git a/contrib/drivers/clickhouse/clickhouse_open.go b/contrib/drivers/clickhouse/clickhouse_open.go index 15eaf147b9f..7cf076d09e1 100644 --- a/contrib/drivers/clickhouse/clickhouse_open.go +++ b/contrib/drivers/clickhouse/clickhouse_open.go @@ -14,43 +14,26 @@ import ( "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/text/gregex" ) // Open creates and returns an underlying sql.DB object for clickhouse. func (d *Driver) Open(config *gdb.ConfigNode) (db *sql.DB, err error) { - source := config.Link + var source string // clickhouse://username:password@host1:9000,host2:9000/database?dial_timeout=200ms&max_execution_time=60 - if config.Link != "" { - // ============================================================================ - // Deprecated from v2.2.0. - // ============================================================================ - // Custom changing the schema in runtime. - if config.Name != "" { - source, _ = gregex.ReplaceString(replaceSchemaPattern, "@$1/"+config.Name, config.Link) - } else { - // If no schema, the link is matched for replacement - dbName, _ := gregex.MatchString(replaceSchemaPattern, config.Link) - if len(dbName) > 0 { - config.Name = dbName[len(dbName)-1] - } - } + if config.Pass != "" { + source = fmt.Sprintf( + "clickhouse://%s:%s@%s:%s/%s?debug=%t", + config.User, url.PathEscape(config.Pass), + config.Host, config.Port, config.Name, config.Debug, + ) } else { - if config.Pass != "" { - source = fmt.Sprintf( - "clickhouse://%s:%s@%s:%s/%s?debug=%t", - config.User, url.PathEscape(config.Pass), - config.Host, config.Port, config.Name, config.Debug, - ) - } else { - source = fmt.Sprintf( - "clickhouse://%s@%s:%s/%s?debug=%t", - config.User, config.Host, config.Port, config.Name, config.Debug, - ) - } - if config.Extra != "" { - source = fmt.Sprintf("%s&%s", source, config.Extra) - } + source = fmt.Sprintf( + "clickhouse://%s@%s:%s/%s?debug=%t", + config.User, config.Host, config.Port, config.Name, config.Debug, + ) + } + if config.Extra != "" { + source = fmt.Sprintf("%s&%s", source, config.Extra) } if db, err = sql.Open(driverName, source); err != nil { err = gerror.WrapCodef( diff --git a/contrib/drivers/clickhouse/clickhouse_z_unit_test.go b/contrib/drivers/clickhouse/clickhouse_z_unit_test.go index a4eb484870e..caf82f77a28 100644 --- a/contrib/drivers/clickhouse/clickhouse_z_unit_test.go +++ b/contrib/drivers/clickhouse/clickhouse_z_unit_test.go @@ -544,7 +544,7 @@ func TestDriverClickhouse_Open(t *testing.T) { // link // DSM // clickhouse://username:password@host1:9000,host2:9000/database?dial_timeout=200ms&max_execution_time=60 - link := "clickhouse://default@127.0.0.1:9000,127.0.0.1:9000/default?dial_timeout=200ms&max_execution_time=60" + link := "clickhouse:default:@tcp(127.0.0.1:9000)/default?dial_timeout=200ms&max_execution_time=60" db, err := gdb.New(gdb.ConfigNode{ Link: link, Type: "clickhouse", diff --git a/contrib/drivers/mssql/mssql_open.go b/contrib/drivers/mssql/mssql_open.go index 9555dc85535..6e571e4e405 100644 --- a/contrib/drivers/mssql/mssql_open.go +++ b/contrib/drivers/mssql/mssql_open.go @@ -13,41 +13,16 @@ import ( "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" ) // Open creates and returns an underlying sql.DB object for mssql. func (d *Driver) Open(config *gdb.ConfigNode) (db *sql.DB, err error) { - var ( - source string - underlyingDriverName = "sqlserver" - ) - if config.Link != "" { - // ============================================================================ - // Deprecated from v2.2.0. - // ============================================================================ - source = config.Link - // Custom changing the schema in runtime. - if config.Name != "" { - source, _ = gregex.ReplaceString(`database=([\w\.\-]+)+`, "database="+config.Name, source) - } - } else { - source = fmt.Sprintf( - "user id=%s;password=%s;server=%s;port=%s;database=%s;encrypt=disable", - config.User, config.Pass, config.Host, config.Port, config.Name, - ) - if config.Extra != "" { - var extraMap map[string]interface{} - if extraMap, err = gstr.Parse(config.Extra); err != nil { - return nil, err - } - for k, v := range extraMap { - source += fmt.Sprintf(`;%s=%s`, k, v) - } - } + source, err := configNodeToSource(config) + if err != nil { + return nil, err } - + underlyingDriverName := "sqlserver" if db, err = sql.Open(underlyingDriverName, source); err != nil { err = gerror.WrapCodef( gcode.CodeDbOperationError, err, @@ -57,3 +32,31 @@ func (d *Driver) Open(config *gdb.ConfigNode) (db *sql.DB, err error) { } return } + +func configNodeToSource(config *gdb.ConfigNode) (string, error) { + var source string + source = fmt.Sprintf( + "user id=%s;password=%s;server=%s;encrypt=disable", + config.User, config.Pass, config.Host, + ) + if config.Name != "" { + source = fmt.Sprintf("%s;database=%s", source, config.Name) + } + if config.Port != "" { + source = fmt.Sprintf("%s;port=%s", source, config.Port) + } + if config.Extra != "" { + extraMap, err := gstr.Parse(config.Extra) + if err != nil { + return "", gerror.WrapCodef( + gcode.CodeInvalidParameter, + err, + `invalid extra configuration: %s`, config.Extra, + ) + } + for k, v := range extraMap { + source += fmt.Sprintf(`;%s=%s`, k, v) + } + } + return source, nil +} diff --git a/contrib/drivers/mysql/mysql_open.go b/contrib/drivers/mysql/mysql_open.go index cd5f74b11c8..fdf3595cb3e 100644 --- a/contrib/drivers/mysql/mysql_open.go +++ b/contrib/drivers/mysql/mysql_open.go @@ -15,7 +15,6 @@ import ( "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/text/gregex" ) // Open creates and returns an underlying sql.DB object for mysql. @@ -35,36 +34,27 @@ func (d *Driver) Open(config *gdb.ConfigNode) (db *sql.DB, err error) { return } +// [username[:password]@][protocol[(address)]]/dbname[?param1=value1&...¶mN=valueN] func configNodeToSource(config *gdb.ConfigNode) string { - var source string - // [username[:password]@][protocol[(address)]]/dbname[?param1=value1&...¶mN=valueN] - if config.Link != "" { - // ============================================================================ - // Deprecated from v2.2.0. - // ============================================================================ - source = config.Link - // Custom changing the schema in runtime. - if config.Name != "" { - source, _ = gregex.ReplaceString(`/([\w\.\-]+)+`, "/"+config.Name, source) - } - } else { - var portStr string - if config.Port != "" { - portStr = ":" + config.Port - } - source = fmt.Sprintf( - "%s:%s@%s(%s%s)/%s?charset=%s", - config.User, config.Pass, config.Protocol, config.Host, portStr, config.Name, config.Charset, - ) - if config.Timezone != "" { - if strings.Contains(config.Timezone, "/") { - config.Timezone = url.QueryEscape(config.Timezone) - } - source = fmt.Sprintf("%s&loc=%s", source, config.Timezone) - } - if config.Extra != "" { - source = fmt.Sprintf("%s&%s", source, config.Extra) + var ( + source string + portStr string + ) + if config.Port != "" { + portStr = ":" + config.Port + } + source = fmt.Sprintf( + "%s:%s@%s(%s%s)/%s?charset=%s", + config.User, config.Pass, config.Protocol, config.Host, portStr, config.Name, config.Charset, + ) + if config.Timezone != "" { + if strings.Contains(config.Timezone, "/") { + config.Timezone = url.QueryEscape(config.Timezone) } + source = fmt.Sprintf("%s&loc=%s", source, config.Timezone) + } + if config.Extra != "" { + source = fmt.Sprintf("%s&%s", source, config.Extra) } return source } diff --git a/contrib/drivers/oracle/oracle_open.go b/contrib/drivers/oracle/oracle_open.go index b720bb9cc80..c41505e2913 100644 --- a/contrib/drivers/oracle/oracle_open.go +++ b/contrib/drivers/oracle/oracle_open.go @@ -15,7 +15,6 @@ import ( "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/util/gconv" ) @@ -35,30 +34,19 @@ func (d *Driver) Open(config *gdb.ConfigNode) (db *sql.DB, err error) { options["TRACE FILE"] = "oracle_trace.log" } // [username:[password]@]host[:port][/service_name][?param1=value1&...¶mN=valueN] - if config.Link != "" { - // ============================================================================ - // Deprecated from v2.2.0. - // ============================================================================ - source = config.Link - // Custom changing the schema in runtime. - if config.Name != "" { - source, _ = gregex.ReplaceString(`@(.+?)/([\w\.\-]+)+`, "@$1/"+config.Name, source) - } - } else { - if config.Extra != "" { - // fix #3226 - list := strings.Split(config.Extra, "&") - for _, v := range list { - kv := strings.Split(v, "=") - if len(kv) == 2 { - options[kv[0]] = kv[1] - } + if config.Extra != "" { + // fix #3226 + list := strings.Split(config.Extra, "&") + for _, v := range list { + kv := strings.Split(v, "=") + if len(kv) == 2 { + options[kv[0]] = kv[1] } } - source = gora.BuildUrl( - config.Host, gconv.Int(config.Port), config.Name, config.User, config.Pass, options, - ) } + source = gora.BuildUrl( + config.Host, gconv.Int(config.Port), config.Name, config.User, config.Pass, options, + ) if db, err = sql.Open(underlyingDriverName, source); err != nil { err = gerror.WrapCodef( diff --git a/contrib/drivers/pgsql/pgsql_open.go b/contrib/drivers/pgsql/pgsql_open.go index 21d3dce13f8..87e0e5092b3 100644 --- a/contrib/drivers/pgsql/pgsql_open.go +++ b/contrib/drivers/pgsql/pgsql_open.go @@ -13,54 +13,17 @@ import ( "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/errors/gcode" "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" ) // Open creates and returns an underlying sql.DB object for pgsql. // https://pkg.go.dev/github.com/lib/pq func (d *Driver) Open(config *gdb.ConfigNode) (db *sql.DB, err error) { - var ( - source string - underlyingDriverName = "postgres" - ) - if config.Link != "" { - // ============================================================================ - // Deprecated from v2.2.0. - // ============================================================================ - source = config.Link - // Custom changing the schema in runtime. - if config.Name != "" { - source, _ = gregex.ReplaceString(`dbname=([\w\.\-]+)+`, "dbname="+config.Name, source) - } - } else { - source = fmt.Sprintf( - "user=%s password='%s' host=%s port=%s sslmode=disable", - config.User, config.Pass, config.Host, config.Port) - - if config.Name != "" { - source = fmt.Sprintf("%s dbname=%s", source, config.Name) - } - - if config.Namespace != "" { - source = fmt.Sprintf("%s search_path=%s", source, config.Namespace) - } - - if config.Timezone != "" { - source = fmt.Sprintf("%s timezone=%s", source, config.Timezone) - } - - if config.Extra != "" { - var extraMap map[string]interface{} - if extraMap, err = gstr.Parse(config.Extra); err != nil { - return nil, err - } - for k, v := range extraMap { - source += fmt.Sprintf(` %s=%s`, k, v) - } - } + source, err := configNodeToSource(config) + if err != nil { + return nil, err } - + underlyingDriverName := "postgres" if db, err = sql.Open(underlyingDriverName, source); err != nil { err = gerror.WrapCodef( gcode.CodeDbOperationError, err, @@ -70,3 +33,37 @@ func (d *Driver) Open(config *gdb.ConfigNode) (db *sql.DB, err error) { } return } + +func configNodeToSource(config *gdb.ConfigNode) (string, error) { + var source string + source = fmt.Sprintf( + "user=%s password='%s' host=%s sslmode=disable", + config.User, config.Pass, config.Host, + ) + if config.Port != "" { + source = fmt.Sprintf("%s port=%s", source, config.Port) + } + if config.Name != "" { + source = fmt.Sprintf("%s dbname=%s", source, config.Name) + } + if config.Namespace != "" { + source = fmt.Sprintf("%s search_path=%s", source, config.Namespace) + } + if config.Timezone != "" { + source = fmt.Sprintf("%s timezone=%s", source, config.Timezone) + } + if config.Extra != "" { + extraMap, err := gstr.Parse(config.Extra) + if err != nil { + return "", gerror.WrapCodef( + gcode.CodeInvalidParameter, + err, + `invalid extra configuration: %s`, config.Extra, + ) + } + for k, v := range extraMap { + source += fmt.Sprintf(` %s=%s`, k, v) + } + } + return source, nil +} diff --git a/contrib/drivers/sqlite/sqlite_open.go b/contrib/drivers/sqlite/sqlite_open.go index 401b4b69451..0f084292c62 100644 --- a/contrib/drivers/sqlite/sqlite_open.go +++ b/contrib/drivers/sqlite/sqlite_open.go @@ -26,19 +26,11 @@ func (d *Driver) Open(config *gdb.ConfigNode) (db *sql.DB, err error) { source string underlyingDriverName = "sqlite" ) - if config.Link != "" { - // ============================================================================ - // Deprecated from v2.2.0. - // ============================================================================ - source = config.Link - } else { - source = config.Name - } + source = config.Name // It searches the source file to locate its absolute path.. if absolutePath, _ := gfile.Search(source); absolutePath != "" { source = absolutePath } - // Multiple PRAGMAs can be specified, e.g.: // path/to/some.db?_pragma=busy_timeout(5000)&_pragma=journal_mode(WAL) if config.Extra != "" { diff --git a/contrib/drivers/sqlite/sqlite_z_unit_core_test.go b/contrib/drivers/sqlite/sqlite_z_unit_core_test.go index 1c151472f5d..cb592db6e31 100644 --- a/contrib/drivers/sqlite/sqlite_z_unit_core_test.go +++ b/contrib/drivers/sqlite/sqlite_z_unit_core_test.go @@ -27,7 +27,7 @@ func Test_New(t *testing.T) { gtest.C(t, func(t *gtest.T) { node := gdb.ConfigNode{ Type: "sqlite", - Link: gfile.Join(dbDir, "test.db"), + Name: gfile.Join(dbDir, "test.db"), Charset: "utf8", } newDb, err := gdb.New(node) diff --git a/contrib/drivers/sqlitecgo/sqlitecgo_open.go b/contrib/drivers/sqlitecgo/sqlitecgo_open.go index 7c014d69d2d..1e2e4b985cc 100644 --- a/contrib/drivers/sqlitecgo/sqlitecgo_open.go +++ b/contrib/drivers/sqlitecgo/sqlitecgo_open.go @@ -34,14 +34,7 @@ func (d *Driver) Open(config *gdb.ConfigNode) (db *sql.DB, err error) { source string underlyingDriverName = "sqlite3" ) - if config.Link != "" { - // ============================================================================ - // Deprecated from v2.2.0. - // ============================================================================ - source = config.Link - } else { - source = config.Name - } + source = config.Name // It searches the source file to locate its absolute path.. if absolutePath, _ := gfile.Search(source); absolutePath != "" { source = absolutePath diff --git a/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_core_test.go b/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_core_test.go index fa2fe2c7138..31b0bc46057 100644 --- a/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_core_test.go +++ b/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_core_test.go @@ -27,7 +27,7 @@ func Test_New(t *testing.T) { gtest.C(t, func(t *gtest.T) { node := gdb.ConfigNode{ Type: "sqlite", - Link: gfile.Join(dbDir, "test.db"), + Name: gfile.Join(dbDir, "test.db"), Charset: "utf8", } newDb, err := gdb.New(node) diff --git a/database/gdb/gdb.go b/database/gdb/gdb.go index 18de920a7e0..da52e75267c 100644 --- a/database/gdb/gdb.go +++ b/database/gdb/gdb.go @@ -638,8 +638,8 @@ const ( ctxKeyCatchSQL gctx.StrKey = `CtxKeyCatchSQL` ctxKeyInternalProducedSQL gctx.StrKey = `CtxKeyInternalProducedSQL` - // type:[username[:password]@][protocol[(address)]]/dbname[?param1=value1&...¶mN=valueN] - linkPattern = `(\w+):([\w\-\$]*):(.*?)@(\w+?)\((.+?)\)/{0,1}([^\?]*)\?{0,1}(.*)` + linkPattern = `(\w+):([\w\-\$]*):(.*?)@(\w+?)\((.+?)\)/{0,1}([^\?]*)\?{0,1}(.*)` + linkPatternDescription = `type:username:password@protocol(host:port)/dbname?param1=value1&...¶mN=valueN` ) type ctxTimeoutType int @@ -843,7 +843,10 @@ func NewByGroup(group ...string) (db DB, err error) { // So all db type configurations in the same group should be the same. func newDBByConfigNode(node *ConfigNode, group string) (db DB, err error) { if node.Link != "" { - node = parseConfigNodeLink(node) + node, err = parseConfigNodeLink(node) + if err != nil { + return + } } c := &Core{ group: group, diff --git a/database/gdb/gdb_core_config.go b/database/gdb/gdb_core_config.go index fdec90f2ea2..291ade99544 100644 --- a/database/gdb/gdb_core_config.go +++ b/database/gdb/gdb_core_config.go @@ -10,6 +10,8 @@ import ( "sync" "time" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/os/gcache" "github.com/gogf/gf/v2/os/glog" "github.com/gogf/gf/v2/text/gregex" @@ -73,42 +75,64 @@ func init() { // SetConfig sets the global configuration for package. // It will overwrite the old configuration of package. -func SetConfig(config Config) { +func SetConfig(config Config) error { defer instances.Clear() configs.Lock() defer configs.Unlock() + for k, nodes := range config { for i, node := range nodes { - nodes[i] = parseConfigNode(node) + parsedNode, err := parseConfigNode(node) + if err != nil { + return err + } + nodes[i] = parsedNode } config[k] = nodes } configs.config = config + return nil } // SetConfigGroup sets the configuration for given group. -func SetConfigGroup(group string, nodes ConfigGroup) { +func SetConfigGroup(group string, nodes ConfigGroup) error { defer instances.Clear() configs.Lock() defer configs.Unlock() + for i, node := range nodes { - nodes[i] = parseConfigNode(node) + parsedNode, err := parseConfigNode(node) + if err != nil { + return err + } + nodes[i] = parsedNode } configs.config[group] = nodes + return nil } // AddConfigNode adds one node configuration to configuration of given group. -func AddConfigNode(group string, node ConfigNode) { +func AddConfigNode(group string, node ConfigNode) error { defer instances.Clear() configs.Lock() defer configs.Unlock() - configs.config[group] = append(configs.config[group], parseConfigNode(node)) + + parsedNode, err := parseConfigNode(node) + if err != nil { + return err + } + configs.config[group] = append(configs.config[group], parsedNode) + return nil } // parseConfigNode parses `Link` configuration syntax. -func parseConfigNode(node ConfigNode) ConfigNode { +func parseConfigNode(node ConfigNode) (ConfigNode, error) { if node.Link != "" { - node = *parseConfigNodeLink(&node) + parsedLinkNode, err := parseConfigNodeLink(&node) + if err != nil { + return node, err + } + node = *parsedLinkNode } if node.Link != "" && node.Type == "" { match, _ := gregex.MatchString(`([a-z]+):(.+)`, node.Link) @@ -117,17 +141,17 @@ func parseConfigNode(node ConfigNode) ConfigNode { node.Link = gstr.Trim(match[2]) } } - return node + return node, nil } // AddDefaultConfigNode adds one node configuration to configuration of default group. -func AddDefaultConfigNode(node ConfigNode) { - AddConfigNode(DefaultGroupName, node) +func AddDefaultConfigNode(node ConfigNode) error { + return AddConfigNode(DefaultGroupName, node) } // AddDefaultConfigGroup adds multiple node configurations to configuration of default group. -func AddDefaultConfigGroup(nodes ConfigGroup) { - SetConfigGroup(DefaultGroupName, nodes) +func AddDefaultConfigGroup(nodes ConfigGroup) error { + return SetConfigGroup(DefaultGroupName, nodes) } // GetConfig retrieves and returns the configuration of given group. @@ -266,34 +290,39 @@ func (c *Core) GetSchema() string { return schema } -func parseConfigNodeLink(node *ConfigNode) *ConfigNode { +func parseConfigNodeLink(node *ConfigNode) (*ConfigNode, error) { var match []string if node.Link != "" { match, _ = gregex.MatchString(linkPattern, node.Link) - if len(match) > 5 { - node.Type = match[1] - node.User = match[2] - node.Pass = match[3] - node.Protocol = match[4] - array := gstr.Split(match[5], ":") - if node.Protocol == "file" { - node.Name = match[5] + if len(match) <= 5 { + return nil, gerror.NewCodef( + gcode.CodeInvalidParameter, + `invalid link configuration: %s, shuold be pattern like: %s`, + node.Link, linkPatternDescription, + ) + } + node.Type = match[1] + node.User = match[2] + node.Pass = match[3] + node.Protocol = match[4] + array := gstr.Split(match[5], ":") + if node.Protocol == "file" { + node.Name = match[5] + } else { + if len(array) == 2 { + // link with port. + node.Host = array[0] + node.Port = array[1] } else { - if len(array) == 2 { - // link with port. - node.Host = array[0] - node.Port = array[1] - } else { - // link without port. - node.Host = array[0] - } - node.Name = match[6] + // link without port. + node.Host = array[0] } - if len(match) > 6 && match[7] != "" { - node.Extra = match[7] - } - node.Link = "" + node.Name = match[6] + } + if len(match) > 6 && match[7] != "" { + node.Extra = match[7] } + node.Link = "" } if node.Extra != "" { if m, _ := gstr.Parse(node.Extra); len(m) > 0 { @@ -307,5 +336,5 @@ func parseConfigNodeLink(node *ConfigNode) *ConfigNode { if node.Protocol == "" { node.Protocol = defaultProtocol } - return node + return node, nil } diff --git a/database/gdb/gdb_z_mysql_internal_test.go b/database/gdb/gdb_z_mysql_internal_test.go index a2428dbee1b..b2ec6e83b95 100644 --- a/database/gdb/gdb_z_mysql_internal_test.go +++ b/database/gdb/gdb_z_mysql_internal_test.go @@ -53,7 +53,8 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) { node := &ConfigNode{ Link: `mysql:root:CxzhD*624:27jh@tcp(9.135.69.119:3306)/khaos_oss?loc=Local&parseTime=true&charset=latin`, } - newNode := parseConfigNodeLink(node) + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) t.Assert(newNode.Type, `mysql`) t.Assert(newNode.User, `root`) t.Assert(newNode.Pass, `CxzhD*624:27jh`) @@ -68,7 +69,8 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) { node := &ConfigNode{ Link: `mysql:root:CxzhD*624:27jh@tcp(9.135.69.119:3306)/khaos_oss?`, } - newNode := parseConfigNodeLink(node) + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) t.Assert(newNode.Type, `mysql`) t.Assert(newNode.User, `root`) t.Assert(newNode.Pass, `CxzhD*624:27jh`) @@ -83,7 +85,8 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) { node := &ConfigNode{ Link: `mysql:root:CxzhD*624:27jh@tcp(9.135.69.119:3306)/khaos_oss`, } - newNode := parseConfigNodeLink(node) + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) t.Assert(newNode.Type, `mysql`) t.Assert(newNode.User, `root`) t.Assert(newNode.Pass, `CxzhD*624:27jh`) @@ -99,7 +102,8 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) { node := &ConfigNode{ Link: `mysql:root:CxzhD*624:27jh@tcp(9.135.69.119:3306)/?loc=Local&parseTime=true&charset=latin`, } - newNode := parseConfigNodeLink(node) + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) t.Assert(newNode.Type, `mysql`) t.Assert(newNode.User, `root`) t.Assert(newNode.Pass, `CxzhD*624:27jh`) @@ -114,7 +118,8 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) { node := &ConfigNode{ Link: `mysql:root:CxzhD*624:27jh@tcp(9.135.69.119:3306)?loc=Local&parseTime=true&charset=latin`, } - newNode := parseConfigNodeLink(node) + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) t.Assert(newNode.Type, `mysql`) t.Assert(newNode.User, `root`) t.Assert(newNode.Pass, `CxzhD*624:27jh`) @@ -129,7 +134,8 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) { node := &ConfigNode{ Link: `mysql:root:CxzhD*624:27jh@tcp(9.135.69.119:3306)/`, } - newNode := parseConfigNodeLink(node) + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) t.Assert(newNode.Type, `mysql`) t.Assert(newNode.User, `root`) t.Assert(newNode.Pass, `CxzhD*624:27jh`) @@ -144,7 +150,8 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) { node := &ConfigNode{ Link: `mysql:root:CxzhD*624:27jh@tcp(9.135.69.119:3306)`, } - newNode := parseConfigNodeLink(node) + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) t.Assert(newNode.Type, `mysql`) t.Assert(newNode.User, `root`) t.Assert(newNode.Pass, `CxzhD*624:27jh`) @@ -160,7 +167,8 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) { node := &ConfigNode{ Link: `mysql:root:CxzhD*624:27jh@udp(9.135.69.119:3306)`, } - newNode := parseConfigNodeLink(node) + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) t.Assert(newNode.Type, `mysql`) t.Assert(newNode.User, `root`) t.Assert(newNode.Pass, `CxzhD*624:27jh`) @@ -175,7 +183,8 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) { node := &ConfigNode{ Link: `sqlite:root:CxzhD*624:27jh@file(/var/data/db.sqlite3)?local=Local&parseTime=true`, } - newNode := parseConfigNodeLink(node) + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) t.Assert(newNode.Type, `sqlite`) t.Assert(newNode.User, `root`) t.Assert(newNode.Pass, `CxzhD*624:27jh`) @@ -190,7 +199,8 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) { node := &ConfigNode{ Link: `sqlite::CxzhD*624:2@7jh@file(/var/data/db.sqlite3)`, } - newNode := parseConfigNodeLink(node) + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) t.Assert(newNode.Type, `sqlite`) t.Assert(newNode.User, ``) t.Assert(newNode.Pass, `CxzhD*624:2@7jh`) @@ -205,7 +215,8 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) { node := &ConfigNode{ Link: `sqlite::@file(/var/data/db.sqlite3)`, } - newNode := parseConfigNodeLink(node) + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) t.Assert(newNode.Type, `sqlite`) t.Assert(newNode.User, ``) t.Assert(newNode.Pass, ``) @@ -221,7 +232,8 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) { node := &ConfigNode{ Link: `pgsql:BASIC$xxxx:123456@tcp(xxxx.hologres.aliyuncs.com:80)/xxx`, } - newNode := parseConfigNodeLink(node) + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) t.Assert(newNode.Type, `pgsql`) t.Assert(newNode.User, `BASIC$xxxx`) t.Assert(newNode.Pass, `123456`) @@ -237,7 +249,8 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) { node := &ConfigNode{ Link: "mysql:user:pwd@tcp(rdsid.mysql.rds.aliyuncs.com)/dbname?charset=utf8&loc=Local", } - newNode := parseConfigNodeLink(node) + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) t.Assert(newNode.Type, `mysql`) t.Assert(newNode.User, `user`) t.Assert(newNode.Pass, `pwd`) @@ -253,7 +266,8 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) { node := &ConfigNode{ Link: "mysql:username:password@unix(/tmp/mysql.sock)/dbname", } - newNode := parseConfigNodeLink(node) + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) t.Assert(newNode.Type, `mysql`) t.Assert(newNode.User, `username`) t.Assert(newNode.Pass, `password`) diff --git a/frame/gins/gins_database.go b/frame/gins/gins_database.go index ece4ed70e49..ef8e07aafdf 100644 --- a/frame/gins/gins_database.go +++ b/frame/gins/gins_database.go @@ -91,7 +91,9 @@ func Database(name ...string) gdb.DB { if len(cg) > 0 { if gdb.GetConfig(group) == nil { intlog.Printf(ctx, "add configuration for group: %s, %#v", g, cg) - gdb.SetConfigGroup(g, cg) + if err := gdb.SetConfigGroup(g, cg); err != nil { + panic(err) + } } else { intlog.Printf(ctx, "ignore configuration as it already exists for group: %s, %#v", g, cg) intlog.Printf(ctx, "%s, %#v", g, cg) @@ -108,7 +110,9 @@ func Database(name ...string) gdb.DB { if len(cg) > 0 { if gdb.GetConfig(group) == nil { intlog.Printf(ctx, "add configuration for group: %s, %#v", gdb.DefaultGroupName, cg) - gdb.SetConfigGroup(gdb.DefaultGroupName, cg) + if err := gdb.SetConfigGroup(gdb.DefaultGroupName, cg); err != nil { + panic(err) + } } else { intlog.Printf( ctx, From 00e2f6b5dc47fb202c446df560b15efa05bd047c Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 11 Dec 2024 10:14:12 +0800 Subject: [PATCH 046/102] chore: improve golangci-lint.yml, upgrade dependencies, and optimize code and comments (#4025) --- .github/workflows/golangci-lint.yml | 15 ++++++- .github/workflows/sonarcloud.yaml | 4 +- Makefile | 2 +- README.MD | 4 +- cmd/gf/gfcmd/gfcmd.go | 5 +-- cmd/gf/go.mod | 2 +- cmd/gf/go.work | 2 +- cmd/gf/internal/cmd/cmd.go | 6 +-- cmd/gf/main.go | 5 ++- contrib/config/apollo/go.mod | 12 ++--- contrib/config/apollo/go.sum | 24 +++++----- contrib/config/consul/go.mod | 12 ++--- contrib/config/consul/go.sum | 24 +++++----- contrib/config/kubecm/go.mod | 14 +++--- contrib/config/kubecm/go.sum | 28 ++++++------ contrib/config/nacos/go.mod | 16 +++---- contrib/config/nacos/go.sum | 32 +++++++------- contrib/config/polaris/go.mod | 12 ++--- contrib/config/polaris/go.sum | 24 +++++----- contrib/drivers/clickhouse/go.mod | 12 ++--- contrib/drivers/clickhouse/go.sum | 24 +++++----- contrib/drivers/dm/go.mod | 12 ++--- contrib/drivers/dm/go.sum | 24 +++++----- contrib/drivers/mssql/go.mod | 14 +++--- contrib/drivers/mssql/go.sum | 28 ++++++------ contrib/drivers/mysql/go.mod | 12 ++--- contrib/drivers/mysql/go.sum | 24 +++++----- contrib/drivers/oracle/go.mod | 12 ++--- contrib/drivers/oracle/go.sum | 24 +++++----- contrib/drivers/pgsql/go.mod | 12 ++--- contrib/drivers/pgsql/go.sum | 24 +++++----- contrib/drivers/sqlite/go.mod | 12 ++--- contrib/drivers/sqlite/go.sum | 24 +++++----- contrib/drivers/sqlitecgo/go.mod | 12 ++--- contrib/drivers/sqlitecgo/go.sum | 24 +++++----- contrib/metric/otelmetric/go.mod | 12 ++--- contrib/metric/otelmetric/go.sum | 24 +++++----- contrib/nosql/redis/go.mod | 14 +++--- contrib/nosql/redis/go.sum | 28 ++++++------ contrib/registry/consul/go.mod | 6 --- contrib/registry/consul/go.sum | 8 ---- contrib/registry/etcd/go.mod | 12 ++--- contrib/registry/etcd/go.sum | 24 +++++----- contrib/registry/file/go.mod | 12 ++--- contrib/registry/file/go.sum | 24 +++++----- contrib/registry/nacos/go.mod | 16 +++---- contrib/registry/nacos/go.sum | 32 +++++++------- contrib/registry/polaris/go.mod | 14 +++--- contrib/registry/polaris/go.sum | 28 +++++------- contrib/registry/zookeeper/go.mod | 14 +++--- contrib/registry/zookeeper/go.sum | 28 ++++++------ contrib/rpc/grpcx/go.mod | 12 ++--- contrib/rpc/grpcx/go.sum | 24 +++++----- contrib/sdk/httpclient/go.mod | 12 ++--- contrib/sdk/httpclient/go.sum | 24 +++++----- contrib/trace/otlpgrpc/go.mod | 12 ++--- contrib/trace/otlpgrpc/go.sum | 24 +++++----- contrib/trace/otlphttp/go.mod | 19 ++++---- contrib/trace/otlphttp/go.sum | 44 ++++++++----------- example/go.mod | 18 ++++---- example/go.sum | 36 +++++++-------- go.mod | 12 ++--- go.sum | 24 +++++----- net/ghttp/ghttp.go | 1 + .../ghttp_middleware_handler_response.go | 2 +- net/ghttp/ghttp_server.go | 8 ++-- net/ghttp/ghttp_server_config_api.go | 2 +- net/gtrace/internal/provider/provider.go | 1 + os/gbuild/gbuild.go | 6 +-- os/gcache/gcache.go | 5 +-- os/gcfg/gcfg.go | 10 +++-- os/gcfg/gcfg_adapter_file.go | 34 +++++++------- os/gctx/gctx.go | 2 +- os/gres/gres_file.go | 1 + os/gres/gres_resource.go | 1 + os/gtime/gtime_format.go | 6 +-- os/gview/gview_config.go | 2 +- os/gview/gview_parse.go | 27 ++++++------ util/gpage/gpage.go | 14 +++--- util/grand/grand.go | 2 +- util/guid/guid.go | 6 +-- util/gutil/gutil.go | 4 +- util/gvalid/gvalid.go | 2 +- util/gvalid/gvalid_validator.go | 2 +- 84 files changed, 611 insertions(+), 621 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 70b6679c274..d1823a8beb6 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -15,6 +15,15 @@ on: - enhance/** - fix/** - feat/** + pull_request: + branches: + - master + - develop + - personal/** + - feature/** + - enhance/** + - fix/** + - feat/** jobs: golangci: @@ -33,11 +42,11 @@ jobs: - name: golangci-lint uses: golangci/golangci-lint-action@v6 with: - # Required: the version of golangci-lint is required and must be specified without patch version: we always use the latest patch version. + # Required: specify the golangci-lint version without the patch version to always use the latest patch. version: v1.62.2 only-new-issues: true github-token: ${{ secrets.GITHUB_TOKEN }} - args: --timeout 3m0s --fix + args: --timeout 3m0s - name: Install gci run: go install github.com/daixiang0/gci@latest - name: Run gci @@ -55,6 +64,8 @@ jobs: -s "prefix(github.com/gogf/gf/example)" \ ./ - name: Check for changes + # Check if the event is a push or a pull request from a forked repository + if: github.event_name == 'push'|| (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true) run: | if [[ -n "$(git status --porcelain)" ]]; then echo "HAS_CHANGES=true" >> $GITHUB_ENV diff --git a/.github/workflows/sonarcloud.yaml b/.github/workflows/sonarcloud.yaml index 38875b88764..f4e77ec3e0d 100644 --- a/.github/workflows/sonarcloud.yaml +++ b/.github/workflows/sonarcloud.yaml @@ -12,7 +12,7 @@ concurrency: cancel-in-progress: true # Declare default permissions as read only. -permissions: read-all +permissions: read jobs: analysis: @@ -34,7 +34,7 @@ jobs: persist-credentials: false - name: "Run analysis" - uses: ossf/scorecard-action@0864cf19026789058feabb7e87baa5f140aac736 # v2.3.1 + uses: ossf/scorecard-action@v2.4.0 # v2.4.0 with: results_file: results.sarif results_format: sarif diff --git a/Makefile b/Makefile index 2210ebcd91c..12b9ce55f29 100644 --- a/Makefile +++ b/Makefile @@ -13,7 +13,7 @@ tidy: .PHONY: lint lint: - golangci-lint run + golangci-lint run -c .golangci.yml # make version to=v2.4.0 .PHONY: version diff --git a/README.MD b/README.MD index 10082791e63..d2b5ccdc778 100644 --- a/README.MD +++ b/README.MD @@ -1,6 +1,6 @@
- +goframe gf logo [![Go Reference](https://pkg.go.dev/badge/github.com/gogf/gf/v2.svg)](https://pkg.go.dev/github.com/gogf/gf/v2) [![GoFrame CI](https://github.com/gogf/gf/actions/workflows/ci-main.yml/badge.svg)](https://github.com/gogf/gf/actions/workflows/ci-main.yml) @@ -36,7 +36,7 @@ A powerful framework for faster, easier, and more efficient project development. 💖 [Thanks to all the contributors who made GoFrame possible](https://github.com/gogf/gf/graphs/contributors) 💖 - +goframe contributors # License diff --git a/cmd/gf/gfcmd/gfcmd.go b/cmd/gf/gfcmd/gfcmd.go index 7e4b55336b9..44b38af4cb7 100644 --- a/cmd/gf/gfcmd/gfcmd.go +++ b/cmd/gf/gfcmd/gfcmd.go @@ -4,6 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://github.com/gogf/gf. +// Package gfcmd provides the management of CLI commands for `gf` tool. package gfcmd import ( @@ -25,9 +26,7 @@ import ( "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" ) -const ( - cliFolderName = `hack` -) +const cliFolderName = `hack` // Command manages the CLI command of `gf`. // This struct can be globally accessible and extended with custom struct. diff --git a/cmd/gf/go.mod b/cmd/gf/go.mod index f4c9e6bc558..48efa73eee5 100644 --- a/cmd/gf/go.mod +++ b/cmd/gf/go.mod @@ -1,6 +1,6 @@ module github.com/gogf/gf/cmd/gf/v2 -go 1.18 +go 1.20 require ( github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.8.2 diff --git a/cmd/gf/go.work b/cmd/gf/go.work index ece415d96ab..1fbd6cb9a7c 100644 --- a/cmd/gf/go.work +++ b/cmd/gf/go.work @@ -1,4 +1,4 @@ -go 1.18 +go 1.20 use ( ./ diff --git a/cmd/gf/internal/cmd/cmd.go b/cmd/gf/internal/cmd/cmd.go index 4a39fd17b9a..2da57110ffd 100644 --- a/cmd/gf/internal/cmd/cmd.go +++ b/cmd/gf/internal/cmd/cmd.go @@ -4,6 +4,7 @@ // If a copy of the MIT was not distributed with this file, // You can obtain one at https://github.com/gogf/gf. +// Package cmd provides the management of CLI commands for `gf` tool. package cmd import ( @@ -19,9 +20,8 @@ import ( "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" ) -var ( - GF = cGF{} -) +// GF is the management object for `gf` command line tool. +var GF = cGF{} type cGF struct { g.Meta `name:"gf" ad:"{cGFAd}"` diff --git a/cmd/gf/main.go b/cmd/gf/main.go index 9021f656fd8..31d3872ebb8 100644 --- a/cmd/gf/main.go +++ b/cmd/gf/main.go @@ -16,9 +16,10 @@ import ( func main() { var ( - ctx = gctx.GetInitCtx() + ctx = gctx.GetInitCtx() + command, err = gfcmd.GetCommand(ctx) ) - command, err := gfcmd.GetCommand(ctx) + if err != nil { mlog.Fatalf(`%+v`, err) } diff --git a/contrib/config/apollo/go.mod b/contrib/config/apollo/go.mod index 149eaf58139..ba0f03501cd 100644 --- a/contrib/config/apollo/go.mod +++ b/contrib/config/apollo/go.mod @@ -11,17 +11,17 @@ require ( github.com/BurntSushi/toml v1.4.0 // 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 github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // indirect github.com/hashicorp/hcl v1.0.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mitchellh/mapstructure v1.4.1 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pelletier/go-toml v1.9.3 // indirect @@ -36,9 +36,9 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect gopkg.in/ini.v1 v1.62.0 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/contrib/config/apollo/go.sum b/contrib/config/apollo/go.sum index 8b79d4e4c10..ea5fb99d01d 100644 --- a/contrib/config/apollo/go.sum +++ b/contrib/config/apollo/go.sum @@ -74,8 +74,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.m github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= @@ -196,8 +196,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +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.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= @@ -206,8 +206,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= @@ -369,8 +369,8 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -437,8 +437,8 @@ golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +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.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -447,8 +447,8 @@ golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.5/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 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/contrib/config/consul/go.mod b/contrib/config/consul/go.mod index 57f58b9ef69..814c2a184b7 100644 --- a/contrib/config/consul/go.mod +++ b/contrib/config/consul/go.mod @@ -13,7 +13,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,10 +24,10 @@ require ( github.com/hashicorp/go-rootcerts v1.0.2 // indirect github.com/hashicorp/golang-lru v1.0.2 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect @@ -37,9 +37,9 @@ 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/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.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/config/consul/go.sum b/contrib/config/consul/go.sum index c3ca809b54a..65a46cfbeee 100644 --- a/contrib/config/consul/go.sum +++ b/contrib/config/consul/go.sum @@ -28,8 +28,8 @@ github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FM github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= 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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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= @@ -103,8 +103,8 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +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= @@ -121,8 +121,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= @@ -198,8 +198,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -226,15 +226,15 @@ golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +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= 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 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +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= diff --git a/contrib/config/kubecm/go.mod b/contrib/config/kubecm/go.mod index bb52676f965..8dbbb714453 100644 --- a/contrib/config/kubecm/go.mod +++ b/contrib/config/kubecm/go.mod @@ -15,7 +15,7 @@ require ( github.com/davecgh/go-spew v1.1.1 // indirect github.com/emicklei/go-restful/v3 v3.9.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 @@ -33,11 +33,11 @@ require ( github.com/imdario/mergo v0.3.6 // indirect github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect - github.com/magiconair/properties v1.8.7 // indirect + github.com/magiconair/properties v1.8.9 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect @@ -48,11 +48,11 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.27.0 // indirect + golang.org/x/net v0.32.0 // indirect golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/term v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/term v0.27.0 // indirect + golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect google.golang.org/appengine v1.6.7 // indirect google.golang.org/protobuf v1.33.0 // indirect diff --git a/contrib/config/kubecm/go.sum b/contrib/config/kubecm/go.sum index ab817bc23a2..42d6e64aa1b 100644 --- a/contrib/config/kubecm/go.sum +++ b/contrib/config/kubecm/go.sum @@ -56,8 +56,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -163,8 +163,8 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 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/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -173,8 +173,8 @@ github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/ github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -287,8 +287,8 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -335,19 +335,19 @@ golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.22.0 h1:BbsgPEJULsl2fV/AT3v15Mjva5yXKQDyKf+TbDz7QJk= -golang.org/x/term v0.22.0/go.mod h1:F3qCibpT5AMpCRfhfT53vVJwhLtIVHhB9XDjfFvnMI4= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -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 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/contrib/config/nacos/go.mod b/contrib/config/nacos/go.mod index 702c942a21a..8ed4a55e91c 100644 --- a/contrib/config/nacos/go.mod +++ b/contrib/config/nacos/go.mod @@ -20,7 +20,7 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // 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 @@ -30,10 +30,10 @@ require ( github.com/grokify/html-strip-tags-go v0.1.0 // indirect github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect github.com/json-iterator/go v1.1.12 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect @@ -52,11 +52,11 @@ 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.25.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/crypto v0.30.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 + golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.1.0 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect google.golang.org/grpc v1.56.3 // indirect diff --git a/contrib/config/nacos/go.sum b/contrib/config/nacos/go.sum index ccb081682a7..f2af4b1f192 100644 --- a/contrib/config/nacos/go.sum +++ b/contrib/config/nacos/go.sum @@ -86,8 +86,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= github.com/fsnotify/fsnotify v1.7.0/go.mod h1:40Bi/Hjc2AVfZrqy+aj+yEI+/bRxZnMJyTJwOpGvigM= @@ -195,16 +195,16 @@ github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 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/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -305,8 +305,8 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= +golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -372,8 +372,8 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -390,8 +390,8 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -432,8 +432,8 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +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.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -441,8 +441,8 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 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 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/contrib/config/polaris/go.mod b/contrib/config/polaris/go.mod index 827108778fc..7fc1af50964 100644 --- a/contrib/config/polaris/go.mod +++ b/contrib/config/polaris/go.mod @@ -14,7 +14,7 @@ require ( github.com/clbanning/mxj/v2 v2.7.0 // indirect github.com/dlclark/regexp2 v1.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,10 +24,10 @@ require ( github.com/grokify/html-strip-tags-go v0.1.0 // indirect github.com/hashicorp/errwrap v1.0.0 // indirect github.com/hashicorp/go-multierror v1.1.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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect @@ -48,9 +48,9 @@ require ( go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.21.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/grpc v1.56.3 // indirect google.golang.org/protobuf v1.33.0 // indirect diff --git a/contrib/config/polaris/go.sum b/contrib/config/polaris/go.sum index 6a99e16ad82..703e7792333 100644 --- a/contrib/config/polaris/go.sum +++ b/contrib/config/polaris/go.sum @@ -224,8 +224,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -373,16 +373,16 @@ github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfn github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= @@ -582,8 +582,8 @@ golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -694,8 +694,8 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +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/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= @@ -709,8 +709,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -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 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/contrib/drivers/clickhouse/go.mod b/contrib/drivers/clickhouse/go.mod index 846f678bf1b..26c18001d6f 100644 --- a/contrib/drivers/clickhouse/go.mod +++ b/contrib/drivers/clickhouse/go.mod @@ -13,16 +13,16 @@ require ( github.com/BurntSushi/toml v1.4.0 // 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 github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/paulmach/orb v0.7.1 // indirect github.com/pierrec/lz4/v4 v4.1.14 // indirect @@ -31,9 +31,9 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.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/drivers/clickhouse/go.sum b/contrib/drivers/clickhouse/go.sum index f3ff16e0223..f6ef4d1c4ac 100644 --- a/contrib/drivers/clickhouse/go.sum +++ b/contrib/drivers/clickhouse/go.sum @@ -10,8 +10,8 @@ github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSs github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -42,16 +42,16 @@ github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhB github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/mkevac/debugcharts v0.0.0-20191222103121-ae1c48aa8615/go.mod h1:Ad7oeElCZqA1Ufj0U9/liOF4BtVepxRcTvr2ey7zTvM= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= @@ -102,8 +102,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -116,12 +116,12 @@ golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/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 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +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-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= diff --git a/contrib/drivers/dm/go.mod b/contrib/drivers/dm/go.mod index 677112a1732..a47cdb3b25d 100644 --- a/contrib/drivers/dm/go.mod +++ b/contrib/drivers/dm/go.mod @@ -13,25 +13,25 @@ require ( github.com/BurntSushi/toml v1.4.0 // 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 github.com/golang/snappy v0.0.1 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.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/drivers/dm/go.sum b/contrib/drivers/dm/go.sum index 08a0ddf30e4..1b0ff9aff02 100644 --- a/contrib/drivers/dm/go.sum +++ b/contrib/drivers/dm/go.sum @@ -7,8 +7,8 @@ github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -23,16 +23,16 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -48,15 +48,15 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -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 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +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= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/contrib/drivers/mssql/go.mod b/contrib/drivers/mssql/go.mod index e8e9579aa3f..1443d1f3fad 100644 --- a/contrib/drivers/mssql/go.mod +++ b/contrib/drivers/mssql/go.mod @@ -11,7 +11,7 @@ require ( github.com/BurntSushi/toml v1.4.0 // 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 @@ -19,20 +19,20 @@ require ( github.com/golang-sql/sqlexp v0.1.0 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/crypto v0.25.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/crypto v0.30.0 // indirect + golang.org/x/net v0.32.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/drivers/mssql/go.sum b/contrib/drivers/mssql/go.sum index b20340e267c..5c588f2f825 100644 --- a/contrib/drivers/mssql/go.sum +++ b/contrib/drivers/mssql/go.sum @@ -11,8 +11,8 @@ github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -32,16 +32,16 @@ github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/microsoft/go-mssqldb v1.7.1 h1:KU/g8aWeM3Hx7IMOFpiwYiUkU+9zeISb4+tx3ScVfsM= github.com/microsoft/go-mssqldb v1.7.1/go.mod h1:kOvZKUdrhhFQmxLZqbwUV0rHkNkZpthMITIb2Ko1IoA= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= @@ -60,16 +60,16 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= +golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/contrib/drivers/mysql/go.mod b/contrib/drivers/mysql/go.mod index c66f8e6532e..954915cd84e 100644 --- a/contrib/drivers/mysql/go.mod +++ b/contrib/drivers/mysql/go.mod @@ -11,25 +11,25 @@ require ( github.com/BurntSushi/toml v1.4.0 // 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 github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.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/drivers/mysql/go.sum b/contrib/drivers/mysql/go.sum index 4e03c25c615..3857f838de7 100644 --- a/contrib/drivers/mysql/go.sum +++ b/contrib/drivers/mysql/go.sum @@ -5,8 +5,8 @@ github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -21,16 +21,16 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -46,14 +46,14 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/contrib/drivers/oracle/go.mod b/contrib/drivers/oracle/go.mod index 832cfd41bf4..bfb15b404ab 100644 --- a/contrib/drivers/oracle/go.mod +++ b/contrib/drivers/oracle/go.mod @@ -11,25 +11,25 @@ require ( github.com/BurntSushi/toml v1.4.0 // 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 github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.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/drivers/oracle/go.sum b/contrib/drivers/oracle/go.sum index 4a201540221..20159b13709 100644 --- a/contrib/drivers/oracle/go.sum +++ b/contrib/drivers/oracle/go.sum @@ -5,8 +5,8 @@ github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -19,16 +19,16 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -46,14 +46,14 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/contrib/drivers/pgsql/go.mod b/contrib/drivers/pgsql/go.mod index afeff53ffc4..85caf1a36b4 100644 --- a/contrib/drivers/pgsql/go.mod +++ b/contrib/drivers/pgsql/go.mod @@ -11,25 +11,25 @@ require ( github.com/BurntSushi/toml v1.4.0 // 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 github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.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/drivers/pgsql/go.sum b/contrib/drivers/pgsql/go.sum index 577f088411b..f1b56657cb8 100644 --- a/contrib/drivers/pgsql/go.sum +++ b/contrib/drivers/pgsql/go.sum @@ -5,8 +5,8 @@ github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -21,16 +21,16 @@ github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtg github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -46,14 +46,14 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/contrib/drivers/sqlite/go.mod b/contrib/drivers/sqlite/go.mod index 75be93aa41c..3f1af171df1 100644 --- a/contrib/drivers/sqlite/go.mod +++ b/contrib/drivers/sqlite/go.mod @@ -12,17 +12,17 @@ require ( github.com/clbanning/mxj/v2 v2.7.0 // indirect github.com/dustin/go-humanize v1.0.1 // 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 github.com/google/uuid v1.3.0 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect github.com/rivo/uniseg v0.4.7 // indirect @@ -30,9 +30,9 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.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 modernc.org/libc v1.22.5 // indirect modernc.org/mathutil v1.5.0 // indirect diff --git a/contrib/drivers/sqlite/go.sum b/contrib/drivers/sqlite/go.sum index 8707f88d517..a6ac1e9edc6 100644 --- a/contrib/drivers/sqlite/go.sum +++ b/contrib/drivers/sqlite/go.sum @@ -7,8 +7,8 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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/glebarez/go-sqlite v1.21.2 h1:3a6LFC4sKahUunAmynQKLZceZCOzUthkRkEAl9gAXWo= @@ -26,16 +26,16 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -54,14 +54,14 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/contrib/drivers/sqlitecgo/go.mod b/contrib/drivers/sqlitecgo/go.mod index a122142e587..3ca9029ec7f 100644 --- a/contrib/drivers/sqlitecgo/go.mod +++ b/contrib/drivers/sqlitecgo/go.mod @@ -11,25 +11,25 @@ require ( github.com/BurntSushi/toml v1.4.0 // 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 github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.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/drivers/sqlitecgo/go.sum b/contrib/drivers/sqlitecgo/go.sum index 8217c594931..e463112f27c 100644 --- a/contrib/drivers/sqlitecgo/go.sum +++ b/contrib/drivers/sqlitecgo/go.sum @@ -5,8 +5,8 @@ github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -19,16 +19,16 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.14.17 h1:mCRHCLDUBXgpKAqIKsaAaAsrAlbkeomtRFKXh2L6YIM= github.com/mattn/go-sqlite3 v1.14.17/go.mod h1:2eHXhiwb8IkHr+BDWZGa96P6+rkvnG63S2DGjv9HUNg= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= @@ -46,14 +46,14 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/contrib/metric/otelmetric/go.mod b/contrib/metric/otelmetric/go.mod index 69f56d644dc..bfe75510e1b 100644 --- a/contrib/metric/otelmetric/go.mod +++ b/contrib/metric/otelmetric/go.mod @@ -19,16 +19,16 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // 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 github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/prometheus/client_model v0.6.1 // indirect @@ -37,9 +37,9 @@ require ( github.com/rivo/uniseg v0.4.7 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/contrib/metric/otelmetric/go.sum b/contrib/metric/otelmetric/go.sum index 43f093d167b..79f4008cb69 100644 --- a/contrib/metric/otelmetric/go.sum +++ b/contrib/metric/otelmetric/go.sum @@ -9,8 +9,8 @@ github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -25,16 +25,16 @@ github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtg github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= 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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= @@ -68,14 +68,14 @@ go.opentelemetry.io/otel/sdk/metric v1.24.0 h1:yyMQrPzF+k88/DbH7o4FMAs80puqd+9os go.opentelemetry.io/otel/sdk/metric v1.24.0/go.mod h1:I6Y5FjH6rvEnTTAYQz3Mmv2kl6Ek5IIrmwTLqMrrOE0= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/contrib/nosql/redis/go.mod b/contrib/nosql/redis/go.mod index 88355cc7bda..1095c2db9c4 100644 --- a/contrib/nosql/redis/go.mod +++ b/contrib/nosql/redis/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/gogf/gf/v2 v2.8.2 - github.com/redis/go-redis/v9 v9.2.1 + github.com/redis/go-redis/v9 v9.7.0 go.opentelemetry.io/otel v1.24.0 go.opentelemetry.io/otel/trace v1.24.0 ) @@ -15,23 +15,23 @@ require ( github.com/clbanning/mxj/v2 v2.7.0 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // 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 github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.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/nosql/redis/go.sum b/contrib/nosql/redis/go.sum index e954f191497..0c3db9d7c1d 100644 --- a/contrib/nosql/redis/go.sum +++ b/contrib/nosql/redis/go.sum @@ -11,8 +11,8 @@ github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/r github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -25,21 +25,21 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= -github.com/redis/go-redis/v9 v9.2.1 h1:WlYJg71ODF0dVspZZCpYmoF1+U1Jjk9Rwd7pq6QmlCg= -github.com/redis/go-redis/v9 v9.2.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= +github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= +github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= @@ -52,14 +52,14 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/contrib/registry/consul/go.mod b/contrib/registry/consul/go.mod index 2bf364b61d5..859c3ffae70 100644 --- a/contrib/registry/consul/go.mod +++ b/contrib/registry/consul/go.mod @@ -16,8 +16,6 @@ require ( 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 - github.com/gorilla/websocket v1.5.3 // indirect - github.com/grokify/html-strip-tags-go v0.1.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-cleanhttp v0.5.2 // indirect github.com/hashicorp/go-hclog v1.5.0 // indirect @@ -29,17 +27,13 @@ require ( github.com/magiconair/properties v1.8.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.15 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect 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/net v0.27.0 // indirect golang.org/x/sys v0.22.0 // indirect golang.org/x/text v0.16.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 1e5a596416a..2eb6fac9031 100644 --- a/contrib/registry/consul/go.sum +++ b/contrib/registry/consul/go.sum @@ -55,9 +55,7 @@ github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= -github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= -github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= github.com/hashicorp/consul/api v1.26.1 h1:5oSXOO5fboPZeW5SN+TdGFP/BILDgBm19OrPZ/pICIM= github.com/hashicorp/consul/api v1.26.1/go.mod h1:B4sQTeaSO16NtynqrAdwOlahJ7IUDZM9cj2420xYL8A= github.com/hashicorp/consul/sdk v0.15.0 h1:2qK9nDrr4tiJKRoxPGhm6B7xJjLVIQqkjiab2M4aKjU= @@ -124,9 +122,7 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= @@ -143,7 +139,6 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= @@ -165,9 +160,7 @@ github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8b github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= -github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= @@ -203,7 +196,6 @@ golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/contrib/registry/etcd/go.mod b/contrib/registry/etcd/go.mod index b0f6723d5ef..e36969ca68c 100644 --- a/contrib/registry/etcd/go.mod +++ b/contrib/registry/etcd/go.mod @@ -14,7 +14,7 @@ require ( github.com/coreos/go-semver v0.3.0 // indirect github.com/coreos/go-systemd/v22 v22.3.2 // 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 @@ -22,10 +22,10 @@ require ( github.com/golang/protobuf v1.5.3 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.etcd.io/etcd/api/v3 v3.5.7 // indirect @@ -37,9 +37,9 @@ require ( go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.17.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect diff --git a/contrib/registry/etcd/go.sum b/contrib/registry/etcd/go.sum index 379f4f2b5cd..2bc5e014f1c 100644 --- a/contrib/registry/etcd/go.sum +++ b/contrib/registry/etcd/go.sum @@ -11,8 +11,8 @@ github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -34,16 +34,16 @@ github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtg github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pkg/errors v0.8.1 h1:iURUrRGxPUNPdy5/HRSm+Yj6okJ6UtLINN0Q9M4+h3I= @@ -88,8 +88,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -98,12 +98,12 @@ golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/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 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +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-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= diff --git a/contrib/registry/file/go.mod b/contrib/registry/file/go.mod index 161b5809ad9..39263e5c0b8 100644 --- a/contrib/registry/file/go.mod +++ b/contrib/registry/file/go.mod @@ -8,25 +8,25 @@ require ( github.com/BurntSushi/toml v1.4.0 // 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 github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.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/file/go.sum b/contrib/registry/file/go.sum index ae66c9eaa6c..3f5df0ec368 100644 --- a/contrib/registry/file/go.sum +++ b/contrib/registry/file/go.sum @@ -5,8 +5,8 @@ github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -19,16 +19,16 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -44,14 +44,14 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/contrib/registry/nacos/go.mod b/contrib/registry/nacos/go.mod index b222f7e61c6..3fc6ef62c39 100644 --- a/contrib/registry/nacos/go.mod +++ b/contrib/registry/nacos/go.mod @@ -20,7 +20,7 @@ require ( github.com/cespare/xxhash/v2 v2.2.0 // 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 @@ -30,10 +30,10 @@ require ( github.com/grokify/html-strip-tags-go v0.1.0 // indirect github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af // indirect github.com/json-iterator/go v1.1.12 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect @@ -51,11 +51,11 @@ require ( go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.21.0 // indirect - golang.org/x/crypto v0.25.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/crypto v0.30.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 + golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.1.0 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect google.golang.org/grpc v1.56.3 // indirect diff --git a/contrib/registry/nacos/go.sum b/contrib/registry/nacos/go.sum index 43d0d9771bc..8f1eddd6fdc 100644 --- a/contrib/registry/nacos/go.sum +++ b/contrib/registry/nacos/go.sum @@ -82,8 +82,8 @@ github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymF github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= @@ -188,16 +188,16 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -288,8 +288,8 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= +golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -351,8 +351,8 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -369,8 +369,8 @@ golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -411,8 +411,8 @@ golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +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.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -420,8 +420,8 @@ golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3 golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 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 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/contrib/registry/polaris/go.mod b/contrib/registry/polaris/go.mod index 2a5d0b95ba7..218c63c73a0 100644 --- a/contrib/registry/polaris/go.mod +++ b/contrib/registry/polaris/go.mod @@ -1,6 +1,6 @@ module github.com/gogf/gf/contrib/registry/polaris/v2 -go 1.21 +go 1.20 require ( github.com/gogf/gf/v2 v2.8.2 @@ -14,7 +14,7 @@ require ( github.com/clbanning/mxj/v2 v2.7.0 // indirect github.com/dlclark/regexp2 v1.11.2 // 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,10 +24,10 @@ require ( github.com/grokify/html-strip-tags-go v0.1.0 // indirect github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect @@ -48,9 +48,9 @@ require ( go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.21.0 // indirect - golang.org/x/net v0.28.0 // indirect - golang.org/x/sys v0.24.0 // indirect - golang.org/x/text v0.17.0 // indirect + golang.org/x/net v0.32.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect google.golang.org/grpc v1.56.3 // indirect google.golang.org/protobuf v1.34.2 // indirect diff --git a/contrib/registry/polaris/go.sum b/contrib/registry/polaris/go.sum index 26b7619c808..e784f1e8dbe 100644 --- a/contrib/registry/polaris/go.sum +++ b/contrib/registry/polaris/go.sum @@ -225,8 +225,8 @@ github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.m github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= @@ -303,7 +303,6 @@ github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/ github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= @@ -373,20 +372,19 @@ github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFB github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= github.com/kr/text v0.1.0 h1:45sCR5RtlFHMR4UwH9sdQ5TC8v0qDQCHnXt+kaKSTVE= github.com/kr/text v0.1.0/go.mod h1:4Jbv+DJW3UT/LiOwJeYQe1efqtUx/iVham/4vfdArNI= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= @@ -447,7 +445,6 @@ github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUc github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ= -github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog= github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= @@ -472,7 +469,6 @@ github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/ github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= -github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= @@ -595,8 +591,8 @@ golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.28.0 h1:a9JDOJc5GMUJ0+UDqmLT86WiEy7iWyIhz8gz8E4e5hE= -golang.org/x/net v0.28.0/go.mod h1:yqtgsTWOOnlGLG9GFRrK3++bGOUEkNBoHZc8MEDWPNg= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -707,8 +703,8 @@ golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.24.0 h1:Twjiwq9dn6R1fQcyiK+wQyHWfaz/BJB+YIpzU/Cv3Xg= -golang.org/x/sys v0.24.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +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/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= @@ -722,8 +718,8 @@ golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.17.0 h1:XtiM5bkSOt+ewxlOE/aE/AKEHibwj/6gvWMl9Rsh0Qc= -golang.org/x/text v0.17.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/contrib/registry/zookeeper/go.mod b/contrib/registry/zookeeper/go.mod index f3d8f183d3d..445b4316ac9 100644 --- a/contrib/registry/zookeeper/go.mod +++ b/contrib/registry/zookeeper/go.mod @@ -5,32 +5,32 @@ go 1.20 require ( github.com/go-zookeeper/zk v1.0.3 github.com/gogf/gf/v2 v2.8.2 - golang.org/x/sync v0.7.0 + golang.org/x/sync v0.10.0 ) require ( github.com/BurntSushi/toml v1.4.0 // 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 github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.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/zookeeper/go.sum b/contrib/registry/zookeeper/go.sum index 4768eeba0d0..f0cf8086b81 100644 --- a/contrib/registry/zookeeper/go.sum +++ b/contrib/registry/zookeeper/go.sum @@ -5,8 +5,8 @@ github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -21,16 +21,16 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -46,16 +46,16 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/contrib/rpc/grpcx/go.mod b/contrib/rpc/grpcx/go.mod index 1089fa5c8a3..d69b902d8b5 100644 --- a/contrib/rpc/grpcx/go.mod +++ b/contrib/rpc/grpcx/go.mod @@ -15,23 +15,23 @@ require ( github.com/BurntSushi/toml v1.4.0 // 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 github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/contrib/rpc/grpcx/go.sum b/contrib/rpc/grpcx/go.sum index 7afa6ebd794..ce2771206f8 100644 --- a/contrib/rpc/grpcx/go.sum +++ b/contrib/rpc/grpcx/go.sum @@ -5,8 +5,8 @@ github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -19,16 +19,16 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -44,14 +44,14 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc= google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA= diff --git a/contrib/sdk/httpclient/go.mod b/contrib/sdk/httpclient/go.mod index bc85f281c0e..f69d2864895 100644 --- a/contrib/sdk/httpclient/go.mod +++ b/contrib/sdk/httpclient/go.mod @@ -8,25 +8,25 @@ require ( github.com/BurntSushi/toml v1.4.0 // 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 github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.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/sdk/httpclient/go.sum b/contrib/sdk/httpclient/go.sum index ae66c9eaa6c..3f5df0ec368 100644 --- a/contrib/sdk/httpclient/go.sum +++ b/contrib/sdk/httpclient/go.sum @@ -5,8 +5,8 @@ github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -19,16 +19,16 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -44,14 +44,14 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/contrib/trace/otlpgrpc/go.mod b/contrib/trace/otlpgrpc/go.mod index 72e88496adb..5d27f8ed3ae 100644 --- a/contrib/trace/otlpgrpc/go.mod +++ b/contrib/trace/otlpgrpc/go.mod @@ -16,25 +16,25 @@ require ( github.com/cenkalti/backoff/v4 v4.2.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 github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect go.opentelemetry.io/proto/otlp v1.1.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/net v0.32.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 // indirect google.golang.org/protobuf v1.34.2 // indirect diff --git a/contrib/trace/otlpgrpc/go.sum b/contrib/trace/otlpgrpc/go.sum index a8b1a5e15b2..92a50b717aa 100644 --- a/contrib/trace/otlpgrpc/go.sum +++ b/contrib/trace/otlpgrpc/go.sum @@ -7,8 +7,8 @@ github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -25,16 +25,16 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 h1:Wqo399gCIufwto+VfwCSvsnfGpF github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0/go.mod h1:qmOFXW2epJhM0qSnUUYpldc7gVz2KMQwJ/QYCDIa7XU= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= 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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -58,14 +58,14 @@ go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI= go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d h1:kHjw/5UfflP/L5EbledDrcG4C2597RtymmGRZvHiCuY= google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d/go.mod h1:mw8MG/Qz5wfgYr6VqVCiZcHe/GJEfI+oGGDCohaVgB0= google.golang.org/genproto/googleapis/rpc v0.0.0-20240701130421-f6361c86f094 h1:BwIjyKYGsK9dMCBOorzRri8MQwmi7mT9rGHsCEinZkA= diff --git a/contrib/trace/otlphttp/go.mod b/contrib/trace/otlphttp/go.mod index 1c7b4364790..326999eee8a 100644 --- a/contrib/trace/otlphttp/go.mod +++ b/contrib/trace/otlphttp/go.mod @@ -15,29 +15,28 @@ require ( github.com/cenkalti/backoff/v4 v4.2.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 - github.com/golang/protobuf v1.5.3 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // indirect github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect go.opentelemetry.io/proto/otlp v1.1.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 // indirect - google.golang.org/grpc v1.61.1 // indirect + golang.org/x/net v0.32.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/text v0.21.0 // indirect + google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect + google.golang.org/grpc v1.64.1 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/contrib/trace/otlphttp/go.sum b/contrib/trace/otlphttp/go.sum index a70b53bcf5a..8178bfd1719 100644 --- a/contrib/trace/otlphttp/go.sum +++ b/contrib/trace/otlphttp/go.sum @@ -7,8 +7,8 @@ github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -16,10 +16,6 @@ github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= @@ -29,16 +25,16 @@ github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0 h1:Wqo399gCIufwto+VfwCSvsnfGpF github.com/grpc-ecosystem/grpc-gateway/v2 v2.19.0/go.mod h1:qmOFXW2epJhM0qSnUUYpldc7gVz2KMQwJ/QYCDIa7XU= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= 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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -61,24 +57,20 @@ go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI= go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/genproto v0.0.0-20231212172506-995d672761c0 h1:YJ5pD9rF8o9Qtta0Cmy9rdBwkSjrTCT6XTiUQVOtIos= -google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917 h1:rcS6EyEaoCO52hQDupoSfrxI3R6C2Tq741is7X8OvnM= -google.golang.org/genproto/googleapis/api v0.0.0-20240102182953-50ed04b92917/go.mod h1:CmlNWB9lSezaYELKS5Ym1r44VrrbPUa7JTvw+6MbpJ0= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917 h1:6G8oQ016D88m1xAKljMlBOOGWDZkes4kMhgGFlf8WcQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240102182953-50ed04b92917/go.mod h1:xtjpI3tXFPP051KaWnhvxkiubL/6dJ18vLVf7q2pTOU= -google.golang.org/grpc v1.61.1 h1:kLAiWrZs7YeDM6MumDe7m3y4aM6wacLzM1Y/wiLP9XY= -google.golang.org/grpc v1.61.1/go.mod h1:VUbo7IFqmF1QtCAstipjG0GIoq49KvMe9+h1jFLBNJs= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= +google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 h1:RFiFrvy37/mpSpdySBDrUdipW/dHwsRwh3J3+A9VgT4= +google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237/go.mod h1:Z5Iiy3jtmioajWHDGFk7CeugTyHtPvMHA4UTmUkyalE= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 h1:NnYq6UN9ReLM9/Y01KWNOWyI5xQ9kbIms5GGJVwS/Yc= +google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237/go.mod h1:WtryC6hu0hhx87FDGxWCDptyssuo68sk10vYjF+T9fY= +google.golang.org/grpc v1.64.1 h1:LKtvyfbX3UGVPFcGqJ9ItpVWW6oN/2XqTxfAnwRRXiA= +google.golang.org/grpc v1.64.1/go.mod h1:hiQF4LFZelK2WKaP6W0L92zGHtiQdZxk8CrSdvyjeP0= google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/example/go.mod b/example/go.mod index ae0ca68ed45..6ae66482c5d 100644 --- a/example/go.mod +++ b/example/go.mod @@ -65,7 +65,7 @@ require ( github.com/dlclark/regexp2 v1.11.2 // indirect github.com/emicklei/go-restful/v3 v3.9.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 @@ -96,7 +96,7 @@ require ( github.com/josharian/intern v1.0.0 // indirect github.com/json-iterator/go v1.1.12 // indirect github.com/klauspost/compress v1.17.9 // indirect - github.com/magiconair/properties v1.8.7 // indirect + github.com/magiconair/properties v1.8.9 // indirect github.com/mailru/easyjson v0.7.7 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect @@ -115,7 +115,7 @@ require ( github.com/prometheus/client_model v0.6.1 // indirect github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect - github.com/redis/go-redis/v9 v9.2.1 // indirect + github.com/redis/go-redis/v9 v9.7.0 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect github.com/spf13/afero v1.6.0 // indirect @@ -135,14 +135,14 @@ require ( go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/multierr v1.10.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.27.0 // indirect + golang.org/x/crypto v0.30.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect - golang.org/x/net v0.29.0 // indirect + golang.org/x/net v0.32.0 // indirect golang.org/x/oauth2 v0.22.0 // indirect - golang.org/x/sync v0.8.0 // indirect - golang.org/x/sys v0.25.0 // indirect - golang.org/x/term v0.24.0 // indirect - golang.org/x/text v0.18.0 // indirect + golang.org/x/sync v0.10.0 // indirect + golang.org/x/sys v0.28.0 // indirect + golang.org/x/term v0.27.0 // indirect + golang.org/x/text v0.21.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect gopkg.in/inf.v0 v0.9.1 // indirect diff --git a/example/go.sum b/example/go.sum index c8a2be1087b..34b69415142 100644 --- a/example/go.sum +++ b/example/go.sum @@ -295,8 +295,8 @@ github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7 github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= 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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= github.com/fsnotify/fsnotify v1.7.0 h1:8JEhPFa5W2WU7YfeZzPNqzMP6Lwt7L2715Ggo0nosvA= @@ -545,8 +545,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= github.com/mattn/go-colorable v0.0.9/go.mod h1:9vuHe8Xs5qXnSaW/c/ABM9alt+Vo+STaOChaDxuIBZU= @@ -658,8 +658,8 @@ github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1 github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= -github.com/redis/go-redis/v9 v9.2.1 h1:WlYJg71ODF0dVspZZCpYmoF1+U1Jjk9Rwd7pq6QmlCg= -github.com/redis/go-redis/v9 v9.2.1/go.mod h1:hdY0cQFCN4fnSYT6TkisLufl/4W5UIXyv0b/CLO2V2M= +github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= +github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= @@ -798,8 +798,8 @@ golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= -golang.org/x/crypto v0.27.0 h1:GXm2NjJrPaiv/h1tb2UH8QfgC/hOf/+z0p6PT8o1w7A= -golang.org/x/crypto v0.27.0/go.mod h1:1Xngt8kV6Dvbssa53Ziq6Eqn0HqbZi5Z6R0ZpwQzt70= +golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= +golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -902,8 +902,8 @@ golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= -golang.org/x/net v0.29.0 h1:5ORfpBpCs4HzDYoodCDBbwHzdR5UrLBZ3sOnUJmFoHo= -golang.org/x/net v0.29.0/go.mod h1:gLkgy8jTGERgjzMic6DS9+SP0ajcu6Xu3Orq/SpETg0= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -944,8 +944,8 @@ golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJ golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.8.0 h1:3NFvSEYkUoMifnESzZl15y791HH1qU2xm6eCJU5ZPXQ= -golang.org/x/sync v0.8.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= @@ -1036,8 +1036,8 @@ golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.25.0 h1:r+8e+loiHxRqhXVl6ML1nO3l1+oFoWbnlu2Ehimmi34= -golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +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/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= @@ -1045,8 +1045,8 @@ golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= -golang.org/x/term v0.24.0 h1:Mh5cbb+Zk2hqqXNO7S1iTjEphVL+jb8ZWaqh/g+JWkM= -golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= @@ -1061,8 +1061,8 @@ golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.18.0 h1:XvMDiNzPAl0jr17s6W9lcaIhGUfUORdGCNsuLmPG224= -golang.org/x/text v0.18.0/go.mod h1:BuEKDfySbSR4drPmRPG/7iBdf8hvFMuRexcpahXilzY= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= diff --git a/go.mod b/go.mod index 2dca4690107..91ec47e8915 100644 --- a/go.mod +++ b/go.mod @@ -6,17 +6,17 @@ require ( github.com/BurntSushi/toml v1.4.0 github.com/clbanning/mxj/v2 v2.7.0 github.com/emirpasic/gods v1.18.1 - github.com/fatih/color v1.17.0 + github.com/fatih/color v1.18.0 github.com/fsnotify/fsnotify v1.7.0 github.com/gorilla/websocket v1.5.3 github.com/grokify/html-strip-tags-go v0.1.0 - github.com/magiconair/properties v1.8.7 + github.com/magiconair/properties v1.8.9 github.com/olekukonko/tablewriter v0.0.5 go.opentelemetry.io/otel v1.24.0 go.opentelemetry.io/otel/sdk v1.24.0 go.opentelemetry.io/otel/trace v1.24.0 - golang.org/x/net v0.27.0 - golang.org/x/text v0.16.0 + golang.org/x/net v0.32.0 + golang.org/x/text v0.21.0 gopkg.in/yaml.v3 v3.0.1 ) @@ -25,8 +25,8 @@ require ( github.com/go-logr/stdr v1.2.2 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect - golang.org/x/sys v0.22.0 // indirect + golang.org/x/sys v0.28.0 // indirect ) diff --git a/go.sum b/go.sum index ae66c9eaa6c..3f5df0ec368 100644 --- a/go.sum +++ b/go.sum @@ -5,8 +5,8 @@ github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= @@ -19,16 +19,16 @@ github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aN github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= @@ -44,14 +44,14 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= -golang.org/x/text v0.16.0/go.mod h1:GhwF1Be+LQoKShO3cGOHzqOgRrGaYc9AvblQOmPVHnI= +golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= +golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/net/ghttp/ghttp.go b/net/ghttp/ghttp.go index 32353319460..bc823307eb8 100644 --- a/net/ghttp/ghttp.go +++ b/net/ghttp/ghttp.go @@ -207,6 +207,7 @@ var ( ) var ( + // ErrNeedJsonBody is the error that indicates the request body content should be JSON format. ErrNeedJsonBody = gerror.NewWithOption(gerror.Option{ Text: "the request body content should be JSON format", Code: gcode.CodeInvalidRequest, diff --git a/net/ghttp/ghttp_middleware_handler_response.go b/net/ghttp/ghttp_middleware_handler_response.go index 574db50813e..cebff3889d3 100644 --- a/net/ghttp/ghttp_middleware_handler_response.go +++ b/net/ghttp/ghttp_middleware_handler_response.go @@ -71,7 +71,7 @@ func MiddlewareHandlerResponse(r *Request) { default: code = gcode.CodeUnknown } - // It creates error as it can be retrieved by other middlewares. + // It creates an error as it can be retrieved by other middlewares. err = gerror.NewCode(code, msg) r.SetError(err) } else { diff --git a/net/ghttp/ghttp_server.go b/net/ghttp/ghttp_server.go index 11a8502853f..be567d068d7 100644 --- a/net/ghttp/ghttp_server.go +++ b/net/ghttp/ghttp_server.go @@ -345,7 +345,7 @@ func (s *Server) doRouterMapDump() { } } -// GetOpenApi returns the OpenApi specification management object of current server. +// GetOpenApi returns the OpenApi specification management object of the current server. func (s *Server) GetOpenApi() *goai.OpenApiV3 { return s.openapi } @@ -452,7 +452,7 @@ func (s *Server) Run() { // Signal handler in asynchronous way. go handleProcessSignal() - // Blocking using channel for graceful restart. + // Blocking using the channel for graceful restart. <-s.closeChan // Remove plugins. if len(s.plugins) > 0 { @@ -653,8 +653,8 @@ func (s *Server) getListenerFdMap() map[string]string { return m } -// GetListenedPort retrieves and returns one port which is listened by current server. -// It returns the normal HTTP port in most priority if both HTTP and HTTPS are enabled. +// GetListenedPort returns a port currently listened to by the server. +// It prioritizes the HTTP port if both HTTP and HTTPS are enabled. func (s *Server) GetListenedPort() int { for _, server := range s.servers { if !server.IsHttps() { diff --git a/net/ghttp/ghttp_server_config_api.go b/net/ghttp/ghttp_server_config_api.go index a89888b1fba..2108b6a533e 100644 --- a/net/ghttp/ghttp_server_config_api.go +++ b/net/ghttp/ghttp_server_config_api.go @@ -22,7 +22,7 @@ func (s *Server) SetOpenApiPath(path string) { s.config.OpenApiPath = path } -// GetOpenApiPath returns the configuration of `OpenApiPath` of server. +// GetOpenApiPath returns the `OpenApiPath` configuration of the server. func (s *Server) GetOpenApiPath() string { return s.config.OpenApiPath } diff --git a/net/gtrace/internal/provider/provider.go b/net/gtrace/internal/provider/provider.go index 28159d5a178..4ae9a866887 100644 --- a/net/gtrace/internal/provider/provider.go +++ b/net/gtrace/internal/provider/provider.go @@ -10,6 +10,7 @@ import ( sdkTrace "go.opentelemetry.io/otel/sdk/trace" ) +// TracerProvider is a wrapper around sdkTrace.TracerProvider. type TracerProvider struct { *sdkTrace.TracerProvider } diff --git a/os/gbuild/gbuild.go b/os/gbuild/gbuild.go index 2ef51abbb77..b7afb9e1a2e 100644 --- a/os/gbuild/gbuild.go +++ b/os/gbuild/gbuild.go @@ -18,10 +18,10 @@ import ( "github.com/gogf/gf/v2/internal/json" ) -// BuildInfo maintains the built info of current binary. +// BuildInfo maintains the built info of the current binary. type BuildInfo struct { GoFrame string // Built used GoFrame version. - Golang string // Built used Golang version. + Golang string // Built the used Golang version. Git string // Built used git repo. commit id and datetime. Time string // Built datetime. Version string // Built version. @@ -81,7 +81,7 @@ func Get(name string, def ...interface{}) *gvar.Var { return nil } -// Data returns the custom build-in variables as map. +// Data returns the custom build-in variables as the map. func Data() map[string]interface{} { return builtInVarMap } diff --git a/os/gcache/gcache.go b/os/gcache/gcache.go index 8aaf6652f20..892b2a03404 100644 --- a/os/gcache/gcache.go +++ b/os/gcache/gcache.go @@ -19,9 +19,8 @@ import ( // Func is the cache function that calculates and returns the value. type Func = func(ctx context.Context) (value interface{}, err error) -const ( - DurationNoExpire = time.Duration(0) // Expire duration that never expires. -) +// DurationNoExpire represents the cache key-value pair that never expires. +const DurationNoExpire = time.Duration(0) // Default cache object. var defaultCache = New() diff --git a/os/gcfg/gcfg.go b/os/gcfg/gcfg.go index c32f00d97d7..f8357b65cfe 100644 --- a/os/gcfg/gcfg.go +++ b/os/gcfg/gcfg.go @@ -25,8 +25,10 @@ type Config struct { } const ( - DefaultInstanceName = "config" // DefaultName is the default instance name for instance usage. - DefaultConfigFileName = "config" // DefaultConfigFile is the default configuration file name. + // DefaultInstanceName is the default instance name for instance usage. + DefaultInstanceName = "config" + // DefaultConfigFileName is the default configuration file name. + DefaultConfigFileName = "config" ) // New creates and returns a Config object with default adapter of AdapterFile. @@ -69,12 +71,12 @@ func Instance(name ...string) *Config { }).(*Config) } -// SetAdapter sets the adapter of current Config object. +// SetAdapter sets the adapter of the current Config object. func (c *Config) SetAdapter(adapter Adapter) { c.adapter = adapter } -// GetAdapter returns the adapter of current Config object. +// GetAdapter returns the adapter of the current Config object. func (c *Config) GetAdapter() Adapter { return c.adapter } diff --git a/os/gcfg/gcfg_adapter_file.go b/os/gcfg/gcfg_adapter_file.go index dc98a378700..1a9a1f83a3c 100644 --- a/os/gcfg/gcfg_adapter_file.go +++ b/os/gcfg/gcfg_adapter_file.go @@ -26,7 +26,7 @@ import ( // AdapterFile implements interface Adapter using file. type AdapterFile struct { defaultFileNameOrPath string // Default configuration file name or file path. - searchPaths *garray.StrArray // Searching path array. + searchPaths *garray.StrArray // Searching the path array. jsonMap *gmap.StrAnyMap // The pared JSON objects for configuration files. violenceCheck bool // Whether it does violence check in value index searching. It affects the performance when set true(false in default). } @@ -47,7 +47,7 @@ var ( "manifest/config/", "manifest/config", "/manifest/config", "/manifest/config/", } - // Prefix array for trying searching in local system. + // Prefix array for trying searching in the local system. localSystemTryFolders = []string{"", "config/", "manifest/config"} ) @@ -91,7 +91,7 @@ func NewAdapterFile(fileNameOrPath ...string) (*AdapterFile, error) { intlog.Errorf(context.TODO(), `%+v`, err) } - // Dir path of main package. + // Dir path of the main package. if mainPath := gfile.MainPkgPath(); mainPath != "" && gfile.Exists(mainPath) { if err = config.AddPath(mainPath); err != nil { intlog.Errorf(context.TODO(), `%+v`, err) @@ -112,7 +112,7 @@ func NewAdapterFile(fileNameOrPath ...string) (*AdapterFile, error) { // This feature needs to be enabled when there is a level symbol in the key name. // It is off in default. // -// Note that, turning on this feature is quite expensive, and it is not recommended +// Note that turning on this feature is quite expensive, and it is not recommended // allowing separators in the key names. It is best to avoid this on the application side. func (a *AdapterFile) SetViolenceCheck(check bool) { a.violenceCheck = check @@ -130,7 +130,7 @@ func (a *AdapterFile) GetFileName() string { } // Get retrieves and returns value by specified `pattern`. -// It returns all values of current Json object if `pattern` is given empty or string ".". +// It returns all values of the current JSON object if `pattern` is given empty or string ".". // It returns nil if no value found by `pattern`. // // We can also access slice item by its index number in `pattern` like: @@ -150,9 +150,9 @@ func (a *AdapterFile) Get(ctx context.Context, pattern string) (value interface{ // Set sets value with specified `pattern`. // It supports hierarchical data access by char separator, which is '.' in default. -// It is commonly used for updates certain configuration value in runtime. -// Note that, it is not recommended using `Set` configuration at runtime as the configuration would be -// automatically refreshed if underlying configuration file changed. +// It is commonly used to update certain configuration values in runtime. +// Note that it is not recommended using `Set` configuration at runtime as the configuration would be +// automatically refreshed if the underlying configuration file changed. func (a *AdapterFile) Set(pattern string, value interface{}) error { j, err := a.getJson() if err != nil { @@ -176,7 +176,7 @@ func (a *AdapterFile) Data(ctx context.Context) (data map[string]interface{}, er return nil, nil } -// MustGet acts as function Get, but it panics if error occurs. +// MustGet acts as a function, but it panics if error occurs. func (a *AdapterFile) MustGet(ctx context.Context, pattern string) *gvar.Var { v, err := a.Get(ctx, pattern) if err != nil { @@ -186,12 +186,12 @@ func (a *AdapterFile) MustGet(ctx context.Context, pattern string) *gvar.Var { } // Clear removes all parsed configuration files content cache, -// which will force reload configuration content from file. +// which will force reload configuration content from the file. func (a *AdapterFile) Clear() { a.jsonMap.Clear() } -// Dump prints current Json object with more manually readable. +// Dump prints current JSON object with more manually readable. func (a *AdapterFile) Dump() { if j, _ := a.getJson(); j != nil { j.Dump() @@ -205,15 +205,15 @@ func (a *AdapterFile) Available(ctx context.Context, fileName ...string) bool { if a.GetContent(checkFileName) != "" { return true } - // Configuration file exists in system path. + // Configuration file exists in the system path. if path, _ := a.GetFilePath(checkFileName); path != "" { return true } return false } -// autoCheckAndAddMainPkgPathToSearchPaths automatically checks and adds directory path of package main -// to the searching path list if it's currently in development environment. +// autoCheckAndAddMainPkgPathToSearchPaths automatically checks and adds the directory path of package main +// to the searching path list if it's currently in the development environment. func (a *AdapterFile) autoCheckAndAddMainPkgPathToSearchPaths() { if gmode.IsDevelop() { mainPkgPath := gfile.MainPkgPath() @@ -236,7 +236,7 @@ func (a *AdapterFile) getJson(fileNameOrPath ...string) (configJson *gjson.Json, } else { usedFileNameOrPath = a.defaultFileNameOrPath } - // It uses json map to cache specified configuration file content. + // It uses JSON map to cache specified configuration file content. result := a.jsonMap.GetOrSetFuncLock(usedFileNameOrPath, func() interface{} { var ( content string @@ -259,7 +259,7 @@ func (a *AdapterFile) getJson(fileNameOrPath ...string) (configJson *gjson.Json, content = gfile.GetContents(filePath) } } - // Note that the underlying configuration json object operations are concurrent safe. + // Note that the underlying configuration JSON object operations are concurrent safe. dataType := gjson.ContentType(gfile.ExtName(filePath)) if gjson.IsValidDataType(dataType) && !isFromConfigContent { configJson, err = gjson.LoadContentType(dataType, []byte(content), true) @@ -276,7 +276,7 @@ func (a *AdapterFile) getJson(fileNameOrPath ...string) (configJson *gjson.Json, } configJson.SetViolenceCheck(a.violenceCheck) // Add monitor for this configuration file, - // any changes of this file will refresh its cache in Config object. + // any changes of this file will refresh its cache in the Config object. if filePath != "" && !gres.Contains(filePath) { _, err = gfsnotify.Add(filePath, func(event *gfsnotify.Event) { a.jsonMap.Remove(usedFileNameOrPath) diff --git a/os/gctx/gctx.go b/os/gctx/gctx.go index a3117fd78c5..2a7e7111314 100644 --- a/os/gctx/gctx.go +++ b/os/gctx/gctx.go @@ -19,7 +19,7 @@ import ( ) type ( - Ctx = context.Context // Ctx is short name alias for context.Context. + Ctx = context.Context // Ctx is a short name alias for context.Context. StrKey string // StrKey is a type for warps basic type string as context key. ) diff --git a/os/gres/gres_file.go b/os/gres/gres_file.go index 8e42ed1d3a4..a63269fcf0f 100644 --- a/os/gres/gres_file.go +++ b/os/gres/gres_file.go @@ -15,6 +15,7 @@ import ( "github.com/gogf/gf/v2/internal/json" ) +// File is a file in a zip file. type File struct { file *zip.File reader *bytes.Reader diff --git a/os/gres/gres_resource.go b/os/gres/gres_resource.go index 085dfc35ed5..783758fdb42 100644 --- a/os/gres/gres_resource.go +++ b/os/gres/gres_resource.go @@ -20,6 +20,7 @@ import ( "github.com/gogf/gf/v2/text/gstr" ) +// Resource is the resource manager for the file system. type Resource struct { tree *gtree.BTree } diff --git a/os/gtime/gtime_format.go b/os/gtime/gtime_format.go index 9214e4b2125..71b27c88502 100644 --- a/os/gtime/gtime_format.go +++ b/os/gtime/gtime_format.go @@ -67,7 +67,7 @@ var ( ) // Format formats and returns the formatted result with custom `format`. -// Refer method Layout, if you want to follow stdlib layout. +// Refer method Layout if you want to follow stdlib layout. func (t *Time) Format(format string) string { if t == nil { return "" @@ -205,7 +205,7 @@ func (t *Time) DayOfYear() int { return dayOfMonth[month-1] + day - 1 } -// DaysInMonth returns the day count of current month. +// DaysInMonth returns the day count of the current month. func (t *Time) DaysInMonth() int { switch t.Month() { case 1, 3, 5, 7, 8, 10, 12: @@ -225,7 +225,7 @@ func (t *Time) WeeksOfYear() int { return week } -// formatToStdLayout converts custom format to stdlib layout. +// formatToStdLayout converts the custom format to stdlib layout. func formatToStdLayout(format string) string { b := bytes.NewBuffer(nil) for i := 0; i < len(format); { diff --git a/os/gview/gview_config.go b/os/gview/gview_config.go index cff9e49d5a0..9323f798b39 100644 --- a/os/gview/gview_config.go +++ b/os/gview/gview_config.go @@ -182,7 +182,7 @@ func (view *View) AddPath(path string) error { isDir = gfile.IsDir(realPath) } } - // Path not exist. + // Path doesn't exist. if realPath == "" { err := gerror.NewCodef(gcode.CodeInvalidParameter, `View.AddPath failed: path "%s" does not exist`, path) if errorPrint() { diff --git a/os/gview/gview_parse.go b/os/gview/gview_parse.go index 44ccbffca94..243231872a7 100644 --- a/os/gview/gview_parse.go +++ b/os/gview/gview_parse.go @@ -34,7 +34,7 @@ const ( templateNameForContentParsing = "TemplateContent" ) -// fileCacheItem is the cache item for template file. +// fileCacheItem is the cache item for the template file. type fileCacheItem struct { path string folder string @@ -52,7 +52,7 @@ var ( "resource/template/", "resource/template", "/resource/template", "/resource/template/", } - // Prefix array for trying searching in local system. + // Prefix array for trying searching in the local system. localSystemTryFolders = []string{"", "template/", "resource/template"} ) @@ -85,7 +85,7 @@ func (view *View) ParseDefault(ctx context.Context, params ...Params) (result st }) } -// ParseContent parses given template content `content` with template variables `params` +// ParseContent parses given template content `content` with template variables `params` // and returns the parsed content in []byte. func (view *View) ParseContent(ctx context.Context, content string, params ...Params) (string, error) { var usedParams Params @@ -115,7 +115,7 @@ func (view *View) ParseOption(ctx context.Context, option Option) (result string if option.File == "" { return "", gerror.New(`template file cannot be empty`) } - // It caches the file, folder and content to enhance performance. + // It caches the file, folder, and content to enhance performance. r := view.fileCacheMap.GetOrSetFuncLock(option.File, func() interface{} { var ( path string @@ -158,7 +158,7 @@ func (view *View) ParseOption(ctx context.Context, option Option) (result string if item.content == "" { return "", nil } - // If it's Orphan option, it just parses the single file by ParseContent. + // If it's an Orphan option, it just parses the single file by ParseContent. if option.Orphan { return view.doParseContent(ctx, item.content, option.Params) } @@ -212,7 +212,7 @@ func (view *View) ParseOption(ctx context.Context, option Option) (result string return result, nil } -// doParseContent parses given template content `content` with template variables `params` +// doParseContent parses given template content `content` with template variables `params` // and returns the parsed content in []byte. func (view *View) doParseContent(ctx context.Context, content string, params Params) (string, error) { // It's not necessary continuing parsing if template content is empty. @@ -301,7 +301,7 @@ func (view *View) getTemplate(filePath, folderPath, pattern string) (tpl interfa view.config.Delimiters[1], ).Funcs(view.funcMap) } - // Firstly checking the resource manager. + // Firstly, checking the resource manager. if !gres.IsEmpty() { if files := gres.ScanDirFile(folderPath, pattern, true); len(files) > 0 { if view.config.AutoEncode { @@ -327,7 +327,7 @@ func (view *View) getTemplate(filePath, folderPath, pattern string) (tpl interfa } } - // Secondly checking the file system, + // Secondly, checking the file system, // and then automatically parsing all its sub-files recursively. var files []string files, err = gfile.ScanDir(folderPath, pattern, true) @@ -361,7 +361,7 @@ func (view *View) getTemplate(filePath, folderPath, pattern string) (tpl interfa return } -// formatTemplateObjectCreatingError formats the error that created from creating template object. +// formatTemplateObjectCreatingError formats the error that created from creating the template object. func (view *View) formatTemplateObjectCreatingError(filePath, tplName string, err error) error { if err != nil { return gerror.NewSkip(1, gstr.Replace(err.Error(), tplName, filePath)) @@ -369,12 +369,11 @@ func (view *View) formatTemplateObjectCreatingError(filePath, tplName string, er return nil } -// searchFile returns the found absolute path for `file` and its template folder path. -// Note that, the returned `folder` is the template folder path, but not the folder of -// the returned template file `path`. +// searchFile returns the absolute path of the `file` and its template folder path. +// The returned `folder` is the template folder path, not the folder of the template file `path`. func (view *View) searchFile(ctx context.Context, file string) (path string, folder string, resource *gres.File, err error) { var tempPath string - // Firstly checking the resource manager. + // Firstly, checking the resource manager. if !gres.IsEmpty() { // Try folders. for _, tryFolder := range resourceTryFolders { @@ -400,7 +399,7 @@ func (view *View) searchFile(ctx context.Context, file string) (path string, fol }) } - // Secondly checking the file system. + // Secondly, checking the file system. if path == "" { // Absolute path. path = gfile.RealPath(file) diff --git a/util/gpage/gpage.go b/util/gpage/gpage.go index afdb3e65062..ac138d60f78 100644 --- a/util/gpage/gpage.go +++ b/util/gpage/gpage.go @@ -37,8 +37,10 @@ type Page struct { } const ( - DefaultPageName = "page" // DefaultPageName defines the default page name. - DefaultPagePlaceHolder = "{.page}" // DefaultPagePlaceHolder defines the place holder for the url template. + // DefaultPageName defines the default page name. + DefaultPageName = "page" + // DefaultPagePlaceHolder defines the placeholder for the URL template. + DefaultPagePlaceHolder = "{.page}" ) // New creates and returns a pagination manager. @@ -142,8 +144,8 @@ func (p *Page) SelectBar() string { } // GetContent returns the page content for predefined mode. -// These predefined contents are mainly for chinese localization purpose. You can defines your own -// page function retrieving the page content according to the implementation of this function. +// These predefined contents are mainly for Chinese localization purposes.You can define your own +// page function to retrieve the page content according to the implementation of this function. func (p *Page) GetContent(mode int) string { switch mode { case 1: @@ -205,8 +207,8 @@ func (p *Page) GetContent(mode int) string { } // GetUrl parses the UrlTemplate with given page number and returns the URL string. -// Note that the UrlTemplate attribute can be either an URL or an URI string with "{.page}" -// place holder specifying the page number position. +// The UrlTemplate attribute can be a URL or URI string containing the "{.page}" placeholder, +// which will be replaced by the actual page number. func (p *Page) GetUrl(page int) string { return gstr.Replace(p.UrlTemplate, DefaultPagePlaceHolder, gconv.String(page)) } diff --git a/util/grand/grand.go b/util/grand/grand.go index 90fd93e6954..00a6da5feb7 100644 --- a/util/grand/grand.go +++ b/util/grand/grand.go @@ -30,7 +30,7 @@ func Intn(max int) int { return max } n := int(binary.LittleEndian.Uint32(<-bufferChan)) % max - if (max > 0 && n < 0) || (max < 0 && n > 0) { + if n < 0 { return -n } return n diff --git a/util/guid/guid.go b/util/guid/guid.go index 80bd6c5ca8c..e475b3deabf 100644 --- a/util/guid/guid.go +++ b/util/guid/guid.go @@ -26,14 +26,14 @@ const ( ) var ( - sequence gtype.Uint32 // Sequence for unique purpose of current process. - macAddrStr = "0000000" // MAC addresses hash result in 7 bytes. + sequence gtype.Uint32 // Sequence for unique purpose of the current process. + macAddrStr = "0000000" // Hash result of MAC addresses in 7 bytes. processIdStr = "0000" // Process id in 4 bytes. ) // init initializes several fixed local variable. func init() { - // MAC addresses hash result in 7 bytes. + // Hash result of MAC addresses in 7 bytes. macs, _ := gipv4.GetMacArray() if len(macs) > 0 { var macAddrBytes []byte diff --git a/util/gutil/gutil.go b/util/gutil/gutil.go index 2c5a555d161..15f4e76a530 100644 --- a/util/gutil/gutil.go +++ b/util/gutil/gutil.go @@ -17,7 +17,7 @@ const ( dumpIndent = ` ` ) -// Keys retrieves and returns the keys from given map or struct. +// Keys retrieves and returns the keys from the given map or struct. func Keys(mapOrStruct any) (keysOrAttrs []string) { keysOrAttrs = make([]string, 0) if m, ok := mapOrStruct.(map[string]any); ok { @@ -68,7 +68,7 @@ func Keys(mapOrStruct any) (keysOrAttrs []string) { return } -// Values retrieves and returns the values from given map or struct. +// Values retrieves and returns the values from the given map or struct. func Values(mapOrStruct interface{}) (values []interface{}) { values = make([]interface{}, 0) if m, ok := mapOrStruct.(map[string]interface{}); ok { diff --git a/util/gvalid/gvalid.go b/util/gvalid/gvalid.go index f94eba0c5b1..462b2e9ed62 100644 --- a/util/gvalid/gvalid.go +++ b/util/gvalid/gvalid.go @@ -91,7 +91,7 @@ var ( // The sequence tag is like: [alias@]rule[...#msg...] func ParseTagValue(tag string) (field, rule, msg string) { // Complete sequence tag. - // Example: name@required|length:2,20|password3|same:password1#||密码强度不足|两次密码不一致 + // Example: name@required|length:2,20|password3|same:password1#||密码强度不足 | 两次密码不一致 match, _ := gregex.MatchString(`\s*((\w+)\s*@){0,1}\s*([^#]+)\s*(#\s*(.*)){0,1}\s*`, tag) if len(match) > 5 { msg = strings.TrimSpace(match[5]) diff --git a/util/gvalid/gvalid_validator.go b/util/gvalid/gvalid_validator.go index f2e265d966a..f461ff32719 100644 --- a/util/gvalid/gvalid_validator.go +++ b/util/gvalid/gvalid_validator.go @@ -85,7 +85,7 @@ func (v *Validator) Run(ctx context.Context) Error { }) } -// Clone creates and returns a new Validator which is a shallow copy of current one. +// Clone creates and returns a new Validator, which is a shallow copy of the current one. func (v *Validator) Clone() *Validator { newValidator := New() *newValidator = *v From d748fb6564846fa68ddc8a8675411c69e3366cda Mon Sep 17 00:00:00 2001 From: John Guo Date: Wed, 11 Dec 2024 10:28:29 +0800 Subject: [PATCH 047/102] fix(contrib/registry/consul): update dependence of gf to v2.8.2 with relative path specified (#4029) --- contrib/registry/consul/go.mod | 4 +++- contrib/registry/consul/go.sum | 2 -- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/contrib/registry/consul/go.mod b/contrib/registry/consul/go.mod index 859c3ffae70..2a782e4a70e 100644 --- a/contrib/registry/consul/go.mod +++ b/contrib/registry/consul/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/consul/v2 go 1.18 require ( - github.com/gogf/gf/v2 v2.8.1 + github.com/gogf/gf/v2 v2.8.2 github.com/hashicorp/consul/api v1.26.1 ) @@ -38,3 +38,5 @@ require ( golang.org/x/text v0.16.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) + +replace github.com/gogf/gf/v2 => ../../../ diff --git a/contrib/registry/consul/go.sum b/contrib/registry/consul/go.sum index 2eb6fac9031..69618933a45 100644 --- a/contrib/registry/consul/go.sum +++ b/contrib/registry/consul/go.sum @@ -42,8 +42,6 @@ github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ4 github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gogf/gf/v2 v2.8.1 h1:1oVQg3G5OgCats4qWFTH3pHLe92nfUQeUDta05tUs1g= -github.com/gogf/gf/v2 v2.8.1/go.mod h1:6iYuZZ+A0ZcH8+4MDS/P0SvTPCvKzRvyAsY1kbkJYJc= github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= From 5c45d3533f0b86374ec63e66ee65ab93e1fa2ed4 Mon Sep 17 00:00:00 2001 From: houseme Date: Wed, 11 Dec 2024 15:42:36 +0800 Subject: [PATCH 048/102] fix(ci/golangci): fix golangcl-lint git push (#4032) --- .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 d1823a8beb6..9be6b9564d8 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 \ No newline at end of file + git push origin HEAD:$(git rev-parse --abbrev-ref HEAD) \ No newline at end of file From 5af342adc3ef4ab0b8ece069e31b71bac3723b07 Mon Sep 17 00:00:00 2001 From: John Guo Date: Fri, 13 Dec 2024 09:29:19 +0800 Subject: [PATCH 049/102] fix(net/ghttp): json omitempty takes no effect in `BuildParams`, which is not compatible with old version (#4041) --- .gitignore | 1 + contrib/registry/consul/go.mod | 8 ++++---- contrib/registry/consul/go.sum | 4 ++++ internal/httputil/httputils.go | 4 +++- internal/httputil/httputils_test.go | 15 +++++++++++++++ 5 files changed, 27 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index b5318f47e01..2428b8d621d 100644 --- a/.gitignore +++ b/.gitignore @@ -18,6 +18,7 @@ example/log go.work go.work.sum !cmd/gf/go.work +.windsurfrules # Ignore for docs node_modules 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= diff --git a/internal/httputil/httputils.go b/internal/httputil/httputils.go index f006f394536..55f181ed8ec 100644 --- a/internal/httputil/httputils.go +++ b/internal/httputil/httputils.go @@ -38,7 +38,9 @@ func BuildParams(params interface{}, noUrlEncode ...bool) (encodedParamStr strin } } // Else converts it to map and does the url encoding. - m, urlEncode := gconv.Map(params), true + m, urlEncode := gconv.Map(params, gconv.MapOption{ + OmitEmpty: true, + }), true if len(m) == 0 { return gconv.String(params) } diff --git a/internal/httputil/httputils_test.go b/internal/httputil/httputils_test.go index b021d55b369..8833b9534c1 100644 --- a/internal/httputil/httputils_test.go +++ b/internal/httputil/httputils_test.go @@ -36,3 +36,18 @@ func TestBuildParams(t *testing.T) { t.Assert(gstr.Contains(params, "b"), false) }) } + +// https://github.com/gogf/gf/issues/4023 +func TestIssue4023(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + type HttpGetRequest struct { + Key1 string `json:"key1"` + Key2 string `json:"key2,omitempty"` + } + r := &HttpGetRequest{ + Key1: "value1", + } + params := httputil.BuildParams(r) + t.Assert(params, "key1=value1") + }) +} From ced4b57991926d7af7b91ad46b39aedcf83a4f88 Mon Sep 17 00:00:00 2001 From: John Guo Date: Fri, 13 Dec 2024 09:29:34 +0800 Subject: [PATCH 050/102] fix(contrib/drivers/pgsql): incompatible placeholder replacement with old version (#4036) --- .github/workflows/apollo/docker-compose.yml | 4 +-- .github/workflows/ci-main.yml | 18 +++++----- .github/workflows/nacos/docker-compose.yml | 2 +- .../drivers/pgsql/pgsql_z_unit_issue_test.go | 34 +++++++++++++++++++ .../pgsql/testdata/issues/issue4033.sql | 5 +++ database/gdb/gdb_func.go | 33 +++++++++++------- 6 files changed, 71 insertions(+), 25 deletions(-) create mode 100644 contrib/drivers/pgsql/testdata/issues/issue4033.sql diff --git a/.github/workflows/apollo/docker-compose.yml b/.github/workflows/apollo/docker-compose.yml index 5e7377871f6..942e6fdd1cb 100644 --- a/.github/workflows/apollo/docker-compose.yml +++ b/.github/workflows/apollo/docker-compose.yml @@ -20,7 +20,7 @@ services: #APOLLO_PORTAL_DB_PASSWORD: 'apollo' apollo-db: - image: "loads/mysql:5.7" + image: "mysql:5.7" container_name: apollo-db environment: TZ: Asia/Shanghai @@ -36,7 +36,7 @@ services: - apollo-dbdata apollo-dbdata: - image: "loads/alpine:3.8" + image: "alpine:3.8" container_name: apollo-dbdata volumes: - /var/lib/mysql diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index c5c73440092..6eeee5dd9ac 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -37,9 +37,9 @@ jobs: # Service containers to run with `code-test` services: # Etcd service. - # docker run -d --name etcd -p 2379:2379 -e ALLOW_NONE_AUTHENTICATION=yes loads/etcd:3.4.24 + # docker run -d --name etcd -p 2379:2379 -e ALLOW_NONE_AUTHENTICATION=yes bitnami/etcd:3.4.24 etcd: - image: loads/etcd:3.4.24 + image: bitnami/etcd:3.4.24 env: ALLOW_NONE_AUTHENTICATION: yes ports: @@ -47,7 +47,7 @@ jobs: # Redis backend server. redis: - image : loads/redis:7.0 + image : redis:7.0 options: >- --health-cmd "redis-cli ping" --health-interval 10s @@ -62,9 +62,9 @@ jobs: # -p 3306:3306 \ # -e MYSQL_DATABASE=test \ # -e MYSQL_ROOT_PASSWORD=12345678 \ - # loads/mysql:5.7 + # mysql:5.7 mysql: - image: loads/mysql:5.7 + image: mysql:5.7 env: MYSQL_DATABASE : test MYSQL_ROOT_PASSWORD: 12345678 @@ -73,7 +73,7 @@ jobs: # MariaDb backend server. mariadb: - image: loads/mariadb:10.4 + image: mariadb:10.4 env: MARIADB_DATABASE: test MARIADB_ROOT_PASSWORD: 12345678 @@ -87,9 +87,9 @@ jobs: # -e POSTGRES_USER=postgres \ # -e POSTGRES_DB=test \ # -v postgres:/Users/john/Temp/postgresql/data \ - # loads/postgres:13 + # postgres:17-alpine postgres: - image: loads/postgres:13 + image: postgres:17-alpine env: POSTGRES_PASSWORD: 12345678 POSTGRES_USER: postgres @@ -184,7 +184,7 @@ jobs: - 5236:5236 zookeeper: - image: loads/zookeeper:3.8 + image: zookeeper:3.8 ports: - 2181:2181 diff --git a/.github/workflows/nacos/docker-compose.yml b/.github/workflows/nacos/docker-compose.yml index f10a1101b8a..3e69daa7c5a 100644 --- a/.github/workflows/nacos/docker-compose.yml +++ b/.github/workflows/nacos/docker-compose.yml @@ -2,7 +2,7 @@ version: "3.8" services: nacos: - image: loads/nacos-server:v2.1.2 + image: nacos/nacos-server:v2.1.2 container_name: nacos env_file: - ./env/nacos.env diff --git a/contrib/drivers/pgsql/pgsql_z_unit_issue_test.go b/contrib/drivers/pgsql/pgsql_z_unit_issue_test.go index 47122c461f8..c0c9ad8f25b 100644 --- a/contrib/drivers/pgsql/pgsql_z_unit_issue_test.go +++ b/contrib/drivers/pgsql/pgsql_z_unit_issue_test.go @@ -171,3 +171,37 @@ func Test_Issue3668(t *testing.T) { t.AssertNil(err) }) } + +type Issue4033Status int + +const ( + Issue4033StatusA Issue4033Status = 1 +) + +func (s Issue4033Status) String() string { + return "somevalue" +} + +func (s Issue4033Status) Int64() int64 { + return int64(s) +} + +// https://github.com/gogf/gf/issues/4033 +func Test_Issue4033(t *testing.T) { + var ( + sqlText = gtest.DataContent("issues", "issue4033.sql") + table = "test_enum" + ) + if _, err := db.Exec(ctx, sqlText); err != nil { + gtest.Fatal(err) + } + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + query := g.Map{ + "status": g.Slice{Issue4033StatusA}, + } + _, err := db.Model(table).Ctx(ctx).Where(query).All() + t.AssertNil(err) + }) +} diff --git a/contrib/drivers/pgsql/testdata/issues/issue4033.sql b/contrib/drivers/pgsql/testdata/issues/issue4033.sql new file mode 100644 index 00000000000..57f97252cde --- /dev/null +++ b/contrib/drivers/pgsql/testdata/issues/issue4033.sql @@ -0,0 +1,5 @@ +CREATE TABLE test_enum ( + id int8 NOT NULL, + status int2 DEFAULT 0 NOT NULL, + CONSTRAINT test_enum_pk PRIMARY KEY (id) +); \ No newline at end of file diff --git a/database/gdb/gdb_func.go b/database/gdb/gdb_func.go index ce5258e9983..ba402e5c970 100644 --- a/database/gdb/gdb_func.go +++ b/database/gdb/gdb_func.go @@ -856,20 +856,9 @@ func handleSliceAndStructArgsForSql( return s }) - default: + // Special struct handling. + case reflect.Struct: switch oldArg.(type) { - // Do not append Raw arg to args but directly into the sql. - case Raw, *Raw: - var counter = 0 - newSql = gstr.ReplaceFunc(newSql, `?`, func(s string) string { - counter++ - if counter == index+insertHolderCount+1 { - return gconv.String(oldArg) - } - return s - }) - continue - // The underlying driver supports time.Time/*time.Time types. case time.Time, *time.Time: newArgs = append(newArgs, oldArg) @@ -892,6 +881,24 @@ func handleSliceAndStructArgsForSql( } } newArgs = append(newArgs, oldArg) + + default: + switch oldArg.(type) { + // Do not append Raw arg to args but directly into the sql. + case Raw, *Raw: + var counter = 0 + newSql = gstr.ReplaceFunc(newSql, `?`, func(s string) string { + counter++ + if counter == index+insertHolderCount+1 { + return gconv.String(oldArg) + } + return s + }) + continue + + default: + } + newArgs = append(newArgs, oldArg) } } return From e3e82c7351a70da2ddfbf64da72575c6dc2ea37b Mon Sep 17 00:00:00 2001 From: Lance Add <1196661499@qq.com> Date: Fri, 13 Dec 2024 09:57:28 +0800 Subject: [PATCH 051/102] feat(contrib/config/nacos): add OnChange callbacks configuration support (#4038) --- contrib/config/nacos/nacos.go | 13 +++++---- contrib/config/nacos/nacos_test.go | 43 +++++++++++++++++++++++++++++- 2 files changed, 50 insertions(+), 6 deletions(-) diff --git a/contrib/config/nacos/nacos.go b/contrib/config/nacos/nacos.go index 5327b9d6ea9..a952fb3fb5f 100644 --- a/contrib/config/nacos/nacos.go +++ b/contrib/config/nacos/nacos.go @@ -23,10 +23,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(namespace, group, dataId, data string) // Configure change callback function } // Client implements gcfg.Adapter implementing using nacos service. @@ -125,9 +126,11 @@ func (c *Client) addWatcher() error { if !c.config.Watch { return nil } - c.config.ConfigParam.OnChange = func(namespace, group, dataId, data string) { c.doUpdate(data) + if c.config.OnConfigChange != nil { + go c.config.OnConfigChange(namespace, group, dataId, data) + } } 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 4adcfdaa6a9..473a8174786 100644 --- a/contrib/config/nacos/nacos_test.go +++ b/contrib/config/nacos/nacos_test.go @@ -7,11 +7,14 @@ package nacos_test import ( + "net/url" "testing" + "time" "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/frame/g" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/test/gtest" @@ -34,6 +37,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) { @@ -48,7 +52,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") @@ -58,3 +61,41 @@ 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(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()) + }, + }) + 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, err := g.Cfg().Data(ctx) + t.AssertNil(err) + j := gjson.New(c) + err = j.Set("app.name", "gf") + t.AssertNil(err) + 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, err := j.ToTomlString() + t.AssertNil(err) + _, err = g.Client().Post(ctx, configPublishUrl+"&content="+url.QueryEscape(res2)) + t.AssertNil(err) + }) +} From ac531708849da249a881b09dec81d6c6aa68ea29 Mon Sep 17 00:00:00 2001 From: John Guo Date: Fri, 13 Dec 2024 11:09:07 +0800 Subject: [PATCH 052/102] feat(contrib/registry/etcd): add retry machenism when keepalive lease expires (#4035) --- .github/workflows/ci-main.sh | 82 +++++-------------- container/gpool/gpool_z_unit_test.go | 7 +- .../clickhouse/clickhouse_z_unit_db_test.go | 2 +- contrib/drivers/dm/dm_z_unit_basic_test.go | 12 +-- contrib/drivers/dm/dm_z_unit_init_test.go | 2 +- .../drivers/mssql/mssql_z_unit_basic_test.go | 10 +-- .../drivers/mssql/mssql_z_unit_init_test.go | 5 +- .../drivers/mssql/mssql_z_unit_model_test.go | 50 +++++------ .../oracle/oracle_z_unit_basic_test.go | 10 +-- .../drivers/oracle/oracle_z_unit_init_test.go | 2 +- .../oracle/oracle_z_unit_model_test.go | 8 +- contrib/drivers/pgsql/pgsql_z_unit_db_test.go | 4 +- .../drivers/sqlite/sqlite_z_unit_core_test.go | 2 +- .../sqlitecgo/sqlitecgo_z_unit_core_test.go | 2 +- contrib/registry/etcd/etcd.go | 7 +- contrib/registry/etcd/etcd_discovery.go | 2 +- contrib/registry/etcd/etcd_registrar.go | 45 ++++++++-- contrib/registry/etcd/etcd_watcher.go | 21 ++++- contrib/registry/etcd/go.mod | 10 +-- contrib/registry/etcd/go.sum | 25 +++--- example/go.mod | 12 +-- example/go.sum | 20 ++--- example/registry/etcd/grpc/client/client.go | 25 ++++-- 23 files changed, 194 insertions(+), 171 deletions(-) diff --git a/.github/workflows/ci-main.sh b/.github/workflows/ci-main.sh index 39d094c9d8e..7171edab4e6 100644 --- a/.github/workflows/ci-main.sh +++ b/.github/workflows/ci-main.sh @@ -1,5 +1,8 @@ #!/usr/bin/env bash +# Define the latest Go version requirement +LATEST_GO_VERSION="1.23" + coverage=$1 # find all path that contains go.mod. @@ -13,82 +16,39 @@ for file in `find . -name go.mod`; do continue 1 fi - if [[ $file =~ "/testdata/" ]]; then - echo "ignore testdata path $file" - continue 1 - fi - # package kuhecm was moved to sub ci procedure. if [ "kubecm" = $(basename $dirpath) ]; then continue 1 fi - # package consul needs golang >= v1.19 - if [ "consul" = $(basename $dirpath) ]; then - if ! go version|grep -qE "go1.[2-9][0-9]"; then - echo "ignore consul as go version: $(go version)" - continue 1 + # Check if it's a contrib directory or example directory + if [[ $dirpath =~ "/contrib/" ]] || [ "example" = $(basename $dirpath) ]; then + # Check if go version meets the requirement + if ! go version | grep -qE "go${LATEST_GO_VERSION}"; then + echo "ignore path $dirpath as go version is not ${LATEST_GO_VERSION}: $(go version)" + continue 1 fi - fi - - # package etcd needs golang >= v1.19 - if [ "etcd" = $(basename $dirpath) ]; then - if ! go version|grep -qE "go1.[2-9][0-9]"; then - echo "ignore etcd as go version: $(go version)" - continue 1 - fi - fi - - # package polaris needs golang >= v1.19 - if [ "polaris" = $(basename $dirpath) ]; then - if ! go version|grep -qE "go1.[2-9][0-9]"; then - echo "ignore polaris as go version: $(go version)" - continue 1 + # If it's example directory, only build without tests + if [ "example" = $(basename $dirpath) ]; then + echo "the example directory only needs to be built, not unit tests and coverage tests." + cd $dirpath + go mod tidy + go build ./... + cd - + continue 1 fi fi - # package example needs golang >= v1.20 - if [ "example" = $(basename $dirpath) ]; then - if ! go version|grep -qE "go1.[2-9][1-9]"; then - echo "ignore example as go version: $(go version)" - continue 1 - fi - echo "the example directory only needs to be built, not unit tests and coverage tests." - cd $dirpath - go mod tidy - go build ./... - cd - + if [[ $file =~ "/testdata/" ]]; then + echo "ignore testdata path $file" continue 1 fi - # package otlpgrpc needs golang >= v1.20 - if [ "otlpgrpc" = $(basename $dirpath) ]; then - if ! go version|grep -qE "go1.[2-9][0-9]"; then - echo "ignore otlpgrpc as go version: $(go version)" - continue 1 - fi - fi - - # package otlphttp needs golang >= v1.20 - if [ "otlphttp" = $(basename $dirpath) ]; then - if ! go version|grep -qE "go1.[2-9][0-9]"; then - echo "ignore otlphttp as go version: $(go version)" - continue 1 - fi - fi - - # package otelmetric needs golang >= v1.20 - if [ "otelmetric" = $(basename $dirpath) ]; then - if ! go version|grep -qE "go1.[2-9][0-9]"; then - echo "ignore otelmetric as go version: $(go version)" - continue 1 - fi - fi - cd $dirpath go mod tidy go build ./... - # check coverage + + # test with coverage if [ "${coverage}" = "coverage" ]; then go test ./... -race -coverprofile=coverage.out -covermode=atomic -coverpkg=./...,github.com/gogf/gf/... || exit 1 diff --git a/container/gpool/gpool_z_unit_test.go b/container/gpool/gpool_z_unit_test.go index dfd000dd096..7becbec569a 100644 --- a/container/gpool/gpool_z_unit_test.go +++ b/container/gpool/gpool_z_unit_test.go @@ -12,6 +12,7 @@ import ( "time" "github.com/gogf/gf/v2/container/gpool" + "github.com/gogf/gf/v2/container/gtype" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/test/gtest" ) @@ -20,10 +21,10 @@ var nf gpool.NewFunc = func() (i interface{}, e error) { return "hello", nil } -var assertIndex int = 0 +var assertIndex = gtype.NewInt(0) var ef gpool.ExpireFunc = func(i interface{}) { - assertIndex++ + assertIndex.Add(1) gtest.Assert(i, assertIndex) } @@ -83,7 +84,7 @@ func Test_Gpool(t *testing.T) { v2, err2 = p2.Get() t.Assert(err2, nil) t.Assert(v2, 0) - assertIndex = 0 + assertIndex.Set(0) p2.Close() time.Sleep(3 * time.Second) t.AssertNE(p2.Put(1), nil) diff --git a/contrib/drivers/clickhouse/clickhouse_z_unit_db_test.go b/contrib/drivers/clickhouse/clickhouse_z_unit_db_test.go index 977cdf7defd..0b818222d0a 100644 --- a/contrib/drivers/clickhouse/clickhouse_z_unit_db_test.go +++ b/contrib/drivers/clickhouse/clickhouse_z_unit_db_test.go @@ -295,7 +295,7 @@ func Test_DB_Tables(t *testing.T) { } result, err := db.Tables(ctx) - gtest.Assert(err, nil) + gtest.AssertNil(err) for i := 0; i < len(tables); i++ { find := false diff --git a/contrib/drivers/dm/dm_z_unit_basic_test.go b/contrib/drivers/dm/dm_z_unit_basic_test.go index 467d32b636f..5bede337c3a 100644 --- a/contrib/drivers/dm/dm_z_unit_basic_test.go +++ b/contrib/drivers/dm/dm_z_unit_basic_test.go @@ -34,7 +34,7 @@ func TestTables(t *testing.T) { } gtest.C(t, func(t *gtest.T) { result, err := db.Tables(ctx) - gtest.Assert(err, nil) + gtest.AssertNil(err) for i := 0; i < len(tables); i++ { find := false @@ -48,7 +48,7 @@ func TestTables(t *testing.T) { } result, err = dblink.Tables(ctx) - gtest.Assert(err, nil) + gtest.AssertNil(err) for i := 0; i < len(tables); i++ { find := false for j := 0; j < len(result); j++ { @@ -95,7 +95,7 @@ func TestTableFields(t *testing.T) { gtest.AssertNE(err, nil) res, err := db.TableFields(ctx, tables) - gtest.Assert(err, nil) + gtest.AssertNil(err) for k, v := range expect { _, ok := res[k] @@ -205,7 +205,7 @@ func TestModelInsert(t *testing.T) { } // _, err := db.Schema(TestDBName).Model(table).Data(data).Insert() _, err := db.Model(table).Insert(&data) - gtest.Assert(err, nil) + gtest.AssertNil(err) }) gtest.C(t, func(t *gtest.T) { @@ -220,7 +220,7 @@ func TestModelInsert(t *testing.T) { } // _, err := db.Schema(TestDBName).Model(table).Data(data).Insert() _, err := db.Model(table).Data(&data).Insert() - gtest.Assert(err, nil) + gtest.AssertNil(err) }) } @@ -238,7 +238,7 @@ func TestDBInsert(t *testing.T) { "UPDATED_TIME": gtime.Now(), } _, err := db.Insert(ctx, table, &data) - gtest.Assert(err, nil) + gtest.AssertNil(err) }) } diff --git a/contrib/drivers/dm/dm_z_unit_init_test.go b/contrib/drivers/dm/dm_z_unit_init_test.go index ad71189da48..5d81f649a3e 100644 --- a/contrib/drivers/dm/dm_z_unit_init_test.go +++ b/contrib/drivers/dm/dm_z_unit_init_test.go @@ -173,7 +173,7 @@ func createInitTable(table ...string) (name string) { }) } result, err := db.Schema(TestDBName).Insert(context.Background(), name, array.Slice()) - gtest.Assert(err, nil) + gtest.AssertNil(err) n, e := result.RowsAffected() gtest.Assert(e, nil) diff --git a/contrib/drivers/mssql/mssql_z_unit_basic_test.go b/contrib/drivers/mssql/mssql_z_unit_basic_test.go index bb67e2e478b..f00e6c84713 100644 --- a/contrib/drivers/mssql/mssql_z_unit_basic_test.go +++ b/contrib/drivers/mssql/mssql_z_unit_basic_test.go @@ -29,7 +29,7 @@ func TestTables(t *testing.T) { } result, err := db.Tables(context.Background()) - gtest.Assert(err, nil) + gtest.AssertNil(err) for i := 0; i < len(tables); i++ { find := false @@ -43,7 +43,7 @@ func TestTables(t *testing.T) { } result, err = db.Tables(context.Background(), "test") - gtest.Assert(err, nil) + gtest.AssertNil(err) for i := 0; i < len(tables); i++ { find := false for j := 0; j < len(result); j++ { @@ -74,7 +74,7 @@ func TestTableFields(t *testing.T) { } res, err := db.TableFields(context.Background(), "t_user") - gtest.Assert(err, nil) + gtest.AssertNil(err) for k, v := range expect { _, ok := res[k] @@ -89,7 +89,7 @@ func TestTableFields(t *testing.T) { } res, err = db.TableFields(context.Background(), "t_user", "test") - gtest.Assert(err, nil) + gtest.AssertNil(err) for k, v := range expect { _, ok := res[k] @@ -124,7 +124,7 @@ func TestDoInsert(t *testing.T) { "create_time": gtime.Now(), } _, err := db.Insert(context.Background(), "t_user", data) - gtest.Assert(err, nil) + gtest.AssertNil(err) }) diff --git a/contrib/drivers/mssql/mssql_z_unit_init_test.go b/contrib/drivers/mssql/mssql_z_unit_init_test.go index c7d67d079d4..eec9b76fe68 100644 --- a/contrib/drivers/mssql/mssql_z_unit_init_test.go +++ b/contrib/drivers/mssql/mssql_z_unit_init_test.go @@ -61,7 +61,8 @@ func init() { nodeErr := gdb.ConfigNode{ Type: "mssql", - Link: fmt.Sprintf("user id=%s;password=%s;server=%s;port=%s;database=%s;encrypt=disable", + Link: fmt.Sprintf( + "mssql:%s:%s@tcp(%s:%s)/%s?encrypt=disable", node.User, "node.Pass", node.Host, node.Port, node.Name), } @@ -130,7 +131,7 @@ func createInitTable(table ...string) (name string) { }) } result, err := db.Insert(context.Background(), name, array.Slice()) - gtest.Assert(err, nil) + gtest.AssertNil(err) n, e := result.RowsAffected() gtest.Assert(e, nil) diff --git a/contrib/drivers/mssql/mssql_z_unit_model_test.go b/contrib/drivers/mssql/mssql_z_unit_model_test.go index e9eac7428b7..14d315600ca 100644 --- a/contrib/drivers/mssql/mssql_z_unit_model_test.go +++ b/contrib/drivers/mssql/mssql_z_unit_model_test.go @@ -26,30 +26,32 @@ import ( func Test_Page(t *testing.T) { table := createInitTable() defer dropTable(table) - // db.SetDebug(true) - result, err := db.Model(table).Page(1, 2).Order("id").All() - gtest.Assert(err, nil) - fmt.Println("page:1--------", result) - gtest.Assert(len(result), 2) - gtest.Assert(result[0]["ID"], 1) - gtest.Assert(result[1]["ID"], 2) - - result, err = db.Model(table).Page(2, 2).Order("id").All() - gtest.Assert(err, nil) - fmt.Println("page: 2--------", result) - gtest.Assert(len(result), 2) - gtest.Assert(result[0]["ID"], 3) - gtest.Assert(result[1]["ID"], 4) - - result, err = db.Model(table).Page(3, 2).Order("id").All() - gtest.Assert(err, nil) - fmt.Println("page:3 --------", result) - gtest.Assert(len(result), 2) - gtest.Assert(result[0]["ID"], 5) - - result, err = db.Model(table).Page(2, 3).All() - gtest.Assert(err, nil) - gtest.Assert(len(result), 3) + gtest.C(t, func(t *gtest.T) { + result, err := db.Model(table).Page(1, 2).Order("id").All() + t.AssertNil(err) + fmt.Println("page:1--------", result) + gtest.Assert(len(result), 2) + gtest.Assert(result[0]["ID"], 1) + gtest.Assert(result[1]["ID"], 2) + + result, err = db.Model(table).Page(2, 2).Order("id").All() + t.AssertNil(err) + fmt.Println("page: 2--------", result) + gtest.Assert(len(result), 2) + gtest.Assert(result[0]["ID"], 3) + gtest.Assert(result[1]["ID"], 4) + + result, err = db.Model(table).Page(3, 2).Order("id").All() + t.AssertNil(err) + fmt.Println("page:3 --------", result) + gtest.Assert(len(result), 2) + gtest.Assert(result[0]["ID"], 5) + + result, err = db.Model(table).Page(2, 3).All() + t.AssertNil(err) + gtest.Assert(len(result), 3) + }) + } func Test_Model_Insert(t *testing.T) { diff --git a/contrib/drivers/oracle/oracle_z_unit_basic_test.go b/contrib/drivers/oracle/oracle_z_unit_basic_test.go index 83b926bfc30..b5cba3945bf 100644 --- a/contrib/drivers/oracle/oracle_z_unit_basic_test.go +++ b/contrib/drivers/oracle/oracle_z_unit_basic_test.go @@ -27,7 +27,7 @@ func Test_Tables(t *testing.T) { } result, err := db.Tables(ctx) - gtest.Assert(err, nil) + gtest.AssertNil(err) for i := 0; i < len(tables); i++ { find := false @@ -41,7 +41,7 @@ func Test_Tables(t *testing.T) { } result, err = db.Tables(ctx, TestSchema) - gtest.Assert(err, nil) + gtest.AssertNil(err) for i := 0; i < len(tables); i++ { find := false for j := 0; j < len(result); j++ { @@ -76,7 +76,7 @@ func Test_Table_Fields(t *testing.T) { gtest.AssertNE(err, nil) res, err := db.TableFields(ctx, "t_user") - gtest.Assert(err, nil) + gtest.AssertNil(err) for k, v := range expect { _, ok := res[k] @@ -88,7 +88,7 @@ func Test_Table_Fields(t *testing.T) { } res, err = db.TableFields(ctx, "t_user", TestSchema) - gtest.Assert(err, nil) + gtest.AssertNil(err) for k, v := range expect { _, ok := res[k] @@ -121,7 +121,7 @@ func Test_Do_Insert(t *testing.T) { "CREATE_TIME": gtime.Now().String(), } _, err := db.Insert(ctx, "t_user", data) - gtest.Assert(err, nil) + gtest.AssertNil(err) }) diff --git a/contrib/drivers/oracle/oracle_z_unit_init_test.go b/contrib/drivers/oracle/oracle_z_unit_init_test.go index f7e041c6a76..3e549d4b265 100644 --- a/contrib/drivers/oracle/oracle_z_unit_init_test.go +++ b/contrib/drivers/oracle/oracle_z_unit_init_test.go @@ -143,7 +143,7 @@ func createInitTable(table ...string) (name string) { }) } result, err := db.Insert(context.Background(), name, array.Slice()) - gtest.Assert(err, nil) + gtest.AssertNil(err) n, e := result.RowsAffected() gtest.Assert(e, nil) diff --git a/contrib/drivers/oracle/oracle_z_unit_model_test.go b/contrib/drivers/oracle/oracle_z_unit_model_test.go index b9ecb5b4cac..26031615e03 100644 --- a/contrib/drivers/oracle/oracle_z_unit_model_test.go +++ b/contrib/drivers/oracle/oracle_z_unit_model_test.go @@ -132,27 +132,27 @@ func Test_Page(t *testing.T) { table := createInitTable() defer dropTable(table) result, err := db.Model(table).Page(1, 2).Order("ID").All() - gtest.Assert(err, nil) + gtest.AssertNil(err) fmt.Println("page:1--------", result) gtest.Assert(len(result), 2) gtest.Assert(result[0]["ID"], 1) gtest.Assert(result[1]["ID"], 2) result, err = db.Model(table).Page(2, 2).Order("ID").All() - gtest.Assert(err, nil) + gtest.AssertNil(err) fmt.Println("page: 2--------", result) gtest.Assert(len(result), 2) gtest.Assert(result[0]["ID"], 3) gtest.Assert(result[1]["ID"], 4) result, err = db.Model(table).Page(3, 2).Order("ID").All() - gtest.Assert(err, nil) + gtest.AssertNil(err) fmt.Println("page:3 --------", result) gtest.Assert(len(result), 2) gtest.Assert(result[0]["ID"], 5) result, err = db.Model(table).Page(2, 3).All() - gtest.Assert(err, nil) + gtest.AssertNil(err) gtest.Assert(len(result), 3) gtest.Assert(result[0]["ID"], 4) gtest.Assert(result[1]["ID"], 5) diff --git a/contrib/drivers/pgsql/pgsql_z_unit_db_test.go b/contrib/drivers/pgsql/pgsql_z_unit_db_test.go index fabccc45f46..688301cd4c1 100644 --- a/contrib/drivers/pgsql/pgsql_z_unit_db_test.go +++ b/contrib/drivers/pgsql/pgsql_z_unit_db_test.go @@ -282,7 +282,7 @@ func Test_DB_Tables(t *testing.T) { createTable(v) } result, err := db.Tables(ctx) - gtest.Assert(err, nil) + gtest.AssertNil(err) for i := 0; i < len(tables); i++ { find := false for j := 0; j < len(result); j++ { @@ -312,7 +312,7 @@ func Test_DB_TableFields(t *testing.T) { } res, err := db.TableFields(ctx, table) - gtest.Assert(err, nil) + gtest.AssertNil(err) for k, v := range expect { _, ok := res[k] diff --git a/contrib/drivers/sqlite/sqlite_z_unit_core_test.go b/contrib/drivers/sqlite/sqlite_z_unit_core_test.go index cb592db6e31..f0ed23bbe9e 100644 --- a/contrib/drivers/sqlite/sqlite_z_unit_core_test.go +++ b/contrib/drivers/sqlite/sqlite_z_unit_core_test.go @@ -1553,7 +1553,7 @@ func Test_TableFields(t *testing.T) { } res, err := db.TableFields(context.Background(), tableName) - gtest.Assert(err, nil) + gtest.AssertNil(err) for k, v := range expect { _, ok := res[k] diff --git a/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_core_test.go b/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_core_test.go index 31b0bc46057..eb4396c92b0 100644 --- a/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_core_test.go +++ b/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_core_test.go @@ -1553,7 +1553,7 @@ func Test_TableFields(t *testing.T) { } res, err := db.TableFields(context.Background(), tableName) - gtest.Assert(err, nil) + gtest.AssertNil(err) for k, v := range expect { _, ok := res[k] diff --git a/contrib/registry/etcd/etcd.go b/contrib/registry/etcd/etcd.go index 0e95f87aafc..e0850c76e01 100644 --- a/contrib/registry/etcd/etcd.go +++ b/contrib/registry/etcd/etcd.go @@ -33,6 +33,7 @@ type Registry struct { lease etcd3.Lease keepaliveTTL time.Duration logger glog.ILogger + etcdConfig etcd3.Config } // Option is the option for the etcd registry. @@ -59,7 +60,7 @@ const ( // New creates and returns a new etcd registry. // Support Etcd Address format: ip:port,ip:port...,ip:port@username:password -func New(address string, option ...Option) gsvc.Registry { +func New(address string, option ...Option) *Registry { if address == "" { panic(gerror.NewCode(gcode.CodeInvalidParameter, `invalid etcd address ""`)) } @@ -110,7 +111,9 @@ func New(address string, option ...Option) gsvc.Registry { if err != nil { panic(gerror.Wrap(err, `create etcd client failed`)) } - return NewWithClient(client, option...) + r := NewWithClient(client, option...) + r.etcdConfig = cfg + return r } // NewWithClient creates and returns a new etcd registry with the given client. diff --git a/contrib/registry/etcd/etcd_discovery.go b/contrib/registry/etcd/etcd_discovery.go index adb918cdfcc..5607aa6672e 100644 --- a/contrib/registry/etcd/etcd_discovery.go +++ b/contrib/registry/etcd/etcd_discovery.go @@ -58,5 +58,5 @@ func (r *Registry) Search(ctx context.Context, in gsvc.SearchInput) ([]gsvc.Serv // Watch watches specified condition changes. // The `key` is the prefix of service key. func (r *Registry) Watch(ctx context.Context, key string) (gsvc.Watcher, error) { - return newWatcher(key, r.client) + return newWatcher(key, r.client, r.etcdConfig.DialTimeout) } diff --git a/contrib/registry/etcd/etcd_registrar.go b/contrib/registry/etcd/etcd_registrar.go index 85b63aa5248..7cc6e267fa3 100644 --- a/contrib/registry/etcd/etcd_registrar.go +++ b/contrib/registry/etcd/etcd_registrar.go @@ -8,21 +8,34 @@ package etcd import ( "context" + "time" etcd3 "go.etcd.io/etcd/client/v3" "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/net/gsvc" + "github.com/gogf/gf/v2/util/grand" ) // Register registers `service` to Registry. // Note that it returns a new Service if it changes the input Service with custom one. func (r *Registry) Register(ctx context.Context, service gsvc.Service) (gsvc.Service, error) { service = NewService(service) + if err := r.doRegisterLease(ctx, service); err != nil { + return nil, err + } + return service, nil +} + +func (r *Registry) doRegisterLease(ctx context.Context, service gsvc.Service) error { r.lease = etcd3.NewLease(r.client) + + ctx, cancel := context.WithTimeout(context.Background(), r.etcdConfig.DialTimeout) + defer cancel() + grant, err := r.lease.Grant(ctx, int64(r.keepaliveTTL.Seconds())) if err != nil { - return nil, gerror.Wrapf(err, `etcd grant failed with keepalive ttl "%s"`, r.keepaliveTTL) + return gerror.Wrapf(err, `etcd grant failed with keepalive ttl "%s"`, r.keepaliveTTL) } var ( key = service.GetKey() @@ -30,7 +43,7 @@ func (r *Registry) Register(ctx context.Context, service gsvc.Service) (gsvc.Ser ) _, err = r.client.Put(ctx, key, value, etcd3.WithLease(grant.ID)) if err != nil { - return nil, gerror.Wrapf( + return gerror.Wrapf( err, `etcd put failed with key "%s", value "%s", lease "%d"`, key, value, grant.ID, @@ -43,10 +56,10 @@ func (r *Registry) Register(ctx context.Context, service gsvc.Service) (gsvc.Ser ) keepAliceCh, err := r.client.KeepAlive(context.Background(), grant.ID) if err != nil { - return nil, err + return err } - go r.doKeepAlive(grant.ID, keepAliceCh) - return service, nil + go r.doKeepAlive(service, grant.ID, keepAliceCh) + return nil } // Deregister off-lines and removes `service` from the Registry. @@ -59,12 +72,14 @@ func (r *Registry) Deregister(ctx context.Context, service gsvc.Service) error { } // doKeepAlive continuously keeps alive the lease from ETCD. -func (r *Registry) doKeepAlive(leaseID etcd3.LeaseID, keepAliceCh <-chan *etcd3.LeaseKeepAliveResponse) { +func (r *Registry) doKeepAlive( + service gsvc.Service, leaseID etcd3.LeaseID, keepAliceCh <-chan *etcd3.LeaseKeepAliveResponse, +) { var ctx = context.Background() for { select { case <-r.client.Ctx().Done(): - r.logger.Noticef(ctx, "keepalive done for lease id: %d", leaseID) + r.logger.Infof(ctx, "keepalive done for lease id: %d", leaseID) return case res, ok := <-keepAliceCh: @@ -72,7 +87,21 @@ func (r *Registry) doKeepAlive(leaseID etcd3.LeaseID, keepAliceCh <-chan *etcd3. // r.logger.Debugf(ctx, `keepalive loop: %v, %s`, ok, res.String()) } if !ok { - r.logger.Noticef(ctx, `keepalive exit, lease id: %d`, leaseID) + r.logger.Warningf(ctx, `keepalive exit, lease id: %d, retry register`, leaseID) + // Re-register the service. + for { + if err := r.doRegisterLease(ctx, service); err != nil { + retryDuration := grand.D(time.Second, time.Second*3) + r.logger.Errorf( + ctx, + `keepalive retry register failed, will retry in %s: %+v`, + retryDuration, err, + ) + time.Sleep(retryDuration) + continue + } + break + } return } } diff --git a/contrib/registry/etcd/etcd_watcher.go b/contrib/registry/etcd/etcd_watcher.go index 3c4da0d5149..058c0b338e4 100644 --- a/contrib/registry/etcd/etcd_watcher.go +++ b/contrib/registry/etcd/etcd_watcher.go @@ -8,9 +8,12 @@ package etcd import ( "context" + "time" etcd3 "go.etcd.io/etcd/client/v3" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/net/gsvc" ) @@ -27,17 +30,31 @@ type watcher struct { kv etcd3.KV } -func newWatcher(key string, client *etcd3.Client) (*watcher, error) { +func newWatcher(key string, client *etcd3.Client, dialTimeout time.Duration) (*watcher, error) { w := &watcher{ key: key, watcher: etcd3.NewWatcher(client), kv: etcd3.NewKV(client), } + + // Create context with timeout + ctx, cancel := context.WithTimeout(context.Background(), dialTimeout) + defer cancel() + + // Test connection first. + if _, err := client.Get(ctx, "ping"); err != nil { + return nil, gerror.WrapCode(gcode.CodeOperationFailed, err, "failed to connect to etcd") + } + w.ctx, w.cancel = context.WithCancel(context.Background()) w.watchChan = w.watcher.Watch(w.ctx, key, etcd3.WithPrefix(), etcd3.WithRev(0)) + if err := w.watcher.RequestProgress(context.Background()); err != nil { - return nil, err + // Clean up + w.cancel() + return nil, gerror.WrapCode(gcode.CodeOperationFailed, err, "failed to establish watch connection") } + return w, nil } diff --git a/contrib/registry/etcd/go.mod b/contrib/registry/etcd/go.mod index e36969ca68c..016b6e79a2f 100644 --- a/contrib/registry/etcd/go.mod +++ b/contrib/registry/etcd/go.mod @@ -1,10 +1,10 @@ module github.com/gogf/gf/contrib/registry/etcd/v2 -go 1.20 +go 1.22 require ( github.com/gogf/gf/v2 v2.8.2 - go.etcd.io/etcd/client/v3 v3.5.7 + go.etcd.io/etcd/client/v3 v3.5.17 google.golang.org/grpc v1.59.0 ) @@ -19,7 +19,7 @@ require ( github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // indirect github.com/magiconair/properties v1.8.9 // indirect @@ -28,8 +28,8 @@ require ( github.com/mattn/go-runewidth v0.0.16 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/rivo/uniseg v0.4.7 // indirect - go.etcd.io/etcd/api/v3 v3.5.7 // indirect - go.etcd.io/etcd/client/pkg/v3 v3.5.7 // indirect + go.etcd.io/etcd/api/v3 v3.5.17 // indirect + go.etcd.io/etcd/client/pkg/v3 v3.5.17 // indirect go.opentelemetry.io/otel v1.24.0 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect diff --git a/contrib/registry/etcd/go.sum b/contrib/registry/etcd/go.sum index 2bc5e014f1c..2bf6733f784 100644 --- a/contrib/registry/etcd/go.sum +++ b/contrib/registry/etcd/go.sum @@ -23,11 +23,10 @@ github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= @@ -56,15 +55,16 @@ github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUc github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/stretchr/testify v1.9.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -go.etcd.io/etcd/api/v3 v3.5.7 h1:sbcmosSVesNrWOJ58ZQFitHMdncusIifYcrBfwrlJSY= -go.etcd.io/etcd/api/v3 v3.5.7/go.mod h1:9qew1gCdDDLu+VwmeG+iFpL+QlpHTo7iubavdVDgCAA= -go.etcd.io/etcd/client/pkg/v3 v3.5.7 h1:y3kf5Gbp4e4q7egZdn5T7W9TSHUvkClN6u+Rq9mEOmg= -go.etcd.io/etcd/client/pkg/v3 v3.5.7/go.mod h1:o0Abi1MK86iad3YrWhgUsbGx1pmTS+hrORWc2CamuhY= -go.etcd.io/etcd/client/v3 v3.5.7 h1:u/OhpiuCgYY8awOHlhIhmGIGpxfBU/GZBUP3m/3/Iz4= -go.etcd.io/etcd/client/v3 v3.5.7/go.mod h1:sOWmj9DZUMyAngS7QQwCyAXXAL6WhgTOPLNS/NabQgw= +go.etcd.io/etcd/api/v3 v3.5.17 h1:cQB8eb8bxwuxOilBpMJAEo8fAONyrdXTHUNcMd8yT1w= +go.etcd.io/etcd/api/v3 v3.5.17/go.mod h1:d1hvkRuXkts6PmaYk2Vrgqbv7H4ADfAKhyJqHNLJCB4= +go.etcd.io/etcd/client/pkg/v3 v3.5.17 h1:XxnDXAWq2pnxqx76ljWwiQ9jylbpC4rvkAeRVOUKKVw= +go.etcd.io/etcd/client/pkg/v3 v3.5.17/go.mod h1:4DqK1TKacp/86nJk4FLQqo6Mn2vvQFBmruW3pP14H/w= +go.etcd.io/etcd/client/v3 v3.5.17 h1:o48sINNeWz5+pjy/Z0+HKpj/xSnBkuVhVvXkjEXbqZY= +go.etcd.io/etcd/client/v3 v3.5.17/go.mod h1:j2d4eXTHWkT2ClBgnnEPm/Wuu7jsqku41v9DZ3OtjQo= go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= @@ -120,14 +120,13 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1: google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= +gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/example/go.mod b/example/go.mod index 6ae66482c5d..6c64e21301f 100644 --- a/example/go.mod +++ b/example/go.mod @@ -1,6 +1,6 @@ module github.com/gogf/gf/example -go 1.21 +go 1.22 require ( github.com/gogf/gf/contrib/config/apollo/v2 v2.8.2 @@ -32,7 +32,7 @@ require ( go.opentelemetry.io/otel/exporters/prometheus v0.46.0 go.opentelemetry.io/otel/sdk v1.29.0 golang.org/x/time v0.6.0 - google.golang.org/grpc v1.67.1 + google.golang.org/grpc v1.68.1 google.golang.org/protobuf v1.34.2 k8s.io/client-go v0.27.4 ) @@ -125,9 +125,9 @@ require ( github.com/spf13/viper v1.8.1 // indirect github.com/subosito/gotenv v1.2.0 // indirect github.com/tjfoc/gmsm v1.4.1 // indirect - go.etcd.io/etcd/api/v3 v3.5.7 // indirect - go.etcd.io/etcd/client/pkg/v3 v3.5.7 // indirect - go.etcd.io/etcd/client/v3 v3.5.7 // indirect + go.etcd.io/etcd/api/v3 v3.5.17 // indirect + go.etcd.io/etcd/client/pkg/v3 v3.5.17 // indirect + go.etcd.io/etcd/client/v3 v3.5.17 // indirect go.opentelemetry.io/contrib/instrumentation/runtime v0.49.0 // indirect go.opentelemetry.io/otel/metric v1.29.0 // indirect go.opentelemetry.io/otel/sdk/metric v1.24.0 // indirect @@ -138,7 +138,7 @@ require ( golang.org/x/crypto v0.30.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect golang.org/x/net v0.32.0 // indirect - golang.org/x/oauth2 v0.22.0 // indirect + golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/term v0.27.0 // indirect diff --git a/example/go.sum b/example/go.sum index 34b69415142..71f6c7064a6 100644 --- a/example/go.sum +++ b/example/go.sum @@ -731,14 +731,14 @@ github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9dec github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= -go.etcd.io/etcd/api/v3 v3.5.7 h1:sbcmosSVesNrWOJ58ZQFitHMdncusIifYcrBfwrlJSY= -go.etcd.io/etcd/api/v3 v3.5.7/go.mod h1:9qew1gCdDDLu+VwmeG+iFpL+QlpHTo7iubavdVDgCAA= +go.etcd.io/etcd/api/v3 v3.5.17 h1:cQB8eb8bxwuxOilBpMJAEo8fAONyrdXTHUNcMd8yT1w= +go.etcd.io/etcd/api/v3 v3.5.17/go.mod h1:d1hvkRuXkts6PmaYk2Vrgqbv7H4ADfAKhyJqHNLJCB4= go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= -go.etcd.io/etcd/client/pkg/v3 v3.5.7 h1:y3kf5Gbp4e4q7egZdn5T7W9TSHUvkClN6u+Rq9mEOmg= -go.etcd.io/etcd/client/pkg/v3 v3.5.7/go.mod h1:o0Abi1MK86iad3YrWhgUsbGx1pmTS+hrORWc2CamuhY= +go.etcd.io/etcd/client/pkg/v3 v3.5.17 h1:XxnDXAWq2pnxqx76ljWwiQ9jylbpC4rvkAeRVOUKKVw= +go.etcd.io/etcd/client/pkg/v3 v3.5.17/go.mod h1:4DqK1TKacp/86nJk4FLQqo6Mn2vvQFBmruW3pP14H/w= go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ= -go.etcd.io/etcd/client/v3 v3.5.7 h1:u/OhpiuCgYY8awOHlhIhmGIGpxfBU/GZBUP3m/3/Iz4= -go.etcd.io/etcd/client/v3 v3.5.7/go.mod h1:sOWmj9DZUMyAngS7QQwCyAXXAL6WhgTOPLNS/NabQgw= +go.etcd.io/etcd/client/v3 v3.5.17 h1:o48sINNeWz5+pjy/Z0+HKpj/xSnBkuVhVvXkjEXbqZY= +go.etcd.io/etcd/client/v3 v3.5.17/go.mod h1:j2d4eXTHWkT2ClBgnnEPm/Wuu7jsqku41v9DZ3OtjQo= go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= @@ -928,8 +928,8 @@ golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb/go.mod h1:jaDAt6Dkxork7Lm golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.22.0 h1:BzDx2FehcG7jJwgWLELCdmLuxk2i+x9UDpSiss2u0ZA= -golang.org/x/oauth2 v0.22.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= +golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= +golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -1334,8 +1334,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= -google.golang.org/grpc v1.67.1 h1:zWnc1Vrcno+lHZCOofnIMvycFcc0QRGIzm9dhnDX68E= -google.golang.org/grpc v1.67.1/go.mod h1:1gLDyUQU7CTLJI90u3nXZ9ekeghjeM7pTDZlqFNg2AA= +google.golang.org/grpc v1.68.1 h1:oI5oTa11+ng8r8XMMN7jAOmWfPZWbYpCFaMUTACxkM0= +google.golang.org/grpc v1.68.1/go.mod h1:+q1XYFJjShcqn0QZHvCyeR4CXPA+llXIeUIfIe00waw= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= diff --git a/example/registry/etcd/grpc/client/client.go b/example/registry/etcd/grpc/client/client.go index 0ff7266c0c7..3d8a3077f9a 100644 --- a/example/registry/etcd/grpc/client/client.go +++ b/example/registry/etcd/grpc/client/client.go @@ -7,8 +7,10 @@ package main import ( + "context" + "time" + "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/contrib/registry/etcd/v2" "github.com/gogf/gf/contrib/rpc/grpcx/v2" @@ -20,14 +22,23 @@ func main() { grpcx.Resolver.Register(etcd.New("127.0.0.1:2379")) var ( - ctx = gctx.New() conn = grpcx.Client.MustNewGrpcClientConn("demo") client = protobuf.NewGreeterClient(conn) ) - res, err := client.SayHello(ctx, &protobuf.HelloRequest{Name: "World"}) - if err != nil { - g.Log().Error(ctx, err) - return + + for { + func() { + ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) + defer cancel() + res, err := client.SayHello(ctx, &protobuf.HelloRequest{Name: "World"}) + if err != nil { + g.Log().Errorf(ctx, `%+v`, err) + } else { + g.Log().Debug(ctx, "Response:", res.Message) + } + }() + + time.Sleep(time.Second) } - g.Log().Debug(ctx, "Response:", res.Message) + } From a09454accf27f5a1a5f9d7cd99ae546cfbedfd34 Mon Sep 17 00:00:00 2001 From: John Guo Date: Mon, 16 Dec 2024 11:17:47 +0800 Subject: [PATCH 053/102] feat(contrib/drivers/mssql): enable unit testing (#4043) --- .github/workflows/ci-main.yml | 15 +++--- contrib/drivers/mssql/mssql_do_filter.go | 50 +++++++++++++------ contrib/drivers/mssql/mssql_do_filter_test.go | 15 +++--- .../drivers/mssql/mssql_z_unit_basic_test.go | 4 +- .../drivers/mssql/mssql_z_unit_init_test.go | 15 ++---- .../drivers/mssql/mssql_z_unit_model_test.go | 1 - 6 files changed, 56 insertions(+), 44 deletions(-) diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index 6eeee5dd9ac..ecbd084c67f 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -109,22 +109,19 @@ jobs: # -p 1433:1433 \ # -e ACCEPT_EULA=Y \ # -e SA_PASSWORD=LoremIpsum86 \ - # -e MSSQL_DB=test \ # -e MSSQL_USER=root \ # -e MSSQL_PASSWORD=LoremIpsum86 \ - # loads/mssqldocker:14.0.3391.2 + # mcr.microsoft.com/mssql/server:2022-latest mssql: - image: loads/mssqldocker:14.0.3391.2 + image: mcr.microsoft.com/mssql/server:2022-latest env: - ACCEPT_EULA: Y - SA_PASSWORD: LoremIpsum86 - MSSQL_DB: test - MSSQL_USER: root - MSSQL_PASSWORD: LoremIpsum86 + TZ: Asia/Shanghai + ACCEPT_EULA: Y + MSSQL_SA_PASSWORD: LoremIpsum86 ports: - 1433:1433 options: >- - --health-cmd="/opt/mssql-tools/bin/sqlcmd -S localhost -U sa -P LoremIpsum86 -l 30 -Q \"SELECT 1\" || exit 1" + --health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P ${MSSQL_SA_PASSWORD} -N -C -l 30 -Q \"SELECT 1\" || exit 1" --health-start-period 10s --health-interval 10s --health-timeout 5s diff --git a/contrib/drivers/mssql/mssql_do_filter.go b/contrib/drivers/mssql/mssql_do_filter.go index f6e4538bddb..6130b9e795e 100644 --- a/contrib/drivers/mssql/mssql_do_filter.go +++ b/contrib/drivers/mssql/mssql_do_filter.go @@ -18,12 +18,18 @@ import ( ) var ( - orderBySqlTmp = `SELECT %s %s OFFSET %d ROWS FETCH NEXT %d ROWS ONLY` - withoutOrderBySqlTmp = `SELECT %s OFFSET %d ROWS FETCH NEXT %d ROWS ONLY` selectWithOrderSqlTmp = ` -SELECT * FROM (SELECT ROW_NUMBER() OVER (ORDER BY %s) as ROW_NUMBER__, %s ) as TMP_ -WHERE TMP_.ROW_NUMBER__ > %d AND TMP_.ROW_NUMBER__ <= %d -` +SELECT * FROM ( + SELECT ROW_NUMBER() OVER (ORDER BY %s) as ROW_NUMBER__, %s + FROM (%s) as InnerQuery +) as TMP_ +WHERE TMP_.ROW_NUMBER__ > %d AND TMP_.ROW_NUMBER__ <= %d` + selectWithoutOrderSqlTmp = ` +SELECT * FROM ( + SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) as ROW_NUMBER__, %s + FROM (%s) as InnerQuery +) as TMP_ +WHERE TMP_.ROW_NUMBER__ > %d AND TMP_.ROW_NUMBER__ <= %d` ) func init() { @@ -32,6 +38,10 @@ func init() { if err != nil { panic(err) } + selectWithoutOrderSqlTmp, err = gdb.FormatMultiLineSqlToSingle(selectWithoutOrderSqlTmp) + if err != nil { + panic(err) + } } // DoFilter deals with the sql string before commits it to underlying sql driver. @@ -98,14 +108,19 @@ func (d *Driver) handleSelectSqlReplacement(toBeCommittedSql string) (newSql str return "", err } - // SELECT and ORDER BY + // Extract SELECT part selectStr := strings.TrimSpace(allMatch[1]) + + // Extract ORDER BY part orderStr := "" if len(allMatch[2]) > 0 { orderStr = strings.TrimSpace(allMatch[2]) + // Remove "ORDER BY" prefix as it will be used in OVER clause + orderStr = strings.TrimPrefix(orderStr, "ORDER BY") + orderStr = strings.TrimSpace(orderStr) } - // LIMIT and OFFSET value + // Calculate LIMIT and OFFSET values first, _ := strconv.Atoi(allMatch[3]) // LIMIT first parameter limit := 0 if len(allMatch) > 4 && allMatch[4] != "" { @@ -115,19 +130,26 @@ func (d *Driver) handleSelectSqlReplacement(toBeCommittedSql string) (newSql str first = 0 } + // Build the final query if orderStr != "" { - // have ORDER BY clause + // Have ORDER BY clause newSql = fmt.Sprintf( - orderBySqlTmp, - selectStr, orderStr, first, limit, + selectWithOrderSqlTmp, + orderStr, // ORDER BY clause for ROW_NUMBER + "*", // Select all columns + fmt.Sprintf("SELECT %s", selectStr), // Original SELECT + first, // OFFSET + first+limit, // OFFSET + LIMIT ) } else { - // without ORDER BY clause + // Without ORDER BY clause newSql = fmt.Sprintf( - withoutOrderBySqlTmp, - selectStr, first, limit, + selectWithoutOrderSqlTmp, + "*", // Select all columns + fmt.Sprintf("SELECT %s", selectStr), // Original SELECT + first, // OFFSET + first+limit, // OFFSET + LIMIT ) } - return newSql, nil } diff --git a/contrib/drivers/mssql/mssql_do_filter_test.go b/contrib/drivers/mssql/mssql_do_filter_test.go index 91ded572382..24e2c80e9ed 100644 --- a/contrib/drivers/mssql/mssql_do_filter_test.go +++ b/contrib/drivers/mssql/mssql_do_filter_test.go @@ -54,7 +54,6 @@ func TestDriver_DoFilter(t *testing.T) { } func TestDriver_handleSelectSqlReplacement(t *testing.T) { - gtest.C(t, func(t *gtest.T) { d := &Driver{} @@ -67,7 +66,7 @@ func TestDriver_handleSelectSqlReplacement(t *testing.T) { // LIMIT query with offset and number of rows inputSql = "SELECT * FROM User ORDER BY ID DESC LIMIT 100, 200" - expectedSql = "SELECT * FROM User ORDER BY ID DESC OFFSET 100 ROWS FETCH NEXT 200 ROWS ONLY" + expectedSql = "SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY ID DESC) as ROW_NUMBER__, * FROM (SELECT * FROM User) as InnerQuery ) as TMP_ WHERE TMP_.ROW_NUMBER__ > 100 AND TMP_.ROW_NUMBER__ <= 300" resultSql, err = d.handleSelectSqlReplacement(inputSql) t.AssertNil(err) t.Assert(resultSql, expectedSql) @@ -88,42 +87,42 @@ func TestDriver_handleSelectSqlReplacement(t *testing.T) { // LIMIT query with only rows inputSql = "SELECT * FROM User LIMIT 50" - expectedSql = "SELECT * FROM User OFFSET 0 ROWS FETCH NEXT 50 ROWS ONLY" + expectedSql = "SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) as ROW_NUMBER__, * FROM (SELECT * FROM User) as InnerQuery ) as TMP_ WHERE TMP_.ROW_NUMBER__ > 0 AND TMP_.ROW_NUMBER__ <= 50" resultSql, err = d.handleSelectSqlReplacement(inputSql) t.AssertNil(err) t.Assert(resultSql, expectedSql) // LIMIT query without ORDER BY inputSql = "SELECT * FROM User LIMIT 30" - expectedSql = "SELECT * FROM User OFFSET 0 ROWS FETCH NEXT 30 ROWS ONLY" + expectedSql = "SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) as ROW_NUMBER__, * FROM (SELECT * FROM User) as InnerQuery ) as TMP_ WHERE TMP_.ROW_NUMBER__ > 0 AND TMP_.ROW_NUMBER__ <= 30" resultSql, err = d.handleSelectSqlReplacement(inputSql) t.AssertNil(err) t.Assert(resultSql, expectedSql) // Complex query with ORDER BY and LIMIT inputSql = "SELECT name, age FROM User WHERE age > 18 ORDER BY age ASC LIMIT 10, 5" - expectedSql = "SELECT name, age FROM User WHERE age > 18 ORDER BY age ASC OFFSET 10 ROWS FETCH NEXT 5 ROWS ONLY" + expectedSql = "SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY age ASC) as ROW_NUMBER__, * FROM (SELECT name, age FROM User WHERE age > 18) as InnerQuery ) as TMP_ WHERE TMP_.ROW_NUMBER__ > 10 AND TMP_.ROW_NUMBER__ <= 15" resultSql, err = d.handleSelectSqlReplacement(inputSql) t.AssertNil(err) t.Assert(resultSql, expectedSql) // Complex conditional queries have limits inputSql = "SELECT * FROM User WHERE age > 18 AND status = 'active' LIMIT 100, 50" - expectedSql = "SELECT * FROM User WHERE age > 18 AND status = 'active' OFFSET 100 ROWS FETCH NEXT 50 ROWS ONLY" + expectedSql = "SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) as ROW_NUMBER__, * FROM (SELECT * FROM User WHERE age > 18 AND status = 'active') as InnerQuery ) as TMP_ WHERE TMP_.ROW_NUMBER__ > 100 AND TMP_.ROW_NUMBER__ <= 150" resultSql, err = d.handleSelectSqlReplacement(inputSql) t.AssertNil(err) t.Assert(resultSql, expectedSql) // A LIMIT query that contains subquery inputSql = "SELECT * FROM (SELECT * FROM User WHERE age > 18) AS subquery LIMIT 10" - expectedSql = "SELECT * FROM (SELECT * FROM User WHERE age > 18) AS subquery OFFSET 0 ROWS FETCH NEXT 10 ROWS ONLY" + expectedSql = "SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) as ROW_NUMBER__, * FROM (SELECT * FROM (SELECT * FROM User WHERE age > 18) AS subquery) as InnerQuery ) as TMP_ WHERE TMP_.ROW_NUMBER__ > 0 AND TMP_.ROW_NUMBER__ <= 10" resultSql, err = d.handleSelectSqlReplacement(inputSql) t.AssertNil(err) t.Assert(resultSql, expectedSql) // Queries with complex ORDER BY and LIMIT inputSql = "SELECT name, age FROM User WHERE age > 18 ORDER BY age DESC, name ASC LIMIT 20, 10" - expectedSql = "SELECT name, age FROM User WHERE age > 18 ORDER BY age DESC, name ASC OFFSET 20 ROWS FETCH NEXT 10 ROWS ONLY" + expectedSql = "SELECT * FROM ( SELECT ROW_NUMBER() OVER (ORDER BY age DESC, name ASC) as ROW_NUMBER__, * FROM (SELECT name, age FROM User WHERE age > 18) as InnerQuery ) as TMP_ WHERE TMP_.ROW_NUMBER__ > 20 AND TMP_.ROW_NUMBER__ <= 30" resultSql, err = d.handleSelectSqlReplacement(inputSql) t.AssertNil(err) t.Assert(resultSql, expectedSql) diff --git a/contrib/drivers/mssql/mssql_z_unit_basic_test.go b/contrib/drivers/mssql/mssql_z_unit_basic_test.go index f00e6c84713..7235f0b1653 100644 --- a/contrib/drivers/mssql/mssql_z_unit_basic_test.go +++ b/contrib/drivers/mssql/mssql_z_unit_basic_test.go @@ -42,7 +42,7 @@ func TestTables(t *testing.T) { gtest.AssertEQ(find, true) } - result, err = db.Tables(context.Background(), "test") + result, err = db.Tables(context.Background(), "master") gtest.AssertNil(err) for i := 0; i < len(tables); i++ { find := false @@ -88,7 +88,7 @@ func TestTableFields(t *testing.T) { gtest.AssertEQ(res[k].Comment, v[5]) } - res, err = db.TableFields(context.Background(), "t_user", "test") + res, err = db.TableFields(context.Background(), "t_user", "master") gtest.AssertNil(err) for k, v := range expect { diff --git a/contrib/drivers/mssql/mssql_z_unit_init_test.go b/contrib/drivers/mssql/mssql_z_unit_init_test.go index eec9b76fe68..08e925c5a40 100644 --- a/contrib/drivers/mssql/mssql_z_unit_init_test.go +++ b/contrib/drivers/mssql/mssql_z_unit_init_test.go @@ -25,14 +25,9 @@ var ( ) const ( - TableSize = 10 - TableName = "t_user" - TestSchema1 = "test1" - TestSchema2 = "test2" - TableNamePrefix1 = "gf_" - TestDbUser = "sa" - TestDbPass = "LoremIpsum86" - CreateTime = "2018-10-24 10:00:00" + TableSize = 10 + TestDbUser = "sa" + TestDbPass = "LoremIpsum86" ) func init() { @@ -41,7 +36,7 @@ func init() { Port: "1433", User: TestDbUser, Pass: TestDbPass, - Name: "test", + Name: "master", Type: "mssql", Role: "master", Charset: "utf8", @@ -52,7 +47,7 @@ func init() { nodeLink := gdb.ConfigNode{ Type: "mssql", - Name: "test", + Name: "master", Link: fmt.Sprintf( "mssql:%s:%s@tcp(%s:%s)/%s?encrypt=disable", node.User, node.Pass, node.Host, node.Port, node.Name, diff --git a/contrib/drivers/mssql/mssql_z_unit_model_test.go b/contrib/drivers/mssql/mssql_z_unit_model_test.go index 14d315600ca..6fff5e30f17 100644 --- a/contrib/drivers/mssql/mssql_z_unit_model_test.go +++ b/contrib/drivers/mssql/mssql_z_unit_model_test.go @@ -51,7 +51,6 @@ func Test_Page(t *testing.T) { t.AssertNil(err) gtest.Assert(len(result), 3) }) - } func Test_Model_Insert(t *testing.T) { From 5104f01b69e13e91d8bfbb03308bcf71e200b35e Mon Sep 17 00:00:00 2001 From: John Guo Date: Tue, 17 Dec 2024 09:23:59 +0800 Subject: [PATCH 054/102] chore: update FUNDING.yml (#4049) --- .github/FUNDING.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml index 9f2fabadd41..21f47d90460 100644 --- a/.github/FUNDING.yml +++ b/.github/FUNDING.yml @@ -1,6 +1,6 @@ # These are supported funding model platforms -github: # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] +github: [gogf] # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2] patreon: # Replace with a single Patreon username open_collective: # Replace with a single Open Collective username ko_fi: # Replace with a single Ko-fi username @@ -9,4 +9,4 @@ community_bridge: # Replace with a single Community Bridge project-name e.g., cl liberapay: # Replace with a single Liberapay username issuehunt: # Replace with a single IssueHunt username otechie: # Replace with a single Otechie username -custom: https://github.com/gogf/gf#donators +custom: # custom From 0c2d5cac193498e3ecb91b11d4f24a136a0a7283 Mon Sep 17 00:00:00 2001 From: John Guo Date: Tue, 17 Dec 2024 09:24:13 +0800 Subject: [PATCH 055/102] feat: new version v2.8.3 (#4048) --- .set_version.sh | 6 ++++++ README.MD | 2 +- cmd/gf/go.mod | 30 +++++++++++++-------------- cmd/gf/go.sum | 32 ++++++++++++++--------------- contrib/config/apollo/go.mod | 2 +- contrib/config/consul/go.mod | 2 +- contrib/config/kubecm/go.mod | 2 +- contrib/config/nacos/go.mod | 2 +- contrib/config/polaris/go.mod | 2 +- contrib/drivers/clickhouse/go.mod | 2 +- contrib/drivers/dm/go.mod | 2 +- contrib/drivers/mssql/go.mod | 2 +- contrib/drivers/mysql/go.mod | 2 +- contrib/drivers/oracle/go.mod | 2 +- contrib/drivers/pgsql/go.mod | 2 +- contrib/drivers/sqlite/go.mod | 2 +- contrib/drivers/sqlitecgo/go.mod | 2 +- contrib/metric/otelmetric/go.mod | 2 +- contrib/nosql/redis/go.mod | 2 +- contrib/registry/consul/go.mod | 2 +- contrib/registry/consul/go.sum | 16 ++++++--------- contrib/registry/etcd/go.mod | 2 +- contrib/registry/file/go.mod | 2 +- contrib/registry/nacos/go.mod | 2 +- contrib/registry/polaris/go.mod | 2 +- contrib/registry/zookeeper/go.mod | 2 +- contrib/rpc/grpcx/go.mod | 4 ++-- contrib/sdk/httpclient/go.mod | 2 +- contrib/trace/otlpgrpc/go.mod | 2 +- contrib/trace/otlphttp/go.mod | 2 +- example/go.mod | 34 +++++++++++++++---------------- version.go | 2 +- 32 files changed, 88 insertions(+), 86 deletions(-) diff --git a/.set_version.sh b/.set_version.sh index fc225795b47..ceedac620b1 100755 --- a/.set_version.sh +++ b/.set_version.sh @@ -43,6 +43,12 @@ for file in `find ${workdir} -name go.mod`; do goModPath=$(dirname $file) echo "" echo "processing dir: $goModPath" + + if [[ $goModPath =~ "/testdata/" ]]; then + echo "ignore testdata path $goModPath" + continue 1 + fi + cd $goModPath if [ $goModPath = "./cmd/gf" ]; then mv go.work go.work.version.bak diff --git a/README.MD b/README.MD index d2b5ccdc778..37dc8a5aa81 100644 --- a/README.MD +++ b/README.MD @@ -36,7 +36,7 @@ A powerful framework for faster, easier, and more efficient project development. 💖 [Thanks to all the contributors who made GoFrame possible](https://github.com/gogf/gf/graphs/contributors) 💖 -goframe contributors +goframe contributors # License diff --git a/cmd/gf/go.mod b/cmd/gf/go.mod index 48efa73eee5..e3cd3bd69ad 100644 --- a/cmd/gf/go.mod +++ b/cmd/gf/go.mod @@ -3,13 +3,13 @@ module github.com/gogf/gf/cmd/gf/v2 go 1.20 require ( - github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.8.2 - github.com/gogf/gf/contrib/drivers/mssql/v2 v2.8.2 - github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.2 - github.com/gogf/gf/contrib/drivers/oracle/v2 v2.8.2 - github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.8.2 - github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.8.2 - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.8.3 + github.com/gogf/gf/contrib/drivers/mssql/v2 v2.8.3 + github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.3 + github.com/gogf/gf/contrib/drivers/oracle/v2 v2.8.3 + github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.8.3 + github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.8.3 + github.com/gogf/gf/v2 v2.8.3 github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f github.com/olekukonko/tablewriter v0.0.5 golang.org/x/mod v0.17.0 @@ -23,7 +23,7 @@ require ( github.com/clbanning/mxj/v2 v2.7.0 // indirect github.com/dustin/go-humanize v1.0.1 // 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/glebarez/go-sqlite v1.21.2 // indirect github.com/go-logr/logr v1.4.2 // indirect @@ -35,10 +35,10 @@ require ( github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // indirect github.com/lib/pq v1.10.9 // 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/mattn/go-runewidth v0.0.15 // indirect + github.com/mattn/go-runewidth v0.0.16 // indirect github.com/microsoft/go-mssqldb v1.7.1 // indirect github.com/paulmach/orb v0.7.1 // indirect github.com/pierrec/lz4/v4 v4.1.14 // indirect @@ -50,11 +50,11 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/crypto v0.25.0 // indirect - golang.org/x/net v0.27.0 // indirect - golang.org/x/sync v0.7.0 // indirect - golang.org/x/sys v0.22.0 // indirect - golang.org/x/text v0.16.0 // indirect + golang.org/x/crypto v0.30.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 + golang.org/x/text v0.21.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect modernc.org/libc v1.22.5 // indirect modernc.org/mathutil v1.5.0 // indirect diff --git a/cmd/gf/go.sum b/cmd/gf/go.sum index e66bcfaa11f..38f6eb0b78e 100644 --- a/cmd/gf/go.sum +++ b/cmd/gf/go.sum @@ -22,8 +22,8 @@ github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkp github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= +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/glebarez/go-sqlite v1.21.2 h1:3a6LFC4sKahUunAmynQKLZceZCOzUthkRkEAl9gAXWo= @@ -68,16 +68,16 @@ github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0 github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= -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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= +github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= -github.com/mattn/go-runewidth v0.0.15/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= +github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/microsoft/go-mssqldb v1.7.1 h1:KU/g8aWeM3Hx7IMOFpiwYiUkU+9zeISb4+tx3ScVfsM= github.com/microsoft/go-mssqldb v1.7.1/go.mod h1:kOvZKUdrhhFQmxLZqbwUV0rHkNkZpthMITIb2Ko1IoA= @@ -131,8 +131,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.25.0 h1:ypSNr+bnYL2YhwoMt2zPxHFmbAN1KZs/njMG3hxUp30= -golang.org/x/crypto v0.25.0/go.mod h1:T+wALwcMOSE0kXgUAnPAHqTLW+XHgcELELW8VaDgm/M= +golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= +golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= @@ -141,13 +141,13 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= -golang.org/x/net v0.27.0/go.mod h1:dDi0PyhWNoiUOrAS8uXv/vnScO4wnHQO4mj9fn/RytE= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.7.0 h1:YsImfSBoP9QPYL0xyKJPq0gcaJdG3rInoqxTWbfQu9M= -golang.org/x/sync v0.7.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= +golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= +golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190916202348-b4ddaad3f8a3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -159,13 +159,13 @@ golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= +golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/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 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= +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-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= diff --git a/contrib/config/apollo/go.mod b/contrib/config/apollo/go.mod index ba0f03501cd..5080c2b1489 100644 --- a/contrib/config/apollo/go.mod +++ b/contrib/config/apollo/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/apolloconfig/agollo/v4 v4.3.1 - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 ) require ( diff --git a/contrib/config/consul/go.mod b/contrib/config/consul/go.mod index 814c2a184b7..06fdbe40d4e 100644 --- a/contrib/config/consul/go.mod +++ b/contrib/config/consul/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/consul/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 github.com/hashicorp/consul/api v1.24.0 github.com/hashicorp/go-cleanhttp v0.5.2 ) diff --git a/contrib/config/kubecm/go.mod b/contrib/config/kubecm/go.mod index 8dbbb714453..262b1bf7ebc 100644 --- a/contrib/config/kubecm/go.mod +++ b/contrib/config/kubecm/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/kubecm/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 k8s.io/api v0.27.4 k8s.io/apimachinery v0.27.4 k8s.io/client-go v0.27.4 diff --git a/contrib/config/nacos/go.mod b/contrib/config/nacos/go.mod index 8ed4a55e91c..1af537fd71b 100644 --- a/contrib/config/nacos/go.mod +++ b/contrib/config/nacos/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/nacos/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 github.com/nacos-group/nacos-sdk-go/v2 v2.2.5 ) diff --git a/contrib/config/polaris/go.mod b/contrib/config/polaris/go.mod index 7fc1af50964..b5ab5eab0ac 100644 --- a/contrib/config/polaris/go.mod +++ b/contrib/config/polaris/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/polaris/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 github.com/polarismesh/polaris-go v1.5.8 ) diff --git a/contrib/drivers/clickhouse/go.mod b/contrib/drivers/clickhouse/go.mod index 26c18001d6f..c5b0f724fd0 100644 --- a/contrib/drivers/clickhouse/go.mod +++ b/contrib/drivers/clickhouse/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/ClickHouse/clickhouse-go/v2 v2.0.15 - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 github.com/google/uuid v1.3.0 github.com/shopspring/decimal v1.3.1 ) diff --git a/contrib/drivers/dm/go.mod b/contrib/drivers/dm/go.mod index a47cdb3b25d..ececa192f79 100644 --- a/contrib/drivers/dm/go.mod +++ b/contrib/drivers/dm/go.mod @@ -6,7 +6,7 @@ replace github.com/gogf/gf/v2 => ../../../ require ( gitee.com/chunanyong/dm v1.8.12 - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 ) require ( diff --git a/contrib/drivers/mssql/go.mod b/contrib/drivers/mssql/go.mod index 1443d1f3fad..aff47d8fde9 100644 --- a/contrib/drivers/mssql/go.mod +++ b/contrib/drivers/mssql/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/mssql/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 github.com/microsoft/go-mssqldb v1.7.1 ) diff --git a/contrib/drivers/mysql/go.mod b/contrib/drivers/mysql/go.mod index 954915cd84e..13255823883 100644 --- a/contrib/drivers/mysql/go.mod +++ b/contrib/drivers/mysql/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/go-sql-driver/mysql v1.7.1 - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 ) require ( diff --git a/contrib/drivers/oracle/go.mod b/contrib/drivers/oracle/go.mod index bfb15b404ab..5b782dc93b6 100644 --- a/contrib/drivers/oracle/go.mod +++ b/contrib/drivers/oracle/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/oracle/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 github.com/sijms/go-ora/v2 v2.7.10 ) diff --git a/contrib/drivers/pgsql/go.mod b/contrib/drivers/pgsql/go.mod index 85caf1a36b4..09ed53aba15 100644 --- a/contrib/drivers/pgsql/go.mod +++ b/contrib/drivers/pgsql/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/pgsql/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 github.com/lib/pq v1.10.9 ) diff --git a/contrib/drivers/sqlite/go.mod b/contrib/drivers/sqlite/go.mod index 3f1af171df1..eed458eada6 100644 --- a/contrib/drivers/sqlite/go.mod +++ b/contrib/drivers/sqlite/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/glebarez/go-sqlite v1.21.2 - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 ) require ( diff --git a/contrib/drivers/sqlitecgo/go.mod b/contrib/drivers/sqlitecgo/go.mod index 3ca9029ec7f..1ced67e3432 100644 --- a/contrib/drivers/sqlitecgo/go.mod +++ b/contrib/drivers/sqlitecgo/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/sqlitecgo/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 github.com/mattn/go-sqlite3 v1.14.17 ) diff --git a/contrib/metric/otelmetric/go.mod b/contrib/metric/otelmetric/go.mod index bfe75510e1b..26670ea86fb 100644 --- a/contrib/metric/otelmetric/go.mod +++ b/contrib/metric/otelmetric/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/metric/otelmetric/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 github.com/prometheus/client_golang v1.19.1 go.opentelemetry.io/contrib/instrumentation/runtime v0.49.0 go.opentelemetry.io/otel v1.24.0 diff --git a/contrib/nosql/redis/go.mod b/contrib/nosql/redis/go.mod index 1095c2db9c4..29dc703d832 100644 --- a/contrib/nosql/redis/go.mod +++ b/contrib/nosql/redis/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/nosql/redis/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 github.com/redis/go-redis/v9 v9.7.0 go.opentelemetry.io/otel v1.24.0 go.opentelemetry.io/otel/trace v1.24.0 diff --git a/contrib/registry/consul/go.mod b/contrib/registry/consul/go.mod index 1eea460728f..b110ccf8241 100644 --- a/contrib/registry/consul/go.mod +++ b/contrib/registry/consul/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/consul/v2 go 1.18 require ( - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 github.com/hashicorp/consul/api v1.26.1 ) diff --git a/contrib/registry/consul/go.sum b/contrib/registry/consul/go.sum index 7daa6367c21..caf44ad1f98 100644 --- a/contrib/registry/consul/go.sum +++ b/contrib/registry/consul/go.sum @@ -28,8 +28,7 @@ github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FM github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= 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 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= 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= @@ -104,8 +103,7 @@ github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORN github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= 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 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= 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= @@ -122,7 +120,7 @@ github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27k github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.15 h1:UNAjwbU9l54TA3KzvqLGxwWjHmMgBUVhBiTjelZgg3U= +github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= @@ -195,7 +193,7 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= -golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= @@ -222,16 +220,14 @@ golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= 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 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= 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= 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 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= 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= diff --git a/contrib/registry/etcd/go.mod b/contrib/registry/etcd/go.mod index 016b6e79a2f..50db4fee6dd 100644 --- a/contrib/registry/etcd/go.mod +++ b/contrib/registry/etcd/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/etcd/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 go.etcd.io/etcd/client/v3 v3.5.17 google.golang.org/grpc v1.59.0 ) diff --git a/contrib/registry/file/go.mod b/contrib/registry/file/go.mod index 39263e5c0b8..f26c0572097 100644 --- a/contrib/registry/file/go.mod +++ b/contrib/registry/file/go.mod @@ -2,7 +2,7 @@ module github.com/gogf/gf/contrib/registry/file/v2 go 1.20 -require github.com/gogf/gf/v2 v2.8.2 +require github.com/gogf/gf/v2 v2.8.3 require ( github.com/BurntSushi/toml v1.4.0 // indirect diff --git a/contrib/registry/nacos/go.mod b/contrib/registry/nacos/go.mod index 3fc6ef62c39..ee1b6f4c3b2 100644 --- a/contrib/registry/nacos/go.mod +++ b/contrib/registry/nacos/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/nacos/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 github.com/nacos-group/nacos-sdk-go/v2 v2.2.7 ) diff --git a/contrib/registry/polaris/go.mod b/contrib/registry/polaris/go.mod index 218c63c73a0..dbbc7ba7213 100644 --- a/contrib/registry/polaris/go.mod +++ b/contrib/registry/polaris/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/polaris/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 github.com/polarismesh/polaris-go v1.5.8 ) diff --git a/contrib/registry/zookeeper/go.mod b/contrib/registry/zookeeper/go.mod index 445b4316ac9..6c2a5c0f5e6 100644 --- a/contrib/registry/zookeeper/go.mod +++ b/contrib/registry/zookeeper/go.mod @@ -4,7 +4,7 @@ go 1.20 require ( github.com/go-zookeeper/zk v1.0.3 - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 golang.org/x/sync v0.10.0 ) diff --git a/contrib/rpc/grpcx/go.mod b/contrib/rpc/grpcx/go.mod index d69b902d8b5..465676b0a56 100644 --- a/contrib/rpc/grpcx/go.mod +++ b/contrib/rpc/grpcx/go.mod @@ -3,8 +3,8 @@ module github.com/gogf/gf/contrib/rpc/grpcx/v2 go 1.20 require ( - github.com/gogf/gf/contrib/registry/file/v2 v2.8.2 - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/contrib/registry/file/v2 v2.8.3 + github.com/gogf/gf/v2 v2.8.3 go.opentelemetry.io/otel v1.24.0 go.opentelemetry.io/otel/trace v1.24.0 google.golang.org/grpc v1.64.1 diff --git a/contrib/sdk/httpclient/go.mod b/contrib/sdk/httpclient/go.mod index f69d2864895..be05225fbea 100644 --- a/contrib/sdk/httpclient/go.mod +++ b/contrib/sdk/httpclient/go.mod @@ -2,7 +2,7 @@ module github.com/gogf/gf/contrib/sdk/httpclient/v2 go 1.20 -require github.com/gogf/gf/v2 v2.8.2 +require github.com/gogf/gf/v2 v2.8.3 require ( github.com/BurntSushi/toml v1.4.0 // indirect diff --git a/contrib/trace/otlpgrpc/go.mod b/contrib/trace/otlpgrpc/go.mod index 5d27f8ed3ae..b32e636b26b 100644 --- a/contrib/trace/otlpgrpc/go.mod +++ b/contrib/trace/otlpgrpc/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/trace/otlpgrpc/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 go.opentelemetry.io/otel v1.24.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 diff --git a/contrib/trace/otlphttp/go.mod b/contrib/trace/otlphttp/go.mod index 326999eee8a..25afc8d744a 100644 --- a/contrib/trace/otlphttp/go.mod +++ b/contrib/trace/otlphttp/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/trace/otlphttp/v2 go 1.20 require ( - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/v2 v2.8.3 go.opentelemetry.io/otel v1.24.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 diff --git a/example/go.mod b/example/go.mod index 6c64e21301f..426044591d5 100644 --- a/example/go.mod +++ b/example/go.mod @@ -3,23 +3,23 @@ module github.com/gogf/gf/example go 1.22 require ( - github.com/gogf/gf/contrib/config/apollo/v2 v2.8.2 - github.com/gogf/gf/contrib/config/consul/v2 v2.8.2 - github.com/gogf/gf/contrib/config/kubecm/v2 v2.8.2 - github.com/gogf/gf/contrib/config/nacos/v2 v2.8.2 - github.com/gogf/gf/contrib/config/polaris/v2 v2.8.2 - github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.2 - github.com/gogf/gf/contrib/metric/otelmetric/v2 v2.8.2 - github.com/gogf/gf/contrib/nosql/redis/v2 v2.8.2 - github.com/gogf/gf/contrib/registry/consul/v2 v2.8.2 - github.com/gogf/gf/contrib/registry/etcd/v2 v2.8.2 - github.com/gogf/gf/contrib/registry/file/v2 v2.8.2 - github.com/gogf/gf/contrib/registry/nacos/v2 v2.8.2 - github.com/gogf/gf/contrib/registry/polaris/v2 v2.8.2 - github.com/gogf/gf/contrib/rpc/grpcx/v2 v2.8.2 - github.com/gogf/gf/contrib/trace/otlpgrpc/v2 v2.8.2 - github.com/gogf/gf/contrib/trace/otlphttp/v2 v2.8.2 - github.com/gogf/gf/v2 v2.8.2 + github.com/gogf/gf/contrib/config/apollo/v2 v2.8.3 + github.com/gogf/gf/contrib/config/consul/v2 v2.8.3 + github.com/gogf/gf/contrib/config/kubecm/v2 v2.8.3 + github.com/gogf/gf/contrib/config/nacos/v2 v2.8.3 + github.com/gogf/gf/contrib/config/polaris/v2 v2.8.3 + github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.3 + github.com/gogf/gf/contrib/metric/otelmetric/v2 v2.8.3 + github.com/gogf/gf/contrib/nosql/redis/v2 v2.8.3 + github.com/gogf/gf/contrib/registry/consul/v2 v2.8.3 + github.com/gogf/gf/contrib/registry/etcd/v2 v2.8.3 + github.com/gogf/gf/contrib/registry/file/v2 v2.8.3 + github.com/gogf/gf/contrib/registry/nacos/v2 v2.8.3 + github.com/gogf/gf/contrib/registry/polaris/v2 v2.8.3 + github.com/gogf/gf/contrib/rpc/grpcx/v2 v2.8.3 + github.com/gogf/gf/contrib/trace/otlpgrpc/v2 v2.8.3 + github.com/gogf/gf/contrib/trace/otlphttp/v2 v2.8.3 + github.com/gogf/gf/v2 v2.8.3 github.com/hashicorp/consul/api v1.26.1 github.com/hashicorp/go-cleanhttp v0.5.2 github.com/nacos-group/nacos-sdk-go/v2 v2.2.7 diff --git a/version.go b/version.go index 31fc31ef69c..f27c3be0482 100644 --- a/version.go +++ b/version.go @@ -2,5 +2,5 @@ package gf const ( // VERSION is the current GoFrame version. - VERSION = "v2.8.2" + VERSION = "v2.8.3" ) From f79aef666917b6f78fc6a89ebc68c4a188bf48d2 Mon Sep 17 00:00:00 2001 From: John Guo Date: Tue, 17 Dec 2024 21:15:54 +0800 Subject: [PATCH 056/102] fix(database/gdb): fix context canceled error in transaction due to usage of `TransTimeout` configuration (#4037) --- Makefile | 12 +- cmd/gf/go.sum | 14 ++ .../drivers/mysql/mysql_z_unit_init_test.go | 12 +- .../drivers/mysql/mysql_z_unit_issue_test.go | 34 ++++ contrib/drivers/mysql/testdata/issue4034.sql | 8 + contrib/drivers/pgsql/pgsql_do_exec.go | 6 - database/gdb/gdb.go | 138 +++++++++++++---- database/gdb/gdb_core.go | 1 - database/gdb/gdb_core_config.go | 146 ++++++++++++++---- database/gdb/gdb_core_txcore.go | 33 +++- database/gdb/gdb_core_underlying.go | 22 +-- net/gudp/gudp_z_unit_test.go | 8 - 12 files changed, 327 insertions(+), 107 deletions(-) create mode 100644 contrib/drivers/mysql/testdata/issue4034.sql diff --git a/Makefile b/Makefile index 12b9ce55f29..9d0ee13e91a 100644 --- a/Makefile +++ b/Makefile @@ -1,16 +1,20 @@ SHELL := /bin/bash +# execute "go mod tidy" on all folders that have go.mod file .PHONY: tidy tidy: $(eval files=$(shell find . -name go.mod)) @set -e; \ for file in ${files}; do \ goModPath=$$(dirname $$file); \ - cd $$goModPath; \ - go mod tidy; \ - cd -; \ + if ! echo $$goModPath | grep -q "testdata"; then \ + cd $$goModPath; \ + go mod tidy; \ + cd -; \ + fi \ done +# execute "golangci-lint" to check code style .PHONY: lint lint: golangci-lint run -c .golangci.yml @@ -22,5 +26,3 @@ version: newVersion=$(to); \ ./.set_version.sh ./ $$newVersion; \ echo "make version to=$(to) done" - - diff --git a/cmd/gf/go.sum b/cmd/gf/go.sum index 38f6eb0b78e..1451be4ef79 100644 --- a/cmd/gf/go.sum +++ b/cmd/gf/go.sum @@ -39,6 +39,20 @@ github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiU github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= +github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.8.2 h1:4g5n8QdJA7ZEuDfWFeVQKMhul6RtOT89ObYAgVnxN+U= +github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.8.2/go.mod h1:xW1mgNK0vTLfRSCnO0No8G4lCGNpXx1Jlhs6B1vzD+8= +github.com/gogf/gf/contrib/drivers/mssql/v2 v2.8.2 h1:aNscErx5mcC28Q1L0MsZFFXybzLY/IJhskyiPAbxB78= +github.com/gogf/gf/contrib/drivers/mssql/v2 v2.8.2/go.mod h1:yj6+Ds2BGzYcHthPvMnxhDRzq0o28HyO9E1Fsko0Lf8= +github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.2 h1:thK4DZT0irDrnhIxkap5JqBuBIJaXQ0IMvlIzuRGgVQ= +github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.2/go.mod h1:Vg7XaiwsQ27YmpDqzwCQ+yt10KntTvcP9iOoFL5DF40= +github.com/gogf/gf/contrib/drivers/oracle/v2 v2.8.2 h1:ZukTXB9drVDmSdrFjCYHVzHj0kAvGKISrrW3WKU1xTg= +github.com/gogf/gf/contrib/drivers/oracle/v2 v2.8.2/go.mod h1:wr+KA5h3+aJQk5XiA1qSNKxWBVrzlu8MVYKl1NqcQj4= +github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.8.2 h1:BsEBGoVfa4SPJ8GhNkH9PPtoSLydXK+VgcbpxyGF9Ps= +github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.8.2/go.mod h1:OSlAQeO7fZMbscxZomMCBcZWHSxpfeXIi6ELeKszSPU= +github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.8.2 h1:144IdPDn6xyHVQ5aP4qsstFvNOLqvWyz+GtH3JD1rWg= +github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.8.2/go.mod h1:xOgOp3SSdWHIEqviYC1kd3p6mJtfFkrcinBWdpgVUxc= +github.com/gogf/gf/v2 v2.8.2 h1:4k641rn+hV1COAKygqsqcTm8+lDTkcO8HQ4iBv/uTFs= +github.com/gogf/gf/v2 v2.8.2/go.mod h1:n++xPYGUUMadw6IygLEgGZqc6y6DRLrJKg5kqCrPLWY= github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f h1:7xfXR/BhG3JDqO1s45n65Oyx9t4E/UqDOXep6jXdLCM= github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f/go.mod h1:HnYoio6S7VaFJdryKcD/r9HgX+4QzYfr00XiXUo/xz0= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= diff --git a/contrib/drivers/mysql/mysql_z_unit_init_test.go b/contrib/drivers/mysql/mysql_z_unit_init_test.go index f0621741c7b..3c0f2f76201 100644 --- a/contrib/drivers/mysql/mysql_z_unit_init_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_init_test.go @@ -44,18 +44,22 @@ func init() { nodeDefault := gdb.ConfigNode{ ExecTimeout: time.Second * 2, Link: fmt.Sprintf("mysql:root:%s@tcp(127.0.0.1:3306)/?loc=Local&parseTime=true", TestDbPass), + TranTimeout: time.Second * 3, } partitionDefault := gdb.ConfigNode{ - Link: fmt.Sprintf("mysql:root:%s@tcp(127.0.0.1:3307)/?loc=Local&parseTime=true", TestDbPass), - Debug: true, + Link: fmt.Sprintf("mysql:root:%s@tcp(127.0.0.1:3307)/?loc=Local&parseTime=true", TestDbPass), + Debug: true, + TranTimeout: time.Second * 3, } nodePrefix := gdb.ConfigNode{ - Link: fmt.Sprintf("mysql:root:%s@tcp(127.0.0.1:3306)/?loc=Local&parseTime=true", TestDbPass), + Link: fmt.Sprintf("mysql:root:%s@tcp(127.0.0.1:3306)/?loc=Local&parseTime=true", TestDbPass), + TranTimeout: time.Second * 3, } nodePrefix.Prefix = TableNamePrefix1 nodeInvalid := gdb.ConfigNode{ - Link: fmt.Sprintf("mysql:root:%s@tcp(127.0.0.1:3307)/?loc=Local&parseTime=true", TestDbPass), + Link: fmt.Sprintf("mysql:root:%s@tcp(127.0.0.1:3307)/?loc=Local&parseTime=true", TestDbPass), + TranTimeout: time.Second * 3, } gdb.AddConfigNode("test", nodeDefault) gdb.AddConfigNode("prefix", nodePrefix) diff --git a/contrib/drivers/mysql/mysql_z_unit_issue_test.go b/contrib/drivers/mysql/mysql_z_unit_issue_test.go index 04a24bc194a..af4e43b29e1 100644 --- a/contrib/drivers/mysql/mysql_z_unit_issue_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_issue_test.go @@ -1556,3 +1556,37 @@ func Test_Issue2119(t *testing.T) { } }) } + +// https://github.com/gogf/gf/issues/4034 +func Test_Issue4034(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + table := "issue4034" + array := gstr.SplitAndTrim(gtest.DataContent(`issue4034.sql`), ";") + for _, v := range array { + _, err := db.Exec(ctx, v) + t.AssertNil(err) + } + defer dropTable(table) + + err := issue4034SaveDeviceAndToken(ctx, table) + t.AssertNil(err) + }) +} + +func issue4034SaveDeviceAndToken(ctx context.Context, table string) error { + return db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + if err := issue4034SaveAppDevice(ctx, table, tx); err != nil { + return err + } + return nil + }) +} + +func issue4034SaveAppDevice(ctx context.Context, table string, tx gdb.TX) error { + _, err := db.Model(table).Safe().Ctx(ctx).TX(tx).Data(g.Map{ + "passport": "111", + "password": "222", + "nickname": "333", + }).Save() + return err +} diff --git a/contrib/drivers/mysql/testdata/issue4034.sql b/contrib/drivers/mysql/testdata/issue4034.sql new file mode 100644 index 00000000000..abb99cedc22 --- /dev/null +++ b/contrib/drivers/mysql/testdata/issue4034.sql @@ -0,0 +1,8 @@ +CREATE TABLE issue4034 ( + id INT PRIMARY KEY AUTO_INCREMENT, + passport VARCHAR(255), + password VARCHAR(255), + nickname VARCHAR(255), + created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP, + updated_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP +); \ No newline at end of file diff --git a/contrib/drivers/pgsql/pgsql_do_exec.go b/contrib/drivers/pgsql/pgsql_do_exec.go index ca3f3a86e3b..a44721752b0 100644 --- a/contrib/drivers/pgsql/pgsql_do_exec.go +++ b/contrib/drivers/pgsql/pgsql_do_exec.go @@ -64,12 +64,6 @@ func (d *Driver) DoExec(ctx context.Context, link gdb.Link, sql string, args ... // Only the insert operation with primary key can execute the following code - if d.GetConfig().ExecTimeout > 0 { - var cancelFunc context.CancelFunc - ctx, cancelFunc = context.WithTimeout(ctx, d.GetConfig().ExecTimeout) - defer cancelFunc() - } - // Sql filtering. sql, args = d.FormatSqlBeforeExecuting(sql, args) sql, args, err = d.DoFilter(ctx, link, sql, args) diff --git a/database/gdb/gdb.go b/database/gdb/gdb.go index da52e75267c..de3cdf3d369 100644 --- a/database/gdb/gdb.go +++ b/database/gdb/gdb.go @@ -528,24 +528,53 @@ type dynamicConfig struct { // DoCommitInput is the input parameters for function DoCommit. type DoCommitInput struct { - Db *sql.DB - Tx *sql.Tx - Stmt *sql.Stmt - Link Link - Sql string - Args []interface{} - Type SqlType - TxOptions sql.TxOptions + // Db is the underlying database connection object. + Db *sql.DB + + // Tx is the underlying transaction object. + Tx *sql.Tx + + // Stmt is the prepared statement object. + Stmt *sql.Stmt + + // Link is the common database function wrapper interface. + Link Link + + // Sql is the SQL string to be executed. + Sql string + + // Args is the arguments for SQL placeholders. + Args []interface{} + + // Type indicates the type of SQL operation. + Type SqlType + + // TxOptions specifies the transaction options. + TxOptions sql.TxOptions + + // TxCancelFunc is the context cancel function for transaction. + TxCancelFunc context.CancelFunc + + // IsTransaction indicates whether current operation is in transaction. IsTransaction bool } // DoCommitOutput is the output parameters for function DoCommit. type DoCommitOutput struct { - Result sql.Result // Result is the result of exec statement. - Records []Record // Records is the result of query statement. - Stmt *Stmt // Stmt is the Statement object result for Prepare. - Tx TX // Tx is the transaction object result for Begin. - RawResult interface{} // RawResult is the underlying result, which might be sql.Result/*sql.Rows/*sql.Row. + // Result is the result of exec statement. + Result sql.Result + + // Records is the result of query statement. + Records []Record + + // Stmt is the Statement object result for Prepare. + Stmt *Stmt + + // Tx is the transaction object result for Begin. + Tx TX + + // RawResult is the underlying result, which might be sql.Result/*sql.Rows/*sql.Row. + RawResult interface{} } // Driver is the interface for integrating sql drivers into package gdb. @@ -581,43 +610,84 @@ type Sql struct { // DoInsertOption is the input struct for function DoInsert. type DoInsertOption struct { - OnDuplicateStr string // Custom string for `on duplicated` statement. - OnDuplicateMap map[string]interface{} // Custom key-value map from `OnDuplicateEx` function for `on duplicated` statement. - OnConflict []string // Custom conflict key of upsert clause, if the database needs it. - InsertOption InsertOption // Insert operation in constant value. - BatchCount int // Batch count for batch inserting. + // OnDuplicateStr is the custom string for `on duplicated` statement. + OnDuplicateStr string + + // OnDuplicateMap is the custom key-value map from `OnDuplicateEx` function for `on duplicated` statement. + OnDuplicateMap map[string]interface{} + + // OnConflict is the custom conflict key of upsert clause, if the database needs it. + OnConflict []string + + // InsertOption is the insert operation in constant value. + InsertOption InsertOption + + // BatchCount is the batch count for batch inserting. + BatchCount int } // TableField is the struct for table field. type TableField struct { - Index int // For ordering purpose as map is unordered. - Name string // Field name. - Type string // Field type. Eg: 'int(10) unsigned', 'varchar(64)'. - Null bool // Field can be null or not. - Key string // The index information(empty if it's not an index). Eg: PRI, MUL. - Default interface{} // Default value for the field. - Extra string // Extra information. Eg: auto_increment. - Comment string // Field comment. + // Index is for ordering purpose as map is unordered. + Index int + + // Name is the field name. + Name string + + // Type is the field type. Eg: 'int(10) unsigned', 'varchar(64)'. + Type string + + // Null is whether the field can be null or not. + Null bool + + // Key is the index information(empty if it's not an index). Eg: PRI, MUL. + Key string + + // Default is the default value for the field. + Default interface{} + + // Extra is the extra information. Eg: auto_increment. + Extra string + + // Comment is the field comment. + Comment string } -// Counter is the type for update count. +// Counter is the type for update count. type Counter struct { + // Field is the field name. Field string + + // Value is the value. Value float64 } type ( - Raw string // Raw is a raw sql that will not be treated as argument but as a direct sql part. - Value = *gvar.Var // Value is the field value type. - Record map[string]Value // Record is the row record of the table. - Result []Record // Result is the row record array. - Map = map[string]interface{} // Map is alias of map[string]interface{}, which is the most common usage map type. - List = []Map // List is type of map array. + // Raw is a raw sql that will not be treated as argument but as a direct sql part. + Raw string + + // Value is the field value type. + Value = *gvar.Var + + // Record is the row record of the table. + Record map[string]Value + + // Result is the row record array. + Result []Record + + // Map is alias of map[string]interface{}, which is the most common usage map type. + Map = map[string]interface{} + + // List is type of map array. + List = []Map ) type CatchSQLManager struct { + // SQLArray is the array of sql. SQLArray *garray.StrArray - DoCommit bool // DoCommit marks it will be committed to underlying driver or not. + + // DoCommit marks it will be committed to underlying driver or not. + DoCommit bool } const ( diff --git a/database/gdb/gdb_core.go b/database/gdb/gdb_core.go index f75ff878f37..50971611258 100644 --- a/database/gdb/gdb_core.go +++ b/database/gdb/gdb_core.go @@ -92,7 +92,6 @@ func (c *Core) GetCtxTimeout(ctx context.Context, timeoutType ctxTimeoutType) (c if c.db.GetConfig().PrepareTimeout > 0 { return context.WithTimeout(ctx, config.PrepareTimeout) } - case ctxTimeoutTypeTrans: if c.db.GetConfig().TranTimeout > 0 { return context.WithTimeout(ctx, config.TranTimeout) diff --git a/database/gdb/gdb_core_config.go b/database/gdb/gdb_core_config.go index 291ade99544..3a15024b42c 100644 --- a/database/gdb/gdb_core_config.go +++ b/database/gdb/gdb_core_config.go @@ -27,36 +27,126 @@ type ConfigGroup []ConfigNode // ConfigNode is configuration for one node. type ConfigNode struct { - Host string `json:"host"` // Host of server, ip or domain like: 127.0.0.1, localhost - Port string `json:"port"` // Port, it's commonly 3306. - User string `json:"user"` // Authentication username. - Pass string `json:"pass"` // Authentication password. - Name string `json:"name"` // Default used database name. - Type string `json:"type"` // Database type: mysql, mariadb, sqlite, mssql, pgsql, oracle, clickhouse, dm. - Link string `json:"link"` // (Optional) Custom link information for all configuration in one single string. - Extra string `json:"extra"` // (Optional) Extra configuration according the registered third-party database driver. - Role string `json:"role"` // (Optional, "master" in default) Node role, used for master-slave mode: master, slave. - Debug bool `json:"debug"` // (Optional) Debug mode enables debug information logging and output. - Prefix string `json:"prefix"` // (Optional) Table prefix. - DryRun bool `json:"dryRun"` // (Optional) Dry run, which does SELECT but no INSERT/UPDATE/DELETE statements. - Weight int `json:"weight"` // (Optional) Weight for load balance calculating, it's useless if there's just one node. - Charset string `json:"charset"` // (Optional, "utf8" in default) Custom charset when operating on database. - Protocol string `json:"protocol"` // (Optional, "tcp" in default) See net.Dial for more information which networks are available. - Timezone string `json:"timezone"` // (Optional) Sets the time zone for displaying and interpreting time stamps. - Namespace string `json:"namespace"` // (Optional) Namespace for some databases. Eg, in pgsql, the `Name` acts as the `catalog`, the `NameSpace` acts as the `schema`. - MaxIdleConnCount int `json:"maxIdle"` // (Optional) Max idle connection configuration for underlying connection pool. - MaxOpenConnCount int `json:"maxOpen"` // (Optional) Max open connection configuration for underlying connection pool. - MaxConnLifeTime time.Duration `json:"maxLifeTime"` // (Optional) Max amount of time a connection may be idle before being closed. - QueryTimeout time.Duration `json:"queryTimeout"` // (Optional) Max query time for per dql. - ExecTimeout time.Duration `json:"execTimeout"` // (Optional) Max exec time for dml. - TranTimeout time.Duration `json:"tranTimeout"` // (Optional) Max exec time for a transaction. - PrepareTimeout time.Duration `json:"prepareTimeout"` // (Optional) Max exec time for prepare operation. - CreatedAt string `json:"createdAt"` // (Optional) The field name of table for automatic-filled created datetime. - UpdatedAt string `json:"updatedAt"` // (Optional) The field name of table for automatic-filled updated datetime. - DeletedAt string `json:"deletedAt"` // (Optional) The field name of table for automatic-filled updated datetime. - TimeMaintainDisabled bool `json:"timeMaintainDisabled"` // (Optional) Disable the automatic time maintaining feature. + // Host specifies the server address, can be either IP address or domain name + // Example: "127.0.0.1", "localhost" + Host string `json:"host"` + + // Port specifies the server port number + // Default is typically "3306" for MySQL + Port string `json:"port"` + + // User specifies the authentication username for database connection + User string `json:"user"` + + // Pass specifies the authentication password for database connection + Pass string `json:"pass"` + + // Name specifies the default database name to be used + Name string `json:"name"` + + // Type specifies the database type + // Example: mysql, mariadb, sqlite, mssql, pgsql, oracle, clickhouse, dm. + Type string `json:"type"` + + // Link provides custom connection string that combines all configuration in one string + // Optional field + Link string `json:"link"` + + // Extra provides additional configuration options for third-party database drivers + // Optional field + Extra string `json:"extra"` + + // Role specifies the node role in master-slave setup + // Optional field, defaults to "master" + // Available values: "master", "slave" + Role Role `json:"role"` + + // Debug enables debug mode for logging and output + // Optional field + Debug bool `json:"debug"` + + // Prefix specifies the table name prefix + // Optional field + Prefix string `json:"prefix"` + + // DryRun enables simulation mode where SELECT statements are executed + // but INSERT/UPDATE/DELETE statements are not + // Optional field + DryRun bool `json:"dryRun"` + + // Weight specifies the node weight for load balancing calculations + // Optional field, only effective in multi-node setups + Weight int `json:"weight"` + + // Charset specifies the character set for database operations + // Optional field, defaults to "utf8" + Charset string `json:"charset"` + + // Protocol specifies the network protocol for database connection + // Optional field, defaults to "tcp" + // See net.Dial for available network protocols + Protocol string `json:"protocol"` + + // Timezone sets the time zone for timestamp interpretation and display + // Optional field + Timezone string `json:"timezone"` + + // Namespace specifies the schema namespace for certain databases + // Optional field, e.g., in PostgreSQL, Name is the catalog and Namespace is the schema + Namespace string `json:"namespace"` + + // MaxIdleConnCount specifies the maximum number of idle connections in the pool + // Optional field + MaxIdleConnCount int `json:"maxIdle"` + + // MaxOpenConnCount specifies the maximum number of open connections in the pool + // Optional field + MaxOpenConnCount int `json:"maxOpen"` + + // MaxConnLifeTime specifies the maximum lifetime of a connection + // Optional field + MaxConnLifeTime time.Duration `json:"maxLifeTime"` + + // QueryTimeout specifies the maximum execution time for DQL operations + // Optional field + QueryTimeout time.Duration `json:"queryTimeout"` + + // ExecTimeout specifies the maximum execution time for DML operations + // Optional field + ExecTimeout time.Duration `json:"execTimeout"` + + // TranTimeout specifies the maximum execution time for a transaction block + // Optional field + TranTimeout time.Duration `json:"tranTimeout"` + + // PrepareTimeout specifies the maximum execution time for prepare operations + // Optional field + PrepareTimeout time.Duration `json:"prepareTimeout"` + + // CreatedAt specifies the field name for automatic timestamp on record creation + // Optional field + CreatedAt string `json:"createdAt"` + + // UpdatedAt specifies the field name for automatic timestamp on record updates + // Optional field + UpdatedAt string `json:"updatedAt"` + + // DeletedAt specifies the field name for automatic timestamp on record deletion + // Optional field + DeletedAt string `json:"deletedAt"` + + // TimeMaintainDisabled controls whether automatic time maintenance is disabled + // Optional field + TimeMaintainDisabled bool `json:"timeMaintainDisabled"` } +type Role string + +const ( + RoleMaster Role = "master" + RoleSlave Role = "slave" +) + const ( DefaultGroupName = "default" // Default group name. ) diff --git a/database/gdb/gdb_core_txcore.go b/database/gdb/gdb_core_txcore.go index 187ea27cdd9..79154068f13 100644 --- a/database/gdb/gdb_core_txcore.go +++ b/database/gdb/gdb_core_txcore.go @@ -20,13 +20,30 @@ import ( // TXCore is the struct for transaction management. type TXCore struct { - db DB // db is the current gdb database manager. - tx *sql.Tx // tx is the raw and underlying transaction manager. - ctx context.Context // ctx is the context for this transaction only. - master *sql.DB // master is the raw and underlying database manager. - transactionId string // transactionId is a unique id generated by this object for this transaction. - transactionCount int // transactionCount marks the times that Begins. - isClosed bool // isClosed marks this transaction has already been committed or rolled back. + // db is the database management interface that implements the DB interface, + // providing access to database operations and configuration. + db DB + // tx is the underlying SQL transaction object from database/sql package, + // which manages the actual transaction operations. + tx *sql.Tx + // ctx is the context specific to this transaction, + // which can be used for timeout control and cancellation. + ctx context.Context + // master is the underlying master database connection pool, + // used for direct database operations when needed. + master *sql.DB + // transactionId is a unique identifier for this transaction instance, + // used for tracking and debugging purposes. + transactionId string + // transactionCount tracks the number of nested transaction begins, + // used for managing transaction nesting depth. + transactionCount int + // isClosed indicates whether this transaction has been finalized + // through either a commit or rollback operation. + isClosed bool + // cancelFunc is the context cancellation function associated with ctx, + // used to cancel the transaction context when needed. + cancelFunc context.CancelFunc } // transactionKeyForNestedPoint forms and returns the transaction key at current save point. @@ -73,6 +90,7 @@ func (tx *TXCore) Commit() error { Tx: tx.tx, Sql: "COMMIT", Type: SqlTypeTXCommit, + TxCancelFunc: tx.cancelFunc, IsTransaction: true, }) if err == nil { @@ -94,6 +112,7 @@ func (tx *TXCore) Rollback() error { Tx: tx.tx, Sql: "ROLLBACK", Type: SqlTypeTXRollback, + TxCancelFunc: tx.cancelFunc, IsTransaction: true, }) if err == nil { diff --git a/database/gdb/gdb_core_underlying.go b/database/gdb/gdb_core_underlying.go index d8c1171ca58..045d11c65af 100644 --- a/database/gdb/gdb_core_underlying.go +++ b/database/gdb/gdb_core_underlying.go @@ -51,12 +51,6 @@ func (c *Core) DoQuery(ctx context.Context, link Link, sql string, args ...inter } } - if c.db.GetConfig().QueryTimeout > 0 { - var cancelFunc context.CancelFunc - ctx, cancelFunc = context.WithTimeout(ctx, c.db.GetConfig().QueryTimeout) - defer cancelFunc() - } - // Sql filtering. sql, args = c.FormatSqlBeforeExecuting(sql, args) sql, args, err = c.db.DoFilter(ctx, link, sql, args) @@ -115,12 +109,6 @@ func (c *Core) DoExec(ctx context.Context, link Link, sql string, args ...interf } } - if c.db.GetConfig().ExecTimeout > 0 { - var cancelFunc context.CancelFunc - ctx, cancelFunc = context.WithTimeout(ctx, c.db.GetConfig().ExecTimeout) - defer cancelFunc() - } - // SQL filtering. sql, args = c.FormatSqlBeforeExecuting(sql, args) sql, args, err = c.db.DoFilter(ctx, link, sql, args) @@ -183,11 +171,10 @@ func (c *Core) DoCommit(ctx context.Context, in DoCommitInput) (out DoCommitOutp ctx, span := tr.Start(ctx, string(in.Type), trace.WithSpanKind(trace.SpanKindInternal)) defer span.End() - // Execution cased by type. + // Execution by type. switch in.Type { case SqlTypeBegin: ctx, cancelFuncForTimeout = c.GetCtxTimeout(ctx, ctxTimeoutTypeTrans) - defer cancelFuncForTimeout() formattedSql = fmt.Sprintf( `%s (IosolationLevel: %s, ReadOnly: %t)`, formattedSql, in.TxOptions.Isolation.String(), in.TxOptions.ReadOnly, @@ -199,15 +186,22 @@ func (c *Core) DoCommit(ctx context.Context, in DoCommitInput) (out DoCommitOutp ctx: context.WithValue(ctx, transactionIdForLoggerCtx, transactionIdGenerator.Add(1)), master: in.Db, transactionId: guid.S(), + cancelFunc: cancelFuncForTimeout, } ctx = out.Tx.GetCtx() } out.RawResult = sqlTx case SqlTypeTXCommit: + if in.TxCancelFunc != nil { + defer in.TxCancelFunc() + } err = in.Tx.Commit() case SqlTypeTXRollback: + if in.TxCancelFunc != nil { + defer in.TxCancelFunc() + } err = in.Tx.Rollback() case SqlTypeExecContext: diff --git a/net/gudp/gudp_z_unit_test.go b/net/gudp/gudp_z_unit_test.go index 505d59e115a..55404a976da 100644 --- a/net/gudp/gudp_z_unit_test.go +++ b/net/gudp/gudp_z_unit_test.go @@ -99,14 +99,6 @@ func Test_Basic(t *testing.T) { t.AssertNil(err) } }) - // gudp.SendRecv - gtest.C(t, func(t *gtest.T) { - for i := 0; i < 100; i++ { - result, err := gudp.SendRecv(s.GetListenedAddress(), []byte(gconv.String(i)), -1) - t.AssertNil(err) - t.Assert(string(result), fmt.Sprintf(`> %d`, i)) - } - }) } // If the read buffer size is less than the sent package size, From e7fdf82dd8117a972b5953c1346b448b60154a94 Mon Sep 17 00:00:00 2001 From: oldme <45782393+oldme-git@users.noreply.github.com> Date: Tue, 17 Dec 2024 21:17:27 +0800 Subject: [PATCH 057/102] test(net/gipv4): add unit tests (#4052) --- net/gipv4/gipv4.go | 30 ++++++---- net/gipv4/gipv4_ip.go | 9 +-- net/gipv4/gipv4_z_unit_ip_test.go | 81 +++++++++++++++++++++++++++ net/gipv4/gipv4_z_unit_lookup_test.go | 30 ++++++++++ net/gipv4/gipv4_z_unit_mac_test.go | 36 ++++++++++++ net/gipv4/gipv4_z_unit_test.go | 81 +++++++++++++++++++++++++++ 6 files changed, 251 insertions(+), 16 deletions(-) create mode 100644 net/gipv4/gipv4_z_unit_ip_test.go create mode 100644 net/gipv4/gipv4_z_unit_lookup_test.go create mode 100644 net/gipv4/gipv4_z_unit_mac_test.go create mode 100644 net/gipv4/gipv4_z_unit_test.go diff --git a/net/gipv4/gipv4.go b/net/gipv4/gipv4.go index df0c3d6dd6e..c4e7ac8697c 100644 --- a/net/gipv4/gipv4.go +++ b/net/gipv4/gipv4.go @@ -10,34 +10,40 @@ package gipv4 import ( - "fmt" + "net" "strconv" - - "github.com/gogf/gf/v2/text/gregex" + "strings" ) // Validate checks whether given `ip` a valid IPv4 address. func Validate(ip string) bool { - return gregex.IsMatchString(`^((25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(25[0-5]|2[0-4]\d|[01]?\d\d?)$`, ip) + parsed := net.ParseIP(ip) + return parsed != nil && parsed.To4() != nil } // ParseAddress parses `address` to its ip and port. // Eg: 192.168.1.1:80 -> 192.168.1.1, 80 func ParseAddress(address string) (string, int) { - match, err := gregex.MatchString(`^(.+):(\d+)$`, address) - if err == nil { - i, _ := strconv.Atoi(match[2]) - return match[1], i + host, port, err := net.SplitHostPort(address) + if err != nil { + return "", 0 + } + portInt, err := strconv.Atoi(port) + if err != nil { + return "", 0 } - return "", 0 + return host, portInt } // GetSegment returns the segment of given ip address. // Eg: 192.168.2.102 -> 192.168.2 func GetSegment(ip string) string { - match, err := gregex.MatchString(`^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$`, ip) - if err != nil || len(match) < 4 { + if !Validate(ip) { + return "" + } + segments := strings.Split(ip, ".") + if len(segments) != 4 { return "" } - return fmt.Sprintf("%s.%s.%s", match[1], match[2], match[3]) + return strings.Join(segments[:3], ".") } diff --git a/net/gipv4/gipv4_ip.go b/net/gipv4/gipv4_ip.go index 95bdb8481a6..7dda6b9265b 100644 --- a/net/gipv4/gipv4_ip.go +++ b/net/gipv4/gipv4_ip.go @@ -24,10 +24,11 @@ func GetIpArray() (ips []string, err error) { } for _, address := range interfaceAddr { ipNet, isValidIpNet := address.(*net.IPNet) - if isValidIpNet && !ipNet.IP.IsLoopback() { - if ipNet.IP.To4() != nil { - ips = append(ips, ipNet.IP.String()) - } + if !(isValidIpNet && !ipNet.IP.IsLoopback()) { + continue + } + if ipNet.IP.To4() != nil { + ips = append(ips, ipNet.IP.String()) } } return ips, nil diff --git a/net/gipv4/gipv4_z_unit_ip_test.go b/net/gipv4/gipv4_z_unit_ip_test.go new file mode 100644 index 00000000000..38849be07fc --- /dev/null +++ b/net/gipv4/gipv4_z_unit_ip_test.go @@ -0,0 +1,81 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package gipv4_test + +import ( + "testing" + + "github.com/gogf/gf/v2/net/gipv4" + "github.com/gogf/gf/v2/test/gtest" +) + +func TestGetIpArray(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + ips, err := gipv4.GetIpArray() + t.AssertNil(err) + t.AssertGT(len(ips), 0) + for _, ip := range ips { + t.Assert(gipv4.Validate(ip), true) + } + }) +} + +func TestMustGetIntranetIp(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + defer func() { + if r := recover(); r != nil { + t.Errorf("MustGetIntranetIp() panicked: %v", r) + } + }() + ip := gipv4.MustGetIntranetIp() + t.Assert(gipv4.IsIntranet(ip), true) + }) +} + +func TestGetIntranetIp(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + ip, err := gipv4.GetIntranetIp() + t.AssertNil(err) + t.AssertNE(ip, "") + t.Assert(gipv4.IsIntranet(ip), true) + }) +} + +func TestGetIntranetIpArray(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + ips, err := gipv4.GetIntranetIpArray() + t.AssertNil(err) + t.AssertGT(len(ips), 0) + for _, ip := range ips { + t.Assert(gipv4.IsIntranet(ip), true) + } + }) +} + +func TestIsIntranet(t *testing.T) { + tests := []struct { + ip string + expected bool + }{ + {"127.0.0.1", true}, + {"10.0.0.1", true}, + {"172.16.0.1", true}, + {"172.31.255.255", true}, + {"192.168.0.1", true}, + {"192.168.255.255", true}, + {"8.8.8.8", false}, + {"172.32.0.1", false}, + {"256.256.256.256", false}, + } + + gtest.C(t, func(t *gtest.T) { + for _, test := range tests { + result := gipv4.IsIntranet(test.ip) + t.Assert(result, test.expected) + } + }) +} diff --git a/net/gipv4/gipv4_z_unit_lookup_test.go b/net/gipv4/gipv4_z_unit_lookup_test.go new file mode 100644 index 00000000000..d0a3e745db9 --- /dev/null +++ b/net/gipv4/gipv4_z_unit_lookup_test.go @@ -0,0 +1,30 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package gipv4_test + +import ( + "testing" + + "github.com/gogf/gf/v2/net/gipv4" + "github.com/gogf/gf/v2/test/gtest" +) + +func TestGetHostByName(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + ip, err := gipv4.GetHostByName("localhost") + t.AssertNil(err) + t.Assert(ip, "127.0.0.1") + }) +} + +func TestGetHostsByName(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + ips, err := gipv4.GetHostsByName("localhost") + t.AssertNil(err) + t.AssertIN("127.0.0.1", ips) + }) +} diff --git a/net/gipv4/gipv4_z_unit_mac_test.go b/net/gipv4/gipv4_z_unit_mac_test.go new file mode 100644 index 00000000000..6236cf9f81a --- /dev/null +++ b/net/gipv4/gipv4_z_unit_mac_test.go @@ -0,0 +1,36 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package gipv4_test + +import ( + "testing" + + "github.com/gogf/gf/v2/net/gipv4" + "github.com/gogf/gf/v2/test/gtest" +) + +func TestGetMac(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + mac, err := gipv4.GetMac() + t.AssertNil(err) + t.AssertNE(mac, "") + // MAC addresses are typically 17 characters in length + t.Assert(len(mac), 17) + }) +} + +func TestGetMacArray(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + macs, err := gipv4.GetMacArray() + t.AssertNil(err) + t.AssertGT(len(macs), 0) + for _, mac := range macs { + // MAC addresses are typically 17 characters in length + t.Assert(len(mac), 17) + } + }) +} diff --git a/net/gipv4/gipv4_z_unit_test.go b/net/gipv4/gipv4_z_unit_test.go new file mode 100644 index 00000000000..580e2d4e0fd --- /dev/null +++ b/net/gipv4/gipv4_z_unit_test.go @@ -0,0 +1,81 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package gipv4_test + +import ( + "testing" + + "github.com/gogf/gf/v2/net/gipv4" + "github.com/gogf/gf/v2/test/gtest" +) + +func TestValidate(t *testing.T) { + tests := []struct { + ip string + expected bool + }{ + {"192.168.1.1", true}, + {"255.255.255.255", true}, + {"0.0.0.0", true}, + {"256.256.256.256", false}, + {"192.168.1", false}, + {"abc.def.ghi.jkl", false}, + {"19216811", false}, + {"abcdefghijkl", false}, + } + + gtest.C(t, func(t *gtest.T) { + for _, test := range tests { + result := gipv4.Validate(test.ip) + t.Assert(result, test.expected) + } + }) +} + +func TestParseAddress(t *testing.T) { + tests := []struct { + address string + expectedIP string + expectedPort int + }{ + {"192.168.1.1:80", "192.168.1.1", 80}, + {"10.0.0.1:8080", "10.0.0.1", 8080}, + {"127.0.0.1:65535", "127.0.0.1", 65535}, + {"invalid:address", "", 0}, + {"192.168.1.1", "", 0}, + {"19216811", "", 0}, + } + + gtest.C(t, func(t *gtest.T) { + for _, test := range tests { + ip, port := gipv4.ParseAddress(test.address) + t.Assert(ip, test.expectedIP) + t.Assert(port, test.expectedPort) + } + }) +} + +func TestGetSegment(t *testing.T) { + tests := []struct { + ip string + expected string + }{ + {"192.168.2.102", "192.168.2"}, + {"10.0.0.1", "10.0.0"}, + {"255.255.255.255", "255.255.255"}, + {"invalid.ip.address", ""}, + {"123", ""}, + {"192.168.2.102.123", ""}, + } + + gtest.C(t, func(t *gtest.T) { + for _, test := range tests { + result := gipv4.GetSegment(test.ip) + t.Assert(result, test.expected) + } + }) +} From 67a9db9e3e5a57039371cbb49bbb73a8ac248193 Mon Sep 17 00:00:00 2001 From: ninjashixuan <37137471+ninjashixuan@users.noreply.github.com> Date: Tue, 17 Dec 2024 21:45:38 +0800 Subject: [PATCH 058/102] perf(contrib/drivers/pgsql): improve conversion performace for slice string (#4046) --- contrib/drivers/pgsql/pgsql_convert.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/drivers/pgsql/pgsql_convert.go b/contrib/drivers/pgsql/pgsql_convert.go index a657bee7647..d2652d307c8 100644 --- a/contrib/drivers/pgsql/pgsql_convert.go +++ b/contrib/drivers/pgsql/pgsql_convert.go @@ -128,7 +128,7 @@ func (d *Driver) ConvertValueForLocal(ctx context.Context, fieldType string, fie if err := result.Scan(fieldValue); err != nil { return nil, err } - return result, nil + return []string(result), nil default: return d.Core.ConvertValueForLocal(ctx, fieldType, fieldValue) From 233295be076408d042021f5fc7bf91b91eea8293 Mon Sep 17 00:00:00 2001 From: ynwcel <454383818@qq.com> Date: Wed, 18 Dec 2024 10:39:01 +0800 Subject: [PATCH 059/102] fix(os/gview): search file faild from resource manager of package gres (#4024) --- os/gview/gview_parse.go | 56 +++++++++++++++++++++++------------ os/gview/gview_z_unit_test.go | 24 +++++++++++++++ 2 files changed, 61 insertions(+), 19 deletions(-) diff --git a/os/gview/gview_parse.go b/os/gview/gview_parse.go index 243231872a7..0b20e7772d9 100644 --- a/os/gview/gview_parse.go +++ b/os/gview/gview_parse.go @@ -12,6 +12,7 @@ import ( "fmt" htmltpl "html/template" "strconv" + "strings" texttpl "text/template" "github.com/gogf/gf/v2/container/gmap" @@ -372,31 +373,48 @@ func (view *View) formatTemplateObjectCreatingError(filePath, tplName string, er // searchFile returns the absolute path of the `file` and its template folder path. // The returned `folder` is the template folder path, not the folder of the template file `path`. func (view *View) searchFile(ctx context.Context, file string) (path string, folder string, resource *gres.File, err error) { - var tempPath string - // Firstly, checking the resource manager. + var ( + tempPath string + trimmedFile = strings.TrimLeft(file, `\/`) + ) + // Firstly checking the resource manager. if !gres.IsEmpty() { - // Try folders. - for _, tryFolder := range resourceTryFolders { - tempPath = tryFolder + file - if resource = gres.Get(tempPath); resource != nil { - path = resource.Name() - folder = tryFolder - return - } - } // Search folders. - view.searchPaths.RLockFunc(func(array []string) { - for _, searchPath := range array { - for _, tryFolder := range resourceTryFolders { - tempPath = searchPath + tryFolder + file - if resFile := gres.Get(tempPath); resFile != nil { - path = resFile.Name() - folder = searchPath + tryFolder + if path == "" { + view.searchPaths.RLockFunc(func(array []string) { + for _, searchPath := range array { + tempPath = strings.TrimRight(searchPath, `\/`) + `/` + trimmedFile + if tmpFile := gres.Get(tempPath); tmpFile != nil { + path = tmpFile.Name() + folder = searchPath + resource = tmpFile return } + + for _, tryFolder := range resourceTryFolders { + tempPath = strings.TrimRight(searchPath, `\/`) + `/` + strings.TrimRight(tryFolder, `\/`) + `/` + file + if tmpFile := gres.Get(tempPath); tmpFile != nil { + path = tmpFile.Name() + folder = searchPath + tryFolder + resource = tmpFile + return + } + } + } + }) + } + // Try folders. + if path == "" { + for _, tryFolder := range resourceTryFolders { + tempPath = strings.TrimRight(tryFolder, `\/`) + `/` + trimmedFile + if tmpFile := gres.Get(tempPath); tmpFile != nil { + path = tmpFile.Name() + folder = tryFolder + resource = tmpFile + return } } - }) + } } // Secondly, checking the file system. diff --git a/os/gview/gview_z_unit_test.go b/os/gview/gview_z_unit_test.go index f345835ea08..bdff3456fd3 100644 --- a/os/gview/gview_z_unit_test.go +++ b/os/gview/gview_z_unit_test.go @@ -621,6 +621,10 @@ func init() { if err := gres.Add("H4sIAAAAAAAC/wrwZmYRYeBg4GBIFA0LY0ACEgycDCWpuQU5iSWp+ullmanl8SWpxSV6GSW5OaEhrAyM5o1fk095n/HdumrdNeaLW7c2MDAw/P8f4M3OoZ+9QESIgYGBj4GBAWYBA0MTmgUcSBaADSxt/JoM0o6sKMCbkUmEGeFCZKNBLoSBbY0gkqB7EcZhdw8ECDD8d0xEMg7JdaxsIAVMDEwMfQwMDAvAygEBAAD//0d6jptEAQAA"); err != nil { panic("add binary content to resource manager failed: " + err.Error()) } + + if err := gres.Add("H4sIAAAAAAAC/wrwZmYRYeBg4GBIFA0LY0ACEgycDCWpuQU5iSWp+ullmanl8SWpxSV6GSW5OaEhrAyM5o1fk095n/HdumrdNeaLW7c2MDAw/P8f4M3OoZ+9QESIgYGBj4GBAWYBA0MTmgUcSBaADSxt/JoM0o6sKMCbkUmEGeFCZKNBLoSBbY0gkqB7EcZhdw8ECDD8d0xEMg7JdaxsIAVMDEwMfQwMDAvAygEBAAD//0d6jptEAQAA", "assets/"); err != nil { + panic("add binary content to resource manager failed: " + err.Error()) + } } func Test_GviewInGres(t *testing.T) { @@ -635,3 +639,23 @@ func Test_GviewInGres(t *testing.T) { t.Assert(result, "name:john") }) } + +func Test_GviewSearchFileInGres(t *testing.T) { + gres.Dump() + gtest.C(t, func(t *gtest.T) { + v := gview.New() + v.SetPath("assets/template") + result, err := v.Parse(context.TODO(), "gview_test.html", g.Map{ + "name": "john", + }) + t.AssertNil(err) + t.Assert(result, "name:john") + + v1 := gview.New("assets/template") + result1, err1 := v1.Parse(context.TODO(), "gview_test.html", g.Map{ + "name": "john", + }) + t.AssertNil(err1) + t.Assert(result1, "name:john") + }) +} From a5c8b966e282c004923a6d3470d16c12ca498f01 Mon Sep 17 00:00:00 2001 From: John Guo Date: Wed, 18 Dec 2024 10:41:09 +0800 Subject: [PATCH 060/102] feat(util/gconv): add basic types conversion support for function Scan (#3991) --- .github/workflows/ci-main.yml | 4 +- .../clickhouse/clickhouse_z_unit_db_test.go | 13 +- .../grpcx_unit_z_grpc_server_config_test.go | 9 +- util/gconv/gconv.go | 275 -------------- util/gconv/gconv_basic.go | 336 ++++++++++++++++++ util/gconv/gconv_float.go | 106 ++++-- util/gconv/gconv_int.go | 134 ++++--- util/gconv/gconv_map.go | 2 + util/gconv/gconv_scan.go | 228 +++++++++--- util/gconv/gconv_uint.go | 148 +++++--- .../gconv_z_unit_scan_basic_types_test.go | 171 +++++++++ util/gconv/gconv_z_unit_scan_test.go | 18 +- util/gconv/gconv_z_unit_uint_test.go | 5 +- 13 files changed, 977 insertions(+), 472 deletions(-) create mode 100644 util/gconv/gconv_basic.go create mode 100644 util/gconv/gconv_z_unit_scan_basic_types_test.go diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index ecbd084c67f..ad37fbcafd1 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -130,9 +130,9 @@ jobs: # ClickHouse backend server. # docker run -d --name clickhouse \ # -p 9000:9000 -p 8123:8123 -p 9001:9001 \ - # loads/clickhouse-server:22.1.3.7 + # clickhouse/clickhouse-server:24.11.1.2557-alpine clickhouse-server: - image: loads/clickhouse-server:22.1.3.7 + image: clickhouse/clickhouse-server:24.11.1.2557-alpine ports: - 9000:9000 - 8123:8123 diff --git a/contrib/drivers/clickhouse/clickhouse_z_unit_db_test.go b/contrib/drivers/clickhouse/clickhouse_z_unit_db_test.go index 0b818222d0a..fc8d62fb813 100644 --- a/contrib/drivers/clickhouse/clickhouse_z_unit_db_test.go +++ b/contrib/drivers/clickhouse/clickhouse_z_unit_db_test.go @@ -280,9 +280,18 @@ func Test_DB_Delete(t *testing.T) { defer dropTable(table) gtest.C(t, func(t *gtest.T) { - _, err := db.Delete(ctx, table, "id>3") - t.AssertNE(err, nil) + //db.SetDebug(true) + count, err := db.Model(table).Ctx(ctx).Count() + t.AssertNil(err) + t.Assert(count, 10) + result, err := db.Delete(ctx, table, "id>3") + t.AssertNil(err) + t.AssertNil(result) + + count, err = db.Model(table).Ctx(ctx).Count() + t.AssertNil(err) + t.Assert(count, 3) }) } diff --git a/contrib/rpc/grpcx/grpcx_unit_z_grpc_server_config_test.go b/contrib/rpc/grpcx/grpcx_unit_z_grpc_server_config_test.go index 9a1baaf8e5f..71e681df081 100644 --- a/contrib/rpc/grpcx/grpcx_unit_z_grpc_server_config_test.go +++ b/contrib/rpc/grpcx/grpcx_unit_z_grpc_server_config_test.go @@ -90,13 +90,10 @@ func Test_Grpcx_Grpc_Server_Config_Logger(t *testing.T) { time.Sleep(time.Millisecond * 100) defer s.Stop() - var ( - logFilePath = fmt.Sprintf("/tmp/log/%s.log", gtime.Now().Format("Y-m-d")) - logFileContent = gfile.GetContents(logFilePath) - ) - defer gfile.Remove(logFilePath) + var logFilePath = fmt.Sprintf("/tmp/log/%s.log", gtime.Now().Format("Y-m-d")) + defer gfile.RemoveFile(logFilePath) t.Assert(gfile.Exists(logFilePath), true) - t.Assert(gstr.Contains(logFileContent, "TestLogger "), true) + t.Assert(s.Logger().GetConfig().Prefix, "TestLogger") }) } diff --git a/util/gconv/gconv.go b/util/gconv/gconv.go index 9a39aee7048..d3bc027ef05 100644 --- a/util/gconv/gconv.go +++ b/util/gconv/gconv.go @@ -10,19 +10,6 @@ package gconv import ( - "context" - "fmt" - "math" - "reflect" - "strconv" - "strings" - "time" - - "github.com/gogf/gf/v2/encoding/gbinary" - "github.com/gogf/gf/v2/internal/intlog" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/internal/reflection" - "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/util/gconv/internal/localinterface" "github.com/gogf/gf/v2/util/gconv/internal/structcache" ) @@ -56,265 +43,3 @@ func init() { Bool: Bool, }) } - -// Byte converts `any` to byte. -func Byte(any interface{}) byte { - if v, ok := any.(byte); ok { - return v - } - return Uint8(any) -} - -// Bytes converts `any` to []byte. -func Bytes(any interface{}) []byte { - if any == nil { - return nil - } - switch value := any.(type) { - case string: - return []byte(value) - - case []byte: - return value - - default: - if f, ok := value.(localinterface.IBytes); ok { - return f.Bytes() - } - originValueAndKind := reflection.OriginValueAndKind(any) - switch originValueAndKind.OriginKind { - case reflect.Map: - bytes, err := json.Marshal(any) - if err != nil { - intlog.Errorf(context.TODO(), `%+v`, err) - } - return bytes - - case reflect.Array, reflect.Slice: - var ( - ok = true - bytes = make([]byte, originValueAndKind.OriginValue.Len()) - ) - for i := range bytes { - int32Value := Int32(originValueAndKind.OriginValue.Index(i).Interface()) - if int32Value < 0 || int32Value > math.MaxUint8 { - ok = false - break - } - bytes[i] = byte(int32Value) - } - if ok { - return bytes - } - } - return gbinary.Encode(any) - } -} - -// Rune converts `any` to rune. -func Rune(any interface{}) rune { - if v, ok := any.(rune); ok { - return v - } - return Int32(any) -} - -// Runes converts `any` to []rune. -func Runes(any interface{}) []rune { - if v, ok := any.([]rune); ok { - return v - } - return []rune(String(any)) -} - -// String converts `any` to string. -// It's most commonly used converting function. -func String(any interface{}) string { - if any == nil { - return "" - } - switch value := any.(type) { - case int: - return strconv.Itoa(value) - case int8: - return strconv.Itoa(int(value)) - case int16: - return strconv.Itoa(int(value)) - case int32: - return strconv.Itoa(int(value)) - case int64: - return strconv.FormatInt(value, 10) - case uint: - return strconv.FormatUint(uint64(value), 10) - case uint8: - return strconv.FormatUint(uint64(value), 10) - case uint16: - return strconv.FormatUint(uint64(value), 10) - case uint32: - return strconv.FormatUint(uint64(value), 10) - case uint64: - return strconv.FormatUint(value, 10) - case float32: - return strconv.FormatFloat(float64(value), 'f', -1, 32) - case float64: - return strconv.FormatFloat(value, 'f', -1, 64) - case bool: - return strconv.FormatBool(value) - case string: - return value - case []byte: - return string(value) - case time.Time: - if value.IsZero() { - return "" - } - return value.String() - case *time.Time: - if value == nil { - return "" - } - return value.String() - case gtime.Time: - if value.IsZero() { - return "" - } - return value.String() - case *gtime.Time: - if value == nil { - return "" - } - return value.String() - default: - if f, ok := value.(localinterface.IString); ok { - // If the variable implements the String() interface, - // then use that interface to perform the conversion - return f.String() - } - if f, ok := value.(localinterface.IError); ok { - // If the variable implements the Error() interface, - // then use that interface to perform the conversion - return f.Error() - } - // Reflect checks. - var ( - rv = reflect.ValueOf(value) - kind = rv.Kind() - ) - switch kind { - case - reflect.Chan, - reflect.Map, - reflect.Slice, - reflect.Func, - reflect.Interface, - reflect.UnsafePointer: - if rv.IsNil() { - return "" - } - case reflect.String: - return rv.String() - case reflect.Ptr: - if rv.IsNil() { - return "" - } - return String(rv.Elem().Interface()) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return strconv.FormatInt(rv.Int(), 10) - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return strconv.FormatUint(rv.Uint(), 10) - case reflect.Uintptr: - return strconv.FormatUint(rv.Uint(), 10) - case reflect.Float32, reflect.Float64: - return strconv.FormatFloat(rv.Float(), 'f', -1, 64) - case reflect.Bool: - return strconv.FormatBool(rv.Bool()) - } - // Finally, we use json.Marshal to convert. - if jsonContent, err := json.Marshal(value); err != nil { - return fmt.Sprint(value) - } else { - return string(jsonContent) - } - } -} - -// Bool converts `any` to bool. -// It returns false if `any` is: false, "", 0, "false", "off", "no", empty slice/map. -func Bool(any interface{}) bool { - if any == nil { - return false - } - switch value := any.(type) { - case bool: - return value - case []byte: - if _, ok := emptyStringMap[strings.ToLower(string(value))]; ok { - return false - } - return true - case string: - if _, ok := emptyStringMap[strings.ToLower(value)]; ok { - return false - } - return true - default: - if f, ok := value.(localinterface.IBool); ok { - return f.Bool() - } - rv := reflect.ValueOf(any) - switch rv.Kind() { - case reflect.Ptr: - if rv.IsNil() { - return false - } - if rv.Type().Elem().Kind() == reflect.Bool { - return rv.Elem().Bool() - } - return Bool(rv.Elem().Interface()) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return rv.Int() != 0 - case reflect.Uintptr, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return rv.Uint() != 0 - case reflect.Float32, reflect.Float64: - return rv.Float() != 0 - case reflect.Bool: - return rv.Bool() - // TODO:(Map,Array,Slice,Struct) It might panic here for these types. - case reflect.Map, reflect.Array: - fallthrough - case reflect.Slice: - return rv.Len() != 0 - case reflect.Struct: - return true - default: - s := strings.ToLower(String(any)) - if _, ok := emptyStringMap[s]; ok { - return false - } - return true - } - } -} - -// checkJsonAndUnmarshalUseNumber checks if given `any` is JSON formatted string value and does converting using `json.UnmarshalUseNumber`. -func checkJsonAndUnmarshalUseNumber(any interface{}, target interface{}) bool { - switch r := any.(type) { - case []byte: - if json.Valid(r) { - if err := json.UnmarshalUseNumber(r, &target); err != nil { - return false - } - return true - } - - case string: - anyAsBytes := []byte(r) - if json.Valid(anyAsBytes) { - if err := json.UnmarshalUseNumber(anyAsBytes, &target); err != nil { - return false - } - return true - } - } - return false -} diff --git a/util/gconv/gconv_basic.go b/util/gconv/gconv_basic.go new file mode 100644 index 00000000000..56a10e07577 --- /dev/null +++ b/util/gconv/gconv_basic.go @@ -0,0 +1,336 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package gconv + +import ( + "fmt" + "math" + "reflect" + "strconv" + "strings" + "time" + + "github.com/gogf/gf/v2/encoding/gbinary" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/internal/reflection" + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/util/gconv/internal/localinterface" +) + +// Byte converts `any` to byte. +func Byte(any any) byte { + v, _ := doByte(any) + return v +} + +func doByte(any any) (byte, error) { + if v, ok := any.(byte); ok { + return v, nil + } + return doUint8(any) +} + +// Bytes converts `any` to []byte. +func Bytes(any any) []byte { + v, _ := doBytes(any) + return v +} + +func doBytes(any any) ([]byte, error) { + if any == nil { + return nil, nil + } + switch value := any.(type) { + case string: + return []byte(value), nil + + case []byte: + return value, nil + + default: + if f, ok := value.(localinterface.IBytes); ok { + return f.Bytes(), nil + } + originValueAndKind := reflection.OriginValueAndKind(any) + switch originValueAndKind.OriginKind { + case reflect.Map: + bytes, err := json.Marshal(any) + if err != nil { + return nil, err + } + return bytes, nil + + case reflect.Array, reflect.Slice: + var ( + ok = true + bytes = make([]byte, originValueAndKind.OriginValue.Len()) + ) + for i := range bytes { + int32Value, err := doInt32(originValueAndKind.OriginValue.Index(i).Interface()) + if err != nil { + return nil, err + } + if int32Value < 0 || int32Value > math.MaxUint8 { + ok = false + break + } + bytes[i] = byte(int32Value) + } + if ok { + return bytes, nil + } + default: + } + return gbinary.Encode(any), nil + } +} + +// Rune converts `any` to rune. +func Rune(any any) rune { + v, _ := doRune(any) + return v +} + +func doRune(any any) (rune, error) { + if v, ok := any.(rune); ok { + return v, nil + } + v, err := doInt32(any) + if err != nil { + return 0, err + } + return v, nil +} + +// Runes converts `any` to []rune. +func Runes(any any) []rune { + v, _ := doRunes(any) + return v +} + +func doRunes(any any) ([]rune, error) { + if v, ok := any.([]rune); ok { + return v, nil + } + s, err := doString(any) + if err != nil { + return nil, err + } + return []rune(s), nil +} + +// String converts `any` to string. +// It's most commonly used converting function. +func String(any any) string { + v, _ := doString(any) + return v +} + +func doString(any any) (string, error) { + if any == nil { + return "", nil + } + switch value := any.(type) { + case int: + return strconv.Itoa(value), nil + case int8: + return strconv.Itoa(int(value)), nil + case int16: + return strconv.Itoa(int(value)), nil + case int32: + return strconv.Itoa(int(value)), nil + case int64: + return strconv.FormatInt(value, 10), nil + case uint: + return strconv.FormatUint(uint64(value), 10), nil + case uint8: + return strconv.FormatUint(uint64(value), 10), nil + case uint16: + return strconv.FormatUint(uint64(value), 10), nil + case uint32: + return strconv.FormatUint(uint64(value), 10), nil + case uint64: + return strconv.FormatUint(value, 10), nil + case float32: + return strconv.FormatFloat(float64(value), 'f', -1, 32), nil + case float64: + return strconv.FormatFloat(value, 'f', -1, 64), nil + case bool: + return strconv.FormatBool(value), nil + case string: + return value, nil + case []byte: + return string(value), nil + case complex64, complex128: + return fmt.Sprintf("%v", value), nil + case time.Time: + if value.IsZero() { + return "", nil + } + return value.String(), nil + case *time.Time: + if value == nil { + return "", nil + } + return value.String(), nil + case gtime.Time: + if value.IsZero() { + return "", nil + } + return value.String(), nil + case *gtime.Time: + if value == nil { + return "", nil + } + return value.String(), nil + default: + if f, ok := value.(localinterface.IString); ok { + // If the variable implements the String() interface, + // then use that interface to perform the conversion + return f.String(), nil + } + if f, ok := value.(localinterface.IError); ok { + // If the variable implements the Error() interface, + // then use that interface to perform the conversion + return f.Error(), nil + } + // Reflect checks. + var ( + rv = reflect.ValueOf(value) + kind = rv.Kind() + ) + switch kind { + case + reflect.Chan, + reflect.Map, + reflect.Slice, + reflect.Func, + reflect.Interface, + reflect.UnsafePointer: + if rv.IsNil() { + return "", nil + } + case reflect.String: + return rv.String(), nil + case reflect.Ptr: + if rv.IsNil() { + return "", nil + } + return doString(rv.Elem().Interface()) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return strconv.FormatInt(rv.Int(), 10), nil + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return strconv.FormatUint(rv.Uint(), 10), nil + case reflect.Uintptr: + return strconv.FormatUint(rv.Uint(), 10), nil + case reflect.Float32, reflect.Float64: + return strconv.FormatFloat(rv.Float(), 'f', -1, 64), nil + case reflect.Bool: + return strconv.FormatBool(rv.Bool()), nil + default: + } + // Finally, we use json.Marshal to convert. + jsonContent, err := json.Marshal(value) + if err != nil { + return fmt.Sprint(value), gerror.WrapCodef( + gcode.CodeInvalidParameter, err, "error marshaling value to JSON for: %v", value, + ) + } + return string(jsonContent), nil + } +} + +// Bool converts `any` to bool. +// It returns false if `any` is: false, "", 0, "false", "off", "no", empty slice/map. +func Bool(any any) bool { + v, _ := doBool(any) + return v +} + +func doBool(any any) (bool, error) { + if any == nil { + return false, nil + } + switch value := any.(type) { + case bool: + return value, nil + case []byte: + if _, ok := emptyStringMap[strings.ToLower(string(value))]; ok { + return false, nil + } + return true, nil + case string: + if _, ok := emptyStringMap[strings.ToLower(value)]; ok { + return false, nil + } + return true, nil + default: + if f, ok := value.(localinterface.IBool); ok { + return f.Bool(), nil + } + rv := reflect.ValueOf(any) + switch rv.Kind() { + case reflect.Ptr: + if rv.IsNil() { + return false, nil + } + if rv.Type().Elem().Kind() == reflect.Bool { + return rv.Elem().Bool(), nil + } + return doBool(rv.Elem().Interface()) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return rv.Int() != 0, nil + case reflect.Uintptr, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return rv.Uint() != 0, nil + case reflect.Float32, reflect.Float64: + return rv.Float() != 0, nil + case reflect.Bool: + return rv.Bool(), nil + // TODO:(Map,Array,Slice,Struct) It might panic here for these types. + case reflect.Map, reflect.Array: + fallthrough + case reflect.Slice: + return rv.Len() != 0, nil + case reflect.Struct: + return true, nil + default: + s, err := doString(any) + if err != nil { + return false, err + } + if _, ok := emptyStringMap[strings.ToLower(s)]; ok { + return false, nil + } + return true, nil + } + } +} + +// checkJsonAndUnmarshalUseNumber checks if given `any` is JSON formatted string value and does converting using `json.UnmarshalUseNumber`. +func checkJsonAndUnmarshalUseNumber(any any, target any) bool { + switch r := any.(type) { + case []byte: + if json.Valid(r) { + if err := json.UnmarshalUseNumber(r, &target); err != nil { + return false + } + return true + } + + case string: + anyAsBytes := []byte(r) + if json.Valid(anyAsBytes) { + if err := json.UnmarshalUseNumber(anyAsBytes, &target); err != nil { + return false + } + return true + } + } + return false +} diff --git a/util/gconv/gconv_float.go b/util/gconv/gconv_float.go index ceda78df4c5..2f7204a5cf9 100644 --- a/util/gconv/gconv_float.go +++ b/util/gconv/gconv_float.go @@ -11,106 +11,138 @@ import ( "strconv" "github.com/gogf/gf/v2/encoding/gbinary" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/util/gconv/internal/localinterface" ) // Float32 converts `any` to float32. -func Float32(any interface{}) float32 { +func Float32(any any) float32 { + v, _ := doFloat32(any) + return v +} + +func doFloat32(any any) (float32, error) { if any == nil { - return 0 + return 0, nil } switch value := any.(type) { case float32: - return value + return value, nil case float64: - return float32(value) + return float32(value), nil case []byte: // TODO: It might panic here for these types. - return gbinary.DecodeToFloat32(value) + return gbinary.DecodeToFloat32(value), nil default: rv := reflect.ValueOf(any) switch rv.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return float32(rv.Int()) + return float32(rv.Int()), nil case reflect.Uintptr, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return float32(rv.Uint()) + return float32(rv.Uint()), nil case reflect.Float32, reflect.Float64: - return float32(rv.Float()) + return float32(rv.Float()), nil case reflect.Bool: if rv.Bool() { - return 1 + return 1, nil } - return 0 + return 0, nil case reflect.String: - f, _ := strconv.ParseFloat(rv.String(), 32) - return float32(f) + f, err := strconv.ParseFloat(rv.String(), 32) + if err != nil { + return 0, gerror.WrapCodef( + gcode.CodeInvalidParameter, err, "converting string to float32 failed for: %v", any, + ) + } + return float32(f), nil case reflect.Ptr: if rv.IsNil() { - return 0 + return 0, nil } if f, ok := value.(localinterface.IFloat32); ok { - return f.Float32() + return f.Float32(), nil } - return Float32(rv.Elem().Interface()) + return doFloat32(rv.Elem().Interface()) default: if f, ok := value.(localinterface.IFloat32); ok { - return f.Float32() + return f.Float32(), nil + } + v, err := strconv.ParseFloat(String(any), 32) + if err != nil { + return 0, gerror.WrapCodef( + gcode.CodeInvalidParameter, err, "converting string to float32 failed for: %v", any, + ) } - v, _ := strconv.ParseFloat(String(any), 32) - return float32(v) + return float32(v), nil } } } // Float64 converts `any` to float64. -func Float64(any interface{}) float64 { +func Float64(any any) float64 { + v, _ := doFloat64(any) + return v +} + +func doFloat64(any any) (float64, error) { if any == nil { - return 0 + return 0, nil } switch value := any.(type) { case float32: - return float64(value) + return float64(value), nil case float64: - return value + return value, nil case []byte: // TODO: It might panic here for these types. - return gbinary.DecodeToFloat64(value) + return gbinary.DecodeToFloat64(value), nil default: rv := reflect.ValueOf(any) switch rv.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return float64(rv.Int()) + return float64(rv.Int()), nil case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return float64(rv.Uint()) + return float64(rv.Uint()), nil case reflect.Uintptr: - return float64(rv.Uint()) + return float64(rv.Uint()), nil case reflect.Float32, reflect.Float64: // Please Note: // When the type is float32 or a custom type defined based on float32, // switching to float64 may result in a few extra decimal places. - return rv.Float() + return rv.Float(), nil case reflect.Bool: if rv.Bool() { - return 1 + return 1, nil } - return 0 + return 0, nil case reflect.String: - f, _ := strconv.ParseFloat(rv.String(), 64) - return f + f, err := strconv.ParseFloat(rv.String(), 64) + if err != nil { + return 0, gerror.WrapCodef( + gcode.CodeInvalidParameter, err, "converting string to float64 failed for: %v", any, + ) + } + return f, nil case reflect.Ptr: if rv.IsNil() { - return 0 + return 0, nil } if f, ok := value.(localinterface.IFloat64); ok { - return f.Float64() + return f.Float64(), nil } - return Float64(rv.Elem().Interface()) + return doFloat64(rv.Elem().Interface()) default: if f, ok := value.(localinterface.IFloat64); ok { - return f.Float64() + return f.Float64(), nil + } + v, err := strconv.ParseFloat(String(any), 64) + if err != nil { + return 0, gerror.WrapCodef( + gcode.CodeInvalidParameter, err, "converting string to float64 failed for: %v", any, + ) } - v, _ := strconv.ParseFloat(String(any), 64) - return v + return v, nil } } } diff --git a/util/gconv/gconv_int.go b/util/gconv/gconv_int.go index 8b389f754ed..7e1e6a129dd 100644 --- a/util/gconv/gconv_int.go +++ b/util/gconv/gconv_int.go @@ -12,85 +12,119 @@ import ( "strconv" "github.com/gogf/gf/v2/encoding/gbinary" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/util/gconv/internal/localinterface" ) // Int converts `any` to int. -func Int(any interface{}) int { - if any == nil { - return 0 - } +func Int(any any) int { + v, _ := doInt(any) + return v +} + +func doInt(any any) (int, error) { if v, ok := any.(int); ok { - return v + return v, nil + } + v, err := doInt64(any) + if err != nil { + return 0, err } - return int(Int64(any)) + return int(v), nil } // Int8 converts `any` to int8. -func Int8(any interface{}) int8 { - if any == nil { - return 0 - } +func Int8(any any) int8 { + v, _ := doInt8(any) + return v +} + +func doInt8(any any) (int8, error) { if v, ok := any.(int8); ok { - return v + return v, nil } - return int8(Int64(any)) + v, err := doInt64(any) + if err != nil { + return 0, err + } + return int8(v), nil } // Int16 converts `any` to int16. -func Int16(any interface{}) int16 { - if any == nil { - return 0 - } +func Int16(any any) int16 { + v, _ := doInt16(any) + return v +} + +func doInt16(any any) (int16, error) { if v, ok := any.(int16); ok { - return v + return v, nil + } + v, err := doInt64(any) + if err != nil { + return 0, err } - return int16(Int64(any)) + return int16(v), nil } // Int32 converts `any` to int32. -func Int32(any interface{}) int32 { - if any == nil { - return 0 - } +func Int32(any any) int32 { + v, _ := doInt32(any) + return v +} + +func doInt32(any any) (int32, error) { if v, ok := any.(int32); ok { - return v + return v, nil + } + v, err := doInt64(any) + if err != nil { + return 0, err } - return int32(Int64(any)) + return int32(v), nil } // Int64 converts `any` to int64. -func Int64(any interface{}) int64 { +func Int64(any any) int64 { + v, _ := doInt64(any) + return v +} + +func doInt64(any any) (int64, error) { if any == nil { - return 0 + return 0, nil + } + if v, ok := any.(int64); ok { + return v, nil } rv := reflect.ValueOf(any) switch rv.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return int64(rv.Int()) + return rv.Int(), nil case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return int64(rv.Uint()) + return int64(rv.Uint()), nil case reflect.Uintptr: - return int64(rv.Uint()) + return int64(rv.Uint()), nil case reflect.Float32, reflect.Float64: - return int64(rv.Float()) + return int64(rv.Float()), nil case reflect.Bool: if rv.Bool() { - return 1 + return 1, nil } - return 0 + return 0, nil case reflect.Ptr: if rv.IsNil() { - return 0 + return 0, nil } if f, ok := any.(localinterface.IInt64); ok { - return f.Int64() + return f.Int64(), nil } - return Int64(rv.Elem().Interface()) + return doInt64(rv.Elem().Interface()) case reflect.Slice: // TODO: It might panic here for these types. if rv.Type().Elem().Kind() == reflect.Uint8 { - return gbinary.DecodeToInt64(rv.Bytes()) + return gbinary.DecodeToInt64(rv.Bytes()), nil } case reflect.String: var ( @@ -109,31 +143,39 @@ func Int64(any interface{}) int64 { if len(s) > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X') { if v, e := strconv.ParseInt(s[2:], 16, 64); e == nil { if isMinus { - return -v + return -v, nil } - return v + return v, nil } } // Decimal. if v, e := strconv.ParseInt(s, 10, 64); e == nil { if isMinus { - return -v + return -v, nil } - return v + return v, nil } // Float64. - if valueInt64 := Float64(s); math.IsNaN(valueInt64) { - return 0 + valueInt64, err := doFloat64(s) + if err != nil { + return 0, err + } + if math.IsNaN(valueInt64) { + return 0, nil } else { if isMinus { - return -int64(valueInt64) + return -int64(valueInt64), nil } - return int64(valueInt64) + return int64(valueInt64), nil } default: if f, ok := any.(localinterface.IInt64); ok { - return f.Int64() + return f.Int64(), nil } } - return 0 + return 0, gerror.NewCodef( + gcode.CodeInvalidParameter, + `unsupport value type for converting to int64: %v`, + reflect.TypeOf(any), + ) } diff --git a/util/gconv/gconv_map.go b/util/gconv/gconv_map.go index 459c438c857..46809da6f13 100644 --- a/util/gconv/gconv_map.go +++ b/util/gconv/gconv_map.go @@ -539,6 +539,8 @@ func doMapConvertForMapOrStructValue(in doMapConvertForMapOrStructValueInput) in }) } return array + + default: } return in.Value } diff --git a/util/gconv/gconv_scan.go b/util/gconv/gconv_scan.go index 8b58788acf3..376a2b1aae2 100644 --- a/util/gconv/gconv_scan.go +++ b/util/gconv/gconv_scan.go @@ -16,14 +16,21 @@ import ( ) // Scan automatically checks the type of `pointer` and converts `params` to `pointer`. -// It supports `pointer` in type of `*map/*[]map/*[]*map/*struct/**struct/*[]struct/*[]*struct` for converting. +// It supports various types of parameter conversions, including: +// 1. Basic types (int, string, float, etc.) +// 2. Pointer types +// 3. Slice types +// 4. Map types +// 5. Struct types // -// TODO change `paramKeyToAttrMap` to `ScanOption` to be more scalable; add `DeepCopy` option for `ScanOption`. -func Scan(srcValue interface{}, dstPointer interface{}, paramKeyToAttrMap ...map[string]string) (err error) { +// The `paramKeyToAttrMap` parameter is used for mapping between attribute names and parameter keys. +// TODO: change `paramKeyToAttrMap` to `ScanOption` to be more scalable; add `DeepCopy` option for `ScanOption`. +func Scan(srcValue any, dstPointer any, paramKeyToAttrMap ...map[string]string) (err error) { + // Check if srcValue is nil, in which case no conversion is needed if srcValue == nil { - // If `srcValue` is nil, no conversion. return nil } + // Check if dstPointer is nil, which is an invalid parameter if dstPointer == nil { return gerror.NewCode( gcode.CodeInvalidParameter, @@ -31,15 +38,7 @@ func Scan(srcValue interface{}, dstPointer interface{}, paramKeyToAttrMap ...map ) } - // json converting check. - ok, err := doConvertWithJsonCheck(srcValue, dstPointer) - if err != nil { - return err - } - if ok { - return nil - } - + // Get the reflection type and value of dstPointer var ( dstPointerReflectType reflect.Type dstPointerReflectValue reflect.Value @@ -49,18 +48,20 @@ func Scan(srcValue interface{}, dstPointer interface{}, paramKeyToAttrMap ...map dstPointerReflectType = v.Type() } else { dstPointerReflectValue = reflect.ValueOf(dstPointer) - // do not use dstPointerReflectValue.Type() as dstPointerReflectValue might be zero. + // Do not use dstPointerReflectValue.Type() as dstPointerReflectValue might be zero dstPointerReflectType = reflect.TypeOf(dstPointer) } - // pointer kind validation. + // Validate the kind of dstPointer var dstPointerReflectKind = dstPointerReflectType.Kind() if dstPointerReflectKind != reflect.Ptr { + // If dstPointer is not a pointer, try to get its address if dstPointerReflectValue.CanAddr() { dstPointerReflectValue = dstPointerReflectValue.Addr() dstPointerReflectType = dstPointerReflectValue.Type() dstPointerReflectKind = dstPointerReflectType.Kind() } else { + // If dstPointer is not a pointer and cannot be addressed, return an error return gerror.NewCodef( gcode.CodeInvalidParameter, `destination pointer should be type of pointer, but got type: %v`, @@ -68,23 +69,144 @@ func Scan(srcValue interface{}, dstPointer interface{}, paramKeyToAttrMap ...map ) } } - // direct assignment checks! + + // Get the reflection value of srcValue var srcValueReflectValue reflect.Value if v, ok := srcValue.(reflect.Value); ok { srcValueReflectValue = v } else { srcValueReflectValue = reflect.ValueOf(srcValue) } - // if `srcValue` and `dstPointer` are the same type, the do directly assignment. - // For performance enhancement purpose. - var dstPointerReflectValueElem = dstPointerReflectValue.Elem() - // if `srcValue` and `dstPointer` are the same type, the do directly assignment. - // for performance enhancement purpose. - if ok = doConvertWithTypeCheck(srcValueReflectValue, dstPointerReflectValueElem); ok { + + // Get the element type and kind of dstPointer + var ( + dstPointerReflectValueElem = dstPointerReflectValue.Elem() + dstPointerReflectValueElemKind = dstPointerReflectValueElem.Kind() + ) + // Handle multiple level pointers + if dstPointerReflectValueElemKind == reflect.Ptr { + if dstPointerReflectValueElem.IsNil() { + // Create a new value for the pointer dereference + nextLevelPtr := reflect.New(dstPointerReflectValueElem.Type().Elem()) + // Recursively scan into the dereferenced pointer + if err = Scan(srcValueReflectValue, nextLevelPtr, paramKeyToAttrMap...); err == nil { + dstPointerReflectValueElem.Set(nextLevelPtr) + } + return + } + return Scan(srcValueReflectValue, dstPointerReflectValueElem, paramKeyToAttrMap...) + } + + // Check if srcValue and dstPointer are the same type, in which case direct assignment can be performed + if ok := doConvertWithTypeCheck(srcValueReflectValue, dstPointerReflectValueElem); ok { + return nil + } + + // Handle different destination types + switch dstPointerReflectValueElemKind { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + // Convert to int type + dstPointerReflectValueElem.SetInt(Int64(srcValue)) + return nil + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + // Convert to uint type + dstPointerReflectValueElem.SetUint(Uint64(srcValue)) + return nil + + case reflect.Float32, reflect.Float64: + // Convert to float type + dstPointerReflectValueElem.SetFloat(Float64(srcValue)) + return nil + + case reflect.String: + // Convert to string type + dstPointerReflectValueElem.SetString(String(srcValue)) + return nil + + case reflect.Bool: + // Convert to bool type + dstPointerReflectValueElem.SetBool(Bool(srcValue)) + return nil + + case reflect.Slice: + // Handle slice type conversion + var ( + dstElemType = dstPointerReflectValueElem.Type().Elem() + dstElemKind = dstElemType.Kind() + ) + // The slice element might be a pointer type + if dstElemKind == reflect.Ptr { + dstElemType = dstElemType.Elem() + dstElemKind = dstElemType.Kind() + } + // Special handling for struct or map slice elements + if dstElemKind == reflect.Struct || dstElemKind == reflect.Map { + return doScanForComplicatedTypes(srcValue, dstPointer, dstPointerReflectType, paramKeyToAttrMap...) + } + // Handle basic type slice conversions + var srcValueReflectValueKind = srcValueReflectValue.Kind() + if srcValueReflectValueKind == reflect.Slice || srcValueReflectValueKind == reflect.Array { + var ( + srcLen = srcValueReflectValue.Len() + newSlice = reflect.MakeSlice(dstPointerReflectValueElem.Type(), srcLen, srcLen) + ) + for i := 0; i < srcLen; i++ { + srcElem := srcValueReflectValue.Index(i).Interface() + switch dstElemType.Kind() { + case reflect.String: + newSlice.Index(i).SetString(String(srcElem)) + case reflect.Int: + newSlice.Index(i).SetInt(Int64(srcElem)) + case reflect.Int64: + newSlice.Index(i).SetInt(Int64(srcElem)) + case reflect.Float64: + newSlice.Index(i).SetFloat(Float64(srcElem)) + case reflect.Bool: + newSlice.Index(i).SetBool(Bool(srcElem)) + default: + return Scan( + srcElem, newSlice.Index(i).Addr().Interface(), paramKeyToAttrMap..., + ) + } + } + dstPointerReflectValueElem.Set(newSlice) + return nil + } + return doScanForComplicatedTypes(srcValue, dstPointer, dstPointerReflectType, paramKeyToAttrMap...) + + default: + // Handle complex types (structs, maps, etc.) + return doScanForComplicatedTypes(srcValue, dstPointer, dstPointerReflectType, paramKeyToAttrMap...) + } +} + +// doScanForComplicatedTypes handles the scanning of complex data types. +// It supports converting between maps, structs, and slices of these types. +// The function first attempts JSON conversion, then falls back to specific type handling. +// +// It supports `pointer` in type of `*map/*[]map/*[]*map/*struct/**struct/*[]struct/*[]*struct` for converting. +// +// Parameters: +// - srcValue: The source value to convert from +// - dstPointer: The destination pointer to convert to +// - dstPointerReflectType: The reflection type of the destination pointer +// - paramKeyToAttrMap: Optional mapping between parameter keys and struct attribute names +func doScanForComplicatedTypes( + srcValue, dstPointer any, + dstPointerReflectType reflect.Type, + paramKeyToAttrMap ...map[string]string, +) error { + // Try JSON conversion first + ok, err := doConvertWithJsonCheck(srcValue, dstPointer) + if err != nil { + return err + } + if ok { return nil } - // do the converting. + // Handle specific type conversions var ( dstPointerReflectTypeElem = dstPointerReflectType.Elem() dstPointerReflectTypeElemKind = dstPointerReflectTypeElem.Kind() @@ -93,8 +215,11 @@ func Scan(srcValue interface{}, dstPointer interface{}, paramKeyToAttrMap ...map if len(paramKeyToAttrMap) > 0 { keyToAttributeNameMapping = paramKeyToAttrMap[0] } + + // Handle different destination types switch dstPointerReflectTypeElemKind { case reflect.Map: + // Convert map to map return doMapToMap(srcValue, dstPointer, paramKeyToAttrMap...) case reflect.Array, reflect.Slice: @@ -102,53 +227,59 @@ func Scan(srcValue interface{}, dstPointer interface{}, paramKeyToAttrMap ...map sliceElem = dstPointerReflectTypeElem.Elem() sliceElemKind = sliceElem.Kind() ) + // Handle pointer elements for sliceElemKind == reflect.Ptr { sliceElem = sliceElem.Elem() sliceElemKind = sliceElem.Kind() } if sliceElemKind == reflect.Map { + // Convert to slice of maps return doMapToMaps(srcValue, dstPointer, paramKeyToAttrMap...) } + // Convert to slice of structs return doStructs(srcValue, dstPointer, keyToAttributeNameMapping, "") default: + // Convert to single struct return doStruct(srcValue, dstPointer, keyToAttributeNameMapping, "") } } +// doConvertWithTypeCheck supports `pointer` in type of `*map/*[]map/*[]*map/*struct/**struct/*[]struct/*[]*struct` +// for converting. func doConvertWithTypeCheck(srcValueReflectValue, dstPointerReflectValueElem reflect.Value) (ok bool) { if !dstPointerReflectValueElem.IsValid() || !srcValueReflectValue.IsValid() { return false } switch { - // Example: - // UploadFile => UploadFile - // []UploadFile => []UploadFile - // *UploadFile => *UploadFile - // *[]UploadFile => *[]UploadFile - // map => map - // []map => []map - // *[]map => *[]map + // Examples: + // UploadFile => UploadFile + // []UploadFile => []UploadFile + // *UploadFile => *UploadFile + // *[]UploadFile => *[]UploadFile + // map[int][int] => map[int][int] + // []map[int][int] => []map[int][int] + // *[]map[int][int] => *[]map[int][int] case dstPointerReflectValueElem.Type() == srcValueReflectValue.Type(): dstPointerReflectValueElem.Set(srcValueReflectValue) return true - // Example: - // UploadFile => *UploadFile - // []UploadFile => *[]UploadFile - // map => *map - // []map => *[]map + // Examples: + // UploadFile => *UploadFile + // []UploadFile => *[]UploadFile + // map[int][int] => *map[int][int] + // []map[int][int] => *[]map[int][int] case dstPointerReflectValueElem.Kind() == reflect.Ptr && dstPointerReflectValueElem.Elem().IsValid() && dstPointerReflectValueElem.Elem().Type() == srcValueReflectValue.Type(): dstPointerReflectValueElem.Elem().Set(srcValueReflectValue) return true - // Example: - // *UploadFile => UploadFile - // *[]UploadFile => []UploadFile - // *map => map - // *[]map => []map + // Examples: + // *UploadFile => UploadFile + // *[]UploadFile => []UploadFile + // *map[int][int] => map[int][int] + // *[]map[int][int] => []map[int][int] case srcValueReflectValue.Kind() == reflect.Ptr && srcValueReflectValue.Elem().IsValid() && dstPointerReflectValueElem.Type() == srcValueReflectValue.Elem().Type(): @@ -160,9 +291,18 @@ func doConvertWithTypeCheck(srcValueReflectValue, dstPointerReflectValueElem ref } } -// doConvertWithJsonCheck does json converting check. -// If given `params` is JSON, it then uses json.Unmarshal doing the converting. -func doConvertWithJsonCheck(srcValue interface{}, dstPointer interface{}) (ok bool, err error) { +// doConvertWithJsonCheck attempts to convert the source value to the destination +// using JSON marshaling and unmarshaling. This is particularly useful for complex +// types that can be represented as JSON. +// +// Parameters: +// - srcValue: The source value to convert from +// - dstPointer: The destination pointer to convert to +// +// Returns: +// - bool: true if JSON conversion was successful +// - error: any error that occurred during conversion +func doConvertWithJsonCheck(srcValue any, dstPointer any) (ok bool, err error) { switch valueResult := srcValue.(type) { case []byte: if json.Valid(valueResult) { diff --git a/util/gconv/gconv_uint.go b/util/gconv/gconv_uint.go index ac193876302..367a71a79a2 100644 --- a/util/gconv/gconv_uint.go +++ b/util/gconv/gconv_uint.go @@ -12,110 +12,174 @@ import ( "strconv" "github.com/gogf/gf/v2/encoding/gbinary" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/util/gconv/internal/localinterface" ) // Uint converts `any` to uint. -func Uint(any interface{}) uint { +func Uint(any any) uint { + v, _ := doUint(any) + return v +} + +func doUint(any any) (uint, error) { if any == nil { - return 0 + return 0, nil } if v, ok := any.(uint); ok { - return v + return v, nil } - return uint(Uint64(any)) + v, err := doUint64(any) + return uint(v), err } // Uint8 converts `any` to uint8. -func Uint8(any interface{}) uint8 { +func Uint8(any any) uint8 { + v, _ := doUint8(any) + return v +} + +func doUint8(any any) (uint8, error) { if any == nil { - return 0 + return 0, nil } if v, ok := any.(uint8); ok { - return v + return v, nil } - return uint8(Uint64(any)) + v, err := doUint64(any) + return uint8(v), err } // Uint16 converts `any` to uint16. -func Uint16(any interface{}) uint16 { +func Uint16(any any) uint16 { + v, _ := doUint16(any) + return v +} + +func doUint16(any any) (uint16, error) { if any == nil { - return 0 + return 0, nil } if v, ok := any.(uint16); ok { - return v + return v, nil } - return uint16(Uint64(any)) + v, err := doUint64(any) + return uint16(v), err } // Uint32 converts `any` to uint32. -func Uint32(any interface{}) uint32 { +func Uint32(any any) uint32 { + v, _ := doUint32(any) + return v +} + +func doUint32(any any) (uint32, error) { if any == nil { - return 0 + return 0, nil } if v, ok := any.(uint32); ok { - return v + return v, nil } - return uint32(Uint64(any)) + v, err := doUint64(any) + return uint32(v), err } // Uint64 converts `any` to uint64. -func Uint64(any interface{}) uint64 { +func Uint64(any any) uint64 { + v, _ := doUint64(any) + return v +} + +func doUint64(any any) (uint64, error) { if any == nil { - return 0 + return 0, nil + } + if v, ok := any.(uint64); ok { + return v, nil } rv := reflect.ValueOf(any) switch rv.Kind() { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return uint64(rv.Int()) + val := rv.Int() + if val < 0 { + return uint64(val), gerror.NewCodef( + gcode.CodeInvalidParameter, + `cannot convert negative value "%d" to uint64`, + val, + ) + } + return uint64(val), nil case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return uint64(rv.Uint()) + return rv.Uint(), nil case reflect.Uintptr: - return uint64(rv.Uint()) + return rv.Uint(), nil case reflect.Float32, reflect.Float64: - return uint64(rv.Float()) + val := rv.Float() + if val < 0 { + return uint64(val), gerror.NewCodef( + gcode.CodeInvalidParameter, + `cannot convert negative value "%f" to uint64`, + val, + ) + } + return uint64(val), nil case reflect.Bool: if rv.Bool() { - return 1 + return 1, nil } - return 0 + return 0, nil case reflect.Ptr: if rv.IsNil() { - return 0 + return 0, nil } if f, ok := any.(localinterface.IUint64); ok { - return f.Uint64() + return f.Uint64(), nil } - return Uint64(rv.Elem().Interface()) + return doUint64(rv.Elem().Interface()) case reflect.Slice: - // TODO:These types should be panic if rv.Type().Elem().Kind() == reflect.Uint8 { - return gbinary.DecodeToUint64(rv.Bytes()) + return gbinary.DecodeToUint64(rv.Bytes()), nil } - case reflect.String: - var ( - s = rv.String() + return 0, gerror.NewCodef( + gcode.CodeInvalidParameter, + `unsupport slice type "%s" for converting to uint64`, + rv.Type().String(), ) + case reflect.String: + var s = rv.String() // Hexadecimal if len(s) > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X') { - if v, e := strconv.ParseUint(s[2:], 16, 64); e == nil { - return v + v, err := strconv.ParseUint(s[2:], 16, 64) + if err == nil { + return v, nil } + return 0, gerror.WrapCodef( + gcode.CodeInvalidParameter, + err, + `cannot convert hexadecimal string "%s" to uint64`, + s, + ) } // Decimal - if v, e := strconv.ParseUint(s, 10, 64); e == nil { - return v + if v, err := strconv.ParseUint(s, 10, 64); err == nil { + return v, nil } // Float64 - if valueFloat64 := Float64(any); math.IsNaN(valueFloat64) { - return 0 - } else { - return uint64(valueFloat64) + if v, err := doFloat64(any); err == nil { + if math.IsNaN(v) { + return 0, nil + } + return uint64(v), nil } default: if f, ok := any.(localinterface.IUint64); ok { - return f.Uint64() + return f.Uint64(), nil } } - return 0 + return 0, gerror.NewCodef( + gcode.CodeInvalidParameter, + `unsupport value type "%s" for converting to uint64`, + reflect.TypeOf(any).String(), + ) } diff --git a/util/gconv/gconv_z_unit_scan_basic_types_test.go b/util/gconv/gconv_z_unit_scan_basic_types_test.go new file mode 100644 index 00000000000..7e13faaab6e --- /dev/null +++ b/util/gconv/gconv_z_unit_scan_basic_types_test.go @@ -0,0 +1,171 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package gconv_test + +import ( + "testing" + "time" + + "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" +) + +type testScan struct { + Src any + Dst any + Expect any +} + +func TestScanBasicTypes(t *testing.T) { + // Define test data structure + type User struct { + Name string + Age int + } + type UserWithTag struct { + Name string `json:"name"` + Age int `json:"age"` + } + + // Prepare test data + var testScanData = []testScan{ + // Basic type conversion + {1, new(int), 1}, + {int8(1), new(int16), int16(1)}, + {int16(1), new(int32), int32(1)}, + {int32(1), new(int64), int64(1)}, + {uint(1), new(int), 1}, + {uint8(1), new(int), 1}, + {uint16(1), new(int), 1}, + {uint32(1), new(int), 1}, + {uint64(1), new(int), 1}, + {float32(1.0), new(int), 1}, + {float64(1.0), new(int), 1}, + {true, new(int), 1}, + {false, new(int), 0}, + {"1", new(int), 1}, + {"true", new(bool), true}, + {"false", new(bool), false}, + {1, new(bool), true}, + {0, new(bool), false}, + + // String conversion + {1, new(string), "1"}, + {1.1, new(string), "1.1"}, + {true, new(string), "true"}, + {false, new(string), "false"}, + {[]byte("hello"), new(string), "hello"}, + + // Slice conversion + {[]int{1, 2, 3}, new([]string), []string{"1", "2", "3"}}, + {[]string{"1", "2", "3"}, new([]int), []int{1, 2, 3}}, + {`["1","2","3"]`, new([]string), []string{"1", "2", "3"}}, + {`[1,2,3]`, new([]int), []int{1, 2, 3}}, + + // Map conversion + { + map[string]interface{}{"name": "john", "age": 18}, + new(User), + &User{Name: "john", Age: 18}, + }, + { + `{"name":"john","age":18}`, + new(User), + &User{Name: "john", Age: 18}, + }, + { + map[string]interface{}{"name": "john", "age": 18}, + new(UserWithTag), + &UserWithTag{Name: "john", Age: 18}, + }, + { + map[string]string{"name": "john", "age": "18"}, + new(map[string]interface{}), + &map[string]interface{}{"name": "john", "age": "18"}, + }, + + // Struct conversion + { + User{Name: "john", Age: 18}, + new(map[string]interface{}), + &map[string]interface{}{"Name": "john", "Age": 18}, + }, + { + &User{Name: "john", Age: 18}, + new(UserWithTag), + &UserWithTag{Name: "john", Age: 18}, + }, + + // Special cases + {nil, new(interface{}), nil}, + {nil, new(*int), (*int)(nil)}, + {[]byte(nil), new(string), ""}, + {"", new(int), 0}, + {"", new(float64), 0.0}, + {"", new(bool), false}, + + // Time type + {time.Date(2023, 1, 2, 0, 0, 0, 0, time.Local), new(string), "2023-01-02 00:00:00"}, + + // Pointer conversion + {&User{Name: "john"}, new(*User), &User{Name: "john"}}, + } + + // Basic types test. + gtest.C(t, func(t *gtest.T) { + for _, v := range testScanData { + // t.Logf(`%#v`, v) + err := gconv.Scan(v.Src, v.Dst) + t.AssertNil(err) + } + }) + + // int -> **int + gtest.C(t, func(t *gtest.T) { + var ( + v = 100 + i *int + ) + err := gconv.Scan(v, &i) + t.AssertNil(err) + t.AssertNE(i, nil) + t.Assert(*i, v) + }) + // *int -> **int + gtest.C(t, func(t *gtest.T) { + var ( + v = 100 + i *int + ) + err := gconv.Scan(&v, &i) + t.AssertNil(err) + t.AssertNE(i, nil) + t.Assert(*i, v) + }) + // string -> **string + gtest.C(t, func(t *gtest.T) { + var ( + v = "1000" + i *string + ) + err := gconv.Scan(v, &i) + t.AssertNil(err) + t.AssertNE(i, nil) + t.Assert(*i, v) + }) + // *string -> **string + gtest.C(t, func(t *gtest.T) { + var ( + v = "1000" + i *string + ) + err := gconv.Scan(&v, &i) + t.AssertNil(err) + t.AssertNE(i, nil) + t.Assert(*i, v) + }) +} diff --git a/util/gconv/gconv_z_unit_scan_test.go b/util/gconv/gconv_z_unit_scan_test.go index 4790565dd49..76620d1f44d 100644 --- a/util/gconv/gconv_z_unit_scan_test.go +++ b/util/gconv/gconv_z_unit_scan_test.go @@ -362,29 +362,15 @@ func TestScan(t *testing.T) { mapParameter = map[string]string{"Name": "Place", "Place": "Name"} ) - // TODO: The following test cases should be working, but they are not. - //err = gconv.Scan(test, &scanExpects.mapStrStr, mapParameter) - //t.AssertNil(err) - //t.Assert(test["Name"], scanExpects.mapStrStr["Place"]) - //t.Assert(test["Place"], scanExpects.mapStrStr["Name"]) - // - //err = gconv.Scan(test, &scanExpects.mapStrAny, mapParameter) - //t.AssertNil(err) - //t.Assert(test["Name"], scanExpects.mapStrAny["Place"]) - //t.Assert(test["Place"], scanExpects.mapStrAny["Name"]) - // - //err = gconv.Scan(test, &scanExpects.mapAnyAny, mapParameter) - //t.AssertNil(err) - //t.Assert(test["Name"], scanExpects.mapAnyAny["Place"]) - //t.Assert(test["Place"], scanExpects.mapAnyAny["Name"]) - err = gconv.Scan(test, &scanExpects.structSub, mapParameter) t.AssertNil(err) t.Assert(test["Name"], scanExpects.structSub.Place) t.Assert(test["Place"], scanExpects.structSub.Name) + //t.Logf("%#v", test) err = gconv.Scan(test, &scanExpects.structSubPtr, mapParameter) t.AssertNil(err) + //t.Logf("%#v", scanExpects.structSubPtr) t.Assert(test["Name"], scanExpects.structSubPtr.Place) t.Assert(test["Place"], scanExpects.structSubPtr.Name) } diff --git a/util/gconv/gconv_z_unit_uint_test.go b/util/gconv/gconv_z_unit_uint_test.go index 2908a79b98c..58ae283d0cf 100644 --- a/util/gconv/gconv_z_unit_uint_test.go +++ b/util/gconv/gconv_z_unit_uint_test.go @@ -120,8 +120,9 @@ var uintTests = []struct { func TestUint(t *testing.T) { gtest.C(t, func(t *gtest.T) { - for _, test := range uintTests { - t.AssertEQ(gconv.Uint(test.value), test.expect) + for _, v := range uintTests { + //t.Logf(`%+v`, v) + t.AssertEQ(gconv.Uint(v.value), v.expect) } }) } From 92eab81926dea3ef090905c8f4da267c84fd11a3 Mon Sep 17 00:00:00 2001 From: John Guo Date: Wed, 18 Dec 2024 15:54:27 +0800 Subject: [PATCH 061/102] fix(database/gdb): add compatibility for old configiration with both `Type` and part of `Link` configurations (#4058) --- database/gdb/gdb_core_config.go | 18 +++++++++++++----- database/gdb/gdb_z_mysql_internal_test.go | 17 +++++++++++++++++ 2 files changed, 30 insertions(+), 5 deletions(-) diff --git a/database/gdb/gdb_core_config.go b/database/gdb/gdb_core_config.go index 3a15024b42c..ae9c7c85ba2 100644 --- a/database/gdb/gdb_core_config.go +++ b/database/gdb/gdb_core_config.go @@ -7,6 +7,7 @@ package gdb import ( + "fmt" "sync" "time" @@ -381,14 +382,22 @@ func (c *Core) GetSchema() string { } func parseConfigNodeLink(node *ConfigNode) (*ConfigNode, error) { - var match []string - if node.Link != "" { - match, _ = gregex.MatchString(linkPattern, node.Link) + var ( + link = node.Link + match []string + ) + if link != "" { + // To be compatible with old configuration, + // it checks and converts the link to new configuration. + if node.Type != "" && !gstr.HasPrefix(link, node.Type+":") { + link = fmt.Sprintf("%s:%s", node.Type, link) + } + match, _ = gregex.MatchString(linkPattern, link) if len(match) <= 5 { return nil, gerror.NewCodef( gcode.CodeInvalidParameter, `invalid link configuration: %s, shuold be pattern like: %s`, - node.Link, linkPatternDescription, + link, linkPatternDescription, ) } node.Type = match[1] @@ -412,7 +421,6 @@ func parseConfigNodeLink(node *ConfigNode) (*ConfigNode, error) { if len(match) > 6 && match[7] != "" { node.Extra = match[7] } - node.Link = "" } if node.Extra != "" { if m, _ := gstr.Parse(node.Extra); len(m) > 0 { diff --git a/database/gdb/gdb_z_mysql_internal_test.go b/database/gdb/gdb_z_mysql_internal_test.go index b2ec6e83b95..ec70000b907 100644 --- a/database/gdb/gdb_z_mysql_internal_test.go +++ b/database/gdb/gdb_z_mysql_internal_test.go @@ -278,6 +278,23 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) { t.Assert(newNode.Charset, `utf8`) t.Assert(newNode.Protocol, `unix`) }) + gtest.C(t, func(t *gtest.T) { + node := &ConfigNode{ + Type: "mysql", + Link: "username:password@unix(/tmp/mysql.sock)/dbname", + } + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) + t.Assert(newNode.Type, `mysql`) + t.Assert(newNode.User, `username`) + t.Assert(newNode.Pass, `password`) + t.Assert(newNode.Host, `/tmp/mysql.sock`) + t.Assert(newNode.Port, ``) + t.Assert(newNode.Name, `dbname`) + t.Assert(newNode.Extra, ``) + t.Assert(newNode.Charset, `utf8`) + t.Assert(newNode.Protocol, `unix`) + }) } func Test_Func_doQuoteWord(t *testing.T) { From 817ac36ce24af81b05e663a9d4f90e479b76d52a Mon Sep 17 00:00:00 2001 From: John Guo Date: Thu, 19 Dec 2024 10:11:55 +0800 Subject: [PATCH 062/102] ci: use latest go version for unit testing cases of contribution components (#4062) --- .github/workflows/ci-main.sh | 3 --- .github/workflows/ci-main.yml | 21 ++++++++++++++------- .github/workflows/ci-sub.yml | 11 ++++++++--- cmd/gf/go.work | 1 - 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci-main.sh b/.github/workflows/ci-main.sh index 7171edab4e6..21891888024 100644 --- a/.github/workflows/ci-main.sh +++ b/.github/workflows/ci-main.sh @@ -1,8 +1,5 @@ #!/usr/bin/env bash -# Define the latest Go version requirement -LATEST_GO_VERSION="1.23" - coverage=$1 # find all path that contains go.mod. diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index ecbd084c67f..888476f77d9 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -28,10 +28,21 @@ concurrency: env: TZ: "Asia/Shanghai" - + # for unit testing cases of some components that only execute on the latest go version. + LATEST_GO_VERSION: "1.23" jobs: code-test: + strategy: + matrix: + # 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥 + # When adding new go version to the list, make sure: + # 1. Update the `LATEST_GO_VERSION` env variable. + # 2. Update the `Report Coverage` action. + # 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥 + go-version: [ "1.20", "1.21", "1.22", "1.23" ] + goarch: [ "386", "amd64" ] + runs-on: ubuntu-20.04 # Service containers to run with `code-test` @@ -185,11 +196,6 @@ jobs: ports: - 2181:2181 - strategy: - matrix: - go-version: [ "1.20", "1.21", "1.22", "1.23" ] - goarch: [ "386", "amd64" ] - steps: # TODO: szenius/set-timezone update to node16 # sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime @@ -256,7 +262,8 @@ jobs: - name: Report Coverage uses: codecov/codecov-action@v4 - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + # Only report coverage on the latest go version and amd64 arch + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.go-version == '1.23' && matrix.goarch == 'amd64' }} with: flags: go-${{ matrix.go-version }}-${{ matrix.goarch }} token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/ci-sub.yml b/.github/workflows/ci-sub.yml index 56d9bb6eba3..5b98814ef36 100644 --- a/.github/workflows/ci-sub.yml +++ b/.github/workflows/ci-sub.yml @@ -29,17 +29,22 @@ concurrency: env: TZ: "Asia/Shanghai" - + # for unit testing cases of some components that only execute on the latest go version. + LATEST_GO_VERSION: "1.23" jobs: code-test: - runs-on: ubuntu-latest - strategy: matrix: + # 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥 + # When adding new go version to the list, make sure: + # 1. Update the `LATEST_GO_VERSION` env variable. + # 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥 go-version: [ "1.20", "1.21", "1.22", "1.23" ] goarch: [ "386", "amd64" ] + runs-on: ubuntu-latest + steps: - name: Setup Timezone uses: szenius/set-timezone@v2.0 diff --git a/cmd/gf/go.work b/cmd/gf/go.work index 1fbd6cb9a7c..19bee584aad 100644 --- a/cmd/gf/go.work +++ b/cmd/gf/go.work @@ -16,6 +16,5 @@ replace ( github.com/gogf/gf/contrib/drivers/oracle/v2 => ../../contrib/drivers/oracle github.com/gogf/gf/contrib/drivers/pgsql/v2 => ../../contrib/drivers/pgsql github.com/gogf/gf/contrib/drivers/sqlite/v2 => ../../contrib/drivers/sqlite - github.com/gogf/gf/contrib/drivers/dm/v2 => ../../contrib/drivers/dm github.com/gogf/gf/v2 => ../../ ) From 4c2a78b7bf23c48aaf17924a46822e452e6624e8 Mon Sep 17 00:00:00 2001 From: "Mr.Fan" <6213378@qq.com> Date: Thu, 19 Dec 2024 21:44:36 +0800 Subject: [PATCH 063/102] fix(database/gdb): regular expression pattern for link configuration to be compitable with tidbcloud (#4064) --- database/gdb/gdb.go | 2 +- database/gdb/gdb_z_mysql_internal_test.go | 34 +++++++++++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/database/gdb/gdb.go b/database/gdb/gdb.go index de3cdf3d369..558ca92c957 100644 --- a/database/gdb/gdb.go +++ b/database/gdb/gdb.go @@ -708,7 +708,7 @@ const ( ctxKeyCatchSQL gctx.StrKey = `CtxKeyCatchSQL` ctxKeyInternalProducedSQL gctx.StrKey = `CtxKeyInternalProducedSQL` - linkPattern = `(\w+):([\w\-\$]*):(.*?)@(\w+?)\((.+?)\)/{0,1}([^\?]*)\?{0,1}(.*)` + linkPattern = `^(\w+):(.*?):(.*?)@(\w+?)\((.+?)\)/{0,1}([^\?]*)\?{0,1}(.*?)$` linkPatternDescription = `type:username:password@protocol(host:port)/dbname?param1=value1&...¶mN=valueN` ) diff --git a/database/gdb/gdb_z_mysql_internal_test.go b/database/gdb/gdb_z_mysql_internal_test.go index ec70000b907..8539c2c9481 100644 --- a/database/gdb/gdb_z_mysql_internal_test.go +++ b/database/gdb/gdb_z_mysql_internal_test.go @@ -295,6 +295,40 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) { t.Assert(newNode.Charset, `utf8`) t.Assert(newNode.Protocol, `unix`) }) + // https://github.com/gogf/gf/issues/4059 + gtest.C(t, func(t *gtest.T) { + node := &ConfigNode{ + Link: "tidb:2hcmRccccxxx9Fizz.root:wP3xxxxPIDc@tcp(xxxx.tidbcloud.com:4000)/db_name?tls=true", + } + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) + t.Assert(newNode.Type, `tidb`) + t.Assert(newNode.User, `2hcmRccccxxx9Fizz.root`) + t.Assert(newNode.Pass, `wP3xxxxPIDc`) + t.Assert(newNode.Host, `xxxx.tidbcloud.com`) + t.Assert(newNode.Port, `4000`) + t.Assert(newNode.Name, `db_name`) + t.Assert(newNode.Extra, `tls=true`) + t.Assert(newNode.Charset, `utf8`) + t.Assert(newNode.Protocol, `tcp`) + }) + gtest.C(t, func(t *gtest.T) { + node := &ConfigNode{ + Type: "tidb", + Link: "2hcmRccccxxx9Fizz.root:wP3xxxxPIDc@tcp(xxxx.tidbcloud.com:4000)/db_name?tls=true", + } + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) + t.Assert(newNode.Type, `tidb`) + t.Assert(newNode.User, `2hcmRccccxxx9Fizz.root`) + t.Assert(newNode.Pass, `wP3xxxxPIDc`) + t.Assert(newNode.Host, `xxxx.tidbcloud.com`) + t.Assert(newNode.Port, `4000`) + t.Assert(newNode.Name, `db_name`) + t.Assert(newNode.Extra, `tls=true`) + t.Assert(newNode.Charset, `utf8`) + t.Assert(newNode.Protocol, `tcp`) + }) } func Test_Func_doQuoteWord(t *testing.T) { From 594979c5afd22f01ca717247e6e243a0fc808d57 Mon Sep 17 00:00:00 2001 From: John Guo Date: Thu, 19 Dec 2024 22:31:17 +0800 Subject: [PATCH 064/102] fix(net/ghttp): nil pointer panic error when server logger set nil (#4055) --- net/ghttp/ghttp_server_config.go | 9 +++++++-- net/ghttp/ghttp_server_config_logging.go | 4 ++-- net/ghttp/ghttp_server_log.go | 4 ++-- net/ghttp/ghttp_z_unit_issue_test.go | 12 ++++++++++++ 4 files changed, 23 insertions(+), 6 deletions(-) diff --git a/net/ghttp/ghttp_server_config.go b/net/ghttp/ghttp_server_config.go index 450f9bb05fb..f5a6f4fe969 100644 --- a/net/ghttp/ghttp_server_config.go +++ b/net/ghttp/ghttp_server_config.go @@ -343,6 +343,9 @@ func (s *Server) SetConfigWithMap(m map[string]interface{}) error { if k, v := gutil.MapPossibleItemByKey(m, "FormParsingMemory"); k != "" { m[k] = gfile.StrToSize(gconv.String(v)) } + if _, v := gutil.MapPossibleItemByKey(m, "Logger"); v == nil { + intlog.Printf(context.TODO(), "SetConfigWithMap: set Logger nil") + } // Update the current configuration object. // It only updates the configured keys not all the object. if err := gconv.Struct(m, &s.config); err != nil { @@ -379,8 +382,10 @@ func (s *Server) SetConfig(c ServerConfig) error { return err } } - if err := s.config.Logger.SetLevelStr(s.config.LogLevel); err != nil { - intlog.Errorf(context.TODO(), `%+v`, err) + if s.config.Logger != nil { + if err := s.config.Logger.SetLevelStr(s.config.LogLevel); err != nil { + intlog.Errorf(context.TODO(), `%+v`, err) + } } gracefulEnabled = c.Graceful intlog.Printf(context.TODO(), "SetConfig: %+v", s.config) diff --git a/net/ghttp/ghttp_server_config_logging.go b/net/ghttp/ghttp_server_config_logging.go index f3e566b397e..c35edeb54eb 100644 --- a/net/ghttp/ghttp_server_config_logging.go +++ b/net/ghttp/ghttp_server_config_logging.go @@ -68,10 +68,10 @@ func (s *Server) GetLogPath() string { // IsAccessLogEnabled checks whether the access log enabled. func (s *Server) IsAccessLogEnabled() bool { - return s.config.AccessLogEnabled + return s.config.AccessLogEnabled && s.config.Logger != nil } // IsErrorLogEnabled checks whether the error log enabled. func (s *Server) IsErrorLogEnabled() bool { - return s.config.ErrorLogEnabled + return s.config.ErrorLogEnabled && s.config.Logger != nil } diff --git a/net/ghttp/ghttp_server_log.go b/net/ghttp/ghttp_server_log.go index 9f4e917dfbd..49b498ad09f 100644 --- a/net/ghttp/ghttp_server_log.go +++ b/net/ghttp/ghttp_server_log.go @@ -31,7 +31,7 @@ func (s *Server) handleAccessLog(r *Request) { r.GetClientIp(), r.Referer(), r.UserAgent(), ) logger := instance.GetOrSetFuncLock(loggerInstanceKey, func() interface{} { - l := s.Logger().Clone() + l := s.Logger() l.SetFile(s.config.AccessLogPattern) l.SetStdoutPrint(s.config.LogStdout) l.SetLevelPrint(false) @@ -73,7 +73,7 @@ func (s *Server) handleErrorLog(err error, r *Request) { content += ", " + err.Error() } logger := instance.GetOrSetFuncLock(loggerInstanceKey, func() interface{} { - l := s.Logger().Clone() + l := s.Logger() l.SetStack(false) l.SetFile(s.config.ErrorLogPattern) l.SetStdoutPrint(s.config.LogStdout) diff --git a/net/ghttp/ghttp_z_unit_issue_test.go b/net/ghttp/ghttp_z_unit_issue_test.go index d0d17b8471c..080597d0d52 100644 --- a/net/ghttp/ghttp_z_unit_issue_test.go +++ b/net/ghttp/ghttp_z_unit_issue_test.go @@ -618,3 +618,15 @@ func Test_Issue3789(t *testing.T) { t.Assert(c.GetContent(ctx, "/hello?id=&secondId=2&thirdId=3"), expect) }) } + +// https://github.com/gogf/gf/issues/4047 +func Test_Issue4047(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + s := g.Server(guid.S()) + err := s.SetConfigWithMap(g.Map{ + "logger": nil, + }) + t.AssertNil(err) + t.Assert(s.Logger(), nil) + }) +} From 3a19ee9268c131c50cc5c207f8fb310f01f07e44 Mon Sep 17 00:00:00 2001 From: yijiong <59520517+yzy613@users.noreply.github.com> Date: Wed, 25 Dec 2024 21:43:55 +0800 Subject: [PATCH 065/102] fix: securiry update CVE-2024-45338 for package `golang.org/x/net` (#4070) --- cmd/gf/go.mod | 4 ++-- cmd/gf/go.sum | 36 +++++++++++++++---------------- contrib/config/apollo/go.mod | 2 +- contrib/config/apollo/go.sum | 4 ++-- contrib/config/consul/go.mod | 2 +- contrib/config/consul/go.sum | 4 ++-- contrib/config/kubecm/go.mod | 2 +- contrib/config/kubecm/go.sum | 4 ++-- contrib/config/nacos/go.mod | 4 ++-- contrib/config/nacos/go.sum | 8 +++---- contrib/config/polaris/go.mod | 2 +- contrib/config/polaris/go.sum | 4 ++-- contrib/drivers/clickhouse/go.mod | 2 +- contrib/drivers/clickhouse/go.sum | 4 ++-- contrib/drivers/dm/go.mod | 2 +- contrib/drivers/dm/go.sum | 4 ++-- contrib/drivers/mssql/go.mod | 4 ++-- contrib/drivers/mssql/go.sum | 8 +++---- contrib/drivers/mysql/go.mod | 2 +- contrib/drivers/mysql/go.sum | 4 ++-- contrib/drivers/oracle/go.mod | 2 +- contrib/drivers/oracle/go.sum | 4 ++-- contrib/drivers/pgsql/go.mod | 2 +- contrib/drivers/pgsql/go.sum | 4 ++-- contrib/drivers/sqlite/go.mod | 2 +- contrib/drivers/sqlite/go.sum | 4 ++-- contrib/drivers/sqlitecgo/go.mod | 2 +- contrib/drivers/sqlitecgo/go.sum | 4 ++-- contrib/metric/otelmetric/go.mod | 2 +- contrib/metric/otelmetric/go.sum | 4 ++-- contrib/nosql/redis/go.mod | 2 +- contrib/nosql/redis/go.sum | 4 ++-- contrib/registry/etcd/go.mod | 2 +- contrib/registry/etcd/go.sum | 4 ++-- contrib/registry/file/go.mod | 2 +- contrib/registry/file/go.sum | 4 ++-- contrib/registry/nacos/go.mod | 4 ++-- contrib/registry/nacos/go.sum | 8 +++---- contrib/registry/polaris/go.mod | 2 +- contrib/registry/polaris/go.sum | 4 ++-- contrib/registry/zookeeper/go.mod | 2 +- contrib/registry/zookeeper/go.sum | 4 ++-- contrib/rpc/grpcx/go.mod | 2 +- contrib/rpc/grpcx/go.sum | 4 ++-- contrib/sdk/httpclient/go.mod | 2 +- contrib/sdk/httpclient/go.sum | 4 ++-- contrib/trace/otlpgrpc/go.mod | 2 +- contrib/trace/otlpgrpc/go.sum | 4 ++-- contrib/trace/otlphttp/go.mod | 2 +- contrib/trace/otlphttp/go.sum | 4 ++-- example/go.mod | 4 ++-- example/go.sum | 8 +++---- go.mod | 2 +- go.sum | 4 ++-- 54 files changed, 110 insertions(+), 110 deletions(-) diff --git a/cmd/gf/go.mod b/cmd/gf/go.mod index e3cd3bd69ad..e2d19e73074 100644 --- a/cmd/gf/go.mod +++ b/cmd/gf/go.mod @@ -50,8 +50,8 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/crypto v0.30.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/crypto v0.31.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect diff --git a/cmd/gf/go.sum b/cmd/gf/go.sum index 1451be4ef79..ad3b4a1875d 100644 --- a/cmd/gf/go.sum +++ b/cmd/gf/go.sum @@ -39,20 +39,20 @@ github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiU github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= -github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.8.2 h1:4g5n8QdJA7ZEuDfWFeVQKMhul6RtOT89ObYAgVnxN+U= -github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.8.2/go.mod h1:xW1mgNK0vTLfRSCnO0No8G4lCGNpXx1Jlhs6B1vzD+8= -github.com/gogf/gf/contrib/drivers/mssql/v2 v2.8.2 h1:aNscErx5mcC28Q1L0MsZFFXybzLY/IJhskyiPAbxB78= -github.com/gogf/gf/contrib/drivers/mssql/v2 v2.8.2/go.mod h1:yj6+Ds2BGzYcHthPvMnxhDRzq0o28HyO9E1Fsko0Lf8= -github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.2 h1:thK4DZT0irDrnhIxkap5JqBuBIJaXQ0IMvlIzuRGgVQ= -github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.2/go.mod h1:Vg7XaiwsQ27YmpDqzwCQ+yt10KntTvcP9iOoFL5DF40= -github.com/gogf/gf/contrib/drivers/oracle/v2 v2.8.2 h1:ZukTXB9drVDmSdrFjCYHVzHj0kAvGKISrrW3WKU1xTg= -github.com/gogf/gf/contrib/drivers/oracle/v2 v2.8.2/go.mod h1:wr+KA5h3+aJQk5XiA1qSNKxWBVrzlu8MVYKl1NqcQj4= -github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.8.2 h1:BsEBGoVfa4SPJ8GhNkH9PPtoSLydXK+VgcbpxyGF9Ps= -github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.8.2/go.mod h1:OSlAQeO7fZMbscxZomMCBcZWHSxpfeXIi6ELeKszSPU= -github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.8.2 h1:144IdPDn6xyHVQ5aP4qsstFvNOLqvWyz+GtH3JD1rWg= -github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.8.2/go.mod h1:xOgOp3SSdWHIEqviYC1kd3p6mJtfFkrcinBWdpgVUxc= -github.com/gogf/gf/v2 v2.8.2 h1:4k641rn+hV1COAKygqsqcTm8+lDTkcO8HQ4iBv/uTFs= -github.com/gogf/gf/v2 v2.8.2/go.mod h1:n++xPYGUUMadw6IygLEgGZqc6y6DRLrJKg5kqCrPLWY= +github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.8.3 h1:b/AQMTxiHKPHsidEdk471AC5pkfoK88a5cPmKnzE53U= +github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.8.3/go.mod h1:qYrF+x5urXLhce3pMcUAyccIsw3Oec0htynoDE4Boi4= +github.com/gogf/gf/contrib/drivers/mssql/v2 v2.8.3 h1:F7Gt1y6YsYOIvgrUlRK07H29BL77dEgLPXilTqqVC80= +github.com/gogf/gf/contrib/drivers/mssql/v2 v2.8.3/go.mod h1:K5prIMZwHANSZrqZbfm6PoEIMfLtd0PwR7u+hZD9HFs= +github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.3 h1:RtoBg5HWACFrgIrFkpzH94kxSd5EWefNAq5k6olNY6c= +github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.3/go.mod h1:elZjckHRCejwml5Kdx2zfhOUDiAV3r5i4BgXcKAeH00= +github.com/gogf/gf/contrib/drivers/oracle/v2 v2.8.3 h1:10/RCoWmvQ6PSm+leoS6CsKijH4dB38HOXLgP5+aScQ= +github.com/gogf/gf/contrib/drivers/oracle/v2 v2.8.3/go.mod h1:XSaHf3/vTlzj/zioUbzKmaffPuoKvPV639fT91caheM= +github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.8.3 h1:DvpoiVac1cwGVDTqC6wzFbDb+gXNzcceRgZUIcuTmaI= +github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.8.3/go.mod h1:zugvYVb6c/X9rJ8Gb6b5WkMe+bFz2BsxQ5OLf4RSZos= +github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.8.3 h1:3pdibfm4UOiTGGh6UD8jfMyGZBGH9ikrrIMU8i/XANA= +github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.8.3/go.mod h1:G5rfcFkBhtmZT4+CU7A3fJH3sNmP4WRIaJ+4JFeVE08= +github.com/gogf/gf/v2 v2.8.3 h1:h9Px3lqJnnH6It0AqHRz4/1hx0JmvaSf1IvUir5x1rA= +github.com/gogf/gf/v2 v2.8.3/go.mod h1:n++xPYGUUMadw6IygLEgGZqc6y6DRLrJKg5kqCrPLWY= github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f h1:7xfXR/BhG3JDqO1s45n65Oyx9t4E/UqDOXep6jXdLCM= github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f/go.mod h1:HnYoio6S7VaFJdryKcD/r9HgX+4QzYfr00XiXUo/xz0= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= @@ -145,8 +145,8 @@ golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACk golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20210220033148-5ea612d1eb83/go.mod h1:jdWPYTVW3xRLrWPugEBEK3UY2ZEsg3UU495nc5E+M+I= -golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= -golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.17.0 h1:zY54UmvipHiNd+pm+m0x9KhZ9hl1/7QNMyxXbc6ICqA= @@ -155,8 +155,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/contrib/config/apollo/go.mod b/contrib/config/apollo/go.mod index 5080c2b1489..6f9ac8ca61a 100644 --- a/contrib/config/apollo/go.mod +++ b/contrib/config/apollo/go.mod @@ -36,7 +36,7 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect gopkg.in/ini.v1 v1.62.0 // indirect diff --git a/contrib/config/apollo/go.sum b/contrib/config/apollo/go.sum index ea5fb99d01d..ee5c6736c59 100644 --- a/contrib/config/apollo/go.sum +++ b/contrib/config/apollo/go.sum @@ -369,8 +369,8 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= diff --git a/contrib/config/consul/go.mod b/contrib/config/consul/go.mod index 06fdbe40d4e..95a6515ca14 100644 --- a/contrib/config/consul/go.mod +++ b/contrib/config/consul/go.mod @@ -37,7 +37,7 @@ 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/net v0.32.0 // indirect + golang.org/x/net v0.33.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/config/consul/go.sum b/contrib/config/consul/go.sum index 65a46cfbeee..3f76ae9107f 100644 --- a/contrib/config/consul/go.sum +++ b/contrib/config/consul/go.sum @@ -198,8 +198,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/contrib/config/kubecm/go.mod b/contrib/config/kubecm/go.mod index 262b1bf7ebc..46d0fa1eadd 100644 --- a/contrib/config/kubecm/go.mod +++ b/contrib/config/kubecm/go.mod @@ -48,7 +48,7 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/term v0.27.0 // indirect diff --git a/contrib/config/kubecm/go.sum b/contrib/config/kubecm/go.sum index 42d6e64aa1b..55e505bf94b 100644 --- a/contrib/config/kubecm/go.sum +++ b/contrib/config/kubecm/go.sum @@ -287,8 +287,8 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= diff --git a/contrib/config/nacos/go.mod b/contrib/config/nacos/go.mod index 1af537fd71b..b978301e178 100644 --- a/contrib/config/nacos/go.mod +++ b/contrib/config/nacos/go.mod @@ -52,8 +52,8 @@ 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/net v0.32.0 // indirect + golang.org/x/crypto v0.31.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect diff --git a/contrib/config/nacos/go.sum b/contrib/config/nacos/go.sum index f2af4b1f192..793db51b044 100644 --- a/contrib/config/nacos/go.sum +++ b/contrib/config/nacos/go.sum @@ -305,8 +305,8 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= -golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -372,8 +372,8 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= diff --git a/contrib/config/polaris/go.mod b/contrib/config/polaris/go.mod index b5ab5eab0ac..0eb981a904a 100644 --- a/contrib/config/polaris/go.mod +++ b/contrib/config/polaris/go.mod @@ -48,7 +48,7 @@ require ( go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.21.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect diff --git a/contrib/config/polaris/go.sum b/contrib/config/polaris/go.sum index 703e7792333..5f743769fa5 100644 --- a/contrib/config/polaris/go.sum +++ b/contrib/config/polaris/go.sum @@ -582,8 +582,8 @@ golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= diff --git a/contrib/drivers/clickhouse/go.mod b/contrib/drivers/clickhouse/go.mod index c5b0f724fd0..7236e2ff569 100644 --- a/contrib/drivers/clickhouse/go.mod +++ b/contrib/drivers/clickhouse/go.mod @@ -31,7 +31,7 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.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/drivers/clickhouse/go.sum b/contrib/drivers/clickhouse/go.sum index f6ef4d1c4ac..b8e2dc36514 100644 --- a/contrib/drivers/clickhouse/go.sum +++ b/contrib/drivers/clickhouse/go.sum @@ -102,8 +102,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/contrib/drivers/dm/go.mod b/contrib/drivers/dm/go.mod index ececa192f79..3ec7d3535f3 100644 --- a/contrib/drivers/dm/go.mod +++ b/contrib/drivers/dm/go.mod @@ -30,7 +30,7 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.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/drivers/dm/go.sum b/contrib/drivers/dm/go.sum index 1b0ff9aff02..f1788d81930 100644 --- a/contrib/drivers/dm/go.sum +++ b/contrib/drivers/dm/go.sum @@ -48,8 +48,8 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/drivers/mssql/go.mod b/contrib/drivers/mssql/go.mod index aff47d8fde9..dc3a870fb8c 100644 --- a/contrib/drivers/mssql/go.mod +++ b/contrib/drivers/mssql/go.mod @@ -29,8 +29,8 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/crypto v0.30.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/crypto v0.31.0 // indirect + golang.org/x/net v0.33.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/drivers/mssql/go.sum b/contrib/drivers/mssql/go.sum index 5c588f2f825..8f14274a111 100644 --- a/contrib/drivers/mssql/go.sum +++ b/contrib/drivers/mssql/go.sum @@ -60,10 +60,10 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= -golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/drivers/mysql/go.mod b/contrib/drivers/mysql/go.mod index 13255823883..d2926f7e635 100644 --- a/contrib/drivers/mysql/go.mod +++ b/contrib/drivers/mysql/go.mod @@ -27,7 +27,7 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.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/drivers/mysql/go.sum b/contrib/drivers/mysql/go.sum index 3857f838de7..6ef4453d917 100644 --- a/contrib/drivers/mysql/go.sum +++ b/contrib/drivers/mysql/go.sum @@ -46,8 +46,8 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/drivers/oracle/go.mod b/contrib/drivers/oracle/go.mod index 5b782dc93b6..e788cb21f61 100644 --- a/contrib/drivers/oracle/go.mod +++ b/contrib/drivers/oracle/go.mod @@ -27,7 +27,7 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.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/drivers/oracle/go.sum b/contrib/drivers/oracle/go.sum index 20159b13709..672dbcdf48c 100644 --- a/contrib/drivers/oracle/go.sum +++ b/contrib/drivers/oracle/go.sum @@ -46,8 +46,8 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/drivers/pgsql/go.mod b/contrib/drivers/pgsql/go.mod index 09ed53aba15..88149c5ff80 100644 --- a/contrib/drivers/pgsql/go.mod +++ b/contrib/drivers/pgsql/go.mod @@ -27,7 +27,7 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.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/drivers/pgsql/go.sum b/contrib/drivers/pgsql/go.sum index f1b56657cb8..d05809bdbc1 100644 --- a/contrib/drivers/pgsql/go.sum +++ b/contrib/drivers/pgsql/go.sum @@ -46,8 +46,8 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/drivers/sqlite/go.mod b/contrib/drivers/sqlite/go.mod index eed458eada6..b976ec39203 100644 --- a/contrib/drivers/sqlite/go.mod +++ b/contrib/drivers/sqlite/go.mod @@ -30,7 +30,7 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.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/drivers/sqlite/go.sum b/contrib/drivers/sqlite/go.sum index a6ac1e9edc6..850148b5db8 100644 --- a/contrib/drivers/sqlite/go.sum +++ b/contrib/drivers/sqlite/go.sum @@ -54,8 +54,8 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/drivers/sqlitecgo/go.mod b/contrib/drivers/sqlitecgo/go.mod index 1ced67e3432..0ab90efd926 100644 --- a/contrib/drivers/sqlitecgo/go.mod +++ b/contrib/drivers/sqlitecgo/go.mod @@ -27,7 +27,7 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.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/drivers/sqlitecgo/go.sum b/contrib/drivers/sqlitecgo/go.sum index e463112f27c..475b2af81fc 100644 --- a/contrib/drivers/sqlitecgo/go.sum +++ b/contrib/drivers/sqlitecgo/go.sum @@ -46,8 +46,8 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/metric/otelmetric/go.mod b/contrib/metric/otelmetric/go.mod index 26670ea86fb..e85f6796884 100644 --- a/contrib/metric/otelmetric/go.mod +++ b/contrib/metric/otelmetric/go.mod @@ -37,7 +37,7 @@ require ( github.com/rivo/uniseg v0.4.7 // indirect github.com/rogpeppe/go-internal v1.12.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect google.golang.org/protobuf v1.34.2 // indirect diff --git a/contrib/metric/otelmetric/go.sum b/contrib/metric/otelmetric/go.sum index 79f4008cb69..227f3b4b615 100644 --- a/contrib/metric/otelmetric/go.sum +++ b/contrib/metric/otelmetric/go.sum @@ -68,8 +68,8 @@ go.opentelemetry.io/otel/sdk/metric v1.24.0 h1:yyMQrPzF+k88/DbH7o4FMAs80puqd+9os go.opentelemetry.io/otel/sdk/metric v1.24.0/go.mod h1:I6Y5FjH6rvEnTTAYQz3Mmv2kl6Ek5IIrmwTLqMrrOE0= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/nosql/redis/go.mod b/contrib/nosql/redis/go.mod index 29dc703d832..31ae3f65a15 100644 --- a/contrib/nosql/redis/go.mod +++ b/contrib/nosql/redis/go.mod @@ -29,7 +29,7 @@ require ( github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.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/nosql/redis/go.sum b/contrib/nosql/redis/go.sum index 0c3db9d7c1d..19373cc9aa0 100644 --- a/contrib/nosql/redis/go.sum +++ b/contrib/nosql/redis/go.sum @@ -52,8 +52,8 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/registry/etcd/go.mod b/contrib/registry/etcd/go.mod index 50db4fee6dd..1f1d3e63c56 100644 --- a/contrib/registry/etcd/go.mod +++ b/contrib/registry/etcd/go.mod @@ -37,7 +37,7 @@ require ( go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.17.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect diff --git a/contrib/registry/etcd/go.sum b/contrib/registry/etcd/go.sum index 2bf6733f784..21b5c2a4fa8 100644 --- a/contrib/registry/etcd/go.sum +++ b/contrib/registry/etcd/go.sum @@ -88,8 +88,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/contrib/registry/file/go.mod b/contrib/registry/file/go.mod index f26c0572097..b72a7aed850 100644 --- a/contrib/registry/file/go.mod +++ b/contrib/registry/file/go.mod @@ -24,7 +24,7 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.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/file/go.sum b/contrib/registry/file/go.sum index 3f5df0ec368..350837ecef3 100644 --- a/contrib/registry/file/go.sum +++ b/contrib/registry/file/go.sum @@ -44,8 +44,8 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/registry/nacos/go.mod b/contrib/registry/nacos/go.mod index ee1b6f4c3b2..1b23b616ed4 100644 --- a/contrib/registry/nacos/go.mod +++ b/contrib/registry/nacos/go.mod @@ -51,8 +51,8 @@ require ( go.uber.org/atomic v1.7.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/net v0.32.0 // indirect + golang.org/x/crypto v0.31.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect diff --git a/contrib/registry/nacos/go.sum b/contrib/registry/nacos/go.sum index 8f1eddd6fdc..d0dc23db6f3 100644 --- a/contrib/registry/nacos/go.sum +++ b/contrib/registry/nacos/go.sum @@ -288,8 +288,8 @@ golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8U golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= -golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= @@ -351,8 +351,8 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= diff --git a/contrib/registry/polaris/go.mod b/contrib/registry/polaris/go.mod index dbbc7ba7213..539919601e3 100644 --- a/contrib/registry/polaris/go.mod +++ b/contrib/registry/polaris/go.mod @@ -48,7 +48,7 @@ require ( go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect go.uber.org/zap v1.21.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect diff --git a/contrib/registry/polaris/go.sum b/contrib/registry/polaris/go.sum index e784f1e8dbe..cdc89d8d300 100644 --- a/contrib/registry/polaris/go.sum +++ b/contrib/registry/polaris/go.sum @@ -591,8 +591,8 @@ golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= diff --git a/contrib/registry/zookeeper/go.mod b/contrib/registry/zookeeper/go.mod index 6c2a5c0f5e6..0f66fc04825 100644 --- a/contrib/registry/zookeeper/go.mod +++ b/contrib/registry/zookeeper/go.mod @@ -28,7 +28,7 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.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/zookeeper/go.sum b/contrib/registry/zookeeper/go.sum index f0cf8086b81..3ecc8084ee2 100644 --- a/contrib/registry/zookeeper/go.sum +++ b/contrib/registry/zookeeper/go.sum @@ -46,8 +46,8 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/contrib/rpc/grpcx/go.mod b/contrib/rpc/grpcx/go.mod index 465676b0a56..30c82f48c3b 100644 --- a/contrib/rpc/grpcx/go.mod +++ b/contrib/rpc/grpcx/go.mod @@ -29,7 +29,7 @@ require ( github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect diff --git a/contrib/rpc/grpcx/go.sum b/contrib/rpc/grpcx/go.sum index ce2771206f8..6940bbe9ec9 100644 --- a/contrib/rpc/grpcx/go.sum +++ b/contrib/rpc/grpcx/go.sum @@ -44,8 +44,8 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/sdk/httpclient/go.mod b/contrib/sdk/httpclient/go.mod index be05225fbea..70ccad2a851 100644 --- a/contrib/sdk/httpclient/go.mod +++ b/contrib/sdk/httpclient/go.mod @@ -24,7 +24,7 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/sdk v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.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/sdk/httpclient/go.sum b/contrib/sdk/httpclient/go.sum index 3f5df0ec368..350837ecef3 100644 --- a/contrib/sdk/httpclient/go.sum +++ b/contrib/sdk/httpclient/go.sum @@ -44,8 +44,8 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/trace/otlpgrpc/go.mod b/contrib/trace/otlpgrpc/go.mod index b32e636b26b..49a842aa061 100644 --- a/contrib/trace/otlpgrpc/go.mod +++ b/contrib/trace/otlpgrpc/go.mod @@ -32,7 +32,7 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect go.opentelemetry.io/proto/otlp v1.1.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240711142825-46eb208f015d // indirect diff --git a/contrib/trace/otlpgrpc/go.sum b/contrib/trace/otlpgrpc/go.sum index 92a50b717aa..860a7184539 100644 --- a/contrib/trace/otlpgrpc/go.sum +++ b/contrib/trace/otlpgrpc/go.sum @@ -58,8 +58,8 @@ go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI= go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY= go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/trace/otlphttp/go.mod b/contrib/trace/otlphttp/go.mod index 25afc8d744a..74f7d0b4c0e 100644 --- a/contrib/trace/otlphttp/go.mod +++ b/contrib/trace/otlphttp/go.mod @@ -31,7 +31,7 @@ require ( go.opentelemetry.io/otel/metric v1.24.0 // indirect go.opentelemetry.io/otel/trace v1.24.0 // indirect go.opentelemetry.io/proto/otlp v1.1.0 // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect google.golang.org/genproto/googleapis/api v0.0.0-20240318140521-94a12d6c2237 // indirect diff --git a/contrib/trace/otlphttp/go.sum b/contrib/trace/otlphttp/go.sum index 8178bfd1719..49b114929b3 100644 --- a/contrib/trace/otlphttp/go.sum +++ b/contrib/trace/otlphttp/go.sum @@ -57,8 +57,8 @@ go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= go.opentelemetry.io/proto/otlp v1.1.0 h1:2Di21piLrCqJ3U3eXGCTPHE9R8Nh+0uglSnOyxikMeI= go.opentelemetry.io/proto/otlp v1.1.0/go.mod h1:GpBHCBWiqvVLDqmHZsoMM3C5ySeKTC7ej/RNTae6MdY= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/example/go.mod b/example/go.mod index 426044591d5..f108cda9d62 100644 --- a/example/go.mod +++ b/example/go.mod @@ -135,9 +135,9 @@ require ( go.opentelemetry.io/proto/otlp v1.3.1 // indirect go.uber.org/multierr v1.10.0 // indirect go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.30.0 // indirect + golang.org/x/crypto v0.31.0 // indirect golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect - golang.org/x/net v0.32.0 // indirect + golang.org/x/net v0.33.0 // indirect golang.org/x/oauth2 v0.23.0 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect diff --git a/example/go.sum b/example/go.sum index 71f6c7064a6..b22f16a2fb2 100644 --- a/example/go.sum +++ b/example/go.sum @@ -798,8 +798,8 @@ golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPh golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= -golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= -golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= +golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= @@ -902,8 +902,8 @@ golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= diff --git a/go.mod b/go.mod index 91ec47e8915..435c17e03bb 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( go.opentelemetry.io/otel v1.24.0 go.opentelemetry.io/otel/sdk v1.24.0 go.opentelemetry.io/otel/trace v1.24.0 - golang.org/x/net v0.32.0 + golang.org/x/net v0.33.0 golang.org/x/text v0.21.0 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index 3f5df0ec368..350837ecef3 100644 --- a/go.sum +++ b/go.sum @@ -44,8 +44,8 @@ go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucg go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= -golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= -golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= +golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= +golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= From 96e833db6e96a4688eff85c3ce56ce455a33ac33 Mon Sep 17 00:00:00 2001 From: wwwfeng <32693877+wwwfeng@users.noreply.github.com> Date: Thu, 26 Dec 2024 10:17:51 +0800 Subject: [PATCH 066/102] feat(gf/gen/pbentity): add a `TablesEx` configuration to exclude the specified table names (#4060) --- .github/workflows/ci-main.sh | 3 - .github/workflows/ci-main.yml | 21 +++-- .github/workflows/ci-sub.yml | 11 ++- cmd/gf/go.work | 1 - .../cmd/cmd_z_unit_gen_pbentity_test.go | 81 +++++++++++++++++++ .../internal/cmd/genpbentity/genpbentity.go | 10 +++ 6 files changed, 113 insertions(+), 14 deletions(-) diff --git a/.github/workflows/ci-main.sh b/.github/workflows/ci-main.sh index 7171edab4e6..21891888024 100644 --- a/.github/workflows/ci-main.sh +++ b/.github/workflows/ci-main.sh @@ -1,8 +1,5 @@ #!/usr/bin/env bash -# Define the latest Go version requirement -LATEST_GO_VERSION="1.23" - coverage=$1 # find all path that contains go.mod. diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index ad37fbcafd1..db0dea5de10 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -28,10 +28,21 @@ concurrency: env: TZ: "Asia/Shanghai" - + # for unit testing cases of some components that only execute on the latest go version. + LATEST_GO_VERSION: "1.23" jobs: code-test: + strategy: + matrix: + # 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥 + # When adding new go version to the list, make sure: + # 1. Update the `LATEST_GO_VERSION` env variable. + # 2. Update the `Report Coverage` action. + # 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥 + go-version: [ "1.20", "1.21", "1.22", "1.23" ] + goarch: [ "386", "amd64" ] + runs-on: ubuntu-20.04 # Service containers to run with `code-test` @@ -185,11 +196,6 @@ jobs: ports: - 2181:2181 - strategy: - matrix: - go-version: [ "1.20", "1.21", "1.22", "1.23" ] - goarch: [ "386", "amd64" ] - steps: # TODO: szenius/set-timezone update to node16 # sudo ln -sf /usr/share/zoneinfo/Asia/Shanghai /etc/localtime @@ -256,7 +262,8 @@ jobs: - name: Report Coverage uses: codecov/codecov-action@v4 - if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} + # Only report coverage on the latest go version and amd64 arch + if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' && matrix.go-version == '1.23' && matrix.goarch == 'amd64' }} with: flags: go-${{ matrix.go-version }}-${{ matrix.goarch }} token: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/ci-sub.yml b/.github/workflows/ci-sub.yml index 56d9bb6eba3..5b98814ef36 100644 --- a/.github/workflows/ci-sub.yml +++ b/.github/workflows/ci-sub.yml @@ -29,17 +29,22 @@ concurrency: env: TZ: "Asia/Shanghai" - + # for unit testing cases of some components that only execute on the latest go version. + LATEST_GO_VERSION: "1.23" jobs: code-test: - runs-on: ubuntu-latest - strategy: matrix: + # 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥 + # When adding new go version to the list, make sure: + # 1. Update the `LATEST_GO_VERSION` env variable. + # 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥 go-version: [ "1.20", "1.21", "1.22", "1.23" ] goarch: [ "386", "amd64" ] + runs-on: ubuntu-latest + steps: - name: Setup Timezone uses: szenius/set-timezone@v2.0 diff --git a/cmd/gf/go.work b/cmd/gf/go.work index 1fbd6cb9a7c..19bee584aad 100644 --- a/cmd/gf/go.work +++ b/cmd/gf/go.work @@ -16,6 +16,5 @@ replace ( github.com/gogf/gf/contrib/drivers/oracle/v2 => ../../contrib/drivers/oracle github.com/gogf/gf/contrib/drivers/pgsql/v2 => ../../contrib/drivers/pgsql github.com/gogf/gf/contrib/drivers/sqlite/v2 => ../../contrib/drivers/sqlite - github.com/gogf/gf/contrib/drivers/dm/v2 => ../../contrib/drivers/dm github.com/gogf/gf/v2 => ../../ ) diff --git a/cmd/gf/internal/cmd/cmd_z_unit_gen_pbentity_test.go b/cmd/gf/internal/cmd/cmd_z_unit_gen_pbentity_test.go index 89770f5ba6f..5ecb7b39c28 100644 --- a/cmd/gf/internal/cmd/cmd_z_unit_gen_pbentity_test.go +++ b/cmd/gf/internal/cmd/cmd_z_unit_gen_pbentity_test.go @@ -286,3 +286,84 @@ func Test_Issue_3685(t *testing.T) { } }) } + +// https://github.com/gogf/gf/issues/3955 +func Test_Issue_3955(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + err error + db = testDB + table1 = "table_user_a" + table2 = "table_user_b" + sqlContent = fmt.Sprintf( + gtest.DataContent(`genpbentity`, `user.tpl.sql`), + table1, + ) + sqlContent2 = fmt.Sprintf( + gtest.DataContent(`genpbentity`, `user.tpl.sql`), + table2, + ) + ) + dropTableWithDb(db, table1) + dropTableWithDb(db, table2) + + array := gstr.SplitAndTrim(sqlContent, ";") + for _, v := range array { + if _, err = db.Exec(ctx, v); err != nil { + t.AssertNil(err) + } + } + + array = gstr.SplitAndTrim(sqlContent2, ";") + for _, v := range array { + if _, err = db.Exec(ctx, v); err != nil { + t.AssertNil(err) + } + } + + defer dropTableWithDb(db, table1) + defer dropTableWithDb(db, table2) + + var ( + path = gfile.Temp(guid.S()) + in = genpbentity.CGenPbEntityInput{ + Path: path, + Package: "unittest", + Link: link, + Tables: "", + Prefix: "", + RemovePrefix: "", + RemoveFieldPrefix: "", + NameCase: "", + JsonCase: "", + Option: "", + TablesEx: "table_user_a", + } + ) + err = gutil.FillStructWithDefault(&in) + t.AssertNil(err) + + err = gfile.Mkdir(path) + t.AssertNil(err) + defer gfile.Remove(path) + + _, err = genpbentity.CGenPbEntity{}.PbEntity(ctx, in) + t.AssertNil(err) + + files, err := gfile.ScanDir(path, "*.proto", false) + t.AssertNil(err) + + t.AssertEQ(len(files), 1) + + t.Assert(files, []string{ + path + filepath.FromSlash("/table_user_b.proto"), + }) + + expectFiles := []string{ + path + filepath.FromSlash("/table_user_b.proto"), + } + for i := range files { + t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i])) + } + }) +} diff --git a/cmd/gf/internal/cmd/genpbentity/genpbentity.go b/cmd/gf/internal/cmd/genpbentity/genpbentity.go index e7138850d30..658b284fa71 100644 --- a/cmd/gf/internal/cmd/genpbentity/genpbentity.go +++ b/cmd/gf/internal/cmd/genpbentity/genpbentity.go @@ -10,6 +10,7 @@ import ( "bytes" "context" "fmt" + "github.com/gogf/gf/v2/container/gset" "path/filepath" "regexp" "strings" @@ -43,6 +44,7 @@ type ( Prefix string `name:"prefix" short:"f" brief:"{CGenPbEntityBriefPrefix}"` RemovePrefix string `name:"removePrefix" short:"r" brief:"{CGenPbEntityBriefRemovePrefix}"` RemoveFieldPrefix string `name:"removeFieldPrefix" short:"rf" brief:"{CGenPbEntityBriefRemoveFieldPrefix}"` + TablesEx string `name:"tablesEx" short:"x" brief:"{CGenDaoBriefTablesEx}"` NameCase string `name:"nameCase" short:"n" brief:"{CGenPbEntityBriefNameCase}" d:"Camel"` JsonCase string `name:"jsonCase" short:"j" brief:"{CGenPbEntityBriefJsonCase}" d:"none"` Option string `name:"option" short:"o" brief:"{CGenPbEntityBriefOption}"` @@ -115,6 +117,7 @@ CONFIGURATION SUPPORT CGenPbEntityBriefTables = `generate models only for given tables, multiple table names separated with ','` CGenPbEntityBriefPrefix = `add specified prefix for all entity names and entity proto files` CGenPbEntityBriefRemovePrefix = `remove specified prefix of the table, multiple prefix separated with ','` + CGenPbEntityBriefTablesEx = `generate all models exclude the specified tables, multiple prefix separated with ','` CGenPbEntityBriefRemoveFieldPrefix = `remove specified prefix of the field, multiple prefix separated with ','` CGenPbEntityBriefOption = `extra protobuf options` CGenPbEntityBriefGroup = ` @@ -240,6 +243,7 @@ func init() { `CGenPbEntityBriefTables`: CGenPbEntityBriefTables, `CGenPbEntityBriefPrefix`: CGenPbEntityBriefPrefix, `CGenPbEntityBriefRemovePrefix`: CGenPbEntityBriefRemovePrefix, + `CGenPbEntityBriefTablesEx`: CGenPbEntityBriefTablesEx, `CGenPbEntityBriefRemoveFieldPrefix`: CGenPbEntityBriefRemoveFieldPrefix, `CGenPbEntityBriefGroup`: CGenPbEntityBriefGroup, `CGenPbEntityBriefNameCase`: CGenPbEntityBriefNameCase, @@ -290,6 +294,9 @@ func doGenPbEntityForArray(ctx context.Context, index int, in CGenPbEntityInput) in.Package = modName + "/" + defaultPackageSuffix } removePrefixArray := gstr.SplitAndTrim(in.RemovePrefix, ",") + + excludeTables := gset.NewStrSetFrom(gstr.SplitAndTrim(in.TablesEx, ",")) + // It uses user passed database configuration. if in.Link != "" { var ( @@ -331,6 +338,9 @@ func doGenPbEntityForArray(ctx context.Context, index int, in CGenPbEntityInput) } for _, tableName := range tableNames { + if excludeTables.Contains(tableName) { + continue + } newTableName := tableName for _, v := range removePrefixArray { newTableName = gstr.TrimLeftStr(newTableName, v, 1) From e6bee78be48fbfc36a7fcfacdfbf8d46e60c3b84 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" Date: Thu, 26 Dec 2024 02:18:19 +0000 Subject: [PATCH 067/102] Apply gci import order changes --- cmd/gf/internal/cmd/genpbentity/genpbentity.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/gf/internal/cmd/genpbentity/genpbentity.go b/cmd/gf/internal/cmd/genpbentity/genpbentity.go index 658b284fa71..8d497fe8edf 100644 --- a/cmd/gf/internal/cmd/genpbentity/genpbentity.go +++ b/cmd/gf/internal/cmd/genpbentity/genpbentity.go @@ -10,7 +10,6 @@ import ( "bytes" "context" "fmt" - "github.com/gogf/gf/v2/container/gset" "path/filepath" "regexp" "strings" @@ -18,6 +17,7 @@ import ( "github.com/olekukonko/tablewriter" "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/container/gset" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" From 89e5285d95352ddbe6476a091ddb971b7313a465 Mon Sep 17 00:00:00 2001 From: Wlynxg Date: Thu, 26 Dec 2024 10:18:47 +0800 Subject: [PATCH 068/102] feat(net/ghttp): move plugin remove logic to Shutdown() && call Shutdown() when Run() exits (#4072) --- database/gdb/gdb.go | 2 +- database/gdb/gdb_z_mysql_internal_test.go | 34 +++++++++++++++++++++++ net/ghttp/ghttp_server.go | 14 ++-------- net/ghttp/ghttp_server_admin.go | 13 ++++++++- net/ghttp/ghttp_server_config.go | 9 ++++-- net/ghttp/ghttp_server_config_logging.go | 4 +-- net/ghttp/ghttp_server_log.go | 4 +-- net/ghttp/ghttp_z_unit_issue_test.go | 12 ++++++++ 8 files changed, 73 insertions(+), 19 deletions(-) diff --git a/database/gdb/gdb.go b/database/gdb/gdb.go index de3cdf3d369..558ca92c957 100644 --- a/database/gdb/gdb.go +++ b/database/gdb/gdb.go @@ -708,7 +708,7 @@ const ( ctxKeyCatchSQL gctx.StrKey = `CtxKeyCatchSQL` ctxKeyInternalProducedSQL gctx.StrKey = `CtxKeyInternalProducedSQL` - linkPattern = `(\w+):([\w\-\$]*):(.*?)@(\w+?)\((.+?)\)/{0,1}([^\?]*)\?{0,1}(.*)` + linkPattern = `^(\w+):(.*?):(.*?)@(\w+?)\((.+?)\)/{0,1}([^\?]*)\?{0,1}(.*?)$` linkPatternDescription = `type:username:password@protocol(host:port)/dbname?param1=value1&...¶mN=valueN` ) diff --git a/database/gdb/gdb_z_mysql_internal_test.go b/database/gdb/gdb_z_mysql_internal_test.go index ec70000b907..8539c2c9481 100644 --- a/database/gdb/gdb_z_mysql_internal_test.go +++ b/database/gdb/gdb_z_mysql_internal_test.go @@ -295,6 +295,40 @@ func Test_parseConfigNodeLink_WithType(t *testing.T) { t.Assert(newNode.Charset, `utf8`) t.Assert(newNode.Protocol, `unix`) }) + // https://github.com/gogf/gf/issues/4059 + gtest.C(t, func(t *gtest.T) { + node := &ConfigNode{ + Link: "tidb:2hcmRccccxxx9Fizz.root:wP3xxxxPIDc@tcp(xxxx.tidbcloud.com:4000)/db_name?tls=true", + } + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) + t.Assert(newNode.Type, `tidb`) + t.Assert(newNode.User, `2hcmRccccxxx9Fizz.root`) + t.Assert(newNode.Pass, `wP3xxxxPIDc`) + t.Assert(newNode.Host, `xxxx.tidbcloud.com`) + t.Assert(newNode.Port, `4000`) + t.Assert(newNode.Name, `db_name`) + t.Assert(newNode.Extra, `tls=true`) + t.Assert(newNode.Charset, `utf8`) + t.Assert(newNode.Protocol, `tcp`) + }) + gtest.C(t, func(t *gtest.T) { + node := &ConfigNode{ + Type: "tidb", + Link: "2hcmRccccxxx9Fizz.root:wP3xxxxPIDc@tcp(xxxx.tidbcloud.com:4000)/db_name?tls=true", + } + newNode, err := parseConfigNodeLink(node) + t.AssertNil(err) + t.Assert(newNode.Type, `tidb`) + t.Assert(newNode.User, `2hcmRccccxxx9Fizz.root`) + t.Assert(newNode.Pass, `wP3xxxxPIDc`) + t.Assert(newNode.Host, `xxxx.tidbcloud.com`) + t.Assert(newNode.Port, `4000`) + t.Assert(newNode.Name, `db_name`) + t.Assert(newNode.Extra, `tls=true`) + t.Assert(newNode.Charset, `utf8`) + t.Assert(newNode.Protocol, `tcp`) + }) } func Test_Func_doQuoteWord(t *testing.T) { diff --git a/net/ghttp/ghttp_server.go b/net/ghttp/ghttp_server.go index be567d068d7..6e84d9c952a 100644 --- a/net/ghttp/ghttp_server.go +++ b/net/ghttp/ghttp_server.go @@ -454,17 +454,9 @@ func (s *Server) Run() { // Blocking using the channel for graceful restart. <-s.closeChan - // Remove plugins. - if len(s.plugins) > 0 { - for _, p := range s.plugins { - intlog.Printf(ctx, `remove plugin: %s`, p.Name()) - if err := p.Remove(); err != nil { - intlog.Errorf(ctx, "%+v", err) - } - } - } - s.doServiceDeregister() - s.Logger().Infof(ctx, "pid[%d]: all servers shutdown", gproc.Pid()) + + // Shutdown the server + _ = s.Shutdown() } // Wait blocks to wait for all servers done. diff --git a/net/ghttp/ghttp_server_admin.go b/net/ghttp/ghttp_server_admin.go index 58f63575dec..987e51a3ea4 100644 --- a/net/ghttp/ghttp_server_admin.go +++ b/net/ghttp/ghttp_server_admin.go @@ -88,14 +88,25 @@ func (s *Server) EnableAdmin(pattern ...string) { s.BindObject(p, &utilAdmin{}) } -// Shutdown shuts down current server. +// Shutdown shuts the current server. func (s *Server) Shutdown() error { var ctx = context.TODO() + // Remove plugins. + if len(s.plugins) > 0 { + for _, p := range s.plugins { + s.Logger().Printf(ctx, `remove plugin: %s`, p.Name()) + if err := p.Remove(); err != nil { + s.Logger().Errorf(ctx, "%+v", err) + } + } + } + s.doServiceDeregister() // Only shut down current servers. // It may have multiple underlying http servers. for _, v := range s.servers { v.Shutdown(ctx) } + s.Logger().Infof(ctx, "pid[%d]: all servers shutdown", gproc.Pid()) return nil } diff --git a/net/ghttp/ghttp_server_config.go b/net/ghttp/ghttp_server_config.go index 450f9bb05fb..f5a6f4fe969 100644 --- a/net/ghttp/ghttp_server_config.go +++ b/net/ghttp/ghttp_server_config.go @@ -343,6 +343,9 @@ func (s *Server) SetConfigWithMap(m map[string]interface{}) error { if k, v := gutil.MapPossibleItemByKey(m, "FormParsingMemory"); k != "" { m[k] = gfile.StrToSize(gconv.String(v)) } + if _, v := gutil.MapPossibleItemByKey(m, "Logger"); v == nil { + intlog.Printf(context.TODO(), "SetConfigWithMap: set Logger nil") + } // Update the current configuration object. // It only updates the configured keys not all the object. if err := gconv.Struct(m, &s.config); err != nil { @@ -379,8 +382,10 @@ func (s *Server) SetConfig(c ServerConfig) error { return err } } - if err := s.config.Logger.SetLevelStr(s.config.LogLevel); err != nil { - intlog.Errorf(context.TODO(), `%+v`, err) + if s.config.Logger != nil { + if err := s.config.Logger.SetLevelStr(s.config.LogLevel); err != nil { + intlog.Errorf(context.TODO(), `%+v`, err) + } } gracefulEnabled = c.Graceful intlog.Printf(context.TODO(), "SetConfig: %+v", s.config) diff --git a/net/ghttp/ghttp_server_config_logging.go b/net/ghttp/ghttp_server_config_logging.go index f3e566b397e..c35edeb54eb 100644 --- a/net/ghttp/ghttp_server_config_logging.go +++ b/net/ghttp/ghttp_server_config_logging.go @@ -68,10 +68,10 @@ func (s *Server) GetLogPath() string { // IsAccessLogEnabled checks whether the access log enabled. func (s *Server) IsAccessLogEnabled() bool { - return s.config.AccessLogEnabled + return s.config.AccessLogEnabled && s.config.Logger != nil } // IsErrorLogEnabled checks whether the error log enabled. func (s *Server) IsErrorLogEnabled() bool { - return s.config.ErrorLogEnabled + return s.config.ErrorLogEnabled && s.config.Logger != nil } diff --git a/net/ghttp/ghttp_server_log.go b/net/ghttp/ghttp_server_log.go index 9f4e917dfbd..49b498ad09f 100644 --- a/net/ghttp/ghttp_server_log.go +++ b/net/ghttp/ghttp_server_log.go @@ -31,7 +31,7 @@ func (s *Server) handleAccessLog(r *Request) { r.GetClientIp(), r.Referer(), r.UserAgent(), ) logger := instance.GetOrSetFuncLock(loggerInstanceKey, func() interface{} { - l := s.Logger().Clone() + l := s.Logger() l.SetFile(s.config.AccessLogPattern) l.SetStdoutPrint(s.config.LogStdout) l.SetLevelPrint(false) @@ -73,7 +73,7 @@ func (s *Server) handleErrorLog(err error, r *Request) { content += ", " + err.Error() } logger := instance.GetOrSetFuncLock(loggerInstanceKey, func() interface{} { - l := s.Logger().Clone() + l := s.Logger() l.SetStack(false) l.SetFile(s.config.ErrorLogPattern) l.SetStdoutPrint(s.config.LogStdout) diff --git a/net/ghttp/ghttp_z_unit_issue_test.go b/net/ghttp/ghttp_z_unit_issue_test.go index d0d17b8471c..080597d0d52 100644 --- a/net/ghttp/ghttp_z_unit_issue_test.go +++ b/net/ghttp/ghttp_z_unit_issue_test.go @@ -618,3 +618,15 @@ func Test_Issue3789(t *testing.T) { t.Assert(c.GetContent(ctx, "/hello?id=&secondId=2&thirdId=3"), expect) }) } + +// https://github.com/gogf/gf/issues/4047 +func Test_Issue4047(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + s := g.Server(guid.S()) + err := s.SetConfigWithMap(g.Map{ + "logger": nil, + }) + t.AssertNil(err) + t.Assert(s.Logger(), nil) + }) +} From 6ea1526b751f7ec5b466eb98016402748eb793d5 Mon Sep 17 00:00:00 2001 From: houseme Date: Thu, 26 Dec 2024 10:19:01 +0800 Subject: [PATCH 069/102] fix(ci/golangci): fix golangcl-lint git push and apply format code on Push (#4077) --- .github/workflows/before_script.sh | 36 ++++++++++- .github/workflows/format-code-on-push.yml | 61 +++++++++++++++++++ .github/workflows/golangci-lint.yml | 44 ++----------- .github/workflows/issue-check-inactive.yml | 6 +- .github/workflows/issue-close-inactive.yml | 6 +- .github/workflows/issue-labeled.yml | 6 +- .github/workflows/issue-remove-inactive.yml | 6 +- .../issue-remove-need-more-details.yml | 6 +- .golangci.yml | 50 ++++++++++----- 9 files changed, 149 insertions(+), 72 deletions(-) create mode 100644 .github/workflows/format-code-on-push.yml diff --git a/.github/workflows/before_script.sh b/.github/workflows/before_script.sh index b0bbee27466..d9851ef497c 100644 --- a/.github/workflows/before_script.sh +++ b/.github/workflows/before_script.sh @@ -1,6 +1,36 @@ #!/usr/bin/env bash -find . -name "*.go" | xargs gofmt -w -git diff --name-only --exit-code || if [ $? != 0 ]; then echo "Notice: gofmt check failed,please gofmt before pr." && exit 1; fi -echo "gofmt check pass." +# Install gci +echo "Installing gci..." +go install github.com/daixiang0/gci@latest + +# Check if the GCI is installed successfully +if ! command -v gci &> /dev/null +then + echo "gci could not be installed. Please check your Go setup." + exit 1 +fi + +# Use GCI to format the code +echo "Running gci to format code..." +gci write \ + --custom-order \ + --skip-generated \ + --skip-vendor \ + -s standard \ + -s blank \ + -s default \ + -s dot \ + -s "prefix(github.com/gogf/gf/v2)" \ + -s "prefix(github.com/gogf/gf/cmd)" \ + -s "prefix(github.com/gogf/gf/contrib)" \ + -s "prefix(github.com/gogf/gf/example)" \ + ./ + +# Check the code for changes +git diff --name-only --exit-code || if [ $? != 0 ]; then echo "Notice: gci check failed, please gci before pr." && exit 1; fi +echo "gci check pass." + +# Add the local domain name to `/etc/hosts` +echo "Adding local domain to /etc/hosts..." sudo echo "127.0.0.1 local" | sudo tee -a /etc/hosts \ No newline at end of file diff --git a/.github/workflows/format-code-on-push.yml b/.github/workflows/format-code-on-push.yml new file mode 100644 index 00000000000..a9c4f63cc0f --- /dev/null +++ b/.github/workflows/format-code-on-push.yml @@ -0,0 +1,61 @@ +name: Format Code on Push + +on: + push + +jobs: + format-code: + strategy: + matrix: + go-version: [ 'stable' ] + name: format-code-by-gci + runs-on: ubuntu-latest + steps: + - name: Checkout code + uses: actions/checkout@v4 + - name: Setup Golang ${{ matrix.go-version }} + uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go-version }} + - name: Install gci + run: go install github.com/daixiang0/gci@latest + - name: Run gci + run: | + gci write --custom-order \ + --skip-generated \ + --skip-vendor \ + -s standard \ + -s blank \ + -s default \ + -s dot \ + -s "prefix(github.com/gogf/gf/v2)" \ + -s "prefix(github.com/gogf/gf/cmd)" \ + -s "prefix(github.com/gogf/gf/contrib)" \ + -s "prefix(github.com/gogf/gf/example)" \ + ./ + - name: Check for changes + run: | + if [[ -n "$(git status --porcelain)" ]]; then + echo "HAS_CHANGES=true" >> $GITHUB_ENV + else + echo "HAS_CHANGES=false" >> $GITHUB_ENV + fi + - name: Configure Git + run: | + if [[ "$HAS_CHANGES" == 'true' ]]; then + git config --global user.name "github-actions[bot]" + git config --global user.email "github-actions[bot]@users.noreply.github.com" + else + echo "HAS_CHANGES= $HAS_CHANGES " + fi + - name: Commit and push changes + run: | + if [[ "$HAS_CHANGES" == 'true' ]]; then + git add . + git commit -m "Apply gci import order changes" + git push origin ${{ github.event.pull_request.head.ref }} + else + echo "No change to commit push" + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index 9be6b9564d8..d15a8086986 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -4,7 +4,7 @@ # If a copy of the MIT was not distributed with this file, # You can obtain one at https://github.com/gogf/gf. -name: GolangCI-Lint +name: GolangCI Lint on: push: branches: @@ -26,11 +26,11 @@ on: - feat/** jobs: - golangci: + golang-ci: strategy: matrix: go-version: [ 'stable' ] - name: golangci-lint + name: golang-ci-lint runs-on: ubuntu-latest steps: - name: Checkout @@ -39,44 +39,12 @@ jobs: uses: actions/setup-go@v5 with: go-version: ${{ matrix.go-version }} - - name: golangci-lint + - name: golang-ci-lint uses: golangci/golangci-lint-action@v6 with: # Required: specify the golangci-lint version without the patch version to always use the latest patch. version: v1.62.2 only-new-issues: true + skip-cache: true github-token: ${{ secrets.GITHUB_TOKEN }} - args: --timeout 3m0s - - name: Install gci - run: go install github.com/daixiang0/gci@latest - - name: Run gci - run: | - gci write --custom-order \ - --skip-generated \ - --skip-vendor \ - -s standard \ - -s blank \ - -s default \ - -s dot \ - -s "prefix(github.com/gogf/gf/v2)" \ - -s "prefix(github.com/gogf/gf/cmd)" \ - -s "prefix(github.com/gogf/gf/contrib)" \ - -s "prefix(github.com/gogf/gf/example)" \ - ./ - - name: Check for changes - # Check if the event is a push or a pull request from a forked repository - if: github.event_name == 'push'|| (github.event_name == 'pull_request' && github.event.pull_request.head.repo.fork == true) - run: | - if [[ -n "$(git status --porcelain)" ]]; then - echo "HAS_CHANGES=true" >> $GITHUB_ENV - else - echo "HAS_CHANGES=false" >> $GITHUB_ENV - fi - - name: Commit and push changes - if: env.HAS_CHANGES == 'true' - run: | - git config --global user.name "github-actions[bot]" - 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 + args: --timeout 3m0s --config=.golangci.yml -v diff --git a/.github/workflows/issue-check-inactive.yml b/.github/workflows/issue-check-inactive.yml index 8ca295d86ca..4b16b4f9a80 100644 --- a/.github/workflows/issue-check-inactive.yml +++ b/.github/workflows/issue-check-inactive.yml @@ -1,12 +1,12 @@ -# 规则描述:每天凌晨3点(GMT+8)执行一次,将最近7天没有活跃且非BUG的ISSUE设置标签:inactive +# Rule description: Execute the ISSUE once a day at 3 a.m. (GMT+8) and set the non-bug issue that has not been active in the last 7 days to inactive name: Issue Check Inactive on: schedule: - cron: "0 19 * * *" -env: # 设置环境变量 - TZ: Asia/Shanghai #时区(设置时区可使页面中的`最近更新时间`使用时区时间) +env: # Set environment variables + TZ: Asia/Shanghai #Time zone (setting the time zone allows the 'Last Updated' on the page to use the time zone) permissions: contents: read diff --git a/.github/workflows/issue-close-inactive.yml b/.github/workflows/issue-close-inactive.yml index 2044b4a7f4c..06272aa2132 100644 --- a/.github/workflows/issue-close-inactive.yml +++ b/.github/workflows/issue-close-inactive.yml @@ -1,12 +1,12 @@ -# 规则描述:每天凌晨 4 点 (GMT+8) 执行一次,将最近 30 天没有活跃且非 BUG 的 ISSUE 关闭 +# RULE DESCRIPTION: EXECUTED ONCE A DAY AT 4 A.M. (GMT+8) TO CLOSE NON-BUG ISSUES THAT HAVE NOT BEEN ACTIVE IN THE LAST 30 DAYS name: Issue Close Inactive on: schedule: - cron: "0 20 * * *" -env: # 设置环境变量 - TZ: Asia/Shanghai #时区(设置时区可使页面中的`最近更新时间`使用时区时间) +env: # Set environment variables + TZ: Asia/Shanghai #Time zone (setting the time zone allows the 'Last Updated' on the page to use the time zone) jobs: close-issues: diff --git a/.github/workflows/issue-labeled.yml b/.github/workflows/issue-labeled.yml index 5f5e2ecdd0f..08b615380a8 100644 --- a/.github/workflows/issue-labeled.yml +++ b/.github/workflows/issue-labeled.yml @@ -1,4 +1,4 @@ -## 规则描述:当 issue 被标记为 help wanted 时,增加评论 +## Rule description: Add comments when an issue is marked as help wanted name: Issue Labeled @@ -6,8 +6,8 @@ on: issues: types: [labeled] -env: # 设置环境变量 - TZ: Asia/Shanghai # 时区(设置时区可使页面中的`最近更新时间`使用时区时间) +env: # Set environment variables + TZ: Asia/Shanghai # Time zone (setting the time zone allows the 'Last Updated' on the page to use the time zone) jobs: reply-labeled: diff --git a/.github/workflows/issue-remove-inactive.yml b/.github/workflows/issue-remove-inactive.yml index 8cd3f1ad7c0..94e975dd288 100644 --- a/.github/workflows/issue-remove-inactive.yml +++ b/.github/workflows/issue-remove-inactive.yml @@ -1,4 +1,4 @@ -# 规则描述:在 issue 没有活跃且尚未被关闭期间,若 issue 作者更新或评论该 ISSUE,则移除其 inactive 标签 +# Rule description: If an issue author updates or comments on an issue while it is not active and has not been closed, the inactive tag will be removed name: Issue Remove Inactive on: @@ -7,8 +7,8 @@ on: issue_comment: types: [created, edited] -env: # 设置环境变量 - TZ: Asia/Shanghai #时区(设置时区可使页面中的`最近更新时间`使用时区时间) +env: # Set environment variables + TZ: Asia/Shanghai #Time zone (setting the time zone allows the 'Last Updated' on the page to use the time zone) permissions: contents: read diff --git a/.github/workflows/issue-remove-need-more-details.yml b/.github/workflows/issue-remove-need-more-details.yml index e9e2ab03b83..80379693e20 100644 --- a/.github/workflows/issue-remove-need-more-details.yml +++ b/.github/workflows/issue-remove-need-more-details.yml @@ -1,4 +1,4 @@ -# 规则描述:将需要提供更多细节且暂未关闭的 issue,在 issue 作者评论后,移除 need more details 标签 +# Rule Description: For issues that need more details and are not yet closed, remove the "need more details" tag after the issue author comments name: Issue Remove Need More Details on: @@ -7,8 +7,8 @@ on: issue_comment: types: [created, edited] -env: # 设置环境变量 - TZ: Asia/Shanghai #时区(设置时区可使页面中的`最近更新时间`使用时区时间) +env: # Set environment variables + TZ: Asia/Shanghai #Time zone (setting the time zone allows the 'Last Updated' on the page to use the time zone) permissions: contents: read diff --git a/.golangci.yml b/.golangci.yml index a2b04ea7735..f1512b2b310 100644 --- a/.golangci.yml +++ b/.golangci.yml @@ -6,28 +6,46 @@ # Options for analysis running. run: + # Timeout for analysis, e.g. 30s, 5m. + # Default: 1m + timeout: 5m # Exit code when at least one issue was found. # Default: 1 issues-exit-code: 2 - # Include test files or not. # Default: true tests: false - - # Which dirs to skip: issues from them won't be reported. - # Can use regexp here: `generated.*`, regexp is applied on full path. - # Default value is empty list, - # but default dirs are skipped independently of this option's value (see skip-dirs-use-default). - # "/" will be replaced by current OS file path separator to properly work on Windows. - skip-dirs: [] - - # Which files to skip: they will be analyzed, but issues from them won't be reported. - # Default value is empty list, - # but there is no need to include all autogenerated files, - # we confidently recognize autogenerated files. - # If it's not please let us know. - # "/" will be replaced by current OS file path separator to properly work on Windows. - skip-files: [] + # List of build tags, all linters use it. + # Default: [] + build-tags: [] + # If set, we pass it to "go list -mod={option}". From "go help modules": + # If invoked with -mod=readonly, the go command is disallowed from the implicit + # automatic updating of go.mod described above. Instead, it fails when any changes + # to go.mod are needed. This setting is most useful to check that go.mod does + # not need updates, such as in a continuous integration and testing system. + # If invoked with -mod=vendor, the go command assumes that the vendor + # directory holds the correct copies of dependencies and ignores + # the dependency descriptions in go.mod. + # + # Allowed values: readonly|vendor|mod + # Default: "" + modules-download-mode: readonly + # Allow multiple parallel golangci-lint instances running. + # If false, golangci-lint acquires file lock on start. + # Default: false + allow-parallel-runners: true + # Allow multiple golangci-lint instances running, but serialize them around a lock. + # If false, golangci-lint exits with an error if it fails to acquire file lock on start. + # Default: false + allow-serial-runners: true + # Define the Go version limit. + # Mainly related to generics support since go1.18. + # Default: use Go version from the go.mod file, fallback on the env var `GOVERSION`, fallback on 1.17 + go: '1.20' + # Number of operating system threads (`GOMAXPROCS`) that can execute golangci-lint simultaneously. + # If it is explicitly set to 0 (i.e. not the default) then golangci-lint will automatically set the value to match Linux container CPU quota. + # Default: the number of logical CPUs in the machine + concurrency: 4 # Main linters configurations. From 9ce24096598854029470acec97bb8d8153e5e899 Mon Sep 17 00:00:00 2001 From: houseme Date: Thu, 26 Dec 2024 16:21:30 +0800 Subject: [PATCH 070/102] fix(util/gpage): `html.EscapeString` for pagination HTML generation and URL parsing (#4079) --- util/gpage/gpage.go | 14 ++++++++----- util/gpage/gpage_z_unit_test.go | 36 ++++++++++++++++----------------- 2 files changed, 27 insertions(+), 23 deletions(-) diff --git a/util/gpage/gpage.go b/util/gpage/gpage.go index ac138d60f78..d434e3f638f 100644 --- a/util/gpage/gpage.go +++ b/util/gpage/gpage.go @@ -164,7 +164,7 @@ func (p *Page) GetContent(mode int) string { p.FirstPageTag = "首页" p.LastPageTag = "尾页" return fmt.Sprintf( - `%s%s[第%d页]%s%s第%s页`, + `%s%s[第 %d 页]%s%s第%s页`, p.FirstPage(), p.PrevPage(), p.CurrentPage, @@ -184,7 +184,7 @@ func (p *Page) GetContent(mode int) string { pageStr += p.NextPage() pageStr += p.LastPage() pageStr += fmt.Sprintf( - `当前页%d/%d 共%d条`, + `当前页 %d/%d 共 %d 条`, p.CurrentPage, p.TotalPage, p.TotalSize, @@ -210,20 +210,24 @@ func (p *Page) GetContent(mode int) string { // The UrlTemplate attribute can be a URL or URI string containing the "{.page}" placeholder, // which will be replaced by the actual page number. func (p *Page) GetUrl(page int) string { - return gstr.Replace(p.UrlTemplate, DefaultPagePlaceHolder, gconv.String(page)) + return html.EscapeString(gstr.Replace(p.UrlTemplate, DefaultPagePlaceHolder, gconv.String(page))) } // GetLink returns the HTML link tag `a` content for given page number. func (p *Page) GetLink(page int, text, title string) string { + var ( + escapedTitle = html.EscapeString(title) + escapedText = html.EscapeString(text) + ) if len(p.AjaxActionName) > 0 { return fmt.Sprintf( `%s`, - p.LinkStyle, p.AjaxActionName, p.GetUrl(page), html.EscapeString(title), text, + p.LinkStyle, p.AjaxActionName, p.GetUrl(page), escapedTitle, escapedText, ) } else { return fmt.Sprintf( `%s`, - p.LinkStyle, p.GetUrl(page), html.EscapeString(title), text, + p.LinkStyle, p.GetUrl(page), escapedTitle, escapedText, ) } } diff --git a/util/gpage/gpage_z_unit_test.go b/util/gpage/gpage_z_unit_test.go index 79881330533..5399db86fdb 100644 --- a/util/gpage/gpage_z_unit_test.go +++ b/util/gpage/gpage_z_unit_test.go @@ -33,27 +33,27 @@ func Test_New(t *testing.T) { func Test_Basic(t *testing.T) { gtest.C(t, func(t *gtest.T) { page := gpage.New(9, 2, 1, `/user/list?page={.page}`) - t.Assert(page.NextPage(), `>`) + t.Assert(page.NextPage(), `>`) t.Assert(page.PrevPage(), `<`) t.Assert(page.FirstPage(), `|<`) - t.Assert(page.LastPage(), `>|`) + t.Assert(page.LastPage(), `>|`) t.Assert(page.PageBar(), `12345`) }) gtest.C(t, func(t *gtest.T) { page := gpage.New(9, 2, 3, `/user/list?page={.page}`) - t.Assert(page.NextPage(), `>`) - t.Assert(page.PrevPage(), `<`) - t.Assert(page.FirstPage(), `|<`) - t.Assert(page.LastPage(), `>|`) + t.Assert(page.NextPage(), `>`) + t.Assert(page.PrevPage(), `<`) + t.Assert(page.FirstPage(), `|<`) + t.Assert(page.LastPage(), `>|`) t.Assert(page.PageBar(), `12345`) }) gtest.C(t, func(t *gtest.T) { page := gpage.New(9, 2, 5, `/user/list?page={.page}`) t.Assert(page.NextPage(), `>`) - t.Assert(page.PrevPage(), `<`) - t.Assert(page.FirstPage(), `|<`) + t.Assert(page.PrevPage(), `<`) + t.Assert(page.FirstPage(), `|<`) t.Assert(page.LastPage(), `>|`) t.Assert(page.PageBar(), `12345`) }) @@ -82,10 +82,10 @@ func Test_CustomStyle(t *testing.T) { page.LinkStyle = "MyPageLink" page.SpanStyle = "MyPageSpan" page.SelectStyle = "MyPageSelect" - t.Assert(page.NextPage(), `>`) - t.Assert(page.PrevPage(), `<`) - t.Assert(page.FirstPage(), `|<`) - t.Assert(page.LastPage(), `>|`) + t.Assert(page.NextPage(), `>`) + t.Assert(page.PrevPage(), `<`) + t.Assert(page.FirstPage(), `|<`) + t.Assert(page.LastPage(), `>|`) t.Assert(page.PageBar(), `12345`) t.Assert(page.SelectBar(), ``) }) @@ -95,10 +95,10 @@ func Test_Ajax(t *testing.T) { gtest.C(t, func(t *gtest.T) { page := gpage.New(5, 1, 2, `/user/list/{.page}`) page.AjaxActionName = "LoadPage" - t.Assert(page.NextPage(), `>`) - t.Assert(page.PrevPage(), `<`) - t.Assert(page.FirstPage(), `|<`) - t.Assert(page.LastPage(), `>|`) + t.Assert(page.NextPage(), `>`) + t.Assert(page.PrevPage(), `<`) + t.Assert(page.FirstPage(), `|<`) + t.Assert(page.LastPage(), `>|`) t.Assert(page.PageBar(), `12345`) }) } @@ -108,8 +108,8 @@ func Test_PredefinedContent(t *testing.T) { page := gpage.New(5, 1, 2, `/user/list/{.page}`) page.AjaxActionName = "LoadPage" t.Assert(page.GetContent(1), `上一页 2 下一页`) - t.Assert(page.GetContent(2), `首页<<上一页[第2页]下一页>>尾页页`) - t.Assert(page.GetContent(3), `首页上一页12345下一页尾页当前页2/5 共5条`) + t.Assert(page.GetContent(2), `首页<<上一页[第 2 页]下一页>>尾页页`) + t.Assert(page.GetContent(3), `首页上一页12345下一页尾页当前页 2/5 共 5 条`) t.Assert(page.GetContent(4), `首页上一页12345下一页尾页`) t.Assert(page.GetContent(5), ``) }) From 80f57d1c24f6a7d8fadb11a3271a4d3f26e8d826 Mon Sep 17 00:00:00 2001 From: CyJaySong <29367599+cyjaysong@users.noreply.github.com> Date: Thu, 26 Dec 2024 18:18:35 +0800 Subject: [PATCH 071/102] fix(database/gdb): `gdb.Counter` not work in `OnDuplicate` (#4073) --- .../drivers/mysql/mysql_z_unit_model_test.go | 22 +++++ contrib/drivers/pgsql/pgsql_format_upsert.go | 19 ++++ .../drivers/pgsql/pgsql_z_unit_model_test.go | 22 +++++ .../drivers/sqlite/sqlite_format_upsert.go | 19 ++++ .../sqlite/sqlite_z_unit_model_test.go | 22 +++++ .../drivers/sqlitecgo/sqlite_format_upsert.go | 90 +++++++++++++++++++ .../drivers/sqlitecgo/sqlitecgo_do_filter.go | 10 --- contrib/drivers/sqlitecgo/sqlitecgo_tables.go | 10 +-- .../sqlitecgo/sqlitecgo_z_unit_init_test.go | 5 -- .../sqlitecgo/sqlitecgo_z_unit_model_test.go | 24 ++++- database/gdb/gdb_core.go | 51 +++++------ database/gdb/gdb_core_underlying.go | 16 ++++ 12 files changed, 264 insertions(+), 46 deletions(-) create mode 100644 contrib/drivers/sqlitecgo/sqlite_format_upsert.go diff --git a/contrib/drivers/mysql/mysql_z_unit_model_test.go b/contrib/drivers/mysql/mysql_z_unit_model_test.go index 9be10ff1313..d28f461c241 100644 --- a/contrib/drivers/mysql/mysql_z_unit_model_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_model_test.go @@ -2812,6 +2812,28 @@ func Test_Model_OnDuplicate(t *testing.T) { }) } +func Test_Model_OnDuplicateWithCounter(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + data := g.Map{ + "id": 1, + "passport": "pp1", + "password": "pw1", + "nickname": "n1", + "create_time": "2016-06-06", + } + _, err := db.Model(table).OnConflict("id").OnDuplicate(g.Map{ + "id": gdb.Counter{Field: "id", Value: 999999}, + }).Data(data).Save() + t.AssertNil(err) + one, err := db.Model(table).WherePri(1).One() + t.AssertNil(err) + t.AssertNil(one) + }) +} + func Test_Model_OnDuplicateEx(t *testing.T) { table := createInitTable() defer dropTable(table) diff --git a/contrib/drivers/pgsql/pgsql_format_upsert.go b/contrib/drivers/pgsql/pgsql_format_upsert.go index c4c8af91122..fc003cb4ce5 100644 --- a/contrib/drivers/pgsql/pgsql_format_upsert.go +++ b/contrib/drivers/pgsql/pgsql_format_upsert.go @@ -40,6 +40,25 @@ func (d *Driver) FormatUpsert(columns []string, list gdb.List, option gdb.DoInse d.Core.QuoteWord(k), v, ) + case gdb.Counter, *gdb.Counter: + var counter gdb.Counter + switch value := v.(type) { + case gdb.Counter: + counter = value + case *gdb.Counter: + counter = *value + } + operator, columnVal := "+", counter.Value + if columnVal < 0 { + operator, columnVal = "-", -columnVal + } + onDuplicateStr += fmt.Sprintf( + "%s=EXCLUDED.%s%s%s", + d.QuoteWord(k), + d.QuoteWord(counter.Field), + operator, + gconv.String(columnVal), + ) default: onDuplicateStr += fmt.Sprintf( "%s=EXCLUDED.%s", diff --git a/contrib/drivers/pgsql/pgsql_z_unit_model_test.go b/contrib/drivers/pgsql/pgsql_z_unit_model_test.go index d7748f07f17..3a51ba264dc 100644 --- a/contrib/drivers/pgsql/pgsql_z_unit_model_test.go +++ b/contrib/drivers/pgsql/pgsql_z_unit_model_test.go @@ -521,6 +521,28 @@ func Test_Model_OnDuplicate(t *testing.T) { }) } +func Test_Model_OnDuplicateWithCounter(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + data := g.Map{ + "id": 1, + "passport": "pp1", + "password": "pw1", + "nickname": "n1", + "create_time": "2016-06-06", + } + _, err := db.Model(table).OnConflict("id").OnDuplicate(g.Map{ + "id": gdb.Counter{Field: "id", Value: 999999}, + }).Data(data).Save() + t.AssertNil(err) + one, err := db.Model(table).WherePri(1).One() + t.AssertNil(err) + t.AssertNil(one) + }) +} + func Test_Model_OnDuplicateEx(t *testing.T) { table := createInitTable() defer dropTable(table) diff --git a/contrib/drivers/sqlite/sqlite_format_upsert.go b/contrib/drivers/sqlite/sqlite_format_upsert.go index 5821144a13e..c80d5dfd74e 100644 --- a/contrib/drivers/sqlite/sqlite_format_upsert.go +++ b/contrib/drivers/sqlite/sqlite_format_upsert.go @@ -40,6 +40,25 @@ func (d *Driver) FormatUpsert(columns []string, list gdb.List, option gdb.DoInse d.Core.QuoteWord(k), v, ) + case gdb.Counter, *gdb.Counter: + var counter gdb.Counter + switch value := v.(type) { + case gdb.Counter: + counter = value + case *gdb.Counter: + counter = *value + } + operator, columnVal := "+", counter.Value + if columnVal < 0 { + operator, columnVal = "-", -columnVal + } + onDuplicateStr += fmt.Sprintf( + "%s=EXCLUDED.%s%s%s", + d.QuoteWord(k), + d.QuoteWord(counter.Field), + operator, + gconv.String(columnVal), + ) default: onDuplicateStr += fmt.Sprintf( "%s=EXCLUDED.%s", diff --git a/contrib/drivers/sqlite/sqlite_z_unit_model_test.go b/contrib/drivers/sqlite/sqlite_z_unit_model_test.go index 19e97bfa51a..03e8465c7fc 100644 --- a/contrib/drivers/sqlite/sqlite_z_unit_model_test.go +++ b/contrib/drivers/sqlite/sqlite_z_unit_model_test.go @@ -4324,3 +4324,25 @@ func Test_OrderRandom(t *testing.T) { t.Assert(len(result), TableSize) }) } + +func Test_Model_OnDuplicateWithCounter(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + data := g.Map{ + "id": 1, + "passport": "pp1", + "password": "pw1", + "nickname": "n1", + "create_time": "2016-06-06", + } + _, err := db.Model(table).OnConflict("id").OnDuplicate(g.Map{ + "id": gdb.Counter{Field: "id", Value: 999999}, + }).Data(data).Save() + t.AssertNil(err) + one, err := db.Model(table).WherePri(1).One() + t.AssertNil(err) + t.AssertNil(one) + }) +} diff --git a/contrib/drivers/sqlitecgo/sqlite_format_upsert.go b/contrib/drivers/sqlitecgo/sqlite_format_upsert.go new file mode 100644 index 00000000000..63cb33e5a06 --- /dev/null +++ b/contrib/drivers/sqlitecgo/sqlite_format_upsert.go @@ -0,0 +1,90 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package sqlitecgo + +import ( + "fmt" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gconv" +) + +// FormatUpsert returns SQL clause of type upsert for SQLite. +// For example: ON CONFLICT (id) DO UPDATE SET ... +func (d *Driver) FormatUpsert(columns []string, list gdb.List, option gdb.DoInsertOption) (string, error) { + if len(option.OnConflict) == 0 { + return "", gerror.NewCode( + gcode.CodeMissingParameter, `Please specify conflict columns`, + ) + } + + var onDuplicateStr string + if option.OnDuplicateStr != "" { + onDuplicateStr = option.OnDuplicateStr + } else if len(option.OnDuplicateMap) > 0 { + for k, v := range option.OnDuplicateMap { + if len(onDuplicateStr) > 0 { + onDuplicateStr += "," + } + switch v.(type) { + case gdb.Raw, *gdb.Raw: + onDuplicateStr += fmt.Sprintf( + "%s=%s", + d.Core.QuoteWord(k), + v, + ) + case gdb.Counter, *gdb.Counter: + var counter gdb.Counter + switch value := v.(type) { + case gdb.Counter: + counter = value + case *gdb.Counter: + counter = *value + } + operator, columnVal := "+", counter.Value + if columnVal < 0 { + operator, columnVal = "-", -columnVal + } + onDuplicateStr += fmt.Sprintf( + "%s=EXCLUDED.%s%s%s", + d.QuoteWord(k), + d.QuoteWord(counter.Field), + operator, + gconv.String(columnVal), + ) + default: + onDuplicateStr += fmt.Sprintf( + "%s=EXCLUDED.%s", + d.Core.QuoteWord(k), + d.Core.QuoteWord(gconv.String(v)), + ) + } + } + } else { + for _, column := range columns { + // If it's SAVE operation, do not automatically update the creating time. + if d.Core.IsSoftCreatedFieldName(column) { + continue + } + if len(onDuplicateStr) > 0 { + onDuplicateStr += "," + } + onDuplicateStr += fmt.Sprintf( + "%s=EXCLUDED.%s", + d.Core.QuoteWord(column), + d.Core.QuoteWord(column), + ) + } + } + + conflictKeys := gstr.Join(option.OnConflict, ",") + + return fmt.Sprintf("ON CONFLICT (%s) DO UPDATE SET ", conflictKeys) + onDuplicateStr, nil +} diff --git a/contrib/drivers/sqlitecgo/sqlitecgo_do_filter.go b/contrib/drivers/sqlitecgo/sqlitecgo_do_filter.go index 6c578225e53..476ae1a0e97 100644 --- a/contrib/drivers/sqlitecgo/sqlitecgo_do_filter.go +++ b/contrib/drivers/sqlitecgo/sqlitecgo_do_filter.go @@ -10,8 +10,6 @@ import ( "context" "github.com/gogf/gf/v2/database/gdb" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/text/gstr" ) @@ -26,14 +24,6 @@ func (d *Driver) DoFilter( case gstr.HasPrefix(sql, gdb.InsertOperationReplace): sql = "INSERT OR REPLACE" + sql[len(gdb.InsertOperationReplace):] - - default: - if gstr.Contains(sql, gdb.InsertOnDuplicateKeyUpdate) { - return sql, args, gerror.NewCode( - gcode.CodeNotSupported, - `Save operation is not supported by sqlite driver`, - ) - } } return d.Core.DoFilter(ctx, link, sql, args) } diff --git a/contrib/drivers/sqlitecgo/sqlitecgo_tables.go b/contrib/drivers/sqlitecgo/sqlitecgo_tables.go index d985c3a62af..993c6cf8bdc 100644 --- a/contrib/drivers/sqlitecgo/sqlitecgo_tables.go +++ b/contrib/drivers/sqlitecgo/sqlitecgo_tables.go @@ -12,6 +12,10 @@ import ( "github.com/gogf/gf/v2/database/gdb" ) +const ( + tablesSqlTmp = `SELECT NAME FROM SQLITE_MASTER WHERE TYPE='table' ORDER BY NAME` +) + // Tables retrieves and returns the tables of current schema. // It's mainly used in cli tool chain for automatically generating the models. func (d *Driver) Tables(ctx context.Context, schema ...string) (tables []string, err error) { @@ -21,11 +25,7 @@ func (d *Driver) Tables(ctx context.Context, schema ...string) (tables []string, return nil, err } - result, err = d.DoSelect( - ctx, - link, - `SELECT NAME FROM SQLITE_MASTER WHERE TYPE='table' ORDER BY NAME`, - ) + result, err = d.DoSelect(ctx, link, tablesSqlTmp) if err != nil { return } diff --git a/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_init_test.go b/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_init_test.go index fe778b93f8f..0dd2aa0dc76 100644 --- a/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_init_test.go +++ b/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_init_test.go @@ -11,8 +11,6 @@ import ( "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/database/gdb" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gctx" "github.com/gogf/gf/v2/os/gfile" @@ -27,9 +25,6 @@ var ( configNode gdb.ConfigNode dbDir = gfile.Temp("sqlite") ctx = gctx.New() - - // Error - ErrorSave = gerror.NewCode(gcode.CodeNotSupported, `Save operation is not supported by sqlite driver`) ) const ( diff --git a/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_model_test.go b/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_model_test.go index 613ef9c64b3..3ad793df2d3 100644 --- a/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_model_test.go +++ b/contrib/drivers/sqlitecgo/sqlitecgo_z_unit_model_test.go @@ -375,7 +375,7 @@ func Test_Model_Save(t *testing.T) { "nickname": "oldme", "create_time": CreateTime, }).OnConflict("id").Save() - t.Assert(err, ErrorSave) + t.AssertNil(err) }) } @@ -4361,3 +4361,25 @@ func TestResult_Structs1(t *testing.T) { t.Assert(array[1].Name, "smith") }) } + +func Test_Model_OnDuplicateWithCounter(t *testing.T) { + table := createInitTable() + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + data := g.Map{ + "id": 1, + "passport": "pp1", + "password": "pw1", + "nickname": "n1", + "create_time": "2016-06-06", + } + _, err := db.Model(table).OnConflict("id").OnDuplicate(g.Map{ + "id": gdb.Counter{Field: "id", Value: 999999}, + }).Data(data).Save() + t.AssertNil(err) + one, err := db.Model(table).WherePri(1).One() + t.AssertNil(err) + t.AssertNil(one) + }) +} diff --git a/database/gdb/gdb_core.go b/database/gdb/gdb_core.go index 50971611258..f4faa0bf4f9 100644 --- a/database/gdb/gdb_core.go +++ b/database/gdb/gdb_core.go @@ -583,24 +583,8 @@ func (c *Core) DoUpdate(ctx context.Context, link Link, table string, data inter switch kind { case reflect.Map, reflect.Struct: var ( - fields []string - dataMap map[string]interface{} - counterHandler = func(column string, counter Counter) { - if counter.Value != 0 { - column = c.QuoteWord(column) - var ( - columnRef = c.QuoteWord(counter.Field) - columnVal = counter.Value - operator = "+" - ) - if columnVal < 0 { - operator = "-" - columnVal = -columnVal - } - fields = append(fields, fmt.Sprintf("%s=%s%s?", column, columnRef, operator)) - params = append(params, columnVal) - } - } + fields []string + dataMap map[string]interface{} ) dataMap, err = c.ConvertDataForRecord(ctx, data, table) if err != nil { @@ -620,13 +604,21 @@ func (c *Core) DoUpdate(ctx context.Context, link Link, table string, data inter } for _, k := range keysInSequence { v := dataMap[k] - switch value := v.(type) { - case *Counter: - counterHandler(k, *value) - - case Counter: - counterHandler(k, value) - + switch v.(type) { + case Counter, *Counter: + var counter Counter + switch value := v.(type) { + case Counter: + counter = value + case *Counter: + counter = *value + } + if counter.Value == 0 { + continue + } + operator, columnVal := c.getCounterAlter(counter) + fields = append(fields, fmt.Sprintf("%s=%s%s?", c.QuoteWord(k), c.QuoteWord(counter.Field), operator)) + params = append(params, columnVal) default: if s, ok := v.(Raw); ok { fields = append(fields, c.QuoteWord(k)+"="+gconv.String(s)) @@ -796,3 +788,12 @@ func (c *Core) IsSoftCreatedFieldName(fieldName string) bool { func (c *Core) FormatSqlBeforeExecuting(sql string, args []interface{}) (newSql string, newArgs []interface{}) { return handleSliceAndStructArgsForSql(sql, args) } + +// getCounterAlter +func (c *Core) getCounterAlter(counter Counter) (operator string, columnVal float64) { + operator, columnVal = "+", counter.Value + if columnVal < 0 { + operator, columnVal = "-", -columnVal + } + return +} diff --git a/database/gdb/gdb_core_underlying.go b/database/gdb/gdb_core_underlying.go index 045d11c65af..25c60a4baf7 100644 --- a/database/gdb/gdb_core_underlying.go +++ b/database/gdb/gdb_core_underlying.go @@ -388,6 +388,22 @@ func (c *Core) FormatUpsert(columns []string, list List, option DoInsertOption) c.QuoteWord(k), v, ) + case Counter, *Counter: + var counter Counter + switch value := v.(type) { + case Counter: + counter = value + case *Counter: + counter = *value + } + operator, columnVal := c.getCounterAlter(counter) + onDuplicateStr += fmt.Sprintf( + "%s=%s%s%s", + c.QuoteWord(k), + c.QuoteWord(counter.Field), + operator, + gconv.String(columnVal), + ) default: onDuplicateStr += fmt.Sprintf( "%s=VALUES(%s)", From f66e09717c94cd83c74eaf349d26be0ca96a9133 Mon Sep 17 00:00:00 2001 From: Gin Date: Thu, 26 Dec 2024 18:30:21 +0800 Subject: [PATCH 072/102] feat(contrib/metric/otelmetric): add metrics option `WithExemplarFilter` support (#4061) --- contrib/metric/otelmetric/go.mod | 14 +++---- contrib/metric/otelmetric/go.sum | 35 ++++++++++------- .../metric/otelmetric/otelmetric_option.go | 21 ++++++++++ go.mod | 15 ++++--- go.sum | 39 ++++++++++++++----- 5 files changed, 89 insertions(+), 35 deletions(-) diff --git a/contrib/metric/otelmetric/go.mod b/contrib/metric/otelmetric/go.mod index 26670ea86fb..c48d97cd5da 100644 --- a/contrib/metric/otelmetric/go.mod +++ b/contrib/metric/otelmetric/go.mod @@ -1,16 +1,16 @@ module github.com/gogf/gf/contrib/metric/otelmetric/v2 -go 1.20 +go 1.22 require ( github.com/gogf/gf/v2 v2.8.3 github.com/prometheus/client_golang v1.19.1 go.opentelemetry.io/contrib/instrumentation/runtime v0.49.0 - go.opentelemetry.io/otel v1.24.0 + go.opentelemetry.io/otel v1.32.0 go.opentelemetry.io/otel/exporters/prometheus v0.46.0 - go.opentelemetry.io/otel/metric v1.24.0 - go.opentelemetry.io/otel/sdk v1.24.0 - go.opentelemetry.io/otel/sdk/metric v1.24.0 + go.opentelemetry.io/otel/metric v1.32.0 + go.opentelemetry.io/otel/sdk v1.32.0 + go.opentelemetry.io/otel/sdk/metric v1.32.0 ) require ( @@ -23,6 +23,7 @@ require ( 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 + github.com/google/uuid v1.6.0 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // indirect github.com/magiconair/properties v1.8.9 // indirect @@ -35,8 +36,7 @@ require ( github.com/prometheus/common v0.55.0 // indirect github.com/prometheus/procfs v0.15.1 // indirect github.com/rivo/uniseg v0.4.7 // indirect - github.com/rogpeppe/go-internal v1.12.0 // indirect - go.opentelemetry.io/otel/trace v1.24.0 // indirect + go.opentelemetry.io/otel/trace v1.32.0 // indirect golang.org/x/net v0.32.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect diff --git a/contrib/metric/otelmetric/go.sum b/contrib/metric/otelmetric/go.sum index 79f4008cb69..d6e21ad99d1 100644 --- a/contrib/metric/otelmetric/go.sum +++ b/contrib/metric/otelmetric/go.sum @@ -7,6 +7,7 @@ github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XL github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= @@ -19,12 +20,17 @@ github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ4 github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -40,6 +46,7 @@ github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8m github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= @@ -51,23 +58,24 @@ github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoG github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8= -github.com/rogpeppe/go-internal v1.12.0/go.mod h1:E+RYuTGaKKdloAfM02xzb0FW3Paa99yedzYV+kq4uf4= -github.com/stretchr/testify v1.9.0 h1:HtqpIVDClZ4nwg75+f6Lvsy/wHu+3BoSGCbBAcpTsTg= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= go.opentelemetry.io/contrib/instrumentation/runtime v0.49.0 h1:dg9y+7ArpumB6zwImJv47RHfdgOGQ1EMkzP5vLkEnTU= go.opentelemetry.io/contrib/instrumentation/runtime v0.49.0/go.mod h1:Ul4MtXqu/hJBM+v7a6dCF0nHwckPMLpIpLeCi4+zfdw= -go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= -go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= +go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= go.opentelemetry.io/otel/exporters/prometheus v0.46.0 h1:I8WIFXR351FoLJYuloU4EgXbtNX2URfU/85pUPheIEQ= go.opentelemetry.io/otel/exporters/prometheus v0.46.0/go.mod h1:ztwVUHe5DTR/1v7PeuGRnU5Bbd4QKYwApWmuutKsJSs= -go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= -go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= -go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= -go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= -go.opentelemetry.io/otel/sdk/metric v1.24.0 h1:yyMQrPzF+k88/DbH7o4FMAs80puqd+9osbiBrJrz/w8= -go.opentelemetry.io/otel/sdk/metric v1.24.0/go.mod h1:I6Y5FjH6rvEnTTAYQz3Mmv2kl6Ek5IIrmwTLqMrrOE0= -go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= -go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= +go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8= +go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4= +go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= +go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiyYCU9snn1CU= +go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ= +go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= +go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -80,5 +88,6 @@ google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6h google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= diff --git a/contrib/metric/otelmetric/otelmetric_option.go b/contrib/metric/otelmetric/otelmetric_option.go index a1aa0604b0b..a2a9b1e7334 100644 --- a/contrib/metric/otelmetric/otelmetric_option.go +++ b/contrib/metric/otelmetric/otelmetric_option.go @@ -8,6 +8,7 @@ package otelmetric import ( "go.opentelemetry.io/otel/sdk/metric" + "go.opentelemetry.io/otel/sdk/metric/exemplar" "go.opentelemetry.io/otel/sdk/resource" ) @@ -38,6 +39,7 @@ type providerConfig struct { viewOption metric.Option readerOption metric.Option resourceOption metric.Option + exemplarFilter metric.Option enabledBuiltInMetrics bool } @@ -58,6 +60,9 @@ func (cfg providerConfig) MetricOptions() []metric.Option { if cfg.resourceOption != nil { metricOptions = append(metricOptions, cfg.resourceOption) } + if cfg.exemplarFilter != nil { + metricOptions = append(metricOptions, cfg.exemplarFilter) + } return metricOptions } @@ -106,3 +111,19 @@ func WithView(views ...metric.View) Option { return cfg }) } + +// WithExemplarFilter configures the exemplar filter. +// +// The exemplar filter determines which measurements are offered to the +// exemplar reservoir, but the exemplar reservoir makes the final decision of +// whether to store an exemplar. +// +// By default, the [exemplar.SampledFilter] +// is used. Exemplars can be entirely disabled by providing the +// [exemplar.AlwaysOffFilter]. +func WithExemplarFilter(filter exemplar.Filter) Option { + return optionFunc(func(cfg providerConfig) providerConfig { + cfg.exemplarFilter = metric.WithExemplarFilter(filter) + return cfg + }) +} diff --git a/go.mod b/go.mod index 91ec47e8915..4d1a1940495 100644 --- a/go.mod +++ b/go.mod @@ -1,6 +1,6 @@ module github.com/gogf/gf/v2 -go 1.20 +go 1.22 require ( github.com/BurntSushi/toml v1.4.0 @@ -12,9 +12,9 @@ require ( github.com/grokify/html-strip-tags-go v0.1.0 github.com/magiconair/properties v1.8.9 github.com/olekukonko/tablewriter v0.0.5 - go.opentelemetry.io/otel v1.24.0 - go.opentelemetry.io/otel/sdk v1.24.0 - go.opentelemetry.io/otel/trace v1.24.0 + go.opentelemetry.io/otel v1.32.0 + go.opentelemetry.io/otel/sdk v1.32.0 + go.opentelemetry.io/otel/trace v1.32.0 golang.org/x/net v0.32.0 golang.org/x/text v0.21.0 gopkg.in/yaml.v3 v3.0.1 @@ -23,10 +23,15 @@ require ( require ( github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect + github.com/google/uuid v1.6.0 // indirect + github.com/kr/pretty v0.3.1 // indirect github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/rivo/uniseg v0.4.7 // indirect - go.opentelemetry.io/otel/metric v1.24.0 // indirect + github.com/rogpeppe/go-internal v1.13.1 // indirect + github.com/stretchr/testify v1.10.0 // indirect + go.opentelemetry.io/otel/metric v1.32.0 // indirect golang.org/x/sys v0.28.0 // indirect + gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c // indirect ) diff --git a/go.sum b/go.sum index 3f5df0ec368..67f84761dc8 100644 --- a/go.sum +++ b/go.sum @@ -2,7 +2,9 @@ github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0 github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= +github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= @@ -15,10 +17,20 @@ github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ4 github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= +github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= +github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= +github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +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/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= @@ -31,19 +43,25 @@ github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6T github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= +github.com/pkg/diff v0.0.0-20210226163009-20ebb0f2a09e/go.mod h1:pJLUxLENpZxwdsKMEsNbx1VGcRFpLqf3715MtcvvzbA= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= -go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= -go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= -go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= -go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= -go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= -go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= -go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= -go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +github.com/rogpeppe/go-internal v1.9.0/go.mod h1:WtVeX8xhTBvf0smdhujwtBcq4Qrzq/fJaraNFVN+nFs= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= +go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= +go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= +go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= +go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8= +go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4= +go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= +go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= +go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= @@ -52,7 +70,8 @@ golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= From fc9093a1aae36f36bb67fea7983be3345d58bb0e Mon Sep 17 00:00:00 2001 From: John Guo Date: Thu, 26 Dec 2024 23:21:03 +0800 Subject: [PATCH 073/102] feat(cmd/gf): add `ShardingPattern` option for command `gf gen dao` to support generating dao files sharding tables (#4081) --- .github/workflows/ci-main.yml | 7 +- cmd/gf/internal/cmd/cmd_gen_dao.go | 4 +- .../cmd/cmd_z_unit_gen_dao_issue_test.go | 458 ++++++++++++++++++ .../cmd/cmd_z_unit_gen_dao_sharding_test.go | 77 +++ .../internal/cmd/cmd_z_unit_gen_dao_test.go | 437 +---------------- cmd/gf/internal/cmd/gendao/gendao.go | 285 ++++------- cmd/gf/internal/cmd/gendao/gendao_dao.go | 83 ++-- cmd/gf/internal/cmd/gendao/gendao_do.go | 29 +- cmd/gf/internal/cmd/gendao/gendao_entity.go | 29 +- cmd/gf/internal/cmd/gendao/gendao_gen_item.go | 4 +- cmd/gf/internal/cmd/gendao/gendao_tag.go | 149 ++++++ .../generated_user/dao/internal/table_user.go | 22 +- .../gendao/generated_user/dao/table_user.go | 9 +- .../dao/internal/table_user.go | 22 +- .../dao/table_user.go | 9 +- .../dao/internal/table_user.go | 22 +- .../generated_user_sqlite3/dao/table_user.go | 9 +- .../dao/internal/table_user.go | 22 +- .../dao/table_user.go | 9 +- .../cmd/testdata/gendao/sharding/sharding.sql | 45 ++ .../issue/3749/dao/internal/table_user.go | 22 +- .../cmd/testdata/issue/3749/dao/table_user.go | 9 +- .../consts/consts_gen_dao_template_dao.go | 93 ++-- .../consts/consts_gen_dao_template_do.go | 10 +- .../consts/consts_gen_dao_template_entity.go | 10 +- os/gview/gview.go | 24 +- os/gview/gview_config.go | 5 + os/gview/gview_parse.go | 93 ++-- util/gutil/gutil_map.go | 12 +- 29 files changed, 1143 insertions(+), 866 deletions(-) create mode 100644 cmd/gf/internal/cmd/cmd_z_unit_gen_dao_issue_test.go create mode 100644 cmd/gf/internal/cmd/cmd_z_unit_gen_dao_sharding_test.go create mode 100644 cmd/gf/internal/cmd/gendao/gendao_tag.go create mode 100644 cmd/gf/internal/cmd/testdata/gendao/sharding/sharding.sql diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index db0dea5de10..a2860760fff 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -83,8 +83,13 @@ jobs: - 3306:3306 # MariaDb backend server. + # docker run -d --name mariadb \ + # -p 3307:3306 \ + # -e MYSQL_DATABASE=test \ + # -e MYSQL_ROOT_PASSWORD=12345678 \ + # mariadb:11.4 mariadb: - image: mariadb:10.4 + image: mariadb:11.4 env: MARIADB_DATABASE: test MARIADB_ROOT_PASSWORD: 12345678 diff --git a/cmd/gf/internal/cmd/cmd_gen_dao.go b/cmd/gf/internal/cmd/cmd_gen_dao.go index 1d4d2e1068d..26edccfccd7 100644 --- a/cmd/gf/internal/cmd/cmd_gen_dao.go +++ b/cmd/gf/internal/cmd/cmd_gen_dao.go @@ -8,13 +8,15 @@ package cmd import ( _ "github.com/gogf/gf/contrib/drivers/clickhouse/v2" - // _ "github.com/gogf/gf/contrib/drivers/dm/v2" // precompilation does not support certain target platforms. _ "github.com/gogf/gf/contrib/drivers/mssql/v2" _ "github.com/gogf/gf/contrib/drivers/mysql/v2" _ "github.com/gogf/gf/contrib/drivers/oracle/v2" _ "github.com/gogf/gf/contrib/drivers/pgsql/v2" _ "github.com/gogf/gf/contrib/drivers/sqlite/v2" + // do not add dm in cli pre-compilation, + // the dm driver does not support certain target platforms. + // _ "github.com/gogf/gf/contrib/drivers/dm/v2" "github.com/gogf/gf/cmd/gf/v2/internal/cmd/gendao" ) diff --git a/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_issue_test.go b/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_issue_test.go new file mode 100644 index 00000000000..55c30d1bb58 --- /dev/null +++ b/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_issue_test.go @@ -0,0 +1,458 @@ +// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package cmd + +import ( + "fmt" + "path/filepath" + "testing" + + "github.com/gogf/gf/v2/database/gdb" + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/os/gcfg" + "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/guid" + "github.com/gogf/gf/v2/util/gutil" + + "github.com/gogf/gf/cmd/gf/v2/internal/cmd/gendao" +) + +// https://github.com/gogf/gf/issues/2572 +func Test_Gen_Dao_Issue2572(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + err error + db = testDB + table1 = "user1" + table2 = "user2" + issueDirPath = gtest.DataPath(`issue`, `2572`) + ) + t.AssertNil(execSqlFile(db, gtest.DataPath(`issue`, `2572`, `sql1.sql`))) + t.AssertNil(execSqlFile(db, gtest.DataPath(`issue`, `2572`, `sql2.sql`))) + defer dropTableWithDb(db, table1) + defer dropTableWithDb(db, table2) + + var ( + path = gfile.Temp(guid.S()) + group = "test" + in = gendao.CGenDaoInput{ + Path: path, + Link: "", + Tables: "", + TablesEx: "", + Group: group, + Prefix: "", + RemovePrefix: "", + JsonCase: "SnakeScreaming", + ImportPrefix: "", + DaoPath: "", + DoPath: "", + EntityPath: "", + TplDaoIndexPath: "", + TplDaoInternalPath: "", + TplDaoDoPath: "", + TplDaoEntityPath: "", + StdTime: false, + WithTime: false, + GJsonSupport: false, + OverwriteDao: false, + DescriptionTag: false, + NoJsonTag: false, + NoModelComment: false, + Clear: false, + TypeMapping: nil, + FieldMapping: nil, + } + ) + err = gutil.FillStructWithDefault(&in) + t.AssertNil(err) + + err = gfile.Copy(issueDirPath, path) + t.AssertNil(err) + + defer gfile.Remove(path) + + pwd := gfile.Pwd() + err = gfile.Chdir(path) + t.AssertNil(err) + + defer gfile.Chdir(pwd) + + _, err = gendao.CGenDao{}.Dao(ctx, in) + t.AssertNil(err) + + generatedFiles, err := gfile.ScanDir(path, "*.go", true) + t.AssertNil(err) + t.Assert(len(generatedFiles), 8) + for i, generatedFile := range generatedFiles { + generatedFiles[i] = gstr.TrimLeftStr(generatedFile, path) + } + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/dao/internal/user_1.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/dao/internal/user_2.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/dao/user_1.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/dao/user_2.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/model/do/user_1.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/model/do/user_2.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/model/entity/user_1.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/model/entity/user_2.go")), true) + }) +} + +// https://github.com/gogf/gf/issues/2616 +func Test_Gen_Dao_Issue2616(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + err error + db = testDB + table1 = "user1" + table2 = "user2" + issueDirPath = gtest.DataPath(`issue`, `2616`) + ) + t.AssertNil(execSqlFile(db, gtest.DataPath(`issue`, `2616`, `sql1.sql`))) + t.AssertNil(execSqlFile(db, gtest.DataPath(`issue`, `2616`, `sql2.sql`))) + defer dropTableWithDb(db, table1) + defer dropTableWithDb(db, table2) + + var ( + path = gfile.Temp(guid.S()) + group = "test" + in = gendao.CGenDaoInput{ + Path: path, + Link: "", + Tables: "", + TablesEx: "", + Group: group, + Prefix: "", + RemovePrefix: "", + JsonCase: "SnakeScreaming", + ImportPrefix: "", + DaoPath: "", + DoPath: "", + EntityPath: "", + TplDaoIndexPath: "", + TplDaoInternalPath: "", + TplDaoDoPath: "", + TplDaoEntityPath: "", + StdTime: false, + WithTime: false, + GJsonSupport: false, + OverwriteDao: false, + DescriptionTag: false, + NoJsonTag: false, + NoModelComment: false, + Clear: false, + TypeMapping: nil, + FieldMapping: nil, + } + ) + err = gutil.FillStructWithDefault(&in) + t.AssertNil(err) + + err = gfile.Copy(issueDirPath, path) + t.AssertNil(err) + + defer gfile.Remove(path) + + pwd := gfile.Pwd() + err = gfile.Chdir(path) + t.AssertNil(err) + + defer gfile.Chdir(pwd) + + _, err = gendao.CGenDao{}.Dao(ctx, in) + t.AssertNil(err) + + generatedFiles, err := gfile.ScanDir(path, "*.go", true) + t.AssertNil(err) + t.Assert(len(generatedFiles), 8) + for i, generatedFile := range generatedFiles { + generatedFiles[i] = gstr.TrimLeftStr(generatedFile, path) + } + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/dao/internal/user_1.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/dao/internal/user_2.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/dao/user_1.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/dao/user_2.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/model/do/user_1.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/model/do/user_2.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/model/entity/user_1.go")), true) + t.Assert(gstr.InArray(generatedFiles, + filepath.FromSlash("/model/entity/user_2.go")), true) + + // Key string to check if overwrite the dao files. + // dao user1 is not be overwritten as configured in config.yaml. + // dao user2 is to be overwritten as configured in config.yaml. + var ( + keyStr = `// I am not overwritten.` + daoUser1Content = gfile.GetContents(path + "/dao/user_1.go") + daoUser2Content = gfile.GetContents(path + "/dao/user_2.go") + ) + t.Assert(gstr.Contains(daoUser1Content, keyStr), true) + t.Assert(gstr.Contains(daoUser2Content, keyStr), false) + }) +} + +// https://github.com/gogf/gf/issues/2746 +func Test_Gen_Dao_Issue2746(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + err error + mdb gdb.DB + link2746 = "mariadb:root:12345678@tcp(127.0.0.1:3307)/test?loc=Local&parseTime=true" + table = "issue2746" + sqlContent = fmt.Sprintf( + gtest.DataContent(`issue`, `2746`, `sql.sql`), + table, + ) + ) + mdb, err = gdb.New(gdb.ConfigNode{ + Link: link2746, + }) + t.AssertNil(err) + + array := gstr.SplitAndTrim(sqlContent, ";") + for _, v := range array { + if _, err = mdb.Exec(ctx, v); err != nil { + t.AssertNil(err) + } + } + defer dropTableWithDb(mdb, table) + + var ( + path = gfile.Temp(guid.S()) + group = "test" + in = gendao.CGenDaoInput{ + Path: path, + Link: link2746, + Tables: "", + TablesEx: "", + Group: group, + Prefix: "", + RemovePrefix: "", + JsonCase: "SnakeScreaming", + ImportPrefix: "", + DaoPath: "", + DoPath: "", + EntityPath: "", + TplDaoIndexPath: "", + TplDaoInternalPath: "", + TplDaoDoPath: "", + TplDaoEntityPath: "", + StdTime: false, + WithTime: false, + GJsonSupport: true, + OverwriteDao: false, + DescriptionTag: false, + NoJsonTag: false, + NoModelComment: false, + Clear: false, + TypeMapping: nil, + FieldMapping: nil, + } + ) + err = gutil.FillStructWithDefault(&in) + t.AssertNil(err) + + err = gfile.Mkdir(path) + t.AssertNil(err) + + _, err = gendao.CGenDao{}.Dao(ctx, in) + t.AssertNil(err) + defer gfile.Remove(path) + + var ( + file = filepath.FromSlash(path + "/model/entity/issue_2746.go") + expectContent = gtest.DataContent(`issue`, `2746`, `issue_2746.go`) + ) + t.Assert(expectContent, gfile.GetContents(file)) + }) +} + +// https://github.com/gogf/gf/issues/3459 +func Test_Gen_Dao_Issue3459(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + err error + db = testDB + table = "table_user" + sqlContent = fmt.Sprintf( + gtest.DataContent(`gendao`, `user.tpl.sql`), + table, + ) + ) + dropTableWithDb(db, table) + array := gstr.SplitAndTrim(sqlContent, ";") + for _, v := range array { + if _, err = db.Exec(ctx, v); err != nil { + t.AssertNil(err) + } + } + defer dropTableWithDb(db, table) + + var ( + confDir = gtest.DataPath("issue", "3459") + path = gfile.Temp(guid.S()) + group = "test" + in = gendao.CGenDaoInput{ + Path: path, + Link: link, + Tables: "", + TablesEx: "", + Group: group, + Prefix: "", + RemovePrefix: "", + JsonCase: "SnakeScreaming", + ImportPrefix: "", + DaoPath: "", + DoPath: "", + EntityPath: "", + TplDaoIndexPath: "", + TplDaoInternalPath: "", + TplDaoDoPath: "", + TplDaoEntityPath: "", + StdTime: false, + WithTime: false, + GJsonSupport: false, + OverwriteDao: false, + DescriptionTag: false, + NoJsonTag: false, + NoModelComment: false, + Clear: false, + TypeMapping: nil, + } + ) + err = g.Cfg().GetAdapter().(*gcfg.AdapterFile).SetPath(confDir) + t.AssertNil(err) + + err = gutil.FillStructWithDefault(&in) + t.AssertNil(err) + + err = gfile.Mkdir(path) + t.AssertNil(err) + + // for go mod import path auto retrieve. + err = gfile.Copy( + gtest.DataPath("gendao", "go.mod.txt"), + gfile.Join(path, "go.mod"), + ) + t.AssertNil(err) + + _, err = gendao.CGenDao{}.Dao(ctx, in) + t.AssertNil(err) + defer gfile.Remove(path) + + // files + files, err := gfile.ScanDir(path, "*.go", true) + t.AssertNil(err) + t.Assert(files, []string{ + filepath.FromSlash(path + "/dao/internal/table_user.go"), + filepath.FromSlash(path + "/dao/table_user.go"), + filepath.FromSlash(path + "/model/do/table_user.go"), + filepath.FromSlash(path + "/model/entity/table_user.go"), + }) + // content + testPath := gtest.DataPath("gendao", "generated_user") + expectFiles := []string{ + filepath.FromSlash(testPath + "/dao/internal/table_user.go"), + filepath.FromSlash(testPath + "/dao/table_user.go"), + filepath.FromSlash(testPath + "/model/do/table_user.go"), + filepath.FromSlash(testPath + "/model/entity/table_user.go"), + } + for i, _ := range files { + //_ = gfile.PutContents(expectFiles[i], gfile.GetContents(files[i])) + t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i])) + } + }) +} + +// https://github.com/gogf/gf/issues/3749 +func Test_Gen_Dao_Issue3749(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + err error + db = testDB + table = "table_user" + sqlContent = fmt.Sprintf( + gtest.DataContent(`issue`, `3749`, `user.tpl.sql`), + table, + ) + ) + dropTableWithDb(db, table) + array := gstr.SplitAndTrim(sqlContent, ";") + for _, v := range array { + if _, err = db.Exec(ctx, v); err != nil { + t.AssertNil(err) + } + } + defer dropTableWithDb(db, table) + + var ( + path = gfile.Temp(guid.S()) + group = "test" + in = gendao.CGenDaoInput{ + Path: path, + Link: link, + Group: group, + } + ) + + err = gutil.FillStructWithDefault(&in) + t.AssertNil(err) + + err = gfile.Mkdir(path) + t.AssertNil(err) + + // for go mod import path auto retrieve. + err = gfile.Copy( + gtest.DataPath("gendao", "go.mod.txt"), + gfile.Join(path, "go.mod"), + ) + t.AssertNil(err) + + _, err = gendao.CGenDao{}.Dao(ctx, in) + t.AssertNil(err) + defer gfile.Remove(path) + + // files + files, err := gfile.ScanDir(path, "*.go", true) + t.AssertNil(err) + t.Assert(files, []string{ + filepath.FromSlash(path + "/dao/internal/table_user.go"), + filepath.FromSlash(path + "/dao/table_user.go"), + filepath.FromSlash(path + "/model/do/table_user.go"), + filepath.FromSlash(path + "/model/entity/table_user.go"), + }) + // content + testPath := gtest.DataPath(`issue`, `3749`) + expectFiles := []string{ + filepath.FromSlash(testPath + "/dao/internal/table_user.go"), + filepath.FromSlash(testPath + "/dao/table_user.go"), + filepath.FromSlash(testPath + "/model/do/table_user.go"), + filepath.FromSlash(testPath + "/model/entity/table_user.go"), + } + for i, _ := range files { + //_ = gfile.PutContents(expectFiles[i], gfile.GetContents(files[i])) + t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i])) + } + }) +} diff --git a/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_sharding_test.go b/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_sharding_test.go new file mode 100644 index 00000000000..a20e92e53c6 --- /dev/null +++ b/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_sharding_test.go @@ -0,0 +1,77 @@ +// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package cmd + +import ( + "testing" + + "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/guid" + "github.com/gogf/gf/v2/util/gutil" + + "github.com/gogf/gf/cmd/gf/v2/internal/cmd/gendao" +) + +func Test_Gen_Dao_Sharding(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + var ( + err error + db = testDB + tableSingle = "single_table" + table1 = "users_0001" + table2 = "users_0002" + table3 = "users_0003" + sqlFilePath = gtest.DataPath(`gendao`, `sharding`, `sharding.sql`) + ) + t.AssertNil(execSqlFile(db, sqlFilePath)) + defer dropTableWithDb(db, tableSingle) + defer dropTableWithDb(db, table1) + defer dropTableWithDb(db, table2) + defer dropTableWithDb(db, table3) + + var ( + path = gfile.Temp(guid.S()) + //path = "/Users/john/Temp/gen_dao_sharding" + group = "test" + in = gendao.CGenDaoInput{ + Path: path, + Link: link, + Group: group, + ShardingPattern: []string{ + `users_?`, + }, + } + ) + err = gutil.FillStructWithDefault(&in) + t.AssertNil(err) + + err = gfile.Mkdir(path) + t.AssertNil(err) + + pwd := gfile.Pwd() + err = gfile.Chdir(path) + t.AssertNil(err) + defer gfile.Chdir(pwd) + defer gfile.RemoveAll(path) + + _, err = gendao.CGenDao{}.Dao(ctx, in) + t.AssertNil(err) + + generatedFiles, err := gfile.ScanDir(path, "*.go", true) + t.AssertNil(err) + t.Assert(len(generatedFiles), 8) + var ( + daoSingleTableContent = gfile.GetContents(gfile.Join(path, "dao", "single_table.go")) + daoUsersContent = gfile.GetContents(gfile.Join(path, "dao", "users.go")) + ) + t.Assert(gstr.Contains(daoSingleTableContent, "SingleTable = singleTableDao{internal.NewSingleTableDao()}"), true) + t.Assert(gstr.Contains(daoUsersContent, "Users = usersDao{internal.NewUsersDao(userShardingHandler)}"), true) + t.Assert(gstr.Contains(daoUsersContent, "m.Sharding(gdb.ShardingConfig{"), true) + }) +} diff --git a/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_test.go b/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_test.go index fbefdb88fb7..8d20fe8c169 100644 --- a/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_test.go +++ b/cmd/gf/internal/cmd/cmd_z_unit_gen_dao_test.go @@ -12,8 +12,6 @@ import ( "testing" "github.com/gogf/gf/v2/database/gdb" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gcfg" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/test/gtest" "github.com/gogf/gf/v2/text/gstr" @@ -211,6 +209,7 @@ func Test_Gen_Dao_TypeMapping(t *testing.T) { filepath.FromSlash(testPath + "/model/entity/table_user.go"), } for i, _ := range files { + //_ = gfile.PutContents(expectFiles[i], gfile.GetContents(files[i])) t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i])) } }) @@ -313,6 +312,7 @@ func Test_Gen_Dao_FieldMapping(t *testing.T) { filepath.FromSlash(testPath + "/model/entity/table_user.go"), } for i, _ := range files { + //_ = gfile.PutContents(expectFiles[i], gfile.GetContents(files[i])) t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i])) } }) @@ -332,438 +332,6 @@ func execSqlFile(db gdb.DB, filePath string, args ...any) error { return nil } -// https://github.com/gogf/gf/issues/2572 -func Test_Gen_Dao_Issue2572(t *testing.T) { - gtest.C(t, func(t *gtest.T) { - var ( - err error - db = testDB - table1 = "user1" - table2 = "user2" - issueDirPath = gtest.DataPath(`issue`, `2572`) - ) - t.AssertNil(execSqlFile(db, gtest.DataPath(`issue`, `2572`, `sql1.sql`))) - t.AssertNil(execSqlFile(db, gtest.DataPath(`issue`, `2572`, `sql2.sql`))) - defer dropTableWithDb(db, table1) - defer dropTableWithDb(db, table2) - - var ( - path = gfile.Temp(guid.S()) - group = "test" - in = gendao.CGenDaoInput{ - Path: path, - Link: "", - Tables: "", - TablesEx: "", - Group: group, - Prefix: "", - RemovePrefix: "", - JsonCase: "SnakeScreaming", - ImportPrefix: "", - DaoPath: "", - DoPath: "", - EntityPath: "", - TplDaoIndexPath: "", - TplDaoInternalPath: "", - TplDaoDoPath: "", - TplDaoEntityPath: "", - StdTime: false, - WithTime: false, - GJsonSupport: false, - OverwriteDao: false, - DescriptionTag: false, - NoJsonTag: false, - NoModelComment: false, - Clear: false, - TypeMapping: nil, - FieldMapping: nil, - } - ) - err = gutil.FillStructWithDefault(&in) - t.AssertNil(err) - - err = gfile.Copy(issueDirPath, path) - t.AssertNil(err) - - defer gfile.Remove(path) - - pwd := gfile.Pwd() - err = gfile.Chdir(path) - t.AssertNil(err) - - defer gfile.Chdir(pwd) - - _, err = gendao.CGenDao{}.Dao(ctx, in) - t.AssertNil(err) - - generatedFiles, err := gfile.ScanDir(path, "*.go", true) - t.AssertNil(err) - t.Assert(len(generatedFiles), 8) - for i, generatedFile := range generatedFiles { - generatedFiles[i] = gstr.TrimLeftStr(generatedFile, path) - } - t.Assert(gstr.InArray(generatedFiles, - filepath.FromSlash("/dao/internal/user_1.go")), true) - t.Assert(gstr.InArray(generatedFiles, - filepath.FromSlash("/dao/internal/user_2.go")), true) - t.Assert(gstr.InArray(generatedFiles, - filepath.FromSlash("/dao/user_1.go")), true) - t.Assert(gstr.InArray(generatedFiles, - filepath.FromSlash("/dao/user_2.go")), true) - t.Assert(gstr.InArray(generatedFiles, - filepath.FromSlash("/model/do/user_1.go")), true) - t.Assert(gstr.InArray(generatedFiles, - filepath.FromSlash("/model/do/user_2.go")), true) - t.Assert(gstr.InArray(generatedFiles, - filepath.FromSlash("/model/entity/user_1.go")), true) - t.Assert(gstr.InArray(generatedFiles, - filepath.FromSlash("/model/entity/user_2.go")), true) - }) -} - -// https://github.com/gogf/gf/issues/2616 -func Test_Gen_Dao_Issue2616(t *testing.T) { - gtest.C(t, func(t *gtest.T) { - var ( - err error - db = testDB - table1 = "user1" - table2 = "user2" - issueDirPath = gtest.DataPath(`issue`, `2616`) - ) - t.AssertNil(execSqlFile(db, gtest.DataPath(`issue`, `2616`, `sql1.sql`))) - t.AssertNil(execSqlFile(db, gtest.DataPath(`issue`, `2616`, `sql2.sql`))) - defer dropTableWithDb(db, table1) - defer dropTableWithDb(db, table2) - - var ( - path = gfile.Temp(guid.S()) - group = "test" - in = gendao.CGenDaoInput{ - Path: path, - Link: "", - Tables: "", - TablesEx: "", - Group: group, - Prefix: "", - RemovePrefix: "", - JsonCase: "SnakeScreaming", - ImportPrefix: "", - DaoPath: "", - DoPath: "", - EntityPath: "", - TplDaoIndexPath: "", - TplDaoInternalPath: "", - TplDaoDoPath: "", - TplDaoEntityPath: "", - StdTime: false, - WithTime: false, - GJsonSupport: false, - OverwriteDao: false, - DescriptionTag: false, - NoJsonTag: false, - NoModelComment: false, - Clear: false, - TypeMapping: nil, - FieldMapping: nil, - } - ) - err = gutil.FillStructWithDefault(&in) - t.AssertNil(err) - - err = gfile.Copy(issueDirPath, path) - t.AssertNil(err) - - defer gfile.Remove(path) - - pwd := gfile.Pwd() - err = gfile.Chdir(path) - t.AssertNil(err) - - defer gfile.Chdir(pwd) - - _, err = gendao.CGenDao{}.Dao(ctx, in) - t.AssertNil(err) - - generatedFiles, err := gfile.ScanDir(path, "*.go", true) - t.AssertNil(err) - t.Assert(len(generatedFiles), 8) - for i, generatedFile := range generatedFiles { - generatedFiles[i] = gstr.TrimLeftStr(generatedFile, path) - } - t.Assert(gstr.InArray(generatedFiles, - filepath.FromSlash("/dao/internal/user_1.go")), true) - t.Assert(gstr.InArray(generatedFiles, - filepath.FromSlash("/dao/internal/user_2.go")), true) - t.Assert(gstr.InArray(generatedFiles, - filepath.FromSlash("/dao/user_1.go")), true) - t.Assert(gstr.InArray(generatedFiles, - filepath.FromSlash("/dao/user_2.go")), true) - t.Assert(gstr.InArray(generatedFiles, - filepath.FromSlash("/model/do/user_1.go")), true) - t.Assert(gstr.InArray(generatedFiles, - filepath.FromSlash("/model/do/user_2.go")), true) - t.Assert(gstr.InArray(generatedFiles, - filepath.FromSlash("/model/entity/user_1.go")), true) - t.Assert(gstr.InArray(generatedFiles, - filepath.FromSlash("/model/entity/user_2.go")), true) - - // Key string to check if overwrite the dao files. - // dao user1 is not be overwritten as configured in config.yaml. - // dao user2 is to be overwritten as configured in config.yaml. - var ( - keyStr = `// I am not overwritten.` - daoUser1Content = gfile.GetContents(path + "/dao/user_1.go") - daoUser2Content = gfile.GetContents(path + "/dao/user_2.go") - ) - t.Assert(gstr.Contains(daoUser1Content, keyStr), true) - t.Assert(gstr.Contains(daoUser2Content, keyStr), false) - }) -} - -// https://github.com/gogf/gf/issues/2746 -func Test_Gen_Dao_Issue2746(t *testing.T) { - gtest.C(t, func(t *gtest.T) { - var ( - err error - mdb gdb.DB - link2746 = "mariadb:root:12345678@tcp(127.0.0.1:3307)/test?loc=Local&parseTime=true" - table = "issue2746" - sqlContent = fmt.Sprintf( - gtest.DataContent(`issue`, `2746`, `sql.sql`), - table, - ) - ) - mdb, err = gdb.New(gdb.ConfigNode{ - Link: link2746, - }) - t.AssertNil(err) - - array := gstr.SplitAndTrim(sqlContent, ";") - for _, v := range array { - if _, err = mdb.Exec(ctx, v); err != nil { - t.AssertNil(err) - } - } - defer dropTableWithDb(mdb, table) - - var ( - path = gfile.Temp(guid.S()) - group = "test" - in = gendao.CGenDaoInput{ - Path: path, - Link: link2746, - Tables: "", - TablesEx: "", - Group: group, - Prefix: "", - RemovePrefix: "", - JsonCase: "SnakeScreaming", - ImportPrefix: "", - DaoPath: "", - DoPath: "", - EntityPath: "", - TplDaoIndexPath: "", - TplDaoInternalPath: "", - TplDaoDoPath: "", - TplDaoEntityPath: "", - StdTime: false, - WithTime: false, - GJsonSupport: true, - OverwriteDao: false, - DescriptionTag: false, - NoJsonTag: false, - NoModelComment: false, - Clear: false, - TypeMapping: nil, - FieldMapping: nil, - } - ) - err = gutil.FillStructWithDefault(&in) - t.AssertNil(err) - - err = gfile.Mkdir(path) - t.AssertNil(err) - - _, err = gendao.CGenDao{}.Dao(ctx, in) - t.AssertNil(err) - defer gfile.Remove(path) - - var ( - file = filepath.FromSlash(path + "/model/entity/issue_2746.go") - expectContent = gtest.DataContent(`issue`, `2746`, `issue_2746.go`) - ) - t.Assert(expectContent, gfile.GetContents(file)) - }) -} - -// https://github.com/gogf/gf/issues/3459 -func Test_Gen_Dao_Issue3459(t *testing.T) { - gtest.C(t, func(t *gtest.T) { - var ( - err error - db = testDB - table = "table_user" - sqlContent = fmt.Sprintf( - gtest.DataContent(`gendao`, `user.tpl.sql`), - table, - ) - ) - dropTableWithDb(db, table) - array := gstr.SplitAndTrim(sqlContent, ";") - for _, v := range array { - if _, err = db.Exec(ctx, v); err != nil { - t.AssertNil(err) - } - } - defer dropTableWithDb(db, table) - - var ( - confDir = gtest.DataPath("issue", "3459") - path = gfile.Temp(guid.S()) - group = "test" - in = gendao.CGenDaoInput{ - Path: path, - Link: link, - Tables: "", - TablesEx: "", - Group: group, - Prefix: "", - RemovePrefix: "", - JsonCase: "SnakeScreaming", - ImportPrefix: "", - DaoPath: "", - DoPath: "", - EntityPath: "", - TplDaoIndexPath: "", - TplDaoInternalPath: "", - TplDaoDoPath: "", - TplDaoEntityPath: "", - StdTime: false, - WithTime: false, - GJsonSupport: false, - OverwriteDao: false, - DescriptionTag: false, - NoJsonTag: false, - NoModelComment: false, - Clear: false, - TypeMapping: nil, - } - ) - err = g.Cfg().GetAdapter().(*gcfg.AdapterFile).SetPath(confDir) - t.AssertNil(err) - - err = gutil.FillStructWithDefault(&in) - t.AssertNil(err) - - err = gfile.Mkdir(path) - t.AssertNil(err) - - // for go mod import path auto retrieve. - err = gfile.Copy( - gtest.DataPath("gendao", "go.mod.txt"), - gfile.Join(path, "go.mod"), - ) - t.AssertNil(err) - - _, err = gendao.CGenDao{}.Dao(ctx, in) - t.AssertNil(err) - defer gfile.Remove(path) - - // files - files, err := gfile.ScanDir(path, "*.go", true) - t.AssertNil(err) - t.Assert(files, []string{ - filepath.FromSlash(path + "/dao/internal/table_user.go"), - filepath.FromSlash(path + "/dao/table_user.go"), - filepath.FromSlash(path + "/model/do/table_user.go"), - filepath.FromSlash(path + "/model/entity/table_user.go"), - }) - // content - testPath := gtest.DataPath("gendao", "generated_user") - expectFiles := []string{ - filepath.FromSlash(testPath + "/dao/internal/table_user.go"), - filepath.FromSlash(testPath + "/dao/table_user.go"), - filepath.FromSlash(testPath + "/model/do/table_user.go"), - filepath.FromSlash(testPath + "/model/entity/table_user.go"), - } - for i, _ := range files { - t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i])) - } - }) -} - -// https://github.com/gogf/gf/issues/3749 -func Test_Gen_Dao_Issue3749(t *testing.T) { - gtest.C(t, func(t *gtest.T) { - var ( - err error - db = testDB - table = "table_user" - sqlContent = fmt.Sprintf( - gtest.DataContent(`issue`, `3749`, `user.tpl.sql`), - table, - ) - ) - dropTableWithDb(db, table) - array := gstr.SplitAndTrim(sqlContent, ";") - for _, v := range array { - if _, err = db.Exec(ctx, v); err != nil { - t.AssertNil(err) - } - } - defer dropTableWithDb(db, table) - - var ( - path = gfile.Temp(guid.S()) - group = "test" - in = gendao.CGenDaoInput{ - Path: path, - Link: link, - Group: group, - } - ) - - err = gutil.FillStructWithDefault(&in) - t.AssertNil(err) - - err = gfile.Mkdir(path) - t.AssertNil(err) - - // for go mod import path auto retrieve. - err = gfile.Copy( - gtest.DataPath("gendao", "go.mod.txt"), - gfile.Join(path, "go.mod"), - ) - t.AssertNil(err) - - _, err = gendao.CGenDao{}.Dao(ctx, in) - t.AssertNil(err) - defer gfile.Remove(path) - - // files - files, err := gfile.ScanDir(path, "*.go", true) - t.AssertNil(err) - t.Assert(files, []string{ - filepath.FromSlash(path + "/dao/internal/table_user.go"), - filepath.FromSlash(path + "/dao/table_user.go"), - filepath.FromSlash(path + "/model/do/table_user.go"), - filepath.FromSlash(path + "/model/entity/table_user.go"), - }) - // content - testPath := gtest.DataPath(`issue`, `3749`) - expectFiles := []string{ - filepath.FromSlash(testPath + "/dao/internal/table_user.go"), - filepath.FromSlash(testPath + "/dao/table_user.go"), - filepath.FromSlash(testPath + "/model/do/table_user.go"), - filepath.FromSlash(testPath + "/model/entity/table_user.go"), - } - for i, _ := range files { - t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i])) - } - }) -} - func Test_Gen_Dao_Sqlite3(t *testing.T) { gtest.C(t, func(t *gtest.T) { var ( @@ -836,6 +404,7 @@ func Test_Gen_Dao_Sqlite3(t *testing.T) { filepath.FromSlash(testPath + "/model/entity/table_user.go"), } for i, _ := range files { + //_ = gfile.PutContents(expectFiles[i], gfile.GetContents(files[i])) t.Assert(gfile.GetContents(files[i]), gfile.GetContents(expectFiles[i])) } }) diff --git a/cmd/gf/internal/cmd/gendao/gendao.go b/cmd/gf/internal/cmd/gendao/gendao.go index d571aada6fb..ff190a401cf 100644 --- a/cmd/gf/internal/cmd/gendao/gendao.go +++ b/cmd/gf/internal/cmd/gendao/gendao.go @@ -14,199 +14,50 @@ import ( "golang.org/x/mod/modfile" "github.com/gogf/gf/v2/container/garray" + "github.com/gogf/gf/v2/container/gset" "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gproc" "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/os/gview" + "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" - "github.com/gogf/gf/v2/util/gtag" "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" "github.com/gogf/gf/cmd/gf/v2/internal/utility/utils" ) -const ( - CGenDaoConfig = `gfcli.gen.dao` - CGenDaoUsage = `gf gen dao [OPTION]` - CGenDaoBrief = `automatically generate go files for dao/do/entity` - CGenDaoEg = ` -gf gen dao -gf gen dao -l "mysql:root:12345678@tcp(127.0.0.1:3306)/test" -gf gen dao -p ./model -g user-center -t user,user_detail,user_login -gf gen dao -r user_ -` - - CGenDaoAd = ` -CONFIGURATION SUPPORT - Options are also supported by configuration file. - It's suggested using configuration file instead of command line arguments making producing. - The configuration node name is "gfcli.gen.dao", which also supports multiple databases, for example(config.yaml): - gfcli: - gen: - dao: - - link: "mysql:root:12345678@tcp(127.0.0.1:3306)/test" - tables: "order,products" - jsonCase: "CamelLower" - - link: "mysql:root:12345678@tcp(127.0.0.1:3306)/primary" - path: "./my-app" - prefix: "primary_" - tables: "user, userDetail" - typeMapping: - decimal: - type: decimal.Decimal - import: github.com/shopspring/decimal - numeric: - type: string - fieldMapping: - table_name.field_name: - type: decimal.Decimal - import: github.com/shopspring/decimal -` - CGenDaoBriefPath = `directory path for generated files` - CGenDaoBriefLink = `database configuration, the same as the ORM configuration of GoFrame` - CGenDaoBriefTables = `generate models only for given tables, multiple table names separated with ','` - CGenDaoBriefTablesEx = `generate models excluding given tables, multiple table names separated with ','` - CGenDaoBriefPrefix = `add prefix for all table of specified link/database tables` - CGenDaoBriefRemovePrefix = `remove specified prefix of the table, multiple prefix separated with ','` - CGenDaoBriefRemoveFieldPrefix = `remove specified prefix of the field, multiple prefix separated with ','` - CGenDaoBriefStdTime = `use time.Time from stdlib instead of gtime.Time for generated time/date fields of tables` - CGenDaoBriefWithTime = `add created time for auto produced go files` - CGenDaoBriefGJsonSupport = `use gJsonSupport to use *gjson.Json instead of string for generated json fields of tables` - CGenDaoBriefImportPrefix = `custom import prefix for generated go files` - CGenDaoBriefDaoPath = `directory path for storing generated dao files under path` - CGenDaoBriefDoPath = `directory path for storing generated do files under path` - CGenDaoBriefEntityPath = `directory path for storing generated entity files under path` - CGenDaoBriefOverwriteDao = `overwrite all dao files both inside/outside internal folder` - CGenDaoBriefModelFile = `custom file name for storing generated model content` - CGenDaoBriefModelFileForDao = `custom file name generating model for DAO operations like Where/Data. It's empty in default` - CGenDaoBriefDescriptionTag = `add comment to description tag for each field` - CGenDaoBriefNoJsonTag = `no json tag will be added for each field` - CGenDaoBriefNoModelComment = `no model comment will be added for each field` - CGenDaoBriefClear = `delete all generated go files that do not exist in database` - CGenDaoBriefTypeMapping = `custom local type mapping for generated struct attributes relevant to fields of table` - CGenDaoBriefFieldMapping = `custom local type mapping for generated struct attributes relevant to specific fields of table` - CGenDaoBriefGroup = ` -specifying the configuration group name of database for generated ORM instance, -it's not necessary and the default value is "default" -` - CGenDaoBriefJsonCase = ` -generated json tag case for model struct, cases are as follows: -| Case | Example | -|---------------- |--------------------| -| Camel | AnyKindOfString | -| CamelLower | anyKindOfString | default -| Snake | any_kind_of_string | -| SnakeScreaming | ANY_KIND_OF_STRING | -| SnakeFirstUpper | rgb_code_md5 | -| Kebab | any-kind-of-string | -| KebabScreaming | ANY-KIND-OF-STRING | -` - CGenDaoBriefTplDaoIndexPath = `template file path for dao index file` - CGenDaoBriefTplDaoInternalPath = `template file path for dao internal file` - CGenDaoBriefTplDaoDoPathPath = `template file path for dao do file` - CGenDaoBriefTplDaoEntityPath = `template file path for dao entity file` - - tplVarTableName = `{TplTableName}` - tplVarTableNameCamelCase = `{TplTableNameCamelCase}` - tplVarTableNameCamelLowerCase = `{TplTableNameCamelLowerCase}` - tplVarPackageImports = `{TplPackageImports}` - tplVarImportPrefix = `{TplImportPrefix}` - tplVarStructDefine = `{TplStructDefine}` - tplVarColumnDefine = `{TplColumnDefine}` - tplVarColumnNames = `{TplColumnNames}` - tplVarGroupName = `{TplGroupName}` - tplVarDatetimeStr = `{TplDatetimeStr}` - tplVarCreatedAtDatetimeStr = `{TplCreatedAtDatetimeStr}` - tplVarPackageName = `{TplPackageName}` -) - -var ( - createdAt = gtime.Now() - defaultTypeMapping = map[DBFieldTypeName]CustomAttributeType{ - "decimal": { - Type: "float64", - }, - "money": { - Type: "float64", - }, - "numeric": { - Type: "float64", - }, - "smallmoney": { - Type: "float64", - }, - } -) - -func init() { - gtag.Sets(g.MapStrStr{ - `CGenDaoConfig`: CGenDaoConfig, - `CGenDaoUsage`: CGenDaoUsage, - `CGenDaoBrief`: CGenDaoBrief, - `CGenDaoEg`: CGenDaoEg, - `CGenDaoAd`: CGenDaoAd, - `CGenDaoBriefPath`: CGenDaoBriefPath, - `CGenDaoBriefLink`: CGenDaoBriefLink, - `CGenDaoBriefTables`: CGenDaoBriefTables, - `CGenDaoBriefTablesEx`: CGenDaoBriefTablesEx, - `CGenDaoBriefPrefix`: CGenDaoBriefPrefix, - `CGenDaoBriefRemovePrefix`: CGenDaoBriefRemovePrefix, - `CGenDaoBriefRemoveFieldPrefix`: CGenDaoBriefRemoveFieldPrefix, - `CGenDaoBriefStdTime`: CGenDaoBriefStdTime, - `CGenDaoBriefWithTime`: CGenDaoBriefWithTime, - `CGenDaoBriefDaoPath`: CGenDaoBriefDaoPath, - `CGenDaoBriefDoPath`: CGenDaoBriefDoPath, - `CGenDaoBriefEntityPath`: CGenDaoBriefEntityPath, - `CGenDaoBriefGJsonSupport`: CGenDaoBriefGJsonSupport, - `CGenDaoBriefImportPrefix`: CGenDaoBriefImportPrefix, - `CGenDaoBriefOverwriteDao`: CGenDaoBriefOverwriteDao, - `CGenDaoBriefModelFile`: CGenDaoBriefModelFile, - `CGenDaoBriefModelFileForDao`: CGenDaoBriefModelFileForDao, - `CGenDaoBriefDescriptionTag`: CGenDaoBriefDescriptionTag, - `CGenDaoBriefNoJsonTag`: CGenDaoBriefNoJsonTag, - `CGenDaoBriefNoModelComment`: CGenDaoBriefNoModelComment, - `CGenDaoBriefClear`: CGenDaoBriefClear, - `CGenDaoBriefTypeMapping`: CGenDaoBriefTypeMapping, - `CGenDaoBriefFieldMapping`: CGenDaoBriefFieldMapping, - `CGenDaoBriefGroup`: CGenDaoBriefGroup, - `CGenDaoBriefJsonCase`: CGenDaoBriefJsonCase, - `CGenDaoBriefTplDaoIndexPath`: CGenDaoBriefTplDaoIndexPath, - `CGenDaoBriefTplDaoInternalPath`: CGenDaoBriefTplDaoInternalPath, - `CGenDaoBriefTplDaoDoPathPath`: CGenDaoBriefTplDaoDoPathPath, - `CGenDaoBriefTplDaoEntityPath`: CGenDaoBriefTplDaoEntityPath, - }) -} - type ( CGenDao struct{} CGenDaoInput struct { g.Meta `name:"dao" config:"{CGenDaoConfig}" usage:"{CGenDaoUsage}" brief:"{CGenDaoBrief}" eg:"{CGenDaoEg}" ad:"{CGenDaoAd}"` - Path string `name:"path" short:"p" brief:"{CGenDaoBriefPath}" d:"internal"` - Link string `name:"link" short:"l" brief:"{CGenDaoBriefLink}"` - Tables string `name:"tables" short:"t" brief:"{CGenDaoBriefTables}"` - TablesEx string `name:"tablesEx" short:"x" brief:"{CGenDaoBriefTablesEx}"` - Group string `name:"group" short:"g" brief:"{CGenDaoBriefGroup}" d:"default"` - Prefix string `name:"prefix" short:"f" brief:"{CGenDaoBriefPrefix}"` - RemovePrefix string `name:"removePrefix" short:"r" brief:"{CGenDaoBriefRemovePrefix}"` - RemoveFieldPrefix string `name:"removeFieldPrefix" short:"rf" brief:"{CGenDaoBriefRemoveFieldPrefix}"` - JsonCase string `name:"jsonCase" short:"j" brief:"{CGenDaoBriefJsonCase}" d:"CamelLower"` - ImportPrefix string `name:"importPrefix" short:"i" brief:"{CGenDaoBriefImportPrefix}"` - DaoPath string `name:"daoPath" short:"d" brief:"{CGenDaoBriefDaoPath}" d:"dao"` - DoPath string `name:"doPath" short:"o" brief:"{CGenDaoBriefDoPath}" d:"model/do"` - EntityPath string `name:"entityPath" short:"e" brief:"{CGenDaoBriefEntityPath}" d:"model/entity"` - TplDaoIndexPath string `name:"tplDaoIndexPath" short:"t1" brief:"{CGenDaoBriefTplDaoIndexPath}"` - TplDaoInternalPath string `name:"tplDaoInternalPath" short:"t2" brief:"{CGenDaoBriefTplDaoInternalPath}"` - TplDaoDoPath string `name:"tplDaoDoPath" short:"t3" brief:"{CGenDaoBriefTplDaoDoPathPath}"` - TplDaoEntityPath string `name:"tplDaoEntityPath" short:"t4" brief:"{CGenDaoBriefTplDaoEntityPath}"` - StdTime bool `name:"stdTime" short:"s" brief:"{CGenDaoBriefStdTime}" orphan:"true"` - WithTime bool `name:"withTime" short:"w" brief:"{CGenDaoBriefWithTime}" orphan:"true"` - GJsonSupport bool `name:"gJsonSupport" short:"n" brief:"{CGenDaoBriefGJsonSupport}" orphan:"true"` - OverwriteDao bool `name:"overwriteDao" short:"v" brief:"{CGenDaoBriefOverwriteDao}" orphan:"true"` - DescriptionTag bool `name:"descriptionTag" short:"c" brief:"{CGenDaoBriefDescriptionTag}" orphan:"true"` - NoJsonTag bool `name:"noJsonTag" short:"k" brief:"{CGenDaoBriefNoJsonTag}" orphan:"true"` - NoModelComment bool `name:"noModelComment" short:"m" brief:"{CGenDaoBriefNoModelComment}" orphan:"true"` - Clear bool `name:"clear" short:"a" brief:"{CGenDaoBriefClear}" orphan:"true"` + Path string `name:"path" short:"p" brief:"{CGenDaoBriefPath}" d:"internal"` + Link string `name:"link" short:"l" brief:"{CGenDaoBriefLink}"` + Tables string `name:"tables" short:"t" brief:"{CGenDaoBriefTables}"` + TablesEx string `name:"tablesEx" short:"x" brief:"{CGenDaoBriefTablesEx}"` + ShardingPattern []string `name:"ShardingPattern" short:"sp" brief:"{CGenDaoBriefShardingPattern}"` + Group string `name:"group" short:"g" brief:"{CGenDaoBriefGroup}" d:"default"` + Prefix string `name:"prefix" short:"f" brief:"{CGenDaoBriefPrefix}"` + RemovePrefix string `name:"removePrefix" short:"r" brief:"{CGenDaoBriefRemovePrefix}"` + RemoveFieldPrefix string `name:"removeFieldPrefix" short:"rf" brief:"{CGenDaoBriefRemoveFieldPrefix}"` + JsonCase string `name:"jsonCase" short:"j" brief:"{CGenDaoBriefJsonCase}" d:"CamelLower"` + ImportPrefix string `name:"importPrefix" short:"i" brief:"{CGenDaoBriefImportPrefix}"` + DaoPath string `name:"daoPath" short:"d" brief:"{CGenDaoBriefDaoPath}" d:"dao"` + DoPath string `name:"doPath" short:"o" brief:"{CGenDaoBriefDoPath}" d:"model/do"` + EntityPath string `name:"entityPath" short:"e" brief:"{CGenDaoBriefEntityPath}" d:"model/entity"` + TplDaoIndexPath string `name:"tplDaoIndexPath" short:"t1" brief:"{CGenDaoBriefTplDaoIndexPath}"` + TplDaoInternalPath string `name:"tplDaoInternalPath" short:"t2" brief:"{CGenDaoBriefTplDaoInternalPath}"` + TplDaoDoPath string `name:"tplDaoDoPath" short:"t3" brief:"{CGenDaoBriefTplDaoDoPathPath}"` + TplDaoEntityPath string `name:"tplDaoEntityPath" short:"t4" brief:"{CGenDaoBriefTplDaoEntityPath}"` + StdTime bool `name:"stdTime" short:"s" brief:"{CGenDaoBriefStdTime}" orphan:"true"` + WithTime bool `name:"withTime" short:"w" brief:"{CGenDaoBriefWithTime}" orphan:"true"` + GJsonSupport bool `name:"gJsonSupport" short:"n" brief:"{CGenDaoBriefGJsonSupport}" orphan:"true"` + OverwriteDao bool `name:"overwriteDao" short:"v" brief:"{CGenDaoBriefOverwriteDao}" orphan:"true"` + DescriptionTag bool `name:"descriptionTag" short:"c" brief:"{CGenDaoBriefDescriptionTag}" orphan:"true"` + NoJsonTag bool `name:"noJsonTag" short:"k" brief:"{CGenDaoBriefNoJsonTag}" orphan:"true"` + NoModelComment bool `name:"noModelComment" short:"m" brief:"{CGenDaoBriefNoModelComment}" orphan:"true"` + Clear bool `name:"clear" short:"a" brief:"{CGenDaoBriefClear}" orphan:"true"` TypeMapping map[DBFieldTypeName]CustomAttributeType `name:"typeMapping" short:"y" brief:"{CGenDaoBriefTypeMapping}" orphan:"true"` FieldMapping map[DBTableFieldName]CustomAttributeType `name:"fieldMapping" short:"fm" brief:"{CGenDaoBriefFieldMapping}" orphan:"true"` @@ -218,9 +69,10 @@ type ( CGenDaoInternalInput struct { CGenDaoInput - DB gdb.DB - TableNames []string - NewTableNames []string + DB gdb.DB + TableNames []string + NewTableNames []string + ShardingTableSet *gset.StrSet } DBTableFieldName = string DBFieldTypeName = string @@ -230,6 +82,25 @@ type ( } ) +var ( + createdAt = gtime.Now() + tplView = gview.New() + defaultTypeMapping = map[DBFieldTypeName]CustomAttributeType{ + "decimal": { + Type: "float64", + }, + "money": { + Type: "float64", + }, + "numeric": { + Type: "float64", + }, + "smallmoney": { + Type: "float64", + }, + } +) + func (c CGenDao) Dao(ctx context.Context, in CGenDaoInput) (out *CGenDaoOutput, err error) { in.genItems = newCGenDaoInternalGenItems() if in.Link != "" { @@ -274,9 +145,12 @@ func doGenDaoForArray(ctx context.Context, index int, in CGenDaoInput) { // It uses user passed database configuration. if in.Link != "" { var tempGroup = gtime.TimestampNanoStr() - gdb.AddConfigNode(tempGroup, gdb.ConfigNode{ + err = gdb.AddConfigNode(tempGroup, gdb.ConfigNode{ Link: in.Link, }) + if err != nil { + mlog.Fatalf(`database configuration failed: %+v`, err) + } if db, err = gdb.Instance(tempGroup); err != nil { mlog.Fatalf(`database initialization failed: %+v`, err) } @@ -317,24 +191,51 @@ func doGenDaoForArray(ctx context.Context, index int, in CGenDaoInput) { } // Generating dao & model go files one by one according to given table name. - newTableNames := make([]string, len(tableNames)) + var ( + newTableNames = make([]string, len(tableNames)) + shardingNewTableSet = gset.NewStrSet() + ) for i, tableName := range tableNames { newTableName := tableName for _, v := range removePrefixArray { newTableName = gstr.TrimLeftStr(newTableName, v, 1) } + if len(in.ShardingPattern) > 0 { + for _, pattern := range in.ShardingPattern { + var ( + match []string + regPattern = gstr.Replace(pattern, "?", `(.+)`) + ) + match, err = gregex.MatchString(regPattern, newTableName) + if err != nil { + mlog.Fatalf(`invalid sharding pattern "%s": %+v`, pattern, err) + } + if len(match) < 2 { + continue + } + newTableName = gstr.Replace(pattern, "?", "") + newTableName = gstr.Trim(newTableName, `_.-`) + if shardingNewTableSet.Contains(newTableName) { + tableNames[i] = "" + continue + } + shardingNewTableSet.Add(newTableName) + } + } newTableName = in.Prefix + newTableName newTableNames[i] = newTableName } + tableNames = garray.NewStrArrayFrom(tableNames).FilterEmpty().Slice() in.genItems.Scale() // Dao: index and internal. generateDao(ctx, CGenDaoInternalInput{ - CGenDaoInput: in, - DB: db, - TableNames: tableNames, - NewTableNames: newTableNames, + CGenDaoInput: in, + DB: db, + TableNames: tableNames, + NewTableNames: newTableNames, + ShardingTableSet: shardingNewTableSet, }) // Do. generateDo(ctx, CGenDaoInternalInput{ @@ -407,13 +308,15 @@ func getImportPartContent(ctx context.Context, source string, isDo bool, appendI return packageImportsStr } -func replaceDefaultVar(in CGenDaoInternalInput, origin string) string { - var tplCreatedAtDatetimeStr string - var tplDatetimeStr string = createdAt.String() +func assignDefaultVar(view *gview.View, in CGenDaoInternalInput) { + var ( + tplCreatedAtDatetimeStr string + tplDatetimeStr = createdAt.String() + ) if in.WithTime { tplCreatedAtDatetimeStr = fmt.Sprintf(`Created at %s`, tplDatetimeStr) } - return gstr.ReplaceByMap(origin, g.MapStrStr{ + view.Assigns(g.Map{ tplVarDatetimeStr: tplDatetimeStr, tplVarCreatedAtDatetimeStr: tplCreatedAtDatetimeStr, }) diff --git a/cmd/gf/internal/cmd/gendao/gendao_dao.go b/cmd/gf/internal/cmd/gendao/gendao_dao.go index 1c2363347b7..83b4c5a4616 100644 --- a/cmd/gf/internal/cmd/gendao/gendao_dao.go +++ b/cmd/gf/internal/cmd/gendao/gendao_dao.go @@ -18,6 +18,7 @@ import ( "github.com/gogf/gf/v2/database/gdb" "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gview" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/cmd/gf/v2/internal/consts" @@ -32,22 +33,30 @@ func generateDao(ctx context.Context, in CGenDaoInternalInput) { ) in.genItems.AppendDirPath(dirPathDao) for i := 0; i < len(in.TableNames); i++ { + var ( + realTableName = in.TableNames[i] + newTableName = in.NewTableNames[i] + ) generateDaoSingle(ctx, generateDaoSingleInput{ CGenDaoInternalInput: in, - TableName: in.TableNames[i], - NewTableName: in.NewTableNames[i], + TableName: realTableName, + NewTableName: newTableName, DirPathDao: dirPathDao, DirPathDaoInternal: dirPathDaoInternal, + IsSharding: in.ShardingTableSet.Contains(newTableName), }) } } type generateDaoSingleInput struct { CGenDaoInternalInput - TableName string // TableName specifies the table name of the table. - NewTableName string // NewTableName specifies the prefix-stripped name of the table. + // TableName specifies the table name of the table. + TableName string + // NewTableName specifies the prefix-stripped or custom edited name of the table. + NewTableName string DirPathDao string DirPathDaoInternal string + IsSharding bool } // generateDaoSingle generates the dao and model content of given table. @@ -109,17 +118,26 @@ func generateDaoIndex(in generateDaoIndexInput) { // It should add path to result slice whenever it would generate the path file or not. in.genItems.AppendGeneratedFilePath(path) if in.OverwriteDao || !gfile.Exists(path) { - indexContent := gstr.ReplaceByMap( - getTemplateFromPathOrDefault(in.TplDaoIndexPath, consts.TemplateGenDaoIndexContent), - g.MapStrStr{ - tplVarImportPrefix: in.ImportPrefix, - tplVarTableName: in.TableName, - tplVarTableNameCamelCase: in.TableNameCamelCase, - tplVarTableNameCamelLowerCase: in.TableNameCamelLowerCase, - tplVarPackageName: filepath.Base(in.DaoPath), - }) - indexContent = replaceDefaultVar(in.CGenDaoInternalInput, indexContent) - if err := gfile.PutContents(path, strings.TrimSpace(indexContent)); err != nil { + var ( + ctx = context.Background() + tplContent = getTemplateFromPathOrDefault( + in.TplDaoIndexPath, consts.TemplateGenDaoIndexContent, + ) + ) + tplView.ClearAssigns() + tplView.Assigns(gview.Params{ + tplVarTableSharding: in.IsSharding, + tplVarImportPrefix: in.ImportPrefix, + tplVarTableName: in.TableName, + tplVarTableNameCamelCase: in.TableNameCamelCase, + tplVarTableNameCamelLowerCase: in.TableNameCamelLowerCase, + tplVarPackageName: filepath.Base(in.DaoPath), + }) + indexContent, err := tplView.ParseContent(ctx, tplContent) + if err != nil { + mlog.Fatalf("parsing template content failed: %v", err) + } + if err = gfile.PutContents(path, strings.TrimSpace(indexContent)); err != nil { mlog.Fatalf("writing content to '%s' failed: %v", path, err) } else { utils.GoFmt(path) @@ -138,20 +156,29 @@ type generateDaoInternalInput struct { } func generateDaoInternal(in generateDaoInternalInput) { + var ( + ctx = context.Background() + removeFieldPrefixArray = gstr.SplitAndTrim(in.RemoveFieldPrefix, ",") + tplContent = getTemplateFromPathOrDefault( + in.TplDaoInternalPath, consts.TemplateGenDaoInternalContent, + ) + ) + tplView.ClearAssigns() + tplView.Assigns(gview.Params{ + tplVarImportPrefix: in.ImportPrefix, + tplVarTableName: in.TableName, + tplVarGroupName: in.Group, + tplVarTableNameCamelCase: in.TableNameCamelCase, + tplVarTableNameCamelLowerCase: in.TableNameCamelLowerCase, + tplVarColumnDefine: gstr.Trim(generateColumnDefinitionForDao(in.FieldMap, removeFieldPrefixArray)), + tplVarColumnNames: gstr.Trim(generateColumnNamesForDao(in.FieldMap, removeFieldPrefixArray)), + }) + assignDefaultVar(tplView, in.CGenDaoInternalInput) + modelContent, err := tplView.ParseContent(ctx, tplContent) + if err != nil { + mlog.Fatalf("parsing template content failed: %v", err) + } path := filepath.FromSlash(gfile.Join(in.DirPathDaoInternal, in.FileName+".go")) - removeFieldPrefixArray := gstr.SplitAndTrim(in.RemoveFieldPrefix, ",") - modelContent := gstr.ReplaceByMap( - getTemplateFromPathOrDefault(in.TplDaoInternalPath, consts.TemplateGenDaoInternalContent), - g.MapStrStr{ - tplVarImportPrefix: in.ImportPrefix, - tplVarTableName: in.TableName, - tplVarGroupName: in.Group, - tplVarTableNameCamelCase: in.TableNameCamelCase, - tplVarTableNameCamelLowerCase: in.TableNameCamelLowerCase, - tplVarColumnDefine: gstr.Trim(generateColumnDefinitionForDao(in.FieldMap, removeFieldPrefixArray)), - tplVarColumnNames: gstr.Trim(generateColumnNamesForDao(in.FieldMap, removeFieldPrefixArray)), - }) - modelContent = replaceDefaultVar(in.CGenDaoInternalInput, modelContent) in.genItems.AppendGeneratedFilePath(path) if err := gfile.PutContents(path, strings.TrimSpace(modelContent)); err != nil { mlog.Fatalf("writing content to '%s' failed: %v", path, err) diff --git a/cmd/gf/internal/cmd/gendao/gendao_do.go b/cmd/gf/internal/cmd/gendao/gendao_do.go index 7a3cb542c0e..98afd6d7837 100644 --- a/cmd/gf/internal/cmd/gendao/gendao_do.go +++ b/cmd/gf/internal/cmd/gendao/gendao_do.go @@ -12,8 +12,8 @@ import ( "path/filepath" "strings" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gview" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" @@ -78,16 +78,23 @@ func generateDo(ctx context.Context, in CGenDaoInternalInput) { func generateDoContent( ctx context.Context, in CGenDaoInternalInput, tableName, tableNameCamelCase, structDefine string, ) string { - doContent := gstr.ReplaceByMap( - getTemplateFromPathOrDefault(in.TplDaoDoPath, consts.TemplateGenDaoDoContent), - g.MapStrStr{ - tplVarTableName: tableName, - tplVarPackageImports: getImportPartContent(ctx, structDefine, true, nil), - tplVarTableNameCamelCase: tableNameCamelCase, - tplVarStructDefine: structDefine, - tplVarPackageName: filepath.Base(in.DoPath), - }, + var ( + tplContent = getTemplateFromPathOrDefault( + in.TplDaoDoPath, consts.TemplateGenDaoDoContent, + ) ) - doContent = replaceDefaultVar(in, doContent) + tplView.ClearAssigns() + tplView.Assigns(gview.Params{ + tplVarTableName: tableName, + tplVarPackageImports: getImportPartContent(ctx, structDefine, true, nil), + tplVarTableNameCamelCase: tableNameCamelCase, + tplVarStructDefine: structDefine, + tplVarPackageName: filepath.Base(in.DoPath), + }) + assignDefaultVar(tplView, in) + doContent, err := tplView.ParseContent(ctx, tplContent) + if err != nil { + mlog.Fatalf("parsing template content failed: %v", err) + } return doContent } diff --git a/cmd/gf/internal/cmd/gendao/gendao_entity.go b/cmd/gf/internal/cmd/gendao/gendao_entity.go index 9d38db428ec..8b059e8108c 100644 --- a/cmd/gf/internal/cmd/gendao/gendao_entity.go +++ b/cmd/gf/internal/cmd/gendao/gendao_entity.go @@ -11,8 +11,8 @@ import ( "path/filepath" "strings" - "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gfile" + "github.com/gogf/gf/v2/os/gview" "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/cmd/gf/v2/internal/consts" @@ -63,16 +63,23 @@ func generateEntity(ctx context.Context, in CGenDaoInternalInput) { func generateEntityContent( ctx context.Context, in CGenDaoInternalInput, tableName, tableNameCamelCase, structDefine string, appendImports []string, ) string { - entityContent := gstr.ReplaceByMap( - getTemplateFromPathOrDefault(in.TplDaoEntityPath, consts.TemplateGenDaoEntityContent), - g.MapStrStr{ - tplVarTableName: tableName, - tplVarPackageImports: getImportPartContent(ctx, structDefine, false, appendImports), - tplVarTableNameCamelCase: tableNameCamelCase, - tplVarStructDefine: structDefine, - tplVarPackageName: filepath.Base(in.EntityPath), - }, + var ( + tplContent = getTemplateFromPathOrDefault( + in.TplDaoEntityPath, consts.TemplateGenDaoEntityContent, + ) ) - entityContent = replaceDefaultVar(in, entityContent) + tplView.ClearAssigns() + tplView.Assigns(gview.Params{ + tplVarTableName: tableName, + tplVarPackageImports: getImportPartContent(ctx, structDefine, false, appendImports), + tplVarTableNameCamelCase: tableNameCamelCase, + tplVarStructDefine: structDefine, + tplVarPackageName: filepath.Base(in.EntityPath), + }) + assignDefaultVar(tplView, in) + entityContent, err := tplView.ParseContent(ctx, tplContent) + if err != nil { + mlog.Fatalf("parsing template content failed: %v", err) + } return entityContent } diff --git a/cmd/gf/internal/cmd/gendao/gendao_gen_item.go b/cmd/gf/internal/cmd/gendao/gendao_gen_item.go index 09fa7fe125b..fcb7bf9beeb 100644 --- a/cmd/gf/internal/cmd/gendao/gendao_gen_item.go +++ b/cmd/gf/internal/cmd/gendao/gendao_gen_item.go @@ -38,14 +38,14 @@ func (i *CGenDaoInternalGenItems) SetClear(clear bool) { i.Items[i.index].Clear = clear } -func (i CGenDaoInternalGenItems) AppendDirPath(storageDirPath string) { +func (i *CGenDaoInternalGenItems) AppendDirPath(storageDirPath string) { i.Items[i.index].StorageDirPaths = append( i.Items[i.index].StorageDirPaths, storageDirPath, ) } -func (i CGenDaoInternalGenItems) AppendGeneratedFilePath(generatedFilePath string) { +func (i *CGenDaoInternalGenItems) AppendGeneratedFilePath(generatedFilePath string) { i.Items[i.index].GeneratedFilePaths = append( i.Items[i.index].GeneratedFilePaths, generatedFilePath, diff --git a/cmd/gf/internal/cmd/gendao/gendao_tag.go b/cmd/gf/internal/cmd/gendao/gendao_tag.go new file mode 100644 index 00000000000..0487184e0d9 --- /dev/null +++ b/cmd/gf/internal/cmd/gendao/gendao_tag.go @@ -0,0 +1,149 @@ +// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package gendao + +import ( + "github.com/gogf/gf/v2/frame/g" + "github.com/gogf/gf/v2/util/gtag" +) + +const ( + CGenDaoConfig = `gfcli.gen.dao` + CGenDaoUsage = `gf gen dao [OPTION]` + CGenDaoBrief = `automatically generate go files for dao/do/entity` + CGenDaoEg = ` +gf gen dao +gf gen dao -l "mysql:root:12345678@tcp(127.0.0.1:3306)/test" +gf gen dao -p ./model -g user-center -t user,user_detail,user_login +gf gen dao -r user_ +` + + CGenDaoAd = ` +CONFIGURATION SUPPORT + Options are also supported by configuration file. + It's suggested using configuration file instead of command line arguments making producing. + The configuration node name is "gfcli.gen.dao", which also supports multiple databases, for example(config.yaml): + gfcli: + gen: + dao: + - link: "mysql:root:12345678@tcp(127.0.0.1:3306)/test" + tables: "order,products" + jsonCase: "CamelLower" + - link: "mysql:root:12345678@tcp(127.0.0.1:3306)/primary" + path: "./my-app" + prefix: "primary_" + tables: "user, userDetail" + typeMapping: + decimal: + type: decimal.Decimal + import: github.com/shopspring/decimal + numeric: + type: string + fieldMapping: + table_name.field_name: + type: decimal.Decimal + import: github.com/shopspring/decimal +` + CGenDaoBriefPath = `directory path for generated files` + CGenDaoBriefLink = `database configuration, the same as the ORM configuration of GoFrame` + CGenDaoBriefTables = `generate models only for given tables, multiple table names separated with ','` + CGenDaoBriefTablesEx = `generate models excluding given tables, multiple table names separated with ','` + CGenDaoBriefPrefix = `add prefix for all table of specified link/database tables` + CGenDaoBriefRemovePrefix = `remove specified prefix of the table, multiple prefix separated with ','` + CGenDaoBriefRemoveFieldPrefix = `remove specified prefix of the field, multiple prefix separated with ','` + CGenDaoBriefStdTime = `use time.Time from stdlib instead of gtime.Time for generated time/date fields of tables` + CGenDaoBriefWithTime = `add created time for auto produced go files` + CGenDaoBriefGJsonSupport = `use gJsonSupport to use *gjson.Json instead of string for generated json fields of tables` + CGenDaoBriefImportPrefix = `custom import prefix for generated go files` + CGenDaoBriefDaoPath = `directory path for storing generated dao files under path` + CGenDaoBriefDoPath = `directory path for storing generated do files under path` + CGenDaoBriefEntityPath = `directory path for storing generated entity files under path` + CGenDaoBriefOverwriteDao = `overwrite all dao files both inside/outside internal folder` + CGenDaoBriefModelFile = `custom file name for storing generated model content` + CGenDaoBriefModelFileForDao = `custom file name generating model for DAO operations like Where/Data. It's empty in default` + CGenDaoBriefDescriptionTag = `add comment to description tag for each field` + CGenDaoBriefNoJsonTag = `no json tag will be added for each field` + CGenDaoBriefNoModelComment = `no model comment will be added for each field` + CGenDaoBriefClear = `delete all generated go files that do not exist in database` + CGenDaoBriefTypeMapping = `custom local type mapping for generated struct attributes relevant to fields of table` + CGenDaoBriefFieldMapping = `custom local type mapping for generated struct attributes relevant to specific fields of table` + CGenDaoBriefShardingPattern = `sharding pattern for table name, e.g. "users_?" will be replace tables "users_001,users_002,..." to "users" dao` + CGenDaoBriefGroup = ` +specifying the configuration group name of database for generated ORM instance, +it's not necessary and the default value is "default" +` + CGenDaoBriefJsonCase = ` +generated json tag case for model struct, cases are as follows: +| Case | Example | +|---------------- |--------------------| +| Camel | AnyKindOfString | +| CamelLower | anyKindOfString | default +| Snake | any_kind_of_string | +| SnakeScreaming | ANY_KIND_OF_STRING | +| SnakeFirstUpper | rgb_code_md5 | +| Kebab | any-kind-of-string | +| KebabScreaming | ANY-KIND-OF-STRING | +` + CGenDaoBriefTplDaoIndexPath = `template file path for dao index file` + CGenDaoBriefTplDaoInternalPath = `template file path for dao internal file` + CGenDaoBriefTplDaoDoPathPath = `template file path for dao do file` + CGenDaoBriefTplDaoEntityPath = `template file path for dao entity file` + + tplVarTableName = `TplTableName` + tplVarTableNameCamelCase = `TplTableNameCamelCase` + tplVarTableNameCamelLowerCase = `TplTableNameCamelLowerCase` + tplVarTableSharding = `TplTableSharding` + tplVarPackageImports = `TplPackageImports` + tplVarImportPrefix = `TplImportPrefix` + tplVarStructDefine = `TplStructDefine` + tplVarColumnDefine = `TplColumnDefine` + tplVarColumnNames = `TplColumnNames` + tplVarGroupName = `TplGroupName` + tplVarDatetimeStr = `TplDatetimeStr` + tplVarCreatedAtDatetimeStr = `TplCreatedAtDatetimeStr` + tplVarPackageName = `TplPackageName` +) + +func init() { + gtag.Sets(g.MapStrStr{ + `CGenDaoConfig`: CGenDaoConfig, + `CGenDaoUsage`: CGenDaoUsage, + `CGenDaoBrief`: CGenDaoBrief, + `CGenDaoEg`: CGenDaoEg, + `CGenDaoAd`: CGenDaoAd, + `CGenDaoBriefPath`: CGenDaoBriefPath, + `CGenDaoBriefLink`: CGenDaoBriefLink, + `CGenDaoBriefTables`: CGenDaoBriefTables, + `CGenDaoBriefTablesEx`: CGenDaoBriefTablesEx, + `CGenDaoBriefPrefix`: CGenDaoBriefPrefix, + `CGenDaoBriefRemovePrefix`: CGenDaoBriefRemovePrefix, + `CGenDaoBriefRemoveFieldPrefix`: CGenDaoBriefRemoveFieldPrefix, + `CGenDaoBriefStdTime`: CGenDaoBriefStdTime, + `CGenDaoBriefWithTime`: CGenDaoBriefWithTime, + `CGenDaoBriefDaoPath`: CGenDaoBriefDaoPath, + `CGenDaoBriefDoPath`: CGenDaoBriefDoPath, + `CGenDaoBriefEntityPath`: CGenDaoBriefEntityPath, + `CGenDaoBriefGJsonSupport`: CGenDaoBriefGJsonSupport, + `CGenDaoBriefImportPrefix`: CGenDaoBriefImportPrefix, + `CGenDaoBriefOverwriteDao`: CGenDaoBriefOverwriteDao, + `CGenDaoBriefModelFile`: CGenDaoBriefModelFile, + `CGenDaoBriefModelFileForDao`: CGenDaoBriefModelFileForDao, + `CGenDaoBriefDescriptionTag`: CGenDaoBriefDescriptionTag, + `CGenDaoBriefNoJsonTag`: CGenDaoBriefNoJsonTag, + `CGenDaoBriefNoModelComment`: CGenDaoBriefNoModelComment, + `CGenDaoBriefClear`: CGenDaoBriefClear, + `CGenDaoBriefTypeMapping`: CGenDaoBriefTypeMapping, + `CGenDaoBriefFieldMapping`: CGenDaoBriefFieldMapping, + `CGenDaoBriefShardingPattern`: CGenDaoBriefShardingPattern, + `CGenDaoBriefGroup`: CGenDaoBriefGroup, + `CGenDaoBriefJsonCase`: CGenDaoBriefJsonCase, + `CGenDaoBriefTplDaoIndexPath`: CGenDaoBriefTplDaoIndexPath, + `CGenDaoBriefTplDaoInternalPath`: CGenDaoBriefTplDaoInternalPath, + `CGenDaoBriefTplDaoDoPathPath`: CGenDaoBriefTplDaoDoPathPath, + `CGenDaoBriefTplDaoEntityPath`: CGenDaoBriefTplDaoEntityPath, + }) +} diff --git a/cmd/gf/internal/cmd/testdata/gendao/generated_user/dao/internal/table_user.go b/cmd/gf/internal/cmd/testdata/gendao/generated_user/dao/internal/table_user.go index 68d96fb0619..ea8bec0c63a 100644 --- a/cmd/gf/internal/cmd/testdata/gendao/generated_user/dao/internal/table_user.go +++ b/cmd/gf/internal/cmd/testdata/gendao/generated_user/dao/internal/table_user.go @@ -13,9 +13,10 @@ import ( // TableUserDao is the data access object for the table table_user. type TableUserDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns TableUserColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns TableUserColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // TableUserColumns defines and stores column names for the table table_user. @@ -41,11 +42,12 @@ var tableUserColumns = TableUserColumns{ } // NewTableUserDao creates and returns a new DAO object for table data access. -func NewTableUserDao() *TableUserDao { +func NewTableUserDao(handlers ...gdb.ModelHandler) *TableUserDao { return &TableUserDao{ - group: "test", - table: "table_user", - columns: tableUserColumns, + group: "test", + table: "table_user", + columns: tableUserColumns, + handlers: handlers, } } @@ -71,7 +73,11 @@ func (dao *TableUserDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *TableUserDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/cmd/gf/internal/cmd/testdata/gendao/generated_user/dao/table_user.go b/cmd/gf/internal/cmd/testdata/gendao/generated_user/dao/table_user.go index 28d2d47973d..22fe176f871 100644 --- a/cmd/gf/internal/cmd/testdata/gendao/generated_user/dao/table_user.go +++ b/cmd/gf/internal/cmd/testdata/gendao/generated_user/dao/table_user.go @@ -8,20 +8,15 @@ import ( "for-gendao-test/pkg/dao/internal" ) -// internalTableUserDao is an internal type for wrapping the internal DAO implementation. -type internalTableUserDao = *internal.TableUserDao - // tableUserDao is the data access object for the table table_user. // You can define custom methods on it to extend its functionality as needed. type tableUserDao struct { - internalTableUserDao + *internal.TableUserDao } var ( // TableUser is a globally accessible object for table table_user operations. - TableUser = tableUserDao{ - internal.NewTableUserDao(), - } + TableUser = tableUserDao{internal.NewTableUserDao()} ) // Add your custom methods and functionality below. diff --git a/cmd/gf/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/internal/table_user.go b/cmd/gf/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/internal/table_user.go index 68d96fb0619..ea8bec0c63a 100644 --- a/cmd/gf/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/internal/table_user.go +++ b/cmd/gf/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/internal/table_user.go @@ -13,9 +13,10 @@ import ( // TableUserDao is the data access object for the table table_user. type TableUserDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns TableUserColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns TableUserColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // TableUserColumns defines and stores column names for the table table_user. @@ -41,11 +42,12 @@ var tableUserColumns = TableUserColumns{ } // NewTableUserDao creates and returns a new DAO object for table data access. -func NewTableUserDao() *TableUserDao { +func NewTableUserDao(handlers ...gdb.ModelHandler) *TableUserDao { return &TableUserDao{ - group: "test", - table: "table_user", - columns: tableUserColumns, + group: "test", + table: "table_user", + columns: tableUserColumns, + handlers: handlers, } } @@ -71,7 +73,11 @@ func (dao *TableUserDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *TableUserDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/cmd/gf/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/table_user.go b/cmd/gf/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/table_user.go index 28d2d47973d..22fe176f871 100644 --- a/cmd/gf/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/table_user.go +++ b/cmd/gf/internal/cmd/testdata/gendao/generated_user_field_mapping/dao/table_user.go @@ -8,20 +8,15 @@ import ( "for-gendao-test/pkg/dao/internal" ) -// internalTableUserDao is an internal type for wrapping the internal DAO implementation. -type internalTableUserDao = *internal.TableUserDao - // tableUserDao is the data access object for the table table_user. // You can define custom methods on it to extend its functionality as needed. type tableUserDao struct { - internalTableUserDao + *internal.TableUserDao } var ( // TableUser is a globally accessible object for table table_user operations. - TableUser = tableUserDao{ - internal.NewTableUserDao(), - } + TableUser = tableUserDao{internal.NewTableUserDao()} ) // Add your custom methods and functionality below. diff --git a/cmd/gf/internal/cmd/testdata/gendao/generated_user_sqlite3/dao/internal/table_user.go b/cmd/gf/internal/cmd/testdata/gendao/generated_user_sqlite3/dao/internal/table_user.go index 8484c101957..6bdfc918360 100644 --- a/cmd/gf/internal/cmd/testdata/gendao/generated_user_sqlite3/dao/internal/table_user.go +++ b/cmd/gf/internal/cmd/testdata/gendao/generated_user_sqlite3/dao/internal/table_user.go @@ -13,9 +13,10 @@ import ( // TableUserDao is the data access object for the table table_user. type TableUserDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns TableUserColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns TableUserColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // TableUserColumns defines and stores column names for the table table_user. @@ -39,11 +40,12 @@ var tableUserColumns = TableUserColumns{ } // NewTableUserDao creates and returns a new DAO object for table data access. -func NewTableUserDao() *TableUserDao { +func NewTableUserDao(handlers ...gdb.ModelHandler) *TableUserDao { return &TableUserDao{ - group: "test", - table: "table_user", - columns: tableUserColumns, + group: "test", + table: "table_user", + columns: tableUserColumns, + handlers: handlers, } } @@ -69,7 +71,11 @@ func (dao *TableUserDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *TableUserDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/cmd/gf/internal/cmd/testdata/gendao/generated_user_sqlite3/dao/table_user.go b/cmd/gf/internal/cmd/testdata/gendao/generated_user_sqlite3/dao/table_user.go index 28d2d47973d..22fe176f871 100644 --- a/cmd/gf/internal/cmd/testdata/gendao/generated_user_sqlite3/dao/table_user.go +++ b/cmd/gf/internal/cmd/testdata/gendao/generated_user_sqlite3/dao/table_user.go @@ -8,20 +8,15 @@ import ( "for-gendao-test/pkg/dao/internal" ) -// internalTableUserDao is an internal type for wrapping the internal DAO implementation. -type internalTableUserDao = *internal.TableUserDao - // tableUserDao is the data access object for the table table_user. // You can define custom methods on it to extend its functionality as needed. type tableUserDao struct { - internalTableUserDao + *internal.TableUserDao } var ( // TableUser is a globally accessible object for table table_user operations. - TableUser = tableUserDao{ - internal.NewTableUserDao(), - } + TableUser = tableUserDao{internal.NewTableUserDao()} ) // Add your custom methods and functionality below. diff --git a/cmd/gf/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/internal/table_user.go b/cmd/gf/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/internal/table_user.go index 68d96fb0619..ea8bec0c63a 100644 --- a/cmd/gf/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/internal/table_user.go +++ b/cmd/gf/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/internal/table_user.go @@ -13,9 +13,10 @@ import ( // TableUserDao is the data access object for the table table_user. type TableUserDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns TableUserColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns TableUserColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // TableUserColumns defines and stores column names for the table table_user. @@ -41,11 +42,12 @@ var tableUserColumns = TableUserColumns{ } // NewTableUserDao creates and returns a new DAO object for table data access. -func NewTableUserDao() *TableUserDao { +func NewTableUserDao(handlers ...gdb.ModelHandler) *TableUserDao { return &TableUserDao{ - group: "test", - table: "table_user", - columns: tableUserColumns, + group: "test", + table: "table_user", + columns: tableUserColumns, + handlers: handlers, } } @@ -71,7 +73,11 @@ func (dao *TableUserDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *TableUserDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/cmd/gf/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/table_user.go b/cmd/gf/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/table_user.go index 28d2d47973d..22fe176f871 100644 --- a/cmd/gf/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/table_user.go +++ b/cmd/gf/internal/cmd/testdata/gendao/generated_user_type_mapping/dao/table_user.go @@ -8,20 +8,15 @@ import ( "for-gendao-test/pkg/dao/internal" ) -// internalTableUserDao is an internal type for wrapping the internal DAO implementation. -type internalTableUserDao = *internal.TableUserDao - // tableUserDao is the data access object for the table table_user. // You can define custom methods on it to extend its functionality as needed. type tableUserDao struct { - internalTableUserDao + *internal.TableUserDao } var ( // TableUser is a globally accessible object for table table_user operations. - TableUser = tableUserDao{ - internal.NewTableUserDao(), - } + TableUser = tableUserDao{internal.NewTableUserDao()} ) // Add your custom methods and functionality below. diff --git a/cmd/gf/internal/cmd/testdata/gendao/sharding/sharding.sql b/cmd/gf/internal/cmd/testdata/gendao/sharding/sharding.sql new file mode 100644 index 00000000000..2c5f70bab35 --- /dev/null +++ b/cmd/gf/internal/cmd/testdata/gendao/sharding/sharding.sql @@ -0,0 +1,45 @@ +CREATE TABLE `single_table` ( + `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'User ID', + `passport` varchar(45) NOT NULL COMMENT 'User Passport', + `password` varchar(45) NOT NULL COMMENT 'User Password', + `nickname` varchar(45) NOT NULL COMMENT 'User Nickname', + `score` decimal(10,2) unsigned DEFAULT NULL COMMENT 'Total score amount.', + `create_at` datetime DEFAULT NULL COMMENT 'Created Time', + `update_at` datetime DEFAULT NULL COMMENT 'Updated Time', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `users_0001` ( + `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'User ID', + `passport` varchar(45) NOT NULL COMMENT 'User Passport', + `password` varchar(45) NOT NULL COMMENT 'User Password', + `nickname` varchar(45) NOT NULL COMMENT 'User Nickname', + `score` decimal(10,2) unsigned DEFAULT NULL COMMENT 'Total score amount.', + `create_at` datetime DEFAULT NULL COMMENT 'Created Time', + `update_at` datetime DEFAULT NULL COMMENT 'Updated Time', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + +CREATE TABLE `users_0002` ( + `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'User ID', + `passport` varchar(45) NOT NULL COMMENT 'User Passport', + `password` varchar(45) NOT NULL COMMENT 'User Password', + `nickname` varchar(45) NOT NULL COMMENT 'User Nickname', + `score` decimal(10,2) unsigned DEFAULT NULL COMMENT 'Total score amount.', + `create_at` datetime DEFAULT NULL COMMENT 'Created Time', + `update_at` datetime DEFAULT NULL COMMENT 'Updated Time', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; + + +CREATE TABLE `users_0003` ( + `id` int unsigned NOT NULL AUTO_INCREMENT COMMENT 'User ID', + `passport` varchar(45) NOT NULL COMMENT 'User Passport', + `password` varchar(45) NOT NULL COMMENT 'User Password', + `nickname` varchar(45) NOT NULL COMMENT 'User Nickname', + `score` decimal(10,2) unsigned DEFAULT NULL COMMENT 'Total score amount.', + `create_at` datetime DEFAULT NULL COMMENT 'Created Time', + `update_at` datetime DEFAULT NULL COMMENT 'Updated Time', + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file diff --git a/cmd/gf/internal/cmd/testdata/issue/3749/dao/internal/table_user.go b/cmd/gf/internal/cmd/testdata/issue/3749/dao/internal/table_user.go index bb7bf30a875..9a3958bc9ef 100644 --- a/cmd/gf/internal/cmd/testdata/issue/3749/dao/internal/table_user.go +++ b/cmd/gf/internal/cmd/testdata/issue/3749/dao/internal/table_user.go @@ -13,9 +13,10 @@ import ( // TableUserDao is the data access object for the table table_user. type TableUserDao struct { - table string // table is the underlying table name of the DAO. - group string // group is the database configuration group name of the current DAO. - columns TableUserColumns // columns contains all the column names of Table for convenient usage. + table string // table is the underlying table name of the DAO. + group string // group is the database configuration group name of the current DAO. + columns TableUserColumns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } // TableUserColumns defines and stores column names for the table table_user. @@ -41,11 +42,12 @@ var tableUserColumns = TableUserColumns{ } // NewTableUserDao creates and returns a new DAO object for table data access. -func NewTableUserDao() *TableUserDao { +func NewTableUserDao(handlers ...gdb.ModelHandler) *TableUserDao { return &TableUserDao{ - group: "test", - table: "table_user", - columns: tableUserColumns, + group: "test", + table: "table_user", + columns: tableUserColumns, + handlers: handlers, } } @@ -71,7 +73,11 @@ func (dao *TableUserDao) Group() string { // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. func (dao *TableUserDao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. diff --git a/cmd/gf/internal/cmd/testdata/issue/3749/dao/table_user.go b/cmd/gf/internal/cmd/testdata/issue/3749/dao/table_user.go index 28d2d47973d..22fe176f871 100644 --- a/cmd/gf/internal/cmd/testdata/issue/3749/dao/table_user.go +++ b/cmd/gf/internal/cmd/testdata/issue/3749/dao/table_user.go @@ -8,20 +8,15 @@ import ( "for-gendao-test/pkg/dao/internal" ) -// internalTableUserDao is an internal type for wrapping the internal DAO implementation. -type internalTableUserDao = *internal.TableUserDao - // tableUserDao is the data access object for the table table_user. // You can define custom methods on it to extend its functionality as needed. type tableUserDao struct { - internalTableUserDao + *internal.TableUserDao } var ( // TableUser is a globally accessible object for table table_user operations. - TableUser = tableUserDao{ - internal.NewTableUserDao(), - } + TableUser = tableUserDao{internal.NewTableUserDao()} ) // Add your custom methods and functionality below. diff --git a/cmd/gf/internal/consts/consts_gen_dao_template_dao.go b/cmd/gf/internal/consts/consts_gen_dao_template_dao.go index c1e20fbe770..d1a82bc03d2 100644 --- a/cmd/gf/internal/consts/consts_gen_dao_template_dao.go +++ b/cmd/gf/internal/consts/consts_gen_dao_template_dao.go @@ -11,35 +11,54 @@ const TemplateGenDaoIndexContent = ` // This file is auto-generated by the GoFrame CLI tool. You may modify it as needed. // ================================================================================= -package {TplPackageName} +package {{.TplPackageName}} import ( - "{TplImportPrefix}/internal" + "{{.TplImportPrefix}}/internal" ) -// internal{TplTableNameCamelCase}Dao is an internal type for wrapping the internal DAO implementation. -type internal{TplTableNameCamelCase}Dao = *internal.{TplTableNameCamelCase}Dao - -// {TplTableNameCamelLowerCase}Dao is the data access object for the table {TplTableName}. +// {{.TplTableNameCamelLowerCase}}Dao is the data access object for the table {{.TplTableName}}. // You can define custom methods on it to extend its functionality as needed. -type {TplTableNameCamelLowerCase}Dao struct { - internal{TplTableNameCamelCase}Dao +type {{.TplTableNameCamelLowerCase}}Dao struct { + *internal.{{.TplTableNameCamelCase}}Dao } var ( - // {TplTableNameCamelCase} is a globally accessible object for table {TplTableName} operations. - {TplTableNameCamelCase} = {TplTableNameCamelLowerCase}Dao{ - internal.New{TplTableNameCamelCase}Dao(), + // {{.TplTableNameCamelCase}} is a globally accessible object for table {{.TplTableName}} operations. + {{.TplTableNameCamelCase}} = {{.TplTableNameCamelLowerCase}}Dao{ +{{- if .TplTableSharding -}} + internal.New{{.TplTableNameCamelCase}}Dao(userShardingHandler), +{{- else -}} + internal.New{{.TplTableNameCamelCase}}Dao(), +{{- end -}} } ) +{{if .TplTableSharding -}} +// userShardingHandler is the handler for sharding operations. +// You can fill this sharding handler with your custom implementation. +func userShardingHandler(m *gdb.Model) *gdb.Model { + m = m.Sharding(gdb.ShardingConfig{ + Table: gdb.ShardingTableConfig{ + Enable: true, + Prefix: "", + // Replace Rule field with your custom sharding rule. + // Or you can use "&gdb.DefaultShardingRule{}" for default sharding rule. + Rule: nil, + }, + Schema: gdb.ShardingSchemaConfig{}, + }) + return m +} +{{- end}} + // Add your custom methods and functionality below. ` const TemplateGenDaoInternalContent = ` // ========================================================================== -// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. {TplCreatedAtDatetimeStr} +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. {{.TplCreatedAtDatetimeStr}} // ========================================================================== package internal @@ -51,55 +70,61 @@ import ( "github.com/gogf/gf/v2/frame/g" ) -// {TplTableNameCamelCase}Dao is the data access object for the table {TplTableName}. -type {TplTableNameCamelCase}Dao struct { +// {{.TplTableNameCamelCase}}Dao is the data access object for the table {{.TplTableName}}. +type {{.TplTableNameCamelCase}}Dao struct { table string // table is the underlying table name of the DAO. group string // group is the database configuration group name of the current DAO. - columns {TplTableNameCamelCase}Columns // columns contains all the column names of Table for convenient usage. + columns {{.TplTableNameCamelCase}}Columns // columns contains all the column names of Table for convenient usage. + handlers []gdb.ModelHandler // handlers for customized model modification. } -// {TplTableNameCamelCase}Columns defines and stores column names for the table {TplTableName}. -type {TplTableNameCamelCase}Columns struct { - {TplColumnDefine} +// {{.TplTableNameCamelCase}}Columns defines and stores column names for the table {{.TplTableName}}. +type {{.TplTableNameCamelCase}}Columns struct { + {{.TplColumnDefine}} } -// {TplTableNameCamelLowerCase}Columns holds the columns for the table {TplTableName}. -var {TplTableNameCamelLowerCase}Columns = {TplTableNameCamelCase}Columns{ - {TplColumnNames} +// {{.TplTableNameCamelLowerCase}}Columns holds the columns for the table {{.TplTableName}}. +var {{.TplTableNameCamelLowerCase}}Columns = {{.TplTableNameCamelCase}}Columns{ + {{.TplColumnNames}} } -// New{TplTableNameCamelCase}Dao creates and returns a new DAO object for table data access. -func New{TplTableNameCamelCase}Dao() *{TplTableNameCamelCase}Dao { - return &{TplTableNameCamelCase}Dao{ - group: "{TplGroupName}", - table: "{TplTableName}", - columns: {TplTableNameCamelLowerCase}Columns, +// New{{.TplTableNameCamelCase}}Dao creates and returns a new DAO object for table data access. +func New{{.TplTableNameCamelCase}}Dao(handlers ...gdb.ModelHandler) *{{.TplTableNameCamelCase}}Dao { + return &{{.TplTableNameCamelCase}}Dao{ + group: "{{.TplGroupName}}", + table: "{{.TplTableName}}", + columns: {{.TplTableNameCamelLowerCase}}Columns, + handlers: handlers, } } // DB retrieves and returns the underlying raw database management object of the current DAO. -func (dao *{TplTableNameCamelCase}Dao) DB() gdb.DB { +func (dao *{{.TplTableNameCamelCase}}Dao) DB() gdb.DB { return g.DB(dao.group) } // Table returns the table name of the current DAO. -func (dao *{TplTableNameCamelCase}Dao) Table() string { +func (dao *{{.TplTableNameCamelCase}}Dao) Table() string { return dao.table } // Columns returns all column names of the current DAO. -func (dao *{TplTableNameCamelCase}Dao) Columns() {TplTableNameCamelCase}Columns { +func (dao *{{.TplTableNameCamelCase}}Dao) Columns() {{.TplTableNameCamelCase}}Columns { return dao.columns } // Group returns the database configuration group name of the current DAO. -func (dao *{TplTableNameCamelCase}Dao) Group() string { +func (dao *{{.TplTableNameCamelCase}}Dao) Group() string { return dao.group } // Ctx creates and returns a Model for the current DAO. It automatically sets the context for the current operation. -func (dao *{TplTableNameCamelCase}Dao) Ctx(ctx context.Context) *gdb.Model { - return dao.DB().Model(dao.table).Safe().Ctx(ctx) +func (dao *{{.TplTableNameCamelCase}}Dao) Ctx(ctx context.Context) *gdb.Model { + model := dao.DB().Model(dao.table) + for _, handler := range dao.handlers { + model = handler(model) + } + return model.Safe().Ctx(ctx) } // Transaction wraps the transaction logic using function f. @@ -108,7 +133,7 @@ func (dao *{TplTableNameCamelCase}Dao) Ctx(ctx context.Context) *gdb.Model { // // Note: Do not commit or roll back the transaction in function f, // as it is automatically handled by this function. -func (dao *{TplTableNameCamelCase}Dao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { +func (dao *{{.TplTableNameCamelCase}}Dao) Transaction(ctx context.Context, f func(ctx context.Context, tx gdb.TX) error) (err error) { return dao.Ctx(ctx).Transaction(ctx, f) } ` diff --git a/cmd/gf/internal/consts/consts_gen_dao_template_do.go b/cmd/gf/internal/consts/consts_gen_dao_template_do.go index 320aaa9e2a3..97a404e267c 100644 --- a/cmd/gf/internal/consts/consts_gen_dao_template_do.go +++ b/cmd/gf/internal/consts/consts_gen_dao_template_do.go @@ -8,13 +8,13 @@ package consts const TemplateGenDaoDoContent = ` // ================================================================================= -// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. {TplCreatedAtDatetimeStr} +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. {{.TplCreatedAtDatetimeStr}} // ================================================================================= -package {TplPackageName} +package {{.TplPackageName}} -{TplPackageImports} +{{.TplPackageImports}} -// {TplTableNameCamelCase} is the golang structure of table {TplTableName} for DAO operations like Where/Data. -{TplStructDefine} +// {{.TplTableNameCamelCase}} is the golang structure of table {{.TplTableName}} for DAO operations like Where/Data. +{{.TplStructDefine}} ` diff --git a/cmd/gf/internal/consts/consts_gen_dao_template_entity.go b/cmd/gf/internal/consts/consts_gen_dao_template_entity.go index 67a868ec700..c54713ae148 100644 --- a/cmd/gf/internal/consts/consts_gen_dao_template_entity.go +++ b/cmd/gf/internal/consts/consts_gen_dao_template_entity.go @@ -8,13 +8,13 @@ package consts const TemplateGenDaoEntityContent = ` // ================================================================================= -// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. {TplCreatedAtDatetimeStr} +// Code generated and maintained by GoFrame CLI tool. DO NOT EDIT. {{.TplCreatedAtDatetimeStr}} // ================================================================================= -package {TplPackageName} +package {{.TplPackageName}} -{TplPackageImports} +{{.TplPackageImports}} -// {TplTableNameCamelCase} is the golang structure for table {TplTableName}. -{TplStructDefine} +// {{.TplTableNameCamelCase}} is the golang structure for table {{.TplTableName}}. +{{.TplStructDefine}} ` diff --git a/os/gview/gview.go b/os/gview/gview.go index 3b60e8a1174..acd395b4828 100644 --- a/os/gview/gview.go +++ b/os/gview/gview.go @@ -13,7 +13,6 @@ package gview import ( "context" - "github.com/gogf/gf/v2" "github.com/gogf/gf/v2/container/garray" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/internal/intlog" @@ -24,16 +23,16 @@ import ( // View object for template engine. type View struct { - searchPaths *garray.StrArray // Searching array for path, NOT concurrent-safe for performance purpose. - data map[string]interface{} // Global template variables. - funcMap map[string]interface{} // Global template function map. - fileCacheMap *gmap.StrAnyMap // File cache map. - config Config // Extra configuration for the view. + searchPaths *garray.StrArray // Searching array for path, NOT concurrent-safe for performance purpose. + data map[string]any // Global template variables. + funcMap map[string]any // Global template function map. + fileCacheMap *gmap.StrAnyMap // File cache map. + config Config // Extra configuration for the view. } type ( - Params = map[string]interface{} // Params is type for template params. - FuncMap = map[string]interface{} // FuncMap is type for custom template functions. + Params = map[string]any // Params is type for template params. + FuncMap = map[string]any // FuncMap is type for custom template functions. ) const ( @@ -68,8 +67,8 @@ func New(path ...string) *View { ) view := &View{ searchPaths: garray.NewStrArray(), - data: make(map[string]interface{}), - funcMap: make(map[string]interface{}), + data: make(map[string]any), + funcMap: make(map[string]any), fileCacheMap: gmap.NewStrAnyMap(true), config: DefaultConfig(), } @@ -110,11 +109,8 @@ func New(path ...string) *View { } } } + // set default delimiters. view.SetDelimiters("{{", "}}") - // default build-in variables. - view.data["GF"] = map[string]interface{}{ - "version": gf.VERSION, - } // default build-in functions. view.BindFuncMap(FuncMap{ "eq": view.buildInFuncEq, diff --git a/os/gview/gview_config.go b/os/gview/gview_config.go index 9323f798b39..58d6108a206 100644 --- a/os/gview/gview_config.go +++ b/os/gview/gview_config.go @@ -223,6 +223,11 @@ func (view *View) Assign(key string, value interface{}) { view.data[key] = value } +// ClearAssigns trunk all global template variables assignments. +func (view *View) ClearAssigns() { + view.data = make(map[string]interface{}) +} + // SetDefaultFile sets default template file for parsing. func (view *View) SetDefaultFile(file string) { view.config.DefaultFile = file diff --git a/os/gview/gview_parse.go b/os/gview/gview_parse.go index 0b20e7772d9..364a065add4 100644 --- a/os/gview/gview_parse.go +++ b/os/gview/gview_parse.go @@ -15,6 +15,7 @@ import ( "strings" texttpl "text/template" + "github.com/gogf/gf/v2" "github.com/gogf/gf/v2/container/gmap" "github.com/gogf/gf/v2/encoding/ghash" "github.com/gogf/gf/v2/errors/gcode" @@ -101,7 +102,11 @@ func (view *View) ParseContent(ctx context.Context, content string, params ...Pa } // Option for template parsing. -type Option struct { +// Deprecated: use Options instead. +type Option = Options + +// Options for template parsing. +type Options struct { File string // Template file path in absolute or relative to searching paths. Content string // Template content, it ignores `File` if `Content` is given. Orphan bool // If true, the `File` is considered as a single file parsing without files recursively parsing from its folder. @@ -109,15 +114,21 @@ type Option struct { } // ParseOption implements template parsing using Option. +// Deprecated: use ParseWithOptions instead. func (view *View) ParseOption(ctx context.Context, option Option) (result string, err error) { - if option.Content != "" { - return view.doParseContent(ctx, option.Content, option.Params) + return view.ParseWithOptions(ctx, option) +} + +// ParseWithOptions implements template parsing using Option. +func (view *View) ParseWithOptions(ctx context.Context, opts Options) (result string, err error) { + if opts.Content != "" { + return view.doParseContent(ctx, opts.Content, opts.Params) } - if option.File == "" { + if opts.File == "" { return "", gerror.New(`template file cannot be empty`) } // It caches the file, folder, and content to enhance performance. - r := view.fileCacheMap.GetOrSetFuncLock(option.File, func() interface{} { + r := view.fileCacheMap.GetOrSetFuncLock(opts.File, func() any { var ( path string folder string @@ -125,7 +136,7 @@ func (view *View) ParseOption(ctx context.Context, option Option) (result string resource *gres.File ) // Searching the absolute file path for `file`. - path, folder, resource, err = view.searchFile(ctx, option.File) + path, folder, resource, err = view.searchFile(ctx, opts.File) if err != nil { return nil } @@ -136,12 +147,14 @@ func (view *View) ParseOption(ctx context.Context, option Option) (result string } // Monitor template files changes using fsnotify asynchronously. if resource == nil { - if _, err = gfsnotify.AddOnce("gview.Parse:"+folder, folder, func(event *gfsnotify.Event) { - // CLEAR THEM ALL. - view.fileCacheMap.Clear() - templates.Clear() - gfsnotify.Exit() - }); err != nil { + if _, err = gfsnotify.AddOnce( + "gview.Parse:"+folder, folder, func(event *gfsnotify.Event) { + // CLEAR THEM ALL. + view.fileCacheMap.Clear() + templates.Clear() + gfsnotify.Exit() + }, + ); err != nil { intlog.Errorf(ctx, `%+v`, err) } } @@ -160,11 +173,11 @@ func (view *View) ParseOption(ctx context.Context, option Option) (result string return "", nil } // If it's an Orphan option, it just parses the single file by ParseContent. - if option.Orphan { - return view.doParseContent(ctx, item.content, option.Params) + if opts.Orphan { + return view.doParseContent(ctx, item.content, opts.Params) } // Get the template object instance for `folder`. - var tpl interface{} + var tpl any tpl, err = view.getTemplate(item.path, item.folder, fmt.Sprintf(`*%s`, gfile.Ext(item.path))) if err != nil { return "", err @@ -183,34 +196,8 @@ func (view *View) ParseOption(ctx context.Context, option Option) (result string if err != nil { return "", err } - // Note that the template variable assignment cannot change the value - // of the existing `params` or view.data because both variables are pointers. - // It needs to merge the values of the two maps into a new map. - variables := gutil.MapMergeCopy(option.Params) - if len(view.data) > 0 { - gutil.MapMerge(variables, view.data) - } - view.setI18nLanguageFromCtx(ctx, variables) - buffer := bytes.NewBuffer(nil) - if view.config.AutoEncode { - newTpl, err := tpl.(*htmltpl.Template).Clone() - if err != nil { - return "", err - } - if err = newTpl.Execute(buffer, variables); err != nil { - return "", err - } - } else { - if err = tpl.(*texttpl.Template).Execute(buffer, variables); err != nil { - return "", err - } - } - - // TODO any graceful plan to replace ""? - result = gstr.Replace(buffer.String(), "", "") - result = view.i18nTranslate(ctx, result, variables) - return result, nil + return view.doParseContentWithStdTemplate(ctx, tpl, opts.Params) } // doParseContent parses given template content `content` with template variables `params` @@ -223,7 +210,7 @@ func (view *View) doParseContent(ctx context.Context, content string, params Par var ( err error key = fmt.Sprintf("%s_%v_%v", templateNameForContentParsing, view.config.Delimiters, view.config.AutoEncode) - tpl = templates.GetOrSetFuncLock(key, func() interface{} { + tpl = templates.GetOrSetFuncLock(key, func() any { if view.config.AutoEncode { return htmltpl.New(templateNameForContentParsing).Delims( view.config.Delimiters[0], @@ -249,10 +236,14 @@ func (view *View) doParseContent(ctx context.Context, content string, params Par err = gerror.Wrapf(err, `template parsing failed`) return "", err } + return view.doParseContentWithStdTemplate(ctx, tpl, params) +} + +func (view *View) doParseContentWithStdTemplate(ctx context.Context, tpl any, params Params) (string, error) { // Note that the template variable assignment cannot change the value // of the existing `params` or view.data because both variables are pointers. // It needs to merge the values of the two maps into a new map. - variables := gutil.MapMergeCopy(params) + variables := gutil.MapMergeCopy(params, view.getBuiltInParams()) if len(view.data) > 0 { gutil.MapMerge(variables, view.data) } @@ -261,7 +252,7 @@ func (view *View) doParseContent(ctx context.Context, content string, params Par buffer := bytes.NewBuffer(nil) if view.config.AutoEncode { var newTpl *htmltpl.Template - newTpl, err = tpl.(*htmltpl.Template).Clone() + newTpl, err := tpl.(*htmltpl.Template).Clone() if err != nil { err = gerror.Wrapf(err, `template clone failed`) return "", err @@ -271,7 +262,7 @@ func (view *View) doParseContent(ctx context.Context, content string, params Par return "", err } } else { - if err = tpl.(*texttpl.Template).Execute(buffer, variables); err != nil { + if err := tpl.(*texttpl.Template).Execute(buffer, variables); err != nil { err = gerror.Wrapf(err, `template parsing failed`) return "", err } @@ -282,14 +273,20 @@ func (view *View) doParseContent(ctx context.Context, content string, params Par return result, nil } +func (view *View) getBuiltInParams() map[string]any { + return map[string]any{ + "version": gf.VERSION, + } +} + // getTemplate returns the template object associated with given template file `path`. // It uses template cache to enhance performance, that is, it will return the same template object // with the same given `path`. It will also automatically refresh the template cache // if the template files under `path` changes (recursively). -func (view *View) getTemplate(filePath, folderPath, pattern string) (tpl interface{}, err error) { +func (view *View) getTemplate(filePath, folderPath, pattern string) (tpl any, err error) { var ( mapKey = fmt.Sprintf("%s_%v", filePath, view.config.Delimiters) - mapFunc = func() interface{} { + mapFunc = func() any { tplName := filePath if view.config.AutoEncode { tpl = htmltpl.New(tplName).Delims( diff --git a/util/gutil/gutil_map.go b/util/gutil/gutil_map.go index 92e470434c5..854471b1c63 100644 --- a/util/gutil/gutil_map.go +++ b/util/gutil/gutil_map.go @@ -42,21 +42,21 @@ func MapDelete(data map[string]interface{}, keys ...string) { } // MapMerge merges all map from `src` to map `dst`. -func MapMerge(dst map[string]interface{}, src ...map[string]interface{}) { - if dst == nil { +func MapMerge(dstMap map[string]interface{}, srcMaps ...map[string]interface{}) { + if dstMap == nil { return } - for _, m := range src { + for _, m := range srcMaps { for k, v := range m { - dst[k] = v + dstMap[k] = v } } } // MapMergeCopy creates and returns a new map which merges all map from `src`. -func MapMergeCopy(src ...map[string]interface{}) (copy map[string]interface{}) { +func MapMergeCopy(maps ...map[string]interface{}) (copy map[string]interface{}) { copy = make(map[string]interface{}) - for _, m := range src { + for _, m := range maps { for k, v := range m { copy[k] = v } From 3f24b4da2e8f4a5acd8be199ea2122d7ec828ed4 Mon Sep 17 00:00:00 2001 From: Wlynxg Date: Mon, 13 Jan 2025 09:26:59 +0800 Subject: [PATCH 074/102] feat(os/gcmd): add default value display for an argument (#4083) --- os/gcmd/gcmd_command.go | 11 ++++++----- os/gcmd/gcmd_command_help.go | 3 +++ os/gcmd/gcmd_command_object.go | 3 +++ 3 files changed, 12 insertions(+), 5 deletions(-) diff --git a/os/gcmd/gcmd_command.go b/os/gcmd/gcmd_command.go index ce05820602d..80c824da3a8 100644 --- a/os/gcmd/gcmd_command.go +++ b/os/gcmd/gcmd_command.go @@ -46,11 +46,12 @@ type FuncWithValue func(ctx context.Context, parser *Parser) (out interface{}, e // Argument is the command value that are used by certain command. type Argument struct { - Name string // Option name. - Short string // Option short. - Brief string // Brief info about this Option, which is used in help info. - IsArg bool // IsArg marks this argument taking value from command line argument instead of option. - Orphan bool // Whether this Option having or having no value bound to it. + Name string // Option name. + Short string // Option short. + Default string // Option default value. + Brief string // Brief info about this Option, which is used in help info. + IsArg bool // IsArg marks this argument taking value from command line argument instead of option. + Orphan bool // Whether this Option having or having no value bound to it. } var ( diff --git a/os/gcmd/gcmd_command_help.go b/os/gcmd/gcmd_command_help.go index ab43641e931..c9aa8598560 100644 --- a/os/gcmd/gcmd_command_help.go +++ b/os/gcmd/gcmd_command_help.go @@ -156,6 +156,9 @@ func (c *Command) PrintTo(writer io.Writer) { spaceLength = maxSpaceLength - len(nameStr) wordwrapPrefix = gstr.Repeat(" ", len(prefix+nameStr)+spaceLength+4) ) + if arg.Default != "" { + brief = fmt.Sprintf("%s (default: \"%s\")", brief, arg.Default) + } c.printLineBrief(printLineBriefInput{ Buffer: buffer, Name: nameStr, diff --git a/os/gcmd/gcmd_command_object.go b/os/gcmd/gcmd_command_object.go index c7e49b54714..f98820591fe 100644 --- a/os/gcmd/gcmd_command_object.go +++ b/os/gcmd/gcmd_command_object.go @@ -378,6 +378,9 @@ func newArgumentsFromInput(object interface{}) (args []Argument, err error) { if arg.Brief == "" { arg.Brief = field.TagDescription() } + if arg.Default == "" { + arg.Default = field.TagDefault() + } if v, ok := metaData[gtag.Arg]; ok { arg.IsArg = gconv.Bool(v) } From e0f734851ef548359b77218ac4a2e05f9a981ef4 Mon Sep 17 00:00:00 2001 From: Wlynxg Date: Tue, 14 Jan 2025 09:28:19 +0800 Subject: [PATCH 075/102] fix(net/ghttp): `MiddlewareHandlerResponse` writes additional information after custom response wrote (#4109) --- .../ghttp_middleware_handler_response.go | 2 +- net/ghttp/ghttp_z_unit_issue_test.go | 26 +++++++++++++++++++ 2 files changed, 27 insertions(+), 1 deletion(-) diff --git a/net/ghttp/ghttp_middleware_handler_response.go b/net/ghttp/ghttp_middleware_handler_response.go index cebff3889d3..7eb50b2d127 100644 --- a/net/ghttp/ghttp_middleware_handler_response.go +++ b/net/ghttp/ghttp_middleware_handler_response.go @@ -37,7 +37,7 @@ func MiddlewareHandlerResponse(r *Request) { r.Middleware.Next() // There's custom buffer content, it then exits current handler. - if r.Response.BufferLength() > 0 { + if r.Response.BufferLength() > 0 || r.Response.Writer.BytesWritten() > 0 { return } diff --git a/net/ghttp/ghttp_z_unit_issue_test.go b/net/ghttp/ghttp_z_unit_issue_test.go index 080597d0d52..e14a38eed46 100644 --- a/net/ghttp/ghttp_z_unit_issue_test.go +++ b/net/ghttp/ghttp_z_unit_issue_test.go @@ -9,6 +9,7 @@ package ghttp_test import ( "context" "fmt" + "net/http" "testing" "time" @@ -630,3 +631,28 @@ func Test_Issue4047(t *testing.T) { t.Assert(s.Logger(), nil) }) } + +// https://github.com/gogf/gf/issues/4108 +func Test_Issue4108(t *testing.T) { + s := g.Server(guid.S()) + s.Group("/", func(group *ghttp.RouterGroup) { + group.Middleware(ghttp.MiddlewareHandlerResponse) + group.GET("/", func(r *ghttp.Request) { + r.Response.Writer.Write([]byte("hello")) + }) + }) + s.SetDumpRouterMap(false) + s.Start() + defer s.Shutdown() + time.Sleep(100 * time.Millisecond) + + gtest.C(t, func(t *gtest.T) { + client := g.Client() + client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) + + rsp, err := client.Get(ctx, "/") + t.AssertNil(err) + t.Assert(rsp.StatusCode, http.StatusOK) + t.Assert(rsp.ReadAllString(), "hello") + }) +} From 99f0fb14a102a00736798607fdf355e21ea30711 Mon Sep 17 00:00:00 2001 From: Wlynxg Date: Wed, 22 Jan 2025 09:28:06 +0800 Subject: [PATCH 076/102] fix(net/ghttp): BufferWriter.Flush writes additional information after custom response wrote (#4116) --- net/ghttp/ghttp_z_unit_issue_test.go | 22 +++++++++++++++++++ .../response/response_buffer_writer.go | 2 +- 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/net/ghttp/ghttp_z_unit_issue_test.go b/net/ghttp/ghttp_z_unit_issue_test.go index e14a38eed46..f8b2069e2ec 100644 --- a/net/ghttp/ghttp_z_unit_issue_test.go +++ b/net/ghttp/ghttp_z_unit_issue_test.go @@ -656,3 +656,25 @@ func Test_Issue4108(t *testing.T) { t.Assert(rsp.ReadAllString(), "hello") }) } + +// https://github.com/gogf/gf/issues/4115 +func Test_Issue4115(t *testing.T) { + s := g.Server(guid.S()) + s.Use(func(r *ghttp.Request) { + r.Response.Writer.Write([]byte("hello")) + }) + s.SetDumpRouterMap(false) + s.Start() + defer s.Shutdown() + time.Sleep(100 * time.Millisecond) + + gtest.C(t, func(t *gtest.T) { + client := g.Client() + client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) + + rsp, err := client.Get(ctx, "/") + t.AssertNil(err) + t.Assert(rsp.StatusCode, http.StatusOK) + t.Assert(rsp.ReadAllString(), "hello") + }) +} diff --git a/net/ghttp/internal/response/response_buffer_writer.go b/net/ghttp/internal/response/response_buffer_writer.go index f1f65c88e19..8b334d79049 100644 --- a/net/ghttp/internal/response/response_buffer_writer.go +++ b/net/ghttp/internal/response/response_buffer_writer.go @@ -82,7 +82,7 @@ func (w *BufferWriter) Flush() { w.Writer.WriteHeader(w.Status) } // Default status text output. - if w.Status != http.StatusOK && w.buffer.Len() == 0 { + if w.Status != http.StatusOK && w.buffer.Len() == 0 && w.Writer.BytesWritten() == 0 { w.buffer.WriteString(http.StatusText(w.Status)) } if w.buffer.Len() > 0 { From 1f8845291adea65d4468a4c81d5c7ac1e0bbf033 Mon Sep 17 00:00:00 2001 From: star liu Date: Wed, 22 Jan 2025 19:20:21 +0800 Subject: [PATCH 077/102] fix(contrib/config/polaris): it only supports json format for configuration contents, add more content formats support (#4126) --- contrib/config/polaris/polaris.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/config/polaris/polaris.go b/contrib/config/polaris/polaris.go index 04765d6591a..1f9d6ee0576 100644 --- a/contrib/config/polaris/polaris.go +++ b/contrib/config/polaris/polaris.go @@ -147,7 +147,7 @@ func (c *Client) doUpdate(ctx context.Context) (err error) { return gerror.New("config file is empty") } var j *gjson.Json - if j, err = gjson.DecodeToJson([]byte(c.client.GetContent())); err != nil { + if j, err = gjson.LoadContent([]byte(c.client.GetContent())); err != nil { return gerror.Wrap(err, `parse config map item from polaris failed`) } c.value.Set(j) From f9c7eae23bd06eb038effc0f6a9c55853f79f9c1 Mon Sep 17 00:00:00 2001 From: heansheng <77931774@qq.com> Date: Wed, 22 Jan 2025 19:22:02 +0800 Subject: [PATCH 078/102] fix(net/ghttp): remove unused code snippet (#4131) --- net/ghttp/ghttp_request_param_request.go | 4 ++-- net/ghttp/ghttp_server_service_handler.go | 17 ----------------- 2 files changed, 2 insertions(+), 19 deletions(-) diff --git a/net/ghttp/ghttp_request_param_request.go b/net/ghttp/ghttp_request_param_request.go index a2874d9de92..601e3f06a92 100644 --- a/net/ghttp/ghttp_request_param_request.go +++ b/net/ghttp/ghttp_request_param_request.go @@ -183,7 +183,7 @@ func (r *Request) doGetRequestStruct(pointer interface{}, mapping ...map[string] return data, nil } // `in` Tag Struct values. - if err = r.mergeInTagStructValue(data, pointer); err != nil { + if err = r.mergeInTagStructValue(data); err != nil { return data, nil } @@ -239,7 +239,7 @@ func (r *Request) mergeDefaultStructValue(data map[string]interface{}, pointer i } // mergeInTagStructValue merges the request parameters with header or cookie values from struct `in` tag definition. -func (r *Request) mergeInTagStructValue(data map[string]interface{}, pointer interface{}) error { +func (r *Request) mergeInTagStructValue(data map[string]interface{}) error { fields := r.serveHandler.Handler.Info.ReqStructFields if len(fields) > 0 { var ( diff --git a/net/ghttp/ghttp_server_service_handler.go b/net/ghttp/ghttp_server_service_handler.go index 76de26aaae8..7e248c75c5e 100644 --- a/net/ghttp/ghttp_server_service_handler.go +++ b/net/ghttp/ghttp_server_service_handler.go @@ -282,20 +282,3 @@ func createRouterFunc(funcInfo handlerFuncInfo) func(r *Request) { } } } - -// trimGeneric removes type definitions string from response type name if generic -func trimGeneric(structName string) string { - var ( - leftBraceIndex = strings.LastIndex(structName, "[") // for generic, it is faster to start at the end than at the beginning - rightBraceIndex = strings.LastIndex(structName, "]") - ) - if leftBraceIndex == -1 || rightBraceIndex == -1 { - // not found '[' or ']' - return structName - } else if leftBraceIndex+1 == rightBraceIndex { - // may be a slice, because generic is '[X]', not '[]' - // to be compatible with bad return parameter type: []XxxRes - return structName - } - return structName[:leftBraceIndex] -} From e12768207e173c9734a6a58ce05c05d0a860ac4b Mon Sep 17 00:00:00 2001 From: wanna Date: Wed, 22 Jan 2025 19:22:36 +0800 Subject: [PATCH 079/102] feat(cmd/gf): beautify progress bar of cli binary downloading for command `gf up` (#4094) --- cmd/gf/go.mod | 3 + cmd/gf/go.sum | 10 +++ .../utility/utils/utils_http_download.go | 62 ++----------------- 3 files changed, 18 insertions(+), 57 deletions(-) diff --git a/cmd/gf/go.mod b/cmd/gf/go.mod index e2d19e73074..ae17a9e1090 100644 --- a/cmd/gf/go.mod +++ b/cmd/gf/go.mod @@ -12,6 +12,7 @@ require ( github.com/gogf/gf/v2 v2.8.3 github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f github.com/olekukonko/tablewriter v0.0.5 + github.com/schollz/progressbar/v3 v3.15.0 golang.org/x/mod v0.17.0 golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d ) @@ -40,6 +41,7 @@ require ( github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect github.com/microsoft/go-mssqldb v1.7.1 // indirect + github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db // indirect github.com/paulmach/orb v0.7.1 // indirect github.com/pierrec/lz4/v4 v4.1.14 // indirect github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec // indirect @@ -54,6 +56,7 @@ require ( golang.org/x/net v0.33.0 // indirect golang.org/x/sync v0.10.0 // indirect golang.org/x/sys v0.28.0 // indirect + golang.org/x/term v0.27.0 // indirect golang.org/x/text v0.21.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect modernc.org/libc v1.22.5 // indirect diff --git a/cmd/gf/go.sum b/cmd/gf/go.sum index ad3b4a1875d..e29244f933b 100644 --- a/cmd/gf/go.sum +++ b/cmd/gf/go.sum @@ -18,6 +18,7 @@ github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn github.com/cloudflare/golz4 v0.0.0-20150217214814-ef862a3cdc58/go.mod h1:EOBUe0h4xcZ5GoxqC5SDxFQ8gwyZPKQoEzownBlhI80= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= +github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/dustin/go-humanize v1.0.1 h1:GzkhY7T5VNhEkwH0PVJgjz+fX1rhBrR7pRT3mDkpeCY= github.com/dustin/go-humanize v1.0.1/go.mod h1:Mu1zIs6XwVuF/gI1OepvI0qD18qycQx+mFykh5fBlto= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= @@ -76,6 +77,7 @@ github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhBSsks= +github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= @@ -95,6 +97,8 @@ github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh github.com/mattn/go-sqlite3 v1.9.0/go.mod h1:FPy6KqzDD04eiIsT53CuJW3U88zkxoIYsOqkbpncsNc= github.com/microsoft/go-mssqldb v1.7.1 h1:KU/g8aWeM3Hx7IMOFpiwYiUkU+9zeISb4+tx3ScVfsM= github.com/microsoft/go-mssqldb v1.7.1/go.mod h1:kOvZKUdrhhFQmxLZqbwUV0rHkNkZpthMITIb2Ko1IoA= +github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db h1:62I3jR2EmQ4l5rM/4FEfDWcRD+abF5XlKShorW5LRoQ= +github.com/mitchellh/colorstring v0.0.0-20190213212951-d06e56a500db/go.mod h1:l0dey0ia/Uv7NcFFVbCLtqEBQbrT4OCwCSKTEv6enCw= github.com/mkevac/debugcharts v0.0.0-20191222103121-ae1c48aa8615/go.mod h1:Ad7oeElCZqA1Ufj0U9/liOF4BtVepxRcTvr2ey7zTvM= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= @@ -113,6 +117,8 @@ github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qq github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/schollz/progressbar/v3 v3.15.0 h1:cNZmcNiVyea6oofBTg80ZhVXxf3wG/JoAhqCCwopkQo= +github.com/schollz/progressbar/v3 v3.15.0/go.mod h1:ncBdc++eweU0dQoeZJ3loXoAc+bjaallHRIm8pVVeQM= github.com/shirou/gopsutil v2.19.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/gopsutil v3.21.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= github.com/shirou/w32 v0.0.0-20160930032740-bb4de0191aa4/go.mod h1:qsXQc7+bwAM3Q1u/4XEfrquwF8Lw7D7y5cD8CuHnfIc= @@ -173,9 +179,13 @@ golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBc golang.org/x/sys v0.0.0-20220429233432-b5fbb4746d32/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= +golang.org/x/sys v0.25.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= golang.org/x/sys v0.28.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= golang.org/x/term v0.0.0-20201117132131-f5c789dd3221/go.mod h1:Nr5EML6q2oocZ2LXRh80K7BxOlk5/8JxuGnuhpl+muw= +golang.org/x/term v0.24.0/go.mod h1:lOBK/LVxemqiMij05LGJ0tzNr8xlmwBRJ81PX6wVLH8= +golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= +golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= diff --git a/cmd/gf/internal/utility/utils/utils_http_download.go b/cmd/gf/internal/utility/utils/utils_http_download.go index a0654d0c641..0b8bb6eb539 100644 --- a/cmd/gf/internal/utility/utils/utils_http_download.go +++ b/cmd/gf/internal/utility/utils/utils_http_download.go @@ -7,13 +7,13 @@ package utils import ( - "fmt" "io" "net/http" "os" - "strconv" "time" + "github.com/schollz/progressbar/v3" + "github.com/gogf/gf/v2/errors/gerror" "github.com/gogf/gf/cmd/gf/v2/internal/utility/mlog" @@ -34,26 +34,16 @@ func HTTPDownloadFileWithPercent(url string, localSaveFilePath string) error { } defer headResp.Body.Close() - size, err := strconv.Atoi(headResp.Header.Get("Content-Length")) - if err != nil { - return gerror.Wrap(err, "retrieve Content-Length failed") - } - doneCh := make(chan int64) - - go doPrintDownloadPercent(doneCh, localSaveFilePath, int64(size)) - resp, err := http.Get(url) if err != nil { return gerror.Wrapf(err, `download "%s" to "%s" failed`, url, localSaveFilePath) } defer resp.Body.Close() - wroteBytesCount, err := io.Copy(out, resp.Body) - if err != nil { - return gerror.Wrapf(err, `download "%s" to "%s" failed`, url, localSaveFilePath) - } + bar := progressbar.NewOptions(int(resp.ContentLength), progressbar.OptionShowBytes(true), progressbar.OptionShowCount()) + writer := io.MultiWriter(out, bar) + _, err = io.Copy(writer, resp.Body) - doneCh <- wroteBytesCount elapsed := time.Since(start) if elapsed > time.Minute { mlog.Printf(`download completed in %.0fm`, float64(elapsed)/float64(time.Minute)) @@ -63,45 +53,3 @@ func HTTPDownloadFileWithPercent(url string, localSaveFilePath string) error { return nil } - -func doPrintDownloadPercent(doneCh chan int64, localSaveFilePath string, total int64) { - var ( - stop = false - lastPercentFmt string - ) - file, err := os.Open(localSaveFilePath) - if err != nil { - mlog.Fatal(err) - } - defer file.Close() - - for { - select { - case <-doneCh: - stop = true - - default: - fi, err := file.Stat() - if err != nil { - mlog.Fatal(err) - } - size := fi.Size() - if size == 0 { - size = 1 - } - var ( - percent = float64(size) / float64(total) * 100 - percentFmt = fmt.Sprintf(`%.0f`, percent) + "%" - ) - if lastPercentFmt != percentFmt { - lastPercentFmt = percentFmt - mlog.Print(percentFmt) - } - } - - if stop { - break - } - time.Sleep(time.Second) - } -} From 20b19878286703c073e558a06ad05ee5d323672a Mon Sep 17 00:00:00 2001 From: heansheng <77931774@qq.com> Date: Thu, 23 Jan 2025 17:58:32 +0800 Subject: [PATCH 080/102] feat(test/gtest): add map type support for `AssertNI/AssertIN` (#4135) --- test/gtest/gtest_util.go | 18 ++++++++++++++++-- test/gtest/gtest_z_unit_test.go | 16 ++++++++++++++++ 2 files changed, 32 insertions(+), 2 deletions(-) diff --git a/test/gtest/gtest_util.go b/test/gtest/gtest_util.go index c9ccb9f0b49..c1609474d56 100644 --- a/test/gtest/gtest_util.go +++ b/test/gtest/gtest_util.go @@ -220,7 +220,6 @@ func AssertLE(value, expect interface{}) { // AssertIN checks `value` is IN `expect`. // The `expect` should be a slice, // but the `value` can be a slice or a basic type variable. -// TODO map support. // TODO: gconv.Strings(0) is not [0] func AssertIN(value, expect interface{}) { var ( @@ -249,6 +248,14 @@ func AssertIN(value, expect interface{}) { expectStr = gconv.String(expect) ) passed = gstr.Contains(expectStr, valueStr) + case reflect.Map: + expectMap := gconv.Map(expect) + for _, v1 := range gconv.Strings(value) { + if _, exists := expectMap[v1]; !exists { + passed = false + break + } + } default: panic(fmt.Sprintf(`[ASSERT] INVALID EXPECT VALUE TYPE: %v`, expectKind)) } @@ -260,7 +267,6 @@ func AssertIN(value, expect interface{}) { // AssertNI checks `value` is NOT IN `expect`. // The `expect` should be a slice, // but the `value` can be a slice or a basic type variable. -// TODO map support. func AssertNI(value, expect interface{}) { var ( passed = true @@ -287,6 +293,14 @@ func AssertNI(value, expect interface{}) { expectStr = gconv.String(expect) ) passed = !gstr.Contains(expectStr, valueStr) + case reflect.Map: + expectMap := gconv.Map(expect) + for _, v1 := range gconv.Strings(value) { + if _, exists := expectMap[v1]; exists { + passed = false + break + } + } default: panic(fmt.Sprintf(`[ASSERT] INVALID EXPECT VALUE TYPE: %v`, expectKind)) } diff --git a/test/gtest/gtest_z_unit_test.go b/test/gtest/gtest_z_unit_test.go index 2c1197f22e6..7d576fd791a 100644 --- a/test/gtest/gtest_z_unit_test.go +++ b/test/gtest/gtest_z_unit_test.go @@ -322,6 +322,22 @@ func TestAssertIN(t *testing.T) { }) } +func TestAssertIN_Map(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + t.AssertIN("k1", map[string]string{"k1": "v1", "k2": "v2"}) + t.AssertIN(1, map[int64]string{1: "v1", 2: "v2"}) + t.AssertIN([]string{"k1", "k2"}, map[string]string{"k1": "v1", "k2": "v2"}) + }) +} + +func TestAssertNI_Map(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + t.AssertNI("k3", map[string]string{"k1": "v1", "k2": "v2"}) + t.AssertNI(3, map[int64]string{1: "v1", 2: "v2"}) + t.AssertNI([]string{"k3", "k4"}, map[string]string{"k1": "v1", "k2": "v2"}) + }) +} + func TestAssertNI(t *testing.T) { gtest.C(t, func(t *gtest.T) { t.AssertNI("d", []string{"a", "b", "c"}) From 0eb229a8876c5637a33976c0227f018e850bae70 Mon Sep 17 00:00:00 2001 From: John Guo Date: Tue, 11 Feb 2025 15:59:27 +0800 Subject: [PATCH 081/102] feat(os/glog): add default time format `2006-01-02T15:04:05.000Z07:00` (#4134) --- os/glog/glog_logger.go | 1 + os/glog/glog_logger_config.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/os/glog/glog_logger.go b/os/glog/glog_logger.go index cf3d03e2984..942986dae97 100644 --- a/os/glog/glog_logger.go +++ b/os/glog/glog_logger.go @@ -40,6 +40,7 @@ type Logger struct { const ( defaultFileFormat = `{Y-m-d}.log` + defaultTimeFormat = "2006-01-02T15:04:05.000Z07:00" defaultFileFlags = os.O_CREATE | os.O_WRONLY | os.O_APPEND defaultFilePerm = os.FileMode(0666) defaultFileExpire = time.Minute diff --git a/os/glog/glog_logger_config.go b/os/glog/glog_logger_config.go index 916665e2db9..fcd83d162bd 100644 --- a/os/glog/glog_logger_config.go +++ b/os/glog/glog_logger_config.go @@ -59,7 +59,7 @@ func DefaultConfig() Config { c := Config{ File: defaultFileFormat, Flags: F_TIME_STD, - TimeFormat: "", + TimeFormat: defaultTimeFormat, Level: LEVEL_ALL, CtxKeys: []interface{}{}, StStatus: 1, From a3b3c656d97b48a5e9c39655d75934e7277dbebf Mon Sep 17 00:00:00 2001 From: CyJaySong <29367599+cyjaysong@users.noreply.github.com> Date: Tue, 11 Feb 2025 16:09:27 +0800 Subject: [PATCH 082/102] feat(database/gdb): enable transaction propagation when using `tx.GetCtx()` after `Begin` (#4121) --- .../mysql/mysql_z_unit_transaction_test.go | 41 +++++++++++++++++++ database/gdb/gdb_core_transaction.go | 2 + database/gdb/gdb_core_underlying.go | 7 +++- 3 files changed, 48 insertions(+), 2 deletions(-) diff --git a/contrib/drivers/mysql/mysql_z_unit_transaction_test.go b/contrib/drivers/mysql/mysql_z_unit_transaction_test.go index 89ed7eba7a5..e9c3315b447 100644 --- a/contrib/drivers/mysql/mysql_z_unit_transaction_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_transaction_test.go @@ -1708,3 +1708,44 @@ func Test_Transaction_Isolation(t *testing.T) { t.AssertNil(err) }) } + +func Test_Transaction_Spread(t *testing.T) { + table := createTable() + defer dropTable(table) + + db.SetDebug(true) + defer db.SetDebug(false) + + gtest.C(t, func(t *gtest.T) { + var ( + err error + ctx = context.TODO() + ) + tx, err := db.Begin(ctx) + t.AssertNil(err) + err = db.Transaction(tx.GetCtx(), func(ctx context.Context, tx gdb.TX) error { + _, err = db.Model(table).Ctx(ctx).Data(g.Map{ + "id": 1, + "passport": "USER_1", + "password": "PASS_1", + "nickname": "NAME_1", + "create_time": gtime.Now().String(), + }).Insert() + return err + }) + t.AssertNil(err) + + all, err := tx.Model(table).All() + t.AssertNil(err) + + t.Assert(len(all), 1) + t.Assert(all[0]["id"], 1) + + err = tx.Rollback() + t.AssertNil(err) + + all, err = db.Ctx(ctx).Model(table).All() + t.AssertNil(err) + t.Assert(len(all), 0) + }) +} diff --git a/database/gdb/gdb_core_transaction.go b/database/gdb/gdb_core_transaction.go index 897b179b1d2..1faa73a6205 100644 --- a/database/gdb/gdb_core_transaction.go +++ b/database/gdb/gdb_core_transaction.go @@ -257,12 +257,14 @@ func WithTX(ctx context.Context, tx TX) context.Context { } // Inject transaction object and id into context. ctx = context.WithValue(ctx, transactionKeyForContext(group), tx) + ctx = context.WithValue(ctx, transactionIdForLoggerCtx, tx.GetCtx().Value(transactionIdForLoggerCtx)) return ctx } // WithoutTX removed transaction object from context and returns a new context. func WithoutTX(ctx context.Context, group string) context.Context { ctx = context.WithValue(ctx, transactionKeyForContext(group), nil) + ctx = context.WithValue(ctx, transactionIdForLoggerCtx, nil) return ctx } diff --git a/database/gdb/gdb_core_underlying.go b/database/gdb/gdb_core_underlying.go index 25c60a4baf7..6e06ff0a50f 100644 --- a/database/gdb/gdb_core_underlying.go +++ b/database/gdb/gdb_core_underlying.go @@ -180,14 +180,17 @@ func (c *Core) DoCommit(ctx context.Context, in DoCommitInput) (out DoCommitOutp formattedSql, in.TxOptions.Isolation.String(), in.TxOptions.ReadOnly, ) if sqlTx, err = in.Db.BeginTx(ctx, &in.TxOptions); err == nil { - out.Tx = &TXCore{ + tx := &TXCore{ db: c.db, tx: sqlTx, - ctx: context.WithValue(ctx, transactionIdForLoggerCtx, transactionIdGenerator.Add(1)), + ctx: ctx, master: in.Db, transactionId: guid.S(), cancelFunc: cancelFuncForTimeout, } + tx.ctx = context.WithValue(ctx, transactionKeyForContext(tx.db.GetGroup()), tx) + tx.ctx = context.WithValue(tx.ctx, transactionIdForLoggerCtx, transactionIdGenerator.Add(1)) + out.Tx = tx ctx = out.Tx.GetCtx() } out.RawResult = sqlTx From 7d3b055d3e3283a3a6d6b3e2f2baff286884d31f Mon Sep 17 00:00:00 2001 From: CyJaySong <29367599+cyjaysong@users.noreply.github.com> Date: Tue, 11 Feb 2025 18:02:26 +0800 Subject: [PATCH 083/102] fix(net/ghttp): `MakeBodyRepeatableRead` takes not effective when called after `ParseForm` (#4143) --- net/ghttp/ghttp_request_param.go | 20 +++++------ ...http_z_unit_feature_request_struct_test.go | 36 +++++++++++++++++++ 2 files changed, 46 insertions(+), 10 deletions(-) diff --git a/net/ghttp/ghttp_request_param.go b/net/ghttp/ghttp_request_param.go index 20f67d2ef53..b7f7e67e45c 100644 --- a/net/ghttp/ghttp_request_param.go +++ b/net/ghttp/ghttp_request_param.go @@ -268,28 +268,28 @@ func (r *Request) parseForm() { if r.ContentLength == 0 { return } + if contentType := r.Header.Get("Content-Type"); contentType != "" { - var ( - err error - repeatableRead = true - ) - if gstr.Contains(contentType, "multipart/") { + var isMultiPartRequest = gstr.Contains(contentType, "multipart/") + var isFormRequest = gstr.Contains(contentType, "form") + var err error + + if !isMultiPartRequest { // To avoid big memory consuming. // The `multipart/` type form always contains binary data, which is not necessary read twice. - repeatableRead = false + r.MakeBodyRepeatableRead(true) + } + if isMultiPartRequest { // multipart/form-data, multipart/mixed if err = r.ParseMultipartForm(r.Server.config.FormParsingMemory); err != nil { panic(gerror.WrapCode(gcode.CodeInvalidRequest, err, "r.ParseMultipartForm failed")) } - } else if gstr.Contains(contentType, "form") { + } else if isFormRequest { // application/x-www-form-urlencoded if err = r.Request.ParseForm(); err != nil { panic(gerror.WrapCode(gcode.CodeInvalidRequest, err, "r.Request.ParseForm failed")) } } - if repeatableRead { - r.MakeBodyRepeatableRead(true) - } if len(r.PostForm) > 0 { // Parse the form data using united parsing way. params := "" diff --git a/net/ghttp/ghttp_z_unit_feature_request_struct_test.go b/net/ghttp/ghttp_z_unit_feature_request_struct_test.go index af846b75da1..a54e73ae434 100644 --- a/net/ghttp/ghttp_z_unit_feature_request_struct_test.go +++ b/net/ghttp/ghttp_z_unit_feature_request_struct_test.go @@ -115,6 +115,42 @@ func Test_Params_ParseForm(t *testing.T) { }) } +// https://github.com/gogf/gf/pull/4143 +func Test_Params_ParseForm_FixMakeBodyRepeatableRead(t *testing.T) { + type User struct { + Id int + Name string + } + s := g.Server(guid.S()) + s.BindHandler("/parse-form", func(r *ghttp.Request) { + var user *User + if err := r.ParseForm(&user); err != nil { + r.Response.WriteExit(err) + } + hasBody := len(r.GetBody()) > 0 + r.Response.WriteExit(hasBody) + }) + s.SetDumpRouterMap(false) + s.Start() + defer s.Shutdown() + + time.Sleep(100 * time.Millisecond) + gtest.C(t, func(t *gtest.T) { + c := g.Client() + c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) + t.Assert(c.GetContent(ctx, "/parse-form"), `false`) + t.Assert(c.GetContent(ctx, "/parse-form", g.Map{ + "id": 1, + "name": "john", + }), false) + t.Assert(c.PostContent(ctx, "/parse-form"), `false`) + t.Assert(c.PostContent(ctx, "/parse-form", g.Map{ + "id": 1, + "name": "john", + }), true) + }) +} + func Test_Params_ComplexJsonStruct(t *testing.T) { type ItemEnv struct { Type string From 1ef1c442d3e1992afbfee68387d3dc21d172eef1 Mon Sep 17 00:00:00 2001 From: heansheng <77931774@qq.com> Date: Fri, 14 Feb 2025 13:36:17 +0800 Subject: [PATCH 084/102] test(os/gproc): add unit test for os/gproc (#4140) --- os/gproc/gproc_z_unit_test.go | 117 ++++++++++++++++++++++++++++++++++ 1 file changed, 117 insertions(+) diff --git a/os/gproc/gproc_z_unit_test.go b/os/gproc/gproc_z_unit_test.go index b4e21bbfcaf..0c6e31c7aba 100644 --- a/os/gproc/gproc_z_unit_test.go +++ b/os/gproc/gproc_z_unit_test.go @@ -9,11 +9,19 @@ package gproc_test import ( + "os" + "path/filepath" "testing" "github.com/gogf/gf/v2/os/gctx" + "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gproc" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" +) + +const ( + envKeyPPid = "GPROC_PPID" ) func Test_ShellExec(t *testing.T) { @@ -28,3 +36,112 @@ func Test_ShellExec(t *testing.T) { t.AssertNE(err, nil) }) } + +func Test_Pid(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + t.Assert(os.Getpid(), gproc.Pid()) + }) +} + +func Test_IsChild(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + originalPPid := os.Getenv(envKeyPPid) + defer os.Setenv(envKeyPPid, originalPPid) + + os.Setenv(envKeyPPid, "1234") + t.Assert(true, gproc.IsChild()) + + os.Unsetenv(envKeyPPid) + t.Assert(false, gproc.IsChild()) + }) +} + +func Test_SetPPid(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + err := gproc.SetPPid(1234) + t.AssertNil(err) + t.Assert("1234", os.Getenv(envKeyPPid)) + + err = gproc.SetPPid(0) + t.AssertNil(err) + t.Assert("", os.Getenv(envKeyPPid)) + }) +} + +func Test_StartTime(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + result := gproc.StartTime() + t.Assert(result, gproc.StartTime()) + }) +} + +func Test_Uptime(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + result := gproc.Uptime() + t.AssertGT(result, 0) + }) +} + +func Test_SearchBinary_FoundInPath(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + tempDir := t.TempDir() + tempFile := filepath.Join(tempDir, "testbinary") + gfile.Create(tempFile) + os.Chmod(tempFile, 0755) + + originalPath := os.Getenv("PATH") + os.Setenv("PATH", tempDir+string(os.PathListSeparator)+originalPath) + defer os.Setenv("PATH", originalPath) + + result := gproc.SearchBinary("testbinary") + t.Assert(result, tempFile) + }) +} + +func Test_SearchBinary_NotFound(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + result := gproc.SearchBinary("nonexistentbinary") + t.Assert(result, "") + }) +} + +func Test_SearchBinaryPath_FoundInPath(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + tempDir := t.TempDir() + tempFile := filepath.Join(tempDir, "testbinary") + gfile.Create(tempFile) + os.Chmod(tempFile, 0755) + + originalPath := os.Getenv("PATH") + os.Setenv("PATH", tempDir+string(os.PathListSeparator)+originalPath) + defer os.Setenv("PATH", originalPath) + + result := gproc.SearchBinaryPath("testbinary") + t.Assert(result, tempFile) + }) +} + +func Test_SearchBinaryPath_NotFound(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + result := gproc.SearchBinaryPath("nonexistentbinary") + t.Assert(result, "") + }) +} + +func Test_PPidOS(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + ppid := gproc.PPidOS() + expectedPpid := os.Getppid() + t.Assert(ppid, expectedPpid) + }) +} + +func Test_PPid(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + customPPid := 12345 + os.Setenv("GPROC_PPID", gconv.String(customPPid)) + defer os.Unsetenv("GPROC_PPID") + + t.Assert(gproc.PPid(), customPPid) + }) +} From 42d8845d35c85c49631a126a2d53d457482d7f1e Mon Sep 17 00:00:00 2001 From: jean Date: Fri, 14 Feb 2025 13:39:13 +0800 Subject: [PATCH 085/102] feat(cmd/gf): add `gopackage` option for command `gf gen pbentity` to specify `go_package` for generated proto files (#4141) --- cmd/gf/internal/cmd/genpbentity/genpbentity.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/gf/internal/cmd/genpbentity/genpbentity.go b/cmd/gf/internal/cmd/genpbentity/genpbentity.go index e7138850d30..74bc4ab04e1 100644 --- a/cmd/gf/internal/cmd/genpbentity/genpbentity.go +++ b/cmd/gf/internal/cmd/genpbentity/genpbentity.go @@ -38,6 +38,7 @@ type ( g.Meta `name:"pbentity" config:"{CGenPbEntityConfig}" brief:"{CGenPbEntityBrief}" eg:"{CGenPbEntityEg}" ad:"{CGenPbEntityAd}"` Path string `name:"path" short:"p" brief:"{CGenPbEntityBriefPath}" d:"manifest/protobuf/pbentity"` Package string `name:"package" short:"k" brief:"{CGenPbEntityBriefPackage}"` + GoPackage string `name:"goPackage" short:"g" brief:"{CGenPbEntityBriefGoPackage}"` Link string `name:"link" short:"l" brief:"{CGenPbEntityBriefLink}"` Tables string `name:"tables" short:"t" brief:"{CGenPbEntityBriefTables}"` Prefix string `name:"prefix" short:"f" brief:"{CGenPbEntityBriefPrefix}"` @@ -111,6 +112,7 @@ CONFIGURATION SUPPORT ` CGenPbEntityBriefPath = `directory path for generated files storing` CGenPbEntityBriefPackage = `package path for all entity proto files` + CGenPbEntityBriefGoPackage = `go package path for all entity proto files` CGenPbEntityBriefLink = `database configuration, the same as the ORM configuration of GoFrame` CGenPbEntityBriefTables = `generate models only for given tables, multiple table names separated with ','` CGenPbEntityBriefPrefix = `add specified prefix for all entity names and entity proto files` @@ -236,6 +238,7 @@ func init() { `CGenPbEntityAd`: CGenPbEntityAd, `CGenPbEntityBriefPath`: CGenPbEntityBriefPath, `CGenPbEntityBriefPackage`: CGenPbEntityBriefPackage, + `CGenPbEntityBriefGoPackage`: CGenPbEntityBriefGoPackage, `CGenPbEntityBriefLink`: CGenPbEntityBriefLink, `CGenPbEntityBriefTables`: CGenPbEntityBriefTables, `CGenPbEntityBriefPrefix`: CGenPbEntityBriefPrefix, @@ -369,10 +372,13 @@ func generatePbEntityContentFile(ctx context.Context, in CGenPbEntityInternalInp } } } + if in.GoPackage == "" { + in.GoPackage = in.Package + } entityContent := gstr.ReplaceByMap(getTplPbEntityContent(""), g.MapStrStr{ "{Imports}": packageImportsArray.Join("\n"), "{PackageName}": gfile.Basename(in.Package), - "{GoPackage}": in.Package, + "{GoPackage}": in.GoPackage, "{OptionContent}": in.Option, "{EntityMessage}": entityMessageDefine, }) From 01593ad8b63c813d54c0fe95130d0f48cb1c8b0a Mon Sep 17 00:00:00 2001 From: John Guo Date: Fri, 14 Feb 2025 22:24:18 +0800 Subject: [PATCH 086/102] fix(ci): golangci-lint failed after upgrading go version to 1.24 (#4158) --- .github/workflows/golangci-lint.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index d15a8086986..4e646ce4cbf 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -30,6 +30,7 @@ jobs: strategy: matrix: go-version: [ 'stable' ] + name: golang-ci-lint runs-on: ubuntu-latest steps: @@ -43,7 +44,7 @@ jobs: uses: golangci/golangci-lint-action@v6 with: # Required: specify the golangci-lint version without the patch version to always use the latest patch. - version: v1.62.2 + version: v1.64.5 only-new-issues: true skip-cache: true github-token: ${{ secrets.GITHUB_TOKEN }} From 2fa03556ef312d54a0b6bf1205b8bccf4465d4a9 Mon Sep 17 00:00:00 2001 From: heansheng <77931774@qq.com> Date: Thu, 20 Feb 2025 16:32:01 +0800 Subject: [PATCH 087/102] chore(util/gvalid): using `64` instead of `10` bitsize parameter for function `strconv.ParseFloat` although it treats `10` as `64` internally (#4154) --- util/gconv/gconv_z_unit_scan_test.go | 28 +++++++++---------- .../internal/builtin/builtin_between.go | 6 ++-- util/gvalid/internal/builtin/builtin_float.go | 2 +- util/gvalid/internal/builtin/builtin_gt.go | 4 +-- util/gvalid/internal/builtin/builtin_gte.go | 4 +-- util/gvalid/internal/builtin/builtin_lt.go | 4 +-- util/gvalid/internal/builtin/builtin_lte.go | 4 +-- util/gvalid/internal/builtin/builtin_max.go | 4 +-- util/gvalid/internal/builtin/builtin_min.go | 4 +-- 9 files changed, 30 insertions(+), 30 deletions(-) diff --git a/util/gconv/gconv_z_unit_scan_test.go b/util/gconv/gconv_z_unit_scan_test.go index 4790565dd49..d5a4841c535 100644 --- a/util/gconv/gconv_z_unit_scan_test.go +++ b/util/gconv/gconv_z_unit_scan_test.go @@ -126,7 +126,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(maps, &mss) t.AssertNil(err) t.Assert(len(mss), len(maps)) - for k, _ := range maps { + for k := range maps { t.Assert(maps[k]["Name"], mss[k]["Name"]) t.Assert(maps[k]["Place"], mss[k]["Place"]) } @@ -135,7 +135,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(maps, &msa) t.AssertNil(err) t.Assert(len(msa), len(maps)) - for k, _ := range maps { + for k := range maps { t.Assert(maps[k]["Name"], msa[k]["Name"]) t.Assert(maps[k]["Place"], msa[k]["Place"]) } @@ -144,7 +144,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(maps, &maa) t.AssertNil(err) t.Assert(len(maa), len(maps)) - for k, _ := range maps { + for k := range maps { t.Assert(maps[k]["Name"], maa[k]["Name"]) t.Assert(maps[k]["Place"], maa[k]["Place"]) } @@ -153,7 +153,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(maps, &ss) t.AssertNil(err) t.Assert(len(ss), len(maps)) - for k, _ := range maps { + for k := range maps { t.Assert(maps[k]["Name"], ss[k].Name) t.Assert(maps[k]["Place"], ss[k].Place) } @@ -162,7 +162,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(maps, &ssp) t.AssertNil(err) t.Assert(len(ssp), len(maps)) - for k, _ := range maps { + for k := range maps { t.Assert(maps[k]["Name"], ssp[k].Name) t.Assert(maps[k]["Place"], ssp[k].Place) } @@ -219,7 +219,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(structs, &mss) t.AssertNil(err) t.Assert(len(mss), len(structs)) - for k, _ := range structs { + for k := range structs { t.Assert(structs[k].Name, mss[k]["Name"]) t.Assert(structs[k].Place, mss[k]["Place"]) } @@ -228,7 +228,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(structs, &msa) t.AssertNil(err) t.Assert(len(msa), len(structs)) - for k, _ := range structs { + for k := range structs { t.Assert(structs[k].Name, msa[k]["Name"]) t.Assert(structs[k].Place, msa[k]["Place"]) } @@ -237,7 +237,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(structs, &maa) t.AssertNil(err) t.Assert(len(maa), len(structs)) - for k, _ := range structs { + for k := range structs { t.Assert(structs[k].Name, maa[k]["Name"]) t.Assert(structs[k].Place, maa[k]["Place"]) } @@ -246,7 +246,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(structs, &ss) t.AssertNil(err) t.Assert(len(ss), len(structs)) - for k, _ := range structs { + for k := range structs { t.Assert(structs[k].Name, ss[k].Name) t.Assert(structs[k].Place, ss[k].Place) } @@ -255,7 +255,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(structs, &ssp) t.AssertNil(err) t.Assert(len(ssp), len(structs)) - for k, _ := range structs { + for k := range structs { t.Assert(structs[k].Name, ssp[k].Name) t.Assert(structs[k].Place, ssp[k].Place) } @@ -312,7 +312,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(jsons, &mss) t.AssertNil(err) t.Assert(len(mss), 2) - for k, _ := range mss { + for k := range mss { t.Assert("Mars", mss[k]["Name"]) t.Assert("奥林帕斯山", mss[k]["Place"]) } @@ -321,7 +321,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(jsons, &msa) t.AssertNil(err) t.Assert(len(msa), 2) - for k, _ := range msa { + for k := range msa { t.Assert("Mars", msa[k]["Name"]) t.Assert("奥林帕斯山", msa[k]["Place"]) } @@ -336,7 +336,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(jsons, &ss) t.AssertNil(err) t.Assert(len(ss), 2) - for k, _ := range ss { + for k := range ss { t.Assert("Mars", ss[k].Name) t.Assert("奥林帕斯山", ss[k].Place) } @@ -345,7 +345,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(jsons, &ssp) t.AssertNil(err) t.Assert(len(ssp), 2) - for k, _ := range ssp { + for k := range ssp { t.Assert("Mars", ssp[k].Name) t.Assert("奥林帕斯山", ssp[k].Place) } diff --git a/util/gvalid/internal/builtin/builtin_between.go b/util/gvalid/internal/builtin/builtin_between.go index ebfcdbf6407..c14f04130a7 100644 --- a/util/gvalid/internal/builtin/builtin_between.go +++ b/util/gvalid/internal/builtin/builtin_between.go @@ -39,16 +39,16 @@ func (r RuleBetween) Run(in RunInput) error { max = float64(0) ) if len(array) > 0 { - if v, err := strconv.ParseFloat(strings.TrimSpace(array[0]), 10); err == nil { + if v, err := strconv.ParseFloat(strings.TrimSpace(array[0]), 64); err == nil { min = v } } if len(array) > 1 { - if v, err := strconv.ParseFloat(strings.TrimSpace(array[1]), 10); err == nil { + if v, err := strconv.ParseFloat(strings.TrimSpace(array[1]), 64); err == nil { max = v } } - valueF, err := strconv.ParseFloat(in.Value.String(), 10) + valueF, err := strconv.ParseFloat(in.Value.String(), 64) if valueF < min || valueF > max || err != nil { return errors.New(gstr.ReplaceByMap(in.Message, map[string]string{ "{min}": strconv.FormatFloat(min, 'f', -1, 64), diff --git a/util/gvalid/internal/builtin/builtin_float.go b/util/gvalid/internal/builtin/builtin_float.go index cbf93d5b677..bd273ef3d3a 100644 --- a/util/gvalid/internal/builtin/builtin_float.go +++ b/util/gvalid/internal/builtin/builtin_float.go @@ -30,7 +30,7 @@ func (r RuleFloat) Message() string { } func (r RuleFloat) Run(in RunInput) error { - if _, err := strconv.ParseFloat(in.Value.String(), 10); err == nil { + if _, err := strconv.ParseFloat(in.Value.String(), 64); err == nil { return nil } return errors.New(in.Message) diff --git a/util/gvalid/internal/builtin/builtin_gt.go b/util/gvalid/internal/builtin/builtin_gt.go index 369fff2a07a..7cd523e0d30 100644 --- a/util/gvalid/internal/builtin/builtin_gt.go +++ b/util/gvalid/internal/builtin/builtin_gt.go @@ -37,8 +37,8 @@ func (r RuleGT) Message() string { func (r RuleGT) Run(in RunInput) error { var ( fieldName, fieldValue = gutil.MapPossibleItemByKey(in.Data.Map(), in.RulePattern) - fieldValueN, err1 = strconv.ParseFloat(gconv.String(fieldValue), 10) - valueN, err2 = strconv.ParseFloat(in.Value.String(), 10) + fieldValueN, err1 = strconv.ParseFloat(gconv.String(fieldValue), 64) + valueN, err2 = strconv.ParseFloat(in.Value.String(), 64) ) if valueN <= fieldValueN || err1 != nil || err2 != nil { diff --git a/util/gvalid/internal/builtin/builtin_gte.go b/util/gvalid/internal/builtin/builtin_gte.go index e25a978694a..a197058559d 100644 --- a/util/gvalid/internal/builtin/builtin_gte.go +++ b/util/gvalid/internal/builtin/builtin_gte.go @@ -37,8 +37,8 @@ func (r RuleGTE) Message() string { func (r RuleGTE) Run(in RunInput) error { var ( fieldName, fieldValue = gutil.MapPossibleItemByKey(in.Data.Map(), in.RulePattern) - fieldValueN, err1 = strconv.ParseFloat(gconv.String(fieldValue), 10) - valueN, err2 = strconv.ParseFloat(in.Value.String(), 10) + fieldValueN, err1 = strconv.ParseFloat(gconv.String(fieldValue), 64) + valueN, err2 = strconv.ParseFloat(in.Value.String(), 64) ) if valueN < fieldValueN || err1 != nil || err2 != nil { diff --git a/util/gvalid/internal/builtin/builtin_lt.go b/util/gvalid/internal/builtin/builtin_lt.go index f5ada92450b..4bb67c036f0 100644 --- a/util/gvalid/internal/builtin/builtin_lt.go +++ b/util/gvalid/internal/builtin/builtin_lt.go @@ -37,8 +37,8 @@ func (r RuleLT) Message() string { func (r RuleLT) Run(in RunInput) error { var ( fieldName, fieldValue = gutil.MapPossibleItemByKey(in.Data.Map(), in.RulePattern) - fieldValueN, err1 = strconv.ParseFloat(gconv.String(fieldValue), 10) - valueN, err2 = strconv.ParseFloat(in.Value.String(), 10) + fieldValueN, err1 = strconv.ParseFloat(gconv.String(fieldValue), 64) + valueN, err2 = strconv.ParseFloat(in.Value.String(), 64) ) if valueN >= fieldValueN || err1 != nil || err2 != nil { diff --git a/util/gvalid/internal/builtin/builtin_lte.go b/util/gvalid/internal/builtin/builtin_lte.go index c5511221ee3..428d9922c14 100644 --- a/util/gvalid/internal/builtin/builtin_lte.go +++ b/util/gvalid/internal/builtin/builtin_lte.go @@ -37,8 +37,8 @@ func (r RuleLTE) Message() string { func (r RuleLTE) Run(in RunInput) error { var ( fieldName, fieldValue = gutil.MapPossibleItemByKey(in.Data.Map(), in.RulePattern) - fieldValueN, err1 = strconv.ParseFloat(gconv.String(fieldValue), 10) - valueN, err2 = strconv.ParseFloat(in.Value.String(), 10) + fieldValueN, err1 = strconv.ParseFloat(gconv.String(fieldValue), 64) + valueN, err2 = strconv.ParseFloat(in.Value.String(), 64) ) if valueN > fieldValueN || err1 != nil || err2 != nil { diff --git a/util/gvalid/internal/builtin/builtin_max.go b/util/gvalid/internal/builtin/builtin_max.go index 6dcb3dc3395..6083fad51db 100644 --- a/util/gvalid/internal/builtin/builtin_max.go +++ b/util/gvalid/internal/builtin/builtin_max.go @@ -33,8 +33,8 @@ func (r RuleMax) Message() string { func (r RuleMax) Run(in RunInput) error { var ( - max, err1 = strconv.ParseFloat(in.RulePattern, 10) - valueN, err2 = strconv.ParseFloat(in.Value.String(), 10) + max, err1 = strconv.ParseFloat(in.RulePattern, 64) + valueN, err2 = strconv.ParseFloat(in.Value.String(), 64) ) if valueN > max || err1 != nil || err2 != nil { return errors.New(gstr.Replace(in.Message, "{max}", strconv.FormatFloat(max, 'f', -1, 64))) diff --git a/util/gvalid/internal/builtin/builtin_min.go b/util/gvalid/internal/builtin/builtin_min.go index 5ee370a7f54..2cfd08757e4 100644 --- a/util/gvalid/internal/builtin/builtin_min.go +++ b/util/gvalid/internal/builtin/builtin_min.go @@ -33,8 +33,8 @@ func (r RuleMin) Message() string { func (r RuleMin) Run(in RunInput) error { var ( - min, err1 = strconv.ParseFloat(in.RulePattern, 10) - valueN, err2 = strconv.ParseFloat(in.Value.String(), 10) + min, err1 = strconv.ParseFloat(in.RulePattern, 64) + valueN, err2 = strconv.ParseFloat(in.Value.String(), 64) ) if valueN < min || err1 != nil || err2 != nil { return errors.New(gstr.Replace(in.Message, "{min}", strconv.FormatFloat(min, 'f', -1, 64))) From 63cb3285f8311c14e6354c1a3aeb7ab103f26ad2 Mon Sep 17 00:00:00 2001 From: hailaz <739476267@qq.com> Date: Thu, 27 Feb 2025 11:59:26 +0800 Subject: [PATCH 088/102] fix(net/ghttp): update response message handling in `MiddlewareHandlerResponse` (#4162) --- .github/workflows/golangci-lint.yml | 3 +- .../internal/cmd/genpbentity/genpbentity.go | 8 +- contrib/config/polaris/polaris.go | 2 +- .../ghttp_middleware_handler_response.go | 2 +- net/ghttp/ghttp_request_param.go | 20 +-- net/ghttp/ghttp_request_param_request.go | 4 +- net/ghttp/ghttp_server_service_handler.go | 17 --- ...ttp_z_unit_feature_openapi_swagger_test.go | 10 +- ...http_z_unit_feature_request_struct_test.go | 36 ++++++ ...ghttp_z_unit_feature_router_strict_test.go | 48 +++---- net/ghttp/ghttp_z_unit_issue_test.go | 12 +- os/gproc/gproc_z_unit_test.go | 117 ++++++++++++++++++ test/gtest/gtest_util.go | 18 ++- test/gtest/gtest_z_unit_test.go | 16 +++ util/gconv/gconv_z_unit_scan_test.go | 28 ++--- util/gvalid/gvalid_z_unit_issue_test.go | 2 +- .../internal/builtin/builtin_between.go | 6 +- util/gvalid/internal/builtin/builtin_float.go | 2 +- util/gvalid/internal/builtin/builtin_gt.go | 4 +- util/gvalid/internal/builtin/builtin_gte.go | 4 +- util/gvalid/internal/builtin/builtin_lt.go | 4 +- util/gvalid/internal/builtin/builtin_lte.go | 4 +- util/gvalid/internal/builtin/builtin_max.go | 4 +- util/gvalid/internal/builtin/builtin_min.go | 4 +- 24 files changed, 274 insertions(+), 101 deletions(-) diff --git a/.github/workflows/golangci-lint.yml b/.github/workflows/golangci-lint.yml index d15a8086986..4e646ce4cbf 100644 --- a/.github/workflows/golangci-lint.yml +++ b/.github/workflows/golangci-lint.yml @@ -30,6 +30,7 @@ jobs: strategy: matrix: go-version: [ 'stable' ] + name: golang-ci-lint runs-on: ubuntu-latest steps: @@ -43,7 +44,7 @@ jobs: uses: golangci/golangci-lint-action@v6 with: # Required: specify the golangci-lint version without the patch version to always use the latest patch. - version: v1.62.2 + version: v1.64.5 only-new-issues: true skip-cache: true github-token: ${{ secrets.GITHUB_TOKEN }} diff --git a/cmd/gf/internal/cmd/genpbentity/genpbentity.go b/cmd/gf/internal/cmd/genpbentity/genpbentity.go index 8d497fe8edf..a552686d92d 100644 --- a/cmd/gf/internal/cmd/genpbentity/genpbentity.go +++ b/cmd/gf/internal/cmd/genpbentity/genpbentity.go @@ -39,6 +39,7 @@ type ( g.Meta `name:"pbentity" config:"{CGenPbEntityConfig}" brief:"{CGenPbEntityBrief}" eg:"{CGenPbEntityEg}" ad:"{CGenPbEntityAd}"` Path string `name:"path" short:"p" brief:"{CGenPbEntityBriefPath}" d:"manifest/protobuf/pbentity"` Package string `name:"package" short:"k" brief:"{CGenPbEntityBriefPackage}"` + GoPackage string `name:"goPackage" short:"g" brief:"{CGenPbEntityBriefGoPackage}"` Link string `name:"link" short:"l" brief:"{CGenPbEntityBriefLink}"` Tables string `name:"tables" short:"t" brief:"{CGenPbEntityBriefTables}"` Prefix string `name:"prefix" short:"f" brief:"{CGenPbEntityBriefPrefix}"` @@ -113,6 +114,7 @@ CONFIGURATION SUPPORT ` CGenPbEntityBriefPath = `directory path for generated files storing` CGenPbEntityBriefPackage = `package path for all entity proto files` + CGenPbEntityBriefGoPackage = `go package path for all entity proto files` CGenPbEntityBriefLink = `database configuration, the same as the ORM configuration of GoFrame` CGenPbEntityBriefTables = `generate models only for given tables, multiple table names separated with ','` CGenPbEntityBriefPrefix = `add specified prefix for all entity names and entity proto files` @@ -239,6 +241,7 @@ func init() { `CGenPbEntityAd`: CGenPbEntityAd, `CGenPbEntityBriefPath`: CGenPbEntityBriefPath, `CGenPbEntityBriefPackage`: CGenPbEntityBriefPackage, + `CGenPbEntityBriefGoPackage`: CGenPbEntityBriefGoPackage, `CGenPbEntityBriefLink`: CGenPbEntityBriefLink, `CGenPbEntityBriefTables`: CGenPbEntityBriefTables, `CGenPbEntityBriefPrefix`: CGenPbEntityBriefPrefix, @@ -379,10 +382,13 @@ func generatePbEntityContentFile(ctx context.Context, in CGenPbEntityInternalInp } } } + if in.GoPackage == "" { + in.GoPackage = in.Package + } entityContent := gstr.ReplaceByMap(getTplPbEntityContent(""), g.MapStrStr{ "{Imports}": packageImportsArray.Join("\n"), "{PackageName}": gfile.Basename(in.Package), - "{GoPackage}": in.Package, + "{GoPackage}": in.GoPackage, "{OptionContent}": in.Option, "{EntityMessage}": entityMessageDefine, }) diff --git a/contrib/config/polaris/polaris.go b/contrib/config/polaris/polaris.go index 04765d6591a..1f9d6ee0576 100644 --- a/contrib/config/polaris/polaris.go +++ b/contrib/config/polaris/polaris.go @@ -147,7 +147,7 @@ func (c *Client) doUpdate(ctx context.Context) (err error) { return gerror.New("config file is empty") } var j *gjson.Json - if j, err = gjson.DecodeToJson([]byte(c.client.GetContent())); err != nil { + if j, err = gjson.LoadContent([]byte(c.client.GetContent())); err != nil { return gerror.Wrap(err, `parse config map item from polaris failed`) } c.value.Set(j) diff --git a/net/ghttp/ghttp_middleware_handler_response.go b/net/ghttp/ghttp_middleware_handler_response.go index 7eb50b2d127..23d3bab7ae8 100644 --- a/net/ghttp/ghttp_middleware_handler_response.go +++ b/net/ghttp/ghttp_middleware_handler_response.go @@ -62,7 +62,6 @@ func MiddlewareHandlerResponse(r *Request) { msg = err.Error() } else { if r.Response.Status > 0 && r.Response.Status != http.StatusOK { - msg = http.StatusText(r.Response.Status) switch r.Response.Status { case http.StatusNotFound: code = gcode.CodeNotFound @@ -77,6 +76,7 @@ func MiddlewareHandlerResponse(r *Request) { } else { code = gcode.CodeOK } + msg = code.Message() } r.Response.WriteJson(DefaultHandlerResponse{ diff --git a/net/ghttp/ghttp_request_param.go b/net/ghttp/ghttp_request_param.go index 20f67d2ef53..b7f7e67e45c 100644 --- a/net/ghttp/ghttp_request_param.go +++ b/net/ghttp/ghttp_request_param.go @@ -268,28 +268,28 @@ func (r *Request) parseForm() { if r.ContentLength == 0 { return } + if contentType := r.Header.Get("Content-Type"); contentType != "" { - var ( - err error - repeatableRead = true - ) - if gstr.Contains(contentType, "multipart/") { + var isMultiPartRequest = gstr.Contains(contentType, "multipart/") + var isFormRequest = gstr.Contains(contentType, "form") + var err error + + if !isMultiPartRequest { // To avoid big memory consuming. // The `multipart/` type form always contains binary data, which is not necessary read twice. - repeatableRead = false + r.MakeBodyRepeatableRead(true) + } + if isMultiPartRequest { // multipart/form-data, multipart/mixed if err = r.ParseMultipartForm(r.Server.config.FormParsingMemory); err != nil { panic(gerror.WrapCode(gcode.CodeInvalidRequest, err, "r.ParseMultipartForm failed")) } - } else if gstr.Contains(contentType, "form") { + } else if isFormRequest { // application/x-www-form-urlencoded if err = r.Request.ParseForm(); err != nil { panic(gerror.WrapCode(gcode.CodeInvalidRequest, err, "r.Request.ParseForm failed")) } } - if repeatableRead { - r.MakeBodyRepeatableRead(true) - } if len(r.PostForm) > 0 { // Parse the form data using united parsing way. params := "" diff --git a/net/ghttp/ghttp_request_param_request.go b/net/ghttp/ghttp_request_param_request.go index a2874d9de92..601e3f06a92 100644 --- a/net/ghttp/ghttp_request_param_request.go +++ b/net/ghttp/ghttp_request_param_request.go @@ -183,7 +183,7 @@ func (r *Request) doGetRequestStruct(pointer interface{}, mapping ...map[string] return data, nil } // `in` Tag Struct values. - if err = r.mergeInTagStructValue(data, pointer); err != nil { + if err = r.mergeInTagStructValue(data); err != nil { return data, nil } @@ -239,7 +239,7 @@ func (r *Request) mergeDefaultStructValue(data map[string]interface{}, pointer i } // mergeInTagStructValue merges the request parameters with header or cookie values from struct `in` tag definition. -func (r *Request) mergeInTagStructValue(data map[string]interface{}, pointer interface{}) error { +func (r *Request) mergeInTagStructValue(data map[string]interface{}) error { fields := r.serveHandler.Handler.Info.ReqStructFields if len(fields) > 0 { var ( diff --git a/net/ghttp/ghttp_server_service_handler.go b/net/ghttp/ghttp_server_service_handler.go index 76de26aaae8..7e248c75c5e 100644 --- a/net/ghttp/ghttp_server_service_handler.go +++ b/net/ghttp/ghttp_server_service_handler.go @@ -282,20 +282,3 @@ func createRouterFunc(funcInfo handlerFuncInfo) func(r *Request) { } } } - -// trimGeneric removes type definitions string from response type name if generic -func trimGeneric(structName string) string { - var ( - leftBraceIndex = strings.LastIndex(structName, "[") // for generic, it is faster to start at the end than at the beginning - rightBraceIndex = strings.LastIndex(structName, "]") - ) - if leftBraceIndex == -1 || rightBraceIndex == -1 { - // not found '[' or ']' - return structName - } else if leftBraceIndex+1 == rightBraceIndex { - // may be a slice, because generic is '[X]', not '[]' - // to be compatible with bad return parameter type: []XxxRes - return structName - } - return structName[:leftBraceIndex] -} diff --git a/net/ghttp/ghttp_z_unit_feature_openapi_swagger_test.go b/net/ghttp/ghttp_z_unit_feature_openapi_swagger_test.go index 2ce097ac9e1..b1b4234246d 100644 --- a/net/ghttp/ghttp_z_unit_feature_openapi_swagger_test.go +++ b/net/ghttp/ghttp_z_unit_feature_openapi_swagger_test.go @@ -59,7 +59,7 @@ func Test_OpenApi_Swagger(t *testing.T) { c := g.Client() c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) - t.Assert(c.GetContent(ctx, "/test?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Age":18,"Name":"john"}}`) + t.Assert(c.GetContent(ctx, "/test?age=18&name=john"), `{"code":0,"message":"OK","data":{"Id":1,"Age":18,"Name":"john"}}`) t.Assert(c.GetContent(ctx, "/test/error"), `{"code":50,"message":"error","data":{"Id":1,"Age":0,"Name":""}}`) t.Assert(gstr.Contains(c.GetContent(ctx, "/swagger/"), `API Reference`), true) @@ -116,9 +116,9 @@ func Test_OpenApi_Multiple_Methods_Swagger(t *testing.T) { c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) // Only works on GET & POST methods. - t.Assert(c.GetContent(ctx, "/test?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Age":18,"Name":"john"}}`) + t.Assert(c.GetContent(ctx, "/test?age=18&name=john"), `{"code":0,"message":"OK","data":{"Id":1,"Age":18,"Name":"john"}}`) t.Assert(c.GetContent(ctx, "/test/error"), `{"code":50,"message":"error","data":{"Id":1,"Age":0,"Name":""}}`) - t.Assert(c.PostContent(ctx, "/test?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Age":18,"Name":"john"}}`) + t.Assert(c.PostContent(ctx, "/test?age=18&name=john"), `{"code":0,"message":"OK","data":{"Id":1,"Age":18,"Name":"john"}}`) t.Assert(c.PostContent(ctx, "/test/error"), `{"code":50,"message":"error","data":{"Id":1,"Age":0,"Name":""}}`) // Not works on other methods. @@ -176,9 +176,9 @@ func Test_OpenApi_Method_All_Swagger(t *testing.T) { c := g.Client() c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) - t.Assert(c.GetContent(ctx, "/test?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Age":18,"Name":"john"}}`) + t.Assert(c.GetContent(ctx, "/test?age=18&name=john"), `{"code":0,"message":"OK","data":{"Id":1,"Age":18,"Name":"john"}}`) t.Assert(c.GetContent(ctx, "/test/error"), `{"code":50,"message":"error","data":{"Id":1,"Age":0,"Name":""}}`) - t.Assert(c.PostContent(ctx, "/test?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Age":18,"Name":"john"}}`) + t.Assert(c.PostContent(ctx, "/test?age=18&name=john"), `{"code":0,"message":"OK","data":{"Id":1,"Age":18,"Name":"john"}}`) t.Assert(c.PostContent(ctx, "/test/error"), `{"code":50,"message":"error","data":{"Id":1,"Age":0,"Name":""}}`) t.Assert(gstr.Contains(c.GetContent(ctx, "/swagger/"), `API Reference`), true) diff --git a/net/ghttp/ghttp_z_unit_feature_request_struct_test.go b/net/ghttp/ghttp_z_unit_feature_request_struct_test.go index af846b75da1..a54e73ae434 100644 --- a/net/ghttp/ghttp_z_unit_feature_request_struct_test.go +++ b/net/ghttp/ghttp_z_unit_feature_request_struct_test.go @@ -115,6 +115,42 @@ func Test_Params_ParseForm(t *testing.T) { }) } +// https://github.com/gogf/gf/pull/4143 +func Test_Params_ParseForm_FixMakeBodyRepeatableRead(t *testing.T) { + type User struct { + Id int + Name string + } + s := g.Server(guid.S()) + s.BindHandler("/parse-form", func(r *ghttp.Request) { + var user *User + if err := r.ParseForm(&user); err != nil { + r.Response.WriteExit(err) + } + hasBody := len(r.GetBody()) > 0 + r.Response.WriteExit(hasBody) + }) + s.SetDumpRouterMap(false) + s.Start() + defer s.Shutdown() + + time.Sleep(100 * time.Millisecond) + gtest.C(t, func(t *gtest.T) { + c := g.Client() + c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) + t.Assert(c.GetContent(ctx, "/parse-form"), `false`) + t.Assert(c.GetContent(ctx, "/parse-form", g.Map{ + "id": 1, + "name": "john", + }), false) + t.Assert(c.PostContent(ctx, "/parse-form"), `false`) + t.Assert(c.PostContent(ctx, "/parse-form", g.Map{ + "id": 1, + "name": "john", + }), true) + }) +} + func Test_Params_ComplexJsonStruct(t *testing.T) { type ItemEnv struct { Type string diff --git a/net/ghttp/ghttp_z_unit_feature_router_strict_test.go b/net/ghttp/ghttp_z_unit_feature_router_strict_test.go index fba43a89488..ef4fa12112b 100644 --- a/net/ghttp/ghttp_z_unit_feature_router_strict_test.go +++ b/net/ghttp/ghttp_z_unit_feature_router_strict_test.go @@ -56,7 +56,7 @@ func Test_Router_Handler_Strict_WithObject(t *testing.T) { client := g.Client() client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) - t.Assert(client.GetContent(ctx, "/test?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Age":18,"Name":"john"}}`) + t.Assert(client.GetContent(ctx, "/test?age=18&name=john"), `{"code":0,"message":"OK","data":{"Id":1,"Age":18,"Name":"john"}}`) t.Assert(client.GetContent(ctx, "/test/error"), `{"code":50,"message":"error","data":{"Id":1,"Age":0,"Name":""}}`) }) } @@ -153,8 +153,8 @@ func Test_Router_Handler_Strict_WithObjectAndMeta(t *testing.T) { client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) t.Assert(client.GetContent(ctx, "/"), `{"code":65,"message":"Not Found","data":null}`) - t.Assert(client.GetContent(ctx, "/custom-test1?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Age":18}}`) - t.Assert(client.GetContent(ctx, "/custom-test2?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Name":"john"}}`) + t.Assert(client.GetContent(ctx, "/custom-test1?age=18&name=john"), `{"code":0,"message":"OK","data":{"Id":1,"Age":18}}`) + t.Assert(client.GetContent(ctx, "/custom-test2?age=18&name=john"), `{"code":0,"message":"OK","data":{"Id":1,"Name":"john"}}`) t.Assert(client.PostContent(ctx, "/custom-test2?age=18&name=john"), `{"code":65,"message":"Not Found","data":null}`) }) } @@ -184,17 +184,17 @@ func Test_Router_Handler_Strict_Group_Bind(t *testing.T) { client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) t.Assert(client.GetContent(ctx, "/"), `{"code":65,"message":"Not Found","data":null}`) - t.Assert(client.GetContent(ctx, "/api/v1/custom-test1?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Age":18}}`) - t.Assert(client.GetContent(ctx, "/api/v1/custom-test2?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Name":"john"}}`) + t.Assert(client.GetContent(ctx, "/api/v1/custom-test1?age=18&name=john"), `{"code":0,"message":"OK","data":{"Id":1,"Age":18}}`) + t.Assert(client.GetContent(ctx, "/api/v1/custom-test2?age=18&name=john"), `{"code":0,"message":"OK","data":{"Id":1,"Name":"john"}}`) t.Assert(client.PostContent(ctx, "/api/v1/custom-test2?age=18&name=john"), `{"code":65,"message":"Not Found","data":null}`) - t.Assert(client.GetContent(ctx, "/api/v1/custom-test3?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Age":18}}`) - t.Assert(client.GetContent(ctx, "/api/v1/custom-test4?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Name":"john"}}`) + t.Assert(client.GetContent(ctx, "/api/v1/custom-test3?age=18&name=john"), `{"code":0,"message":"OK","data":{"Id":1,"Age":18}}`) + t.Assert(client.GetContent(ctx, "/api/v1/custom-test4?age=18&name=john"), `{"code":0,"message":"OK","data":{"Id":1,"Name":"john"}}`) - t.Assert(client.GetContent(ctx, "/api/v2/custom-test1?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Age":18}}`) - t.Assert(client.GetContent(ctx, "/api/v2/custom-test2?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Name":"john"}}`) - t.Assert(client.GetContent(ctx, "/api/v2/custom-test3?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Age":18}}`) - t.Assert(client.GetContent(ctx, "/api/v2/custom-test4?age=18&name=john"), `{"code":0,"message":"","data":{"Id":1,"Name":"john"}}`) + t.Assert(client.GetContent(ctx, "/api/v2/custom-test1?age=18&name=john"), `{"code":0,"message":"OK","data":{"Id":1,"Age":18}}`) + t.Assert(client.GetContent(ctx, "/api/v2/custom-test2?age=18&name=john"), `{"code":0,"message":"OK","data":{"Id":1,"Name":"john"}}`) + t.Assert(client.GetContent(ctx, "/api/v2/custom-test3?age=18&name=john"), `{"code":0,"message":"OK","data":{"Id":1,"Age":18}}`) + t.Assert(client.GetContent(ctx, "/api/v2/custom-test4?age=18&name=john"), `{"code":0,"message":"OK","data":{"Id":1,"Name":"john"}}`) }) } @@ -251,7 +251,7 @@ func Test_Issue1708(t *testing.T) { ` t.Assert( client.PostContent(ctx, "/test", content), - `{"code":0,"message":"","data":{"page":0,"size":0,"targetType":"topic","targetId":10785,"test":[[{"name":"123"}]]}}`, + `{"code":0,"message":"OK","data":{"page":0,"size":0,"targetType":"topic","targetId":10785,"test":[[{"name":"123"}]]}}`, ) }) } @@ -295,7 +295,7 @@ func Test_Custom_Slice_Type_Attribute(t *testing.T) { ` t.Assert( client.PostContent(ctx, "/test", content), - `{"code":0,"message":"","data":{"Content":"{\"Id\":1,\"List\":{\"key\":[\"a\",\"b\",\"c\"]}}"}}`, + `{"code":0,"message":"OK","data":{"Content":"{\"Id\":1,\"List\":{\"key\":[\"a\",\"b\",\"c\"]}}"}}`, ) }) } @@ -370,12 +370,12 @@ func Test_Router_Handler_Strict_WithGeneric(t *testing.T) { client := g.Client() client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) - t.Assert(client.GetContent(ctx, "/test1?age=1"), `{"code":0,"message":"","data":{"Age":{"Test":1}}}`) - t.Assert(client.GetContent(ctx, "/test1_slice?age=1"), `{"code":0,"message":"","data":[{"Age":{"Test":1}}]}`) - t.Assert(client.GetContent(ctx, "/test2?age=2"), `{"code":0,"message":"","data":{"Test":2}}`) - t.Assert(client.GetContent(ctx, "/test2_slice?age=2"), `{"code":0,"message":"","data":[{"Test":2}]}`) - t.Assert(client.GetContent(ctx, "/test3?age=3"), `{"code":0,"message":"","data":{"Test":3}}`) - t.Assert(client.GetContent(ctx, "/test3_slice?age=3"), `{"code":0,"message":"","data":[{"Test":3}]}`) + t.Assert(client.GetContent(ctx, "/test1?age=1"), `{"code":0,"message":"OK","data":{"Age":{"Test":1}}}`) + t.Assert(client.GetContent(ctx, "/test1_slice?age=1"), `{"code":0,"message":"OK","data":[{"Age":{"Test":1}}]}`) + t.Assert(client.GetContent(ctx, "/test2?age=2"), `{"code":0,"message":"OK","data":{"Test":2}}`) + t.Assert(client.GetContent(ctx, "/test2_slice?age=2"), `{"code":0,"message":"OK","data":[{"Test":2}]}`) + t.Assert(client.GetContent(ctx, "/test3?age=3"), `{"code":0,"message":"OK","data":{"Test":3}}`) + t.Assert(client.GetContent(ctx, "/test3_slice?age=3"), `{"code":0,"message":"OK","data":[{"Test":3}]}`) }) } @@ -415,7 +415,7 @@ func Test_Router_Handler_Strict_ParameterCaseSensitive(t *testing.T) { for i := 0; i < 1000; i++ { t.Assert( client.PostContent(ctx, "/api/111", `{"Path":"222"}`), - `{"code":0,"message":"","data":{"Path":"222"}}`, + `{"code":0,"message":"OK","data":{"Path":"222"}}`, ) } }) @@ -474,10 +474,10 @@ func Test_JsonRawMessage_Issue3449(t *testing.T) { }, } - expect1 := `{"code":0,"message":"","data":{"name":"test","jsonRaw":[{"jkey1":"11","jkey2":"12"},{"jkey1":"21","jkey2":"22"}]}}` + expect1 := `{"code":0,"message":"OK","data":{"name":"test","jsonRaw":[{"jkey1":"11","jkey2":"12"},{"jkey1":"21","jkey2":"22"}]}}` t.Assert(client.PostContent(ctx, "/test", data), expect1) - expect2 := `{"code":0,"message":"","data":{"name":"test","jsonRaw":{"jkey1":"11","jkey2":"12"}}}` + expect2 := `{"code":0,"message":"OK","data":{"name":"test","jsonRaw":{"jkey1":"11","jkey2":"12"}}}` t.Assert(client.PostContent(ctx, "/test", map[string]any{ "Name": "test", "jsonRaw": v1, @@ -524,13 +524,13 @@ func Test_NullString_Issue3465(t *testing.T) { "name": "null", } - expect1 := `{"code":0,"message":"","data":{"name":["null"]}}` + expect1 := `{"code":0,"message":"OK","data":{"name":["null"]}}` t.Assert(client.GetContent(ctx, "/test", data1), expect1) data2 := map[string]any{ "name": []string{"null", "null"}, } - expect2 := `{"code":0,"message":"","data":{"name":["null","null"]}}` + expect2 := `{"code":0,"message":"OK","data":{"name":["null","null"]}}` t.Assert(client.GetContent(ctx, "/test", data2), expect2) }) diff --git a/net/ghttp/ghttp_z_unit_issue_test.go b/net/ghttp/ghttp_z_unit_issue_test.go index b695d35fc56..df5838301d6 100644 --- a/net/ghttp/ghttp_z_unit_issue_test.go +++ b/net/ghttp/ghttp_z_unit_issue_test.go @@ -165,7 +165,7 @@ func Test_Issue1653(t *testing.T) { } ` resContent := c.PostContent(ctx, "/boot/test", dataReq) - t.Assert(resContent, `{"code":0,"message":"","data":{"uuid":"28ee701c-7daf-4cdc-9a62-6d6704e6112b","feed_back":"P00001"}}`) + t.Assert(resContent, `{"code":0,"message":"OK","data":{"uuid":"28ee701c-7daf-4cdc-9a62-6d6704e6112b","feed_back":"P00001"}}`) }) } @@ -261,7 +261,7 @@ func Test_Issue2172(t *testing.T) { c := g.Client() c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) dataReq := `{"data":{"asd":1}}` - t.Assert(c.PostContent(ctx, "/demo", dataReq), `{"code":0,"message":"","data":{"Content":"{\"asd\":1}"}}`) + t.Assert(c.PostContent(ctx, "/demo", dataReq), `{"code":0,"message":"OK","data":{"Content":"{\"asd\":1}"}}`) }) } @@ -365,7 +365,7 @@ func Test_Issue2482(t *testing.T) { ] } ` - t.Assert(c.PutContent(ctx, "/api/v2/order", content), `{"code":0,"message":"","data":null}`) + t.Assert(c.PutContent(ctx, "/api/v2/order", content), `{"code":0,"message":"OK","data":null}`) }) } @@ -522,7 +522,7 @@ func Test_Issue2457(t *testing.T) { c := g.Client() c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) - t.Assert(c.GetContent(ctx, "/list"), `{"code":0,"message":"","data":{"Code":100,"Data":{"Title":"title","Content":"hello"},"Msg":""}}`) + t.Assert(c.GetContent(ctx, "/list"), `{"code":0,"message":"OK","data":{"Code":100,"Data":{"Title":"title","Content":"hello"},"Msg":""}}`) }) } @@ -565,7 +565,7 @@ func Test_Issue3245(t *testing.T) { c.SetHeader("Header-Name", "oldme") c.SetCookie("Header-Age", "25") - expect := `{"code":0,"message":"","data":{"Reply":{"name":"oldme","X-Header-Name":"oldme","X-Header-Age":25}}}` + expect := `{"code":0,"message":"OK","data":{"Reply":{"name":"oldme","X-Header-Name":"oldme","X-Header-Age":25}}}` t.Assert(c.GetContent(ctx, "/hello?nickname=oldme"), expect) }) } @@ -615,7 +615,7 @@ func Test_Issue3789(t *testing.T) { c := g.Client() c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) - expect := `{"code":0,"message":"","data":{"id":"0","secondId":"2","thirdId":"3"}}` + expect := `{"code":0,"message":"OK","data":{"id":"0","secondId":"2","thirdId":"3"}}` t.Assert(c.GetContent(ctx, "/hello?id=&secondId=2&thirdId=3"), expect) }) } diff --git a/os/gproc/gproc_z_unit_test.go b/os/gproc/gproc_z_unit_test.go index b4e21bbfcaf..0c6e31c7aba 100644 --- a/os/gproc/gproc_z_unit_test.go +++ b/os/gproc/gproc_z_unit_test.go @@ -9,11 +9,19 @@ package gproc_test import ( + "os" + "path/filepath" "testing" "github.com/gogf/gf/v2/os/gctx" + "github.com/gogf/gf/v2/os/gfile" "github.com/gogf/gf/v2/os/gproc" "github.com/gogf/gf/v2/test/gtest" + "github.com/gogf/gf/v2/util/gconv" +) + +const ( + envKeyPPid = "GPROC_PPID" ) func Test_ShellExec(t *testing.T) { @@ -28,3 +36,112 @@ func Test_ShellExec(t *testing.T) { t.AssertNE(err, nil) }) } + +func Test_Pid(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + t.Assert(os.Getpid(), gproc.Pid()) + }) +} + +func Test_IsChild(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + originalPPid := os.Getenv(envKeyPPid) + defer os.Setenv(envKeyPPid, originalPPid) + + os.Setenv(envKeyPPid, "1234") + t.Assert(true, gproc.IsChild()) + + os.Unsetenv(envKeyPPid) + t.Assert(false, gproc.IsChild()) + }) +} + +func Test_SetPPid(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + err := gproc.SetPPid(1234) + t.AssertNil(err) + t.Assert("1234", os.Getenv(envKeyPPid)) + + err = gproc.SetPPid(0) + t.AssertNil(err) + t.Assert("", os.Getenv(envKeyPPid)) + }) +} + +func Test_StartTime(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + result := gproc.StartTime() + t.Assert(result, gproc.StartTime()) + }) +} + +func Test_Uptime(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + result := gproc.Uptime() + t.AssertGT(result, 0) + }) +} + +func Test_SearchBinary_FoundInPath(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + tempDir := t.TempDir() + tempFile := filepath.Join(tempDir, "testbinary") + gfile.Create(tempFile) + os.Chmod(tempFile, 0755) + + originalPath := os.Getenv("PATH") + os.Setenv("PATH", tempDir+string(os.PathListSeparator)+originalPath) + defer os.Setenv("PATH", originalPath) + + result := gproc.SearchBinary("testbinary") + t.Assert(result, tempFile) + }) +} + +func Test_SearchBinary_NotFound(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + result := gproc.SearchBinary("nonexistentbinary") + t.Assert(result, "") + }) +} + +func Test_SearchBinaryPath_FoundInPath(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + tempDir := t.TempDir() + tempFile := filepath.Join(tempDir, "testbinary") + gfile.Create(tempFile) + os.Chmod(tempFile, 0755) + + originalPath := os.Getenv("PATH") + os.Setenv("PATH", tempDir+string(os.PathListSeparator)+originalPath) + defer os.Setenv("PATH", originalPath) + + result := gproc.SearchBinaryPath("testbinary") + t.Assert(result, tempFile) + }) +} + +func Test_SearchBinaryPath_NotFound(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + result := gproc.SearchBinaryPath("nonexistentbinary") + t.Assert(result, "") + }) +} + +func Test_PPidOS(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + ppid := gproc.PPidOS() + expectedPpid := os.Getppid() + t.Assert(ppid, expectedPpid) + }) +} + +func Test_PPid(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + customPPid := 12345 + os.Setenv("GPROC_PPID", gconv.String(customPPid)) + defer os.Unsetenv("GPROC_PPID") + + t.Assert(gproc.PPid(), customPPid) + }) +} diff --git a/test/gtest/gtest_util.go b/test/gtest/gtest_util.go index c9ccb9f0b49..c1609474d56 100644 --- a/test/gtest/gtest_util.go +++ b/test/gtest/gtest_util.go @@ -220,7 +220,6 @@ func AssertLE(value, expect interface{}) { // AssertIN checks `value` is IN `expect`. // The `expect` should be a slice, // but the `value` can be a slice or a basic type variable. -// TODO map support. // TODO: gconv.Strings(0) is not [0] func AssertIN(value, expect interface{}) { var ( @@ -249,6 +248,14 @@ func AssertIN(value, expect interface{}) { expectStr = gconv.String(expect) ) passed = gstr.Contains(expectStr, valueStr) + case reflect.Map: + expectMap := gconv.Map(expect) + for _, v1 := range gconv.Strings(value) { + if _, exists := expectMap[v1]; !exists { + passed = false + break + } + } default: panic(fmt.Sprintf(`[ASSERT] INVALID EXPECT VALUE TYPE: %v`, expectKind)) } @@ -260,7 +267,6 @@ func AssertIN(value, expect interface{}) { // AssertNI checks `value` is NOT IN `expect`. // The `expect` should be a slice, // but the `value` can be a slice or a basic type variable. -// TODO map support. func AssertNI(value, expect interface{}) { var ( passed = true @@ -287,6 +293,14 @@ func AssertNI(value, expect interface{}) { expectStr = gconv.String(expect) ) passed = !gstr.Contains(expectStr, valueStr) + case reflect.Map: + expectMap := gconv.Map(expect) + for _, v1 := range gconv.Strings(value) { + if _, exists := expectMap[v1]; exists { + passed = false + break + } + } default: panic(fmt.Sprintf(`[ASSERT] INVALID EXPECT VALUE TYPE: %v`, expectKind)) } diff --git a/test/gtest/gtest_z_unit_test.go b/test/gtest/gtest_z_unit_test.go index 2c1197f22e6..7d576fd791a 100644 --- a/test/gtest/gtest_z_unit_test.go +++ b/test/gtest/gtest_z_unit_test.go @@ -322,6 +322,22 @@ func TestAssertIN(t *testing.T) { }) } +func TestAssertIN_Map(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + t.AssertIN("k1", map[string]string{"k1": "v1", "k2": "v2"}) + t.AssertIN(1, map[int64]string{1: "v1", 2: "v2"}) + t.AssertIN([]string{"k1", "k2"}, map[string]string{"k1": "v1", "k2": "v2"}) + }) +} + +func TestAssertNI_Map(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + t.AssertNI("k3", map[string]string{"k1": "v1", "k2": "v2"}) + t.AssertNI(3, map[int64]string{1: "v1", 2: "v2"}) + t.AssertNI([]string{"k3", "k4"}, map[string]string{"k1": "v1", "k2": "v2"}) + }) +} + func TestAssertNI(t *testing.T) { gtest.C(t, func(t *gtest.T) { t.AssertNI("d", []string{"a", "b", "c"}) diff --git a/util/gconv/gconv_z_unit_scan_test.go b/util/gconv/gconv_z_unit_scan_test.go index 76620d1f44d..eddfc9bbc98 100644 --- a/util/gconv/gconv_z_unit_scan_test.go +++ b/util/gconv/gconv_z_unit_scan_test.go @@ -126,7 +126,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(maps, &mss) t.AssertNil(err) t.Assert(len(mss), len(maps)) - for k, _ := range maps { + for k := range maps { t.Assert(maps[k]["Name"], mss[k]["Name"]) t.Assert(maps[k]["Place"], mss[k]["Place"]) } @@ -135,7 +135,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(maps, &msa) t.AssertNil(err) t.Assert(len(msa), len(maps)) - for k, _ := range maps { + for k := range maps { t.Assert(maps[k]["Name"], msa[k]["Name"]) t.Assert(maps[k]["Place"], msa[k]["Place"]) } @@ -144,7 +144,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(maps, &maa) t.AssertNil(err) t.Assert(len(maa), len(maps)) - for k, _ := range maps { + for k := range maps { t.Assert(maps[k]["Name"], maa[k]["Name"]) t.Assert(maps[k]["Place"], maa[k]["Place"]) } @@ -153,7 +153,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(maps, &ss) t.AssertNil(err) t.Assert(len(ss), len(maps)) - for k, _ := range maps { + for k := range maps { t.Assert(maps[k]["Name"], ss[k].Name) t.Assert(maps[k]["Place"], ss[k].Place) } @@ -162,7 +162,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(maps, &ssp) t.AssertNil(err) t.Assert(len(ssp), len(maps)) - for k, _ := range maps { + for k := range maps { t.Assert(maps[k]["Name"], ssp[k].Name) t.Assert(maps[k]["Place"], ssp[k].Place) } @@ -219,7 +219,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(structs, &mss) t.AssertNil(err) t.Assert(len(mss), len(structs)) - for k, _ := range structs { + for k := range structs { t.Assert(structs[k].Name, mss[k]["Name"]) t.Assert(structs[k].Place, mss[k]["Place"]) } @@ -228,7 +228,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(structs, &msa) t.AssertNil(err) t.Assert(len(msa), len(structs)) - for k, _ := range structs { + for k := range structs { t.Assert(structs[k].Name, msa[k]["Name"]) t.Assert(structs[k].Place, msa[k]["Place"]) } @@ -237,7 +237,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(structs, &maa) t.AssertNil(err) t.Assert(len(maa), len(structs)) - for k, _ := range structs { + for k := range structs { t.Assert(structs[k].Name, maa[k]["Name"]) t.Assert(structs[k].Place, maa[k]["Place"]) } @@ -246,7 +246,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(structs, &ss) t.AssertNil(err) t.Assert(len(ss), len(structs)) - for k, _ := range structs { + for k := range structs { t.Assert(structs[k].Name, ss[k].Name) t.Assert(structs[k].Place, ss[k].Place) } @@ -255,7 +255,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(structs, &ssp) t.AssertNil(err) t.Assert(len(ssp), len(structs)) - for k, _ := range structs { + for k := range structs { t.Assert(structs[k].Name, ssp[k].Name) t.Assert(structs[k].Place, ssp[k].Place) } @@ -312,7 +312,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(jsons, &mss) t.AssertNil(err) t.Assert(len(mss), 2) - for k, _ := range mss { + for k := range mss { t.Assert("Mars", mss[k]["Name"]) t.Assert("奥林帕斯山", mss[k]["Place"]) } @@ -321,7 +321,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(jsons, &msa) t.AssertNil(err) t.Assert(len(msa), 2) - for k, _ := range msa { + for k := range msa { t.Assert("Mars", msa[k]["Name"]) t.Assert("奥林帕斯山", msa[k]["Place"]) } @@ -336,7 +336,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(jsons, &ss) t.AssertNil(err) t.Assert(len(ss), 2) - for k, _ := range ss { + for k := range ss { t.Assert("Mars", ss[k].Name) t.Assert("奥林帕斯山", ss[k].Place) } @@ -345,7 +345,7 @@ func TestScan(t *testing.T) { err = gconv.Scan(jsons, &ssp) t.AssertNil(err) t.Assert(len(ssp), 2) - for k, _ := range ssp { + for k := range ssp { t.Assert("Mars", ssp[k].Name) t.Assert("奥林帕斯山", ssp[k].Place) } diff --git a/util/gvalid/gvalid_z_unit_issue_test.go b/util/gvalid/gvalid_z_unit_issue_test.go index 38aea073937..3e9490226ec 100644 --- a/util/gvalid/gvalid_z_unit_issue_test.go +++ b/util/gvalid/gvalid_z_unit_issue_test.go @@ -110,7 +110,7 @@ func Test_Issue3636(t *testing.T) { c.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) t.Assert( c.PostContent(ctx, "/hello", `{"name": "t", "s" : []}`), - `{"code":0,"message":"","data":{"name":"t","s":[]}}`, + `{"code":0,"message":"OK","data":{"name":"t","s":[]}}`, ) }) } diff --git a/util/gvalid/internal/builtin/builtin_between.go b/util/gvalid/internal/builtin/builtin_between.go index ebfcdbf6407..c14f04130a7 100644 --- a/util/gvalid/internal/builtin/builtin_between.go +++ b/util/gvalid/internal/builtin/builtin_between.go @@ -39,16 +39,16 @@ func (r RuleBetween) Run(in RunInput) error { max = float64(0) ) if len(array) > 0 { - if v, err := strconv.ParseFloat(strings.TrimSpace(array[0]), 10); err == nil { + if v, err := strconv.ParseFloat(strings.TrimSpace(array[0]), 64); err == nil { min = v } } if len(array) > 1 { - if v, err := strconv.ParseFloat(strings.TrimSpace(array[1]), 10); err == nil { + if v, err := strconv.ParseFloat(strings.TrimSpace(array[1]), 64); err == nil { max = v } } - valueF, err := strconv.ParseFloat(in.Value.String(), 10) + valueF, err := strconv.ParseFloat(in.Value.String(), 64) if valueF < min || valueF > max || err != nil { return errors.New(gstr.ReplaceByMap(in.Message, map[string]string{ "{min}": strconv.FormatFloat(min, 'f', -1, 64), diff --git a/util/gvalid/internal/builtin/builtin_float.go b/util/gvalid/internal/builtin/builtin_float.go index cbf93d5b677..bd273ef3d3a 100644 --- a/util/gvalid/internal/builtin/builtin_float.go +++ b/util/gvalid/internal/builtin/builtin_float.go @@ -30,7 +30,7 @@ func (r RuleFloat) Message() string { } func (r RuleFloat) Run(in RunInput) error { - if _, err := strconv.ParseFloat(in.Value.String(), 10); err == nil { + if _, err := strconv.ParseFloat(in.Value.String(), 64); err == nil { return nil } return errors.New(in.Message) diff --git a/util/gvalid/internal/builtin/builtin_gt.go b/util/gvalid/internal/builtin/builtin_gt.go index 369fff2a07a..7cd523e0d30 100644 --- a/util/gvalid/internal/builtin/builtin_gt.go +++ b/util/gvalid/internal/builtin/builtin_gt.go @@ -37,8 +37,8 @@ func (r RuleGT) Message() string { func (r RuleGT) Run(in RunInput) error { var ( fieldName, fieldValue = gutil.MapPossibleItemByKey(in.Data.Map(), in.RulePattern) - fieldValueN, err1 = strconv.ParseFloat(gconv.String(fieldValue), 10) - valueN, err2 = strconv.ParseFloat(in.Value.String(), 10) + fieldValueN, err1 = strconv.ParseFloat(gconv.String(fieldValue), 64) + valueN, err2 = strconv.ParseFloat(in.Value.String(), 64) ) if valueN <= fieldValueN || err1 != nil || err2 != nil { diff --git a/util/gvalid/internal/builtin/builtin_gte.go b/util/gvalid/internal/builtin/builtin_gte.go index e25a978694a..a197058559d 100644 --- a/util/gvalid/internal/builtin/builtin_gte.go +++ b/util/gvalid/internal/builtin/builtin_gte.go @@ -37,8 +37,8 @@ func (r RuleGTE) Message() string { func (r RuleGTE) Run(in RunInput) error { var ( fieldName, fieldValue = gutil.MapPossibleItemByKey(in.Data.Map(), in.RulePattern) - fieldValueN, err1 = strconv.ParseFloat(gconv.String(fieldValue), 10) - valueN, err2 = strconv.ParseFloat(in.Value.String(), 10) + fieldValueN, err1 = strconv.ParseFloat(gconv.String(fieldValue), 64) + valueN, err2 = strconv.ParseFloat(in.Value.String(), 64) ) if valueN < fieldValueN || err1 != nil || err2 != nil { diff --git a/util/gvalid/internal/builtin/builtin_lt.go b/util/gvalid/internal/builtin/builtin_lt.go index f5ada92450b..4bb67c036f0 100644 --- a/util/gvalid/internal/builtin/builtin_lt.go +++ b/util/gvalid/internal/builtin/builtin_lt.go @@ -37,8 +37,8 @@ func (r RuleLT) Message() string { func (r RuleLT) Run(in RunInput) error { var ( fieldName, fieldValue = gutil.MapPossibleItemByKey(in.Data.Map(), in.RulePattern) - fieldValueN, err1 = strconv.ParseFloat(gconv.String(fieldValue), 10) - valueN, err2 = strconv.ParseFloat(in.Value.String(), 10) + fieldValueN, err1 = strconv.ParseFloat(gconv.String(fieldValue), 64) + valueN, err2 = strconv.ParseFloat(in.Value.String(), 64) ) if valueN >= fieldValueN || err1 != nil || err2 != nil { diff --git a/util/gvalid/internal/builtin/builtin_lte.go b/util/gvalid/internal/builtin/builtin_lte.go index c5511221ee3..428d9922c14 100644 --- a/util/gvalid/internal/builtin/builtin_lte.go +++ b/util/gvalid/internal/builtin/builtin_lte.go @@ -37,8 +37,8 @@ func (r RuleLTE) Message() string { func (r RuleLTE) Run(in RunInput) error { var ( fieldName, fieldValue = gutil.MapPossibleItemByKey(in.Data.Map(), in.RulePattern) - fieldValueN, err1 = strconv.ParseFloat(gconv.String(fieldValue), 10) - valueN, err2 = strconv.ParseFloat(in.Value.String(), 10) + fieldValueN, err1 = strconv.ParseFloat(gconv.String(fieldValue), 64) + valueN, err2 = strconv.ParseFloat(in.Value.String(), 64) ) if valueN > fieldValueN || err1 != nil || err2 != nil { diff --git a/util/gvalid/internal/builtin/builtin_max.go b/util/gvalid/internal/builtin/builtin_max.go index 6dcb3dc3395..6083fad51db 100644 --- a/util/gvalid/internal/builtin/builtin_max.go +++ b/util/gvalid/internal/builtin/builtin_max.go @@ -33,8 +33,8 @@ func (r RuleMax) Message() string { func (r RuleMax) Run(in RunInput) error { var ( - max, err1 = strconv.ParseFloat(in.RulePattern, 10) - valueN, err2 = strconv.ParseFloat(in.Value.String(), 10) + max, err1 = strconv.ParseFloat(in.RulePattern, 64) + valueN, err2 = strconv.ParseFloat(in.Value.String(), 64) ) if valueN > max || err1 != nil || err2 != nil { return errors.New(gstr.Replace(in.Message, "{max}", strconv.FormatFloat(max, 'f', -1, 64))) diff --git a/util/gvalid/internal/builtin/builtin_min.go b/util/gvalid/internal/builtin/builtin_min.go index 5ee370a7f54..2cfd08757e4 100644 --- a/util/gvalid/internal/builtin/builtin_min.go +++ b/util/gvalid/internal/builtin/builtin_min.go @@ -33,8 +33,8 @@ func (r RuleMin) Message() string { func (r RuleMin) Run(in RunInput) error { var ( - min, err1 = strconv.ParseFloat(in.RulePattern, 10) - valueN, err2 = strconv.ParseFloat(in.Value.String(), 10) + min, err1 = strconv.ParseFloat(in.RulePattern, 64) + valueN, err2 = strconv.ParseFloat(in.Value.String(), 64) ) if valueN < min || err1 != nil || err2 != nil { return errors.New(gstr.Replace(in.Message, "{min}", strconv.FormatFloat(min, 'f', -1, 64))) From bda42d18ee9fe73184e5e8696f86814079d32d46 Mon Sep 17 00:00:00 2001 From: ywanbing Date: Thu, 27 Feb 2025 14:21:40 +0800 Subject: [PATCH 089/102] feat(cmd/gf): add controller comment support for command `gf gen ctrl` (#4169) --- .../internal/cmd/genctrl/genctrl_api_item.go | 16 +++++++++- .../internal/cmd/genctrl/genctrl_ast_parse.go | 27 +++++++++++++---- .../internal/cmd/genctrl/genctrl_calculate.go | 5 ++-- .../cmd/genctrl/genctrl_generate_ctrl.go | 29 ++++++++++--------- .../cmd/genctrl/genctrl_generate_sdk.go | 1 + .../testdata/genctrl/api/article/v1/edit.go | 1 + .../controller/article/article_v1_create.go | 1 + .../consts/consts_gen_ctrl_template.go | 4 +-- .../consts/consts_gen_ctrl_template_sdk.go | 2 +- 9 files changed, 62 insertions(+), 24 deletions(-) diff --git a/cmd/gf/internal/cmd/genctrl/genctrl_api_item.go b/cmd/gf/internal/cmd/genctrl/genctrl_api_item.go index b495e262440..c502e3eeaec 100644 --- a/cmd/gf/internal/cmd/genctrl/genctrl_api_item.go +++ b/cmd/gf/internal/cmd/genctrl/genctrl_api_item.go @@ -6,7 +6,11 @@ package genctrl -import "github.com/gogf/gf/v2/text/gstr" +import ( + "fmt" + + "github.com/gogf/gf/v2/text/gstr" +) type apiItem struct { Import string `eg:"demo.com/api/user/v1"` @@ -14,6 +18,7 @@ type apiItem struct { Module string `eg:"user"` Version string `eg:"v1"` MethodName string `eg:"GetList"` + Comment string `eg:"GetList get list"` } func (a apiItem) String() string { @@ -21,3 +26,12 @@ func (a apiItem) String() string { a.Import, a.Module, a.Version, a.MethodName, }, ",") } + +// GetComment returns the comment of apiItem. +func (a apiItem) GetComment() string { + if a.Comment == "" { + return "" + } + // format for handling comments + return fmt.Sprintf("\n// %s %s", a.MethodName, a.Comment) +} diff --git a/cmd/gf/internal/cmd/genctrl/genctrl_ast_parse.go b/cmd/gf/internal/cmd/genctrl/genctrl_ast_parse.go index cf27089cb2f..9f87bf57400 100644 --- a/cmd/gf/internal/cmd/genctrl/genctrl_ast_parse.go +++ b/cmd/gf/internal/cmd/genctrl/genctrl_ast_parse.go @@ -17,9 +17,14 @@ import ( "github.com/gogf/gf/v2/text/gstr" ) -// getStructsNameInSrc retrieves all struct names +type structInfo struct { + structName string + comment string +} + +// getStructsNameInSrc retrieves all struct names and comment // that end in "Req" and have "g.Meta" in their body. -func (c CGenCtrl) getStructsNameInSrc(filePath string) (structsName []string, err error) { +func (c CGenCtrl) getStructsNameInSrc(filePath string) (structInfos []*structInfo, err error) { var ( fileContent = gfile.GetContents(filePath) fileSet = token.NewFileSet() @@ -32,8 +37,8 @@ func (c CGenCtrl) getStructsNameInSrc(filePath string) (structsName []string, er ast.Inspect(node, func(n ast.Node) bool { if typeSpec, ok := n.(*ast.TypeSpec); ok { - methodName := typeSpec.Name.Name - if !gstr.HasSuffix(methodName, "Req") { + structName := typeSpec.Name.Name + if !gstr.HasSuffix(structName, "Req") { // ignore struct name that do not end in "Req" return true } @@ -46,7 +51,19 @@ func (c CGenCtrl) getStructsNameInSrc(filePath string) (structsName []string, er if !gstr.Contains(buf.String(), `g.Meta`) { return true } - structsName = append(structsName, methodName) + + comment := typeSpec.Doc.Text() + // remove the struct name from the comment + if gstr.HasPrefix(comment, structName) { + comment = gstr.TrimLeftStr(comment, structName, 1) + } + // remove the comment \n or space + comment = gstr.Trim(comment) + + structInfos = append(structInfos, &structInfo{ + structName: structName, + comment: comment, + }) } } return true diff --git a/cmd/gf/internal/cmd/genctrl/genctrl_calculate.go b/cmd/gf/internal/cmd/genctrl/genctrl_calculate.go index db27022ee25..8e53f9e5fb8 100644 --- a/cmd/gf/internal/cmd/genctrl/genctrl_calculate.go +++ b/cmd/gf/internal/cmd/genctrl/genctrl_calculate.go @@ -39,15 +39,16 @@ func (c CGenCtrl) getApiItemsInSrc(apiModuleFolderPath string) (items []apiItem, if err != nil { return nil, err } - for _, methodName := range structsInfo { + for _, s := range structsInfo { // remove end "Req" - methodName = gstr.TrimRightStr(methodName, "Req", 1) + methodName := gstr.TrimRightStr(s.structName, "Req", 1) item := apiItem{ Import: gstr.Trim(importPath, `"`), FileName: gfile.Name(apiFileFolderPath), Module: gfile.Basename(apiModuleFolderPath), Version: gfile.Basename(apiVersionFolderPath), MethodName: methodName, + Comment: s.comment, } items = append(items, item) } diff --git a/cmd/gf/internal/cmd/genctrl/genctrl_generate_ctrl.go b/cmd/gf/internal/cmd/genctrl/genctrl_generate_ctrl.go index 6c427462f7c..047dbb74070 100644 --- a/cmd/gf/internal/cmd/genctrl/genctrl_generate_ctrl.go +++ b/cmd/gf/internal/cmd/genctrl/genctrl_generate_ctrl.go @@ -138,10 +138,11 @@ func (c *controllerGenerator) doGenerateCtrlItem(dstModuleFolderPath string, ite if gfile.Exists(methodFilePath) { content = gstr.ReplaceByMap(consts.TemplateGenCtrlControllerMethodFuncMerge, g.MapStrStr{ - "{Module}": item.Module, - "{CtrlName}": ctrlName, - "{Version}": item.Version, - "{MethodName}": item.MethodName, + "{Module}": item.Module, + "{CtrlName}": ctrlName, + "{Version}": item.Version, + "{MethodName}": item.MethodName, + "{MethodComment}": item.GetComment(), }) if gstr.Contains(gfile.GetContents(methodFilePath), fmt.Sprintf(`func (c *%v) %v(`, ctrlName, item.MethodName)) { @@ -152,11 +153,12 @@ func (c *controllerGenerator) doGenerateCtrlItem(dstModuleFolderPath string, ite } } else { content = gstr.ReplaceByMap(consts.TemplateGenCtrlControllerMethodFunc, g.MapStrStr{ - "{Module}": item.Module, - "{ImportPath}": item.Import, - "{CtrlName}": ctrlName, - "{Version}": item.Version, - "{MethodName}": item.MethodName, + "{Module}": item.Module, + "{ImportPath}": item.Import, + "{CtrlName}": ctrlName, + "{Version}": item.Version, + "{MethodName}": item.MethodName, + "{MethodComment}": item.GetComment(), }) if err = gfile.PutContents(methodFilePath, gstr.TrimLeft(content)); err != nil { return err @@ -192,10 +194,11 @@ func (c *controllerGenerator) doGenerateCtrlMergeItem(dstModuleFolderPath string } ctrl := gstr.TrimLeft(gstr.ReplaceByMap(consts.TemplateGenCtrlControllerMethodFuncMerge, g.MapStrStr{ - "{Module}": api.Module, - "{CtrlName}": fmt.Sprintf(`Controller%s`, gstr.UcFirst(api.Version)), - "{Version}": api.Version, - "{MethodName}": api.MethodName, + "{Module}": api.Module, + "{CtrlName}": fmt.Sprintf(`Controller%s`, gstr.UcFirst(api.Version)), + "{Version}": api.Version, + "{MethodName}": api.MethodName, + "{MethodComment}": api.GetComment(), })) ctrlFileItem.controllers.WriteString(ctrl) doneApiSet.Add(api.String()) diff --git a/cmd/gf/internal/cmd/genctrl/genctrl_generate_sdk.go b/cmd/gf/internal/cmd/genctrl/genctrl_generate_sdk.go index 1e79266b085..df6996b089a 100644 --- a/cmd/gf/internal/cmd/genctrl/genctrl_generate_sdk.go +++ b/cmd/gf/internal/cmd/genctrl/genctrl_generate_sdk.go @@ -180,6 +180,7 @@ func (c *apiSdkGenerator) doGenerateSdkImplementer( "{Version}": item.Version, "{MethodName}": item.MethodName, "{ImplementerName}": implementerName, + "{MethodComment}": item.GetComment(), })) implementerFileContent += "\n" } diff --git a/cmd/gf/internal/cmd/testdata/genctrl/api/article/v1/edit.go b/cmd/gf/internal/cmd/testdata/genctrl/api/article/v1/edit.go index 9e893d87cda..195ceda0f64 100644 --- a/cmd/gf/internal/cmd/testdata/genctrl/api/article/v1/edit.go +++ b/cmd/gf/internal/cmd/testdata/genctrl/api/article/v1/edit.go @@ -9,6 +9,7 @@ package v1 import "github.com/gogf/gf/v2/frame/g" type ( + // CreateReq add title. CreateReq struct { g.Meta `path:"/article/create" method:"post" tags:"ArticleService"` Title string `v:"required"` diff --git a/cmd/gf/internal/cmd/testdata/genctrl/controller/article/article_v1_create.go b/cmd/gf/internal/cmd/testdata/genctrl/controller/article/article_v1_create.go index 48bfcefb910..f5e39b5afd9 100644 --- a/cmd/gf/internal/cmd/testdata/genctrl/controller/article/article_v1_create.go +++ b/cmd/gf/internal/cmd/testdata/genctrl/controller/article/article_v1_create.go @@ -9,6 +9,7 @@ import ( "github.com/gogf/gf/cmd/gf/v2/internal/cmd/testdata/genctrl/api/article/v1" ) +// Create add title. func (c *ControllerV1) Create(ctx context.Context, req *v1.CreateReq) (res *v1.CreateRes, err error) { return nil, gerror.NewCode(gcode.CodeNotImplemented) } diff --git a/cmd/gf/internal/consts/consts_gen_ctrl_template.go b/cmd/gf/internal/consts/consts_gen_ctrl_template.go index da0429ee9bd..ac6ee7d8808 100644 --- a/cmd/gf/internal/consts/consts_gen_ctrl_template.go +++ b/cmd/gf/internal/consts/consts_gen_ctrl_template.go @@ -45,7 +45,7 @@ import ( "{ImportPath}" ) - +{MethodComment} func (c *{CtrlName}) {MethodName}(ctx context.Context, req *{Version}.{MethodName}Req) (res *{Version}.{MethodName}Res, err error) { return nil, gerror.NewCode(gcode.CodeNotImplemented) } @@ -66,7 +66,7 @@ import ( ` const TemplateGenCtrlControllerMethodFuncMerge = ` - +{MethodComment} func (c *{CtrlName}) {MethodName}(ctx context.Context, req *{Version}.{MethodName}Req) (res *{Version}.{MethodName}Res, err error) { return nil, gerror.NewCode(gcode.CodeNotImplemented) } diff --git a/cmd/gf/internal/consts/consts_gen_ctrl_template_sdk.go b/cmd/gf/internal/consts/consts_gen_ctrl_template_sdk.go index 09f3795e393..f2c46701a75 100644 --- a/cmd/gf/internal/consts/consts_gen_ctrl_template_sdk.go +++ b/cmd/gf/internal/consts/consts_gen_ctrl_template_sdk.go @@ -81,7 +81,7 @@ func (i *implementer) {ImplementerName}() {Module}.I{ImplementerName} { ` -const TemplateGenCtrlSdkImplementerFunc = ` +const TemplateGenCtrlSdkImplementerFunc = `{MethodComment} func (i *implementer{ImplementerName}) {MethodName}(ctx context.Context, req *{Version}.{MethodName}Req) (res *{Version}.{MethodName}Res, err error) { err = i.Request(ctx, req, &res) return From 2d3ab4f9fb818a5fc8fdeaac9744def67892545a Mon Sep 17 00:00:00 2001 From: John Guo Date: Thu, 27 Feb 2025 14:35:00 +0800 Subject: [PATCH 090/102] feat: add submodule `examples` (#4137) --- .github/workflows/ci-main.sh | 13 +- .github/workflows/ci-main.yml | 10 +- .github/workflows/ci-sub.yml | 2 +- .github/workflows/nacos/docker-compose.yml | 2 +- .gitignore | 1 - .gitmodules | 3 + CONTRIBUTING.md | 15 + Makefile | 28 + contrib/config/apollo/go.mod | 2 +- contrib/config/apollo/go.sum | 4 +- contrib/config/kubecm/go.mod | 6 +- contrib/config/kubecm/go.sum | 12 +- contrib/config/nacos/go.mod | 20 +- contrib/config/nacos/go.sum | 423 +---- contrib/config/polaris/go.mod | 22 +- contrib/config/polaris/go.sum | 36 +- contrib/drivers/clickhouse/go.mod | 2 +- contrib/drivers/clickhouse/go.sum | 4 +- contrib/drivers/dm/go.mod | 2 +- contrib/drivers/dm/go.sum | 4 +- contrib/drivers/mssql/go.mod | 4 +- contrib/drivers/mssql/go.sum | 8 +- contrib/drivers/mysql/go.mod | 2 +- contrib/drivers/mysql/go.sum | 4 +- contrib/drivers/oracle/go.mod | 2 +- contrib/drivers/oracle/go.sum | 4 +- contrib/drivers/pgsql/go.mod | 2 +- contrib/drivers/pgsql/go.sum | 4 +- contrib/drivers/sqlite/go.mod | 2 +- contrib/drivers/sqlite/go.sum | 4 +- contrib/drivers/sqlitecgo/go.mod | 2 +- contrib/drivers/sqlitecgo/go.sum | 4 +- contrib/metric/otelmetric/go.mod | 4 +- contrib/metric/otelmetric/go.sum | 8 +- contrib/nosql/redis/go.mod | 4 +- contrib/nosql/redis/go.sum | 8 +- contrib/registry/consul/go.sum | 4 +- contrib/registry/etcd/go.mod | 6 +- contrib/registry/etcd/go.sum | 32 +- contrib/registry/file/go.mod | 2 +- contrib/registry/file/go.sum | 4 +- contrib/registry/nacos/go.mod | 20 +- contrib/registry/nacos/go.sum | 436 +---- contrib/registry/polaris/go.mod | 4 +- contrib/registry/polaris/go.sum | 8 +- contrib/registry/zookeeper/go.mod | 2 +- contrib/registry/zookeeper/go.sum | 4 +- contrib/rpc/grpcx/go.mod | 2 +- contrib/rpc/grpcx/go.sum | 4 +- contrib/sdk/httpclient/go.mod | 2 +- contrib/sdk/httpclient/go.sum | 4 +- example/balancer/http/client/client.go | 27 - example/balancer/http/server/server.go | 26 - example/balancer/polaris/README.md | 3 - example/balancer/polaris/client/client.go | 45 - example/balancer/polaris/server/server.go | 39 - example/config/apollo/boot/boot.go | 34 - example/config/apollo/main.go | 27 - example/config/consul/boot/boot.go | 42 - example/config/consul/main.go | 27 - example/config/kubecm/boot_in_pod/boot.go | 37 - example/config/kubecm/boot_out_pod/boot.go | 51 - example/config/kubecm/main.go | 27 - example/config/nacos/boot/boot.go | 46 - example/config/nacos/main.go | 27 - example/config/polaris/boot/boot.go | 39 - example/config/polaris/main.go | 27 - example/config/polaris/testdata/polaris.yaml | 11 - .../alias-type-convert-with-refer/main.go | 58 - example/converter/alias-type-scan/main.go | 72 - .../struct-convert-with-refer/main.go | 54 - example/converter/struct-scan/main.go | 68 - .../config.yaml | 3 - .../driver-encrypt-decrypt-password/main.go | 83 - example/go.mod | 181 --- example/go.sum | 1417 ----------------- example/httpserver/default-value/main.go | 47 - example/httpserver/proxy/main.go | 63 - example/httpserver/rate/main.go | 59 - .../response-with-json-array/controller.go | 40 - .../response-with-json-array/main.go | 29 - example/httpserver/serve-file/main.go | 45 - .../swagger-set-template/config.yaml | 4 - .../httpserver/swagger-set-template/main.go | 121 -- example/httpserver/swagger/config.yaml | 4 - example/httpserver/swagger/main.go | 58 - example/httpserver/upload-file/main.go | 44 - example/metric/basic/main.go | 137 -- example/metric/callback/main.go | 79 - example/metric/dynamic_attributes/main.go | 88 - example/metric/global_attributes/main.go | 93 -- example/metric/http_client/main.go | 45 - example/metric/http_server/main.go | 55 - example/metric/meter_attributes/main.go | 89 -- example/metric/prometheus/prometheus.go | 57 - example/nosql/redis/adapter/main.go | 52 - .../redis/configuration/basic/config.yaml | 4 - .../nosql/redis/configuration/basic/main.go | 29 - .../nosql/redis/configuration/senior/main.go | 40 - example/nosql/redis/expire/config.yaml | 4 - example/nosql/redis/expire/main.go | 40 - example/nosql/redis/hmset/config.yaml | 4 - example/nosql/redis/hmset/main.go | 36 - example/nosql/redis/hset/config.yaml | 4 - example/nosql/redis/hset/main.go | 50 - example/nosql/redis/key-value/config.yaml | 4 - example/nosql/redis/key-value/main.go | 29 - example/os/cron/linux-crontab/main.go | 39 - example/os/log/ctx-keys/config.yaml | 4 - example/os/log/ctx-keys/main.go | 20 - example/os/log/rotate/config.toml | 8 - example/os/log/rotate/main.go | 29 - example/pack/hack/config.yaml | 9 - example/pack/main.go | 38 - example/pack/manifest/i18n/ja.yaml | 2 - example/pack/manifest/i18n/ru.yaml | 2 - example/pack/manifest/i18n/zh-CN.yaml | 2 - example/pack/packed/packed.go | 7 - example/pack/resource/public/index.html | 8 - example/registry/consul/grpc/client/client.go | 39 - .../consul/grpc/controller/helloworld.go | 28 - .../consul/grpc/protobuf/helloworld.pb.go | 217 --- .../consul/grpc/protobuf/helloworld.proto | 24 - .../grpc/protobuf/helloworld_grpc.pb.go | 107 -- .../registry/consul/grpc/server/config.yaml | 8 - example/registry/consul/grpc/server/server.go | 30 - example/registry/consul/http/client/client.go | 29 - example/registry/consul/http/server/server.go | 32 - example/registry/etcd/grpc/client/client.go | 44 - .../etcd/grpc/controller/helloworld.go | 28 - .../etcd/grpc/protobuf/helloworld.pb.go | 217 --- .../etcd/grpc/protobuf/helloworld.proto | 24 - .../etcd/grpc/protobuf/helloworld_grpc.pb.go | 107 -- example/registry/etcd/grpc/server/config.yaml | 8 - example/registry/etcd/grpc/server/server.go | 22 - example/registry/etcd/http/client/client.go | 22 - example/registry/etcd/http/server/server.go | 26 - example/registry/file/client/client.go | 34 - example/registry/file/server/server.go | 27 - example/registry/nacos/grpc/client/client.go | 33 - .../nacos/grpc/controller/helloworld.go | 28 - .../nacos/grpc/protobuf/helloworld.pb.go | 217 --- .../nacos/grpc/protobuf/helloworld.proto | 24 - .../nacos/grpc/protobuf/helloworld_grpc.pb.go | 107 -- .../registry/nacos/grpc/server/config.yaml | 8 - example/registry/nacos/grpc/server/server.go | 24 - example/registry/nacos/http/client/client.go | 22 - example/registry/nacos/http/server/server.go | 26 - example/registry/polaris/client/client.go | 42 - example/registry/polaris/server/server.go | 38 - example/rpc/grpcx/balancer/client/client.go | 35 - .../grpcx/balancer/controller/helloworld.go | 28 - .../grpcx/balancer/protobuf/helloworld.pb.go | 217 --- .../grpcx/balancer/protobuf/helloworld.proto | 24 - .../balancer/protobuf/helloworld_grpc.pb.go | 107 -- example/rpc/grpcx/balancer/server/config.yaml | 8 - example/rpc/grpcx/balancer/server/server.go | 19 - example/rpc/grpcx/basic/client/client.go | 30 - .../rpc/grpcx/basic/controller/helloworld.go | 28 - .../rpc/grpcx/basic/protobuf/helloworld.pb.go | 217 --- .../rpc/grpcx/basic/protobuf/helloworld.proto | 24 - .../basic/protobuf/helloworld_grpc.pb.go | 107 -- example/rpc/grpcx/basic/server/config.yaml | 8 - example/rpc/grpcx/basic/server/server.go | 19 - example/rpc/grpcx/ctx/client/client.go | 34 - .../rpc/grpcx/ctx/controller/helloworld.go | 32 - .../rpc/grpcx/ctx/protobuf/helloworld.pb.go | 217 --- .../rpc/grpcx/ctx/protobuf/helloworld.proto | 24 - .../grpcx/ctx/protobuf/helloworld_grpc.pb.go | 107 -- example/rpc/grpcx/ctx/server/config.yaml | 8 - example/rpc/grpcx/ctx/server/server.go | 19 - example/rpc/grpcx/rawgrpc/client/client.go | 55 - .../grpcx/rawgrpc/helloworld/helloworld.pb.go | 234 --- .../grpcx/rawgrpc/helloworld/helloworld.proto | 25 - .../rawgrpc/helloworld/helloworld_grpc.pb.go | 107 -- example/rpc/grpcx/rawgrpc/server/server.go | 71 - example/rpc/grpcx/resolver/client/client.go | 33 - .../grpcx/resolver/controller/helloworld.go | 28 - .../grpcx/resolver/protobuf/helloworld.pb.go | 217 --- .../grpcx/resolver/protobuf/helloworld.proto | 24 - .../resolver/protobuf/helloworld_grpc.pb.go | 107 -- example/rpc/grpcx/resolver/server/config.yaml | 8 - example/rpc/grpcx/resolver/server/server.go | 22 - example/tcp/server/proxy/main.go | 99 -- example/trace/README.MD | 80 - example/trace/grpc-with-db/client/client.go | 89 -- .../grpc-with-db/protobuf/user/user.pb.go | 469 ------ .../grpc-with-db/protobuf/user/user.proto | 35 - .../protobuf/user/user_grpc.pb.go | 188 --- example/trace/grpc-with-db/server/config.yaml | 31 - example/trace/grpc-with-db/server/server.go | 101 -- example/trace/grpc-with-db/sql.sql | 6 - example/trace/http-with-db/client/client.go | 89 -- example/trace/http-with-db/server/config.yaml | 23 - example/trace/http-with-db/server/server.go | 130 -- example/trace/http-with-db/sql.sql | 6 - example/trace/http/client/client.go | 45 - example/trace/http/server/server.go | 51 - example/trace/inprocess-grpc/main.go | 102 -- example/trace/inprocess/main.go | 102 -- example/trace/otlp/README.md | 21 - example/trace/otlp/grpc/main.go | 46 - example/trace/otlp/http/main.go | 46 - example/trace/processes/gcmd/main.go | 31 - example/trace/processes/gcmd/sub/sub.go | 30 - example/trace/processes/gproc/main.go | 21 - example/trace/processes/gproc/sub/sub.go | 17 - example/trace/provider/grpc/main.go | 114 -- example/trace/provider/http/main.go | 111 -- example/trace/provider/internal/consts.go | 17 - example/trace/provider/internal/provider.go | 57 - example/trace/provider/internal/request.go | 24 - examples | 1 + go.mod | 2 +- go.sum | 4 +- net/gclient/gclient_websocket.go | 4 + 216 files changed, 260 insertions(+), 11120 deletions(-) create mode 100644 .gitmodules create mode 100644 CONTRIBUTING.md delete mode 100644 example/balancer/http/client/client.go delete mode 100644 example/balancer/http/server/server.go delete mode 100644 example/balancer/polaris/README.md delete mode 100644 example/balancer/polaris/client/client.go delete mode 100644 example/balancer/polaris/server/server.go delete mode 100644 example/config/apollo/boot/boot.go delete mode 100644 example/config/apollo/main.go delete mode 100644 example/config/consul/boot/boot.go delete mode 100644 example/config/consul/main.go delete mode 100644 example/config/kubecm/boot_in_pod/boot.go delete mode 100644 example/config/kubecm/boot_out_pod/boot.go delete mode 100644 example/config/kubecm/main.go delete mode 100644 example/config/nacos/boot/boot.go delete mode 100644 example/config/nacos/main.go delete mode 100644 example/config/polaris/boot/boot.go delete mode 100644 example/config/polaris/main.go delete mode 100644 example/config/polaris/testdata/polaris.yaml delete mode 100644 example/converter/alias-type-convert-with-refer/main.go delete mode 100644 example/converter/alias-type-scan/main.go delete mode 100644 example/converter/struct-convert-with-refer/main.go delete mode 100644 example/converter/struct-scan/main.go delete mode 100644 example/database/mysql/driver-encrypt-decrypt-password/config.yaml delete mode 100644 example/database/mysql/driver-encrypt-decrypt-password/main.go delete mode 100644 example/go.mod delete mode 100644 example/go.sum delete mode 100644 example/httpserver/default-value/main.go delete mode 100644 example/httpserver/proxy/main.go delete mode 100644 example/httpserver/rate/main.go delete mode 100644 example/httpserver/response-with-json-array/controller.go delete mode 100644 example/httpserver/response-with-json-array/main.go delete mode 100644 example/httpserver/serve-file/main.go delete mode 100644 example/httpserver/swagger-set-template/config.yaml delete mode 100644 example/httpserver/swagger-set-template/main.go delete mode 100644 example/httpserver/swagger/config.yaml delete mode 100644 example/httpserver/swagger/main.go delete mode 100644 example/httpserver/upload-file/main.go delete mode 100644 example/metric/basic/main.go delete mode 100644 example/metric/callback/main.go delete mode 100644 example/metric/dynamic_attributes/main.go delete mode 100644 example/metric/global_attributes/main.go delete mode 100644 example/metric/http_client/main.go delete mode 100644 example/metric/http_server/main.go delete mode 100644 example/metric/meter_attributes/main.go delete mode 100644 example/metric/prometheus/prometheus.go delete mode 100644 example/nosql/redis/adapter/main.go delete mode 100644 example/nosql/redis/configuration/basic/config.yaml delete mode 100644 example/nosql/redis/configuration/basic/main.go delete mode 100644 example/nosql/redis/configuration/senior/main.go delete mode 100644 example/nosql/redis/expire/config.yaml delete mode 100644 example/nosql/redis/expire/main.go delete mode 100644 example/nosql/redis/hmset/config.yaml delete mode 100644 example/nosql/redis/hmset/main.go delete mode 100644 example/nosql/redis/hset/config.yaml delete mode 100644 example/nosql/redis/hset/main.go delete mode 100644 example/nosql/redis/key-value/config.yaml delete mode 100644 example/nosql/redis/key-value/main.go delete mode 100644 example/os/cron/linux-crontab/main.go delete mode 100644 example/os/log/ctx-keys/config.yaml delete mode 100644 example/os/log/ctx-keys/main.go delete mode 100644 example/os/log/rotate/config.toml delete mode 100644 example/os/log/rotate/main.go delete mode 100644 example/pack/hack/config.yaml delete mode 100644 example/pack/main.go delete mode 100644 example/pack/manifest/i18n/ja.yaml delete mode 100644 example/pack/manifest/i18n/ru.yaml delete mode 100644 example/pack/manifest/i18n/zh-CN.yaml delete mode 100644 example/pack/packed/packed.go delete mode 100644 example/pack/resource/public/index.html delete mode 100644 example/registry/consul/grpc/client/client.go delete mode 100644 example/registry/consul/grpc/controller/helloworld.go delete mode 100644 example/registry/consul/grpc/protobuf/helloworld.pb.go delete mode 100644 example/registry/consul/grpc/protobuf/helloworld.proto delete mode 100644 example/registry/consul/grpc/protobuf/helloworld_grpc.pb.go delete mode 100644 example/registry/consul/grpc/server/config.yaml delete mode 100644 example/registry/consul/grpc/server/server.go delete mode 100644 example/registry/consul/http/client/client.go delete mode 100644 example/registry/consul/http/server/server.go delete mode 100644 example/registry/etcd/grpc/client/client.go delete mode 100644 example/registry/etcd/grpc/controller/helloworld.go delete mode 100644 example/registry/etcd/grpc/protobuf/helloworld.pb.go delete mode 100644 example/registry/etcd/grpc/protobuf/helloworld.proto delete mode 100644 example/registry/etcd/grpc/protobuf/helloworld_grpc.pb.go delete mode 100644 example/registry/etcd/grpc/server/config.yaml delete mode 100644 example/registry/etcd/grpc/server/server.go delete mode 100644 example/registry/etcd/http/client/client.go delete mode 100644 example/registry/etcd/http/server/server.go delete mode 100644 example/registry/file/client/client.go delete mode 100644 example/registry/file/server/server.go delete mode 100644 example/registry/nacos/grpc/client/client.go delete mode 100644 example/registry/nacos/grpc/controller/helloworld.go delete mode 100644 example/registry/nacos/grpc/protobuf/helloworld.pb.go delete mode 100644 example/registry/nacos/grpc/protobuf/helloworld.proto delete mode 100644 example/registry/nacos/grpc/protobuf/helloworld_grpc.pb.go delete mode 100644 example/registry/nacos/grpc/server/config.yaml delete mode 100644 example/registry/nacos/grpc/server/server.go delete mode 100644 example/registry/nacos/http/client/client.go delete mode 100644 example/registry/nacos/http/server/server.go delete mode 100644 example/registry/polaris/client/client.go delete mode 100644 example/registry/polaris/server/server.go delete mode 100644 example/rpc/grpcx/balancer/client/client.go delete mode 100644 example/rpc/grpcx/balancer/controller/helloworld.go delete mode 100644 example/rpc/grpcx/balancer/protobuf/helloworld.pb.go delete mode 100644 example/rpc/grpcx/balancer/protobuf/helloworld.proto delete mode 100644 example/rpc/grpcx/balancer/protobuf/helloworld_grpc.pb.go delete mode 100644 example/rpc/grpcx/balancer/server/config.yaml delete mode 100644 example/rpc/grpcx/balancer/server/server.go delete mode 100644 example/rpc/grpcx/basic/client/client.go delete mode 100644 example/rpc/grpcx/basic/controller/helloworld.go delete mode 100644 example/rpc/grpcx/basic/protobuf/helloworld.pb.go delete mode 100644 example/rpc/grpcx/basic/protobuf/helloworld.proto delete mode 100644 example/rpc/grpcx/basic/protobuf/helloworld_grpc.pb.go delete mode 100644 example/rpc/grpcx/basic/server/config.yaml delete mode 100644 example/rpc/grpcx/basic/server/server.go delete mode 100644 example/rpc/grpcx/ctx/client/client.go delete mode 100644 example/rpc/grpcx/ctx/controller/helloworld.go delete mode 100644 example/rpc/grpcx/ctx/protobuf/helloworld.pb.go delete mode 100644 example/rpc/grpcx/ctx/protobuf/helloworld.proto delete mode 100644 example/rpc/grpcx/ctx/protobuf/helloworld_grpc.pb.go delete mode 100644 example/rpc/grpcx/ctx/server/config.yaml delete mode 100644 example/rpc/grpcx/ctx/server/server.go delete mode 100644 example/rpc/grpcx/rawgrpc/client/client.go delete mode 100644 example/rpc/grpcx/rawgrpc/helloworld/helloworld.pb.go delete mode 100644 example/rpc/grpcx/rawgrpc/helloworld/helloworld.proto delete mode 100644 example/rpc/grpcx/rawgrpc/helloworld/helloworld_grpc.pb.go delete mode 100644 example/rpc/grpcx/rawgrpc/server/server.go delete mode 100644 example/rpc/grpcx/resolver/client/client.go delete mode 100644 example/rpc/grpcx/resolver/controller/helloworld.go delete mode 100644 example/rpc/grpcx/resolver/protobuf/helloworld.pb.go delete mode 100644 example/rpc/grpcx/resolver/protobuf/helloworld.proto delete mode 100644 example/rpc/grpcx/resolver/protobuf/helloworld_grpc.pb.go delete mode 100644 example/rpc/grpcx/resolver/server/config.yaml delete mode 100644 example/rpc/grpcx/resolver/server/server.go delete mode 100644 example/tcp/server/proxy/main.go delete mode 100644 example/trace/README.MD delete mode 100644 example/trace/grpc-with-db/client/client.go delete mode 100644 example/trace/grpc-with-db/protobuf/user/user.pb.go delete mode 100644 example/trace/grpc-with-db/protobuf/user/user.proto delete mode 100644 example/trace/grpc-with-db/protobuf/user/user_grpc.pb.go delete mode 100644 example/trace/grpc-with-db/server/config.yaml delete mode 100644 example/trace/grpc-with-db/server/server.go delete mode 100644 example/trace/grpc-with-db/sql.sql delete mode 100644 example/trace/http-with-db/client/client.go delete mode 100644 example/trace/http-with-db/server/config.yaml delete mode 100644 example/trace/http-with-db/server/server.go delete mode 100644 example/trace/http-with-db/sql.sql delete mode 100644 example/trace/http/client/client.go delete mode 100644 example/trace/http/server/server.go delete mode 100644 example/trace/inprocess-grpc/main.go delete mode 100644 example/trace/inprocess/main.go delete mode 100644 example/trace/otlp/README.md delete mode 100644 example/trace/otlp/grpc/main.go delete mode 100644 example/trace/otlp/http/main.go delete mode 100644 example/trace/processes/gcmd/main.go delete mode 100644 example/trace/processes/gcmd/sub/sub.go delete mode 100644 example/trace/processes/gproc/main.go delete mode 100644 example/trace/processes/gproc/sub/sub.go delete mode 100644 example/trace/provider/grpc/main.go delete mode 100644 example/trace/provider/http/main.go delete mode 100644 example/trace/provider/internal/consts.go delete mode 100644 example/trace/provider/internal/provider.go delete mode 100644 example/trace/provider/internal/request.go create mode 160000 examples diff --git a/.github/workflows/ci-main.sh b/.github/workflows/ci-main.sh index 21891888024..7123b851ad3 100644 --- a/.github/workflows/ci-main.sh +++ b/.github/workflows/ci-main.sh @@ -2,6 +2,9 @@ coverage=$1 +# update code of submodules +make subup + # find all path that contains go.mod. for file in `find . -name go.mod`; do dirpath=$(dirname $file) @@ -18,16 +21,16 @@ for file in `find . -name go.mod`; do continue 1 fi - # Check if it's a contrib directory or example directory - if [[ $dirpath =~ "/contrib/" ]] || [ "example" = $(basename $dirpath) ]; then + # Check if it's a contrib directory or examples directory + if [[ $dirpath =~ "/contrib/" ]] || [ "examples" = $(basename $dirpath) ]; then # Check if go version meets the requirement if ! go version | grep -qE "go${LATEST_GO_VERSION}"; then echo "ignore path $dirpath as go version is not ${LATEST_GO_VERSION}: $(go version)" continue 1 fi - # If it's example directory, only build without tests - if [ "example" = $(basename $dirpath) ]; then - echo "the example directory only needs to be built, not unit tests and coverage tests." + # If it's examples directory, only build without tests + if [ "examples" = $(basename $dirpath) ]; then + echo "the examples directory only needs to be built, not unit tests and coverage tests." cd $dirpath go mod tidy go build ./... diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index a2860760fff..3f5cf22e536 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -40,7 +40,7 @@ jobs: # 1. Update the `LATEST_GO_VERSION` env variable. # 2. Update the `Report Coverage` action. # 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥 - go-version: [ "1.20", "1.21", "1.22", "1.23" ] + go-version: [ "1.22", "1.23" ] goarch: [ "386", "amd64" ] runs-on: ubuntu-20.04 @@ -157,13 +157,9 @@ jobs: # Polaris backend server. # docker run -d --name polaris \ # -p 8090:8090 -p 8091:8091 -p 8093:8093 -p 9090:9090 -p 9091:9091 \ - # loads/polaris-server-standalone:1.11.2 - # - # docker run -d --name polaris \ - # -p 8090:8090 -p 8091:8091 -p 8093:8093 -p 9090:9090 -p 9091:9091 \ - # loads/polaris-standalone:v1.16.3 + # polarismesh/polaris-standalone:v1.17.2 polaris: - image: loads/polaris-standalone:v1.17.2 + image: polarismesh/polaris-standalone:v1.17.2 ports: - 8090:8090 - 8091:8091 diff --git a/.github/workflows/ci-sub.yml b/.github/workflows/ci-sub.yml index 5b98814ef36..6a1244385c1 100644 --- a/.github/workflows/ci-sub.yml +++ b/.github/workflows/ci-sub.yml @@ -40,7 +40,7 @@ jobs: # When adding new go version to the list, make sure: # 1. Update the `LATEST_GO_VERSION` env variable. # 🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥🔥 - go-version: [ "1.20", "1.21", "1.22", "1.23" ] + go-version: [ "1.22", "1.23" ] goarch: [ "386", "amd64" ] runs-on: ubuntu-latest diff --git a/.github/workflows/nacos/docker-compose.yml b/.github/workflows/nacos/docker-compose.yml index 3e69daa7c5a..24b39e3e6d0 100644 --- a/.github/workflows/nacos/docker-compose.yml +++ b/.github/workflows/nacos/docker-compose.yml @@ -17,7 +17,7 @@ services: retries: 10 initializer: - image: loads/curl:latest + image: alpine/curl:latest depends_on: nacos: condition: service_healthy diff --git a/.gitignore b/.gitignore index 2428b8d621d..d18d5fc4aee 100644 --- a/.gitignore +++ b/.gitignore @@ -7,7 +7,6 @@ .settings/ .vscode/ vendor/ -pkg/ bin/ **/.DS_Store .test/ diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 00000000000..895782dadd7 --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "examples"] + path = examples + url = git@github.com:gogf/examples.git diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 00000000000..1d26a21f207 --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,15 @@ +# Contributing + +Thanks for taking the time to join our community and start contributing! + +## With issues +- Use the search tool before opening a new issue. +- Please provide source code and commit sha if you found a bug. +- Review existing issues and provide feedback or react to them. + +## With pull requests +- Open your pull request against `master` +- Your pull request should have no more than two commits, if not you should squash them. +- It should pass all tests in the available continuous integrations systems such as GitHub CI. +- You should add/modify tests to cover your proposed code changes. +- If your pull request contains a new feature, please document it on the README. diff --git a/Makefile b/Makefile index 9d0ee13e91a..46265203a92 100644 --- a/Makefile +++ b/Makefile @@ -8,6 +8,7 @@ tidy: for file in ${files}; do \ goModPath=$$(dirname $$file); \ if ! echo $$goModPath | grep -q "testdata"; then \ + echo "handle: $$goModPath"; \ cd $$goModPath; \ go mod tidy; \ cd -; \ @@ -26,3 +27,30 @@ version: newVersion=$(to); \ ./.set_version.sh ./ $$newVersion; \ echo "make version to=$(to) done" + + +# update submodules +.PHONY: subup +subup: + @set -e; \ + cd examples; \ + echo "Updating submodules..."; \ + git pull origin; \ + cd ..; + +# update and commit submodules +.PHONY: subsync +subsync: subup + @set -e; \ + echo "";\ + cd examples; \ + echo "Checking for changes..."; \ + if git diff-index --quiet HEAD --; then \ + echo "No changes to commit"; \ + else \ + echo "Found changes, committing..."; \ + git add -A; \ + git commit -m "examples update"; \ + git push origin; \ + fi; \ + cd ..; diff --git a/contrib/config/apollo/go.mod b/contrib/config/apollo/go.mod index 7a3f5048128..5c8aa52f773 100644 --- a/contrib/config/apollo/go.mod +++ b/contrib/config/apollo/go.mod @@ -39,7 +39,7 @@ require ( go.opentelemetry.io/otel/metric v1.32.0 // indirect go.opentelemetry.io/otel/sdk v1.32.0 // indirect go.opentelemetry.io/otel/trace v1.32.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.32.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect gopkg.in/ini.v1 v1.62.0 // indirect diff --git a/contrib/config/apollo/go.sum b/contrib/config/apollo/go.sum index e3f48291c3c..6c1ae549b60 100644 --- a/contrib/config/apollo/go.sum +++ b/contrib/config/apollo/go.sum @@ -376,8 +376,8 @@ golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= diff --git a/contrib/config/kubecm/go.mod b/contrib/config/kubecm/go.mod index fb42b6471d5..e21e6e46d36 100644 --- a/contrib/config/kubecm/go.mod +++ b/contrib/config/kubecm/go.mod @@ -25,7 +25,7 @@ require ( github.com/go-openapi/jsonreference v0.20.1 // indirect github.com/go-openapi/swag v0.22.3 // indirect github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/gnostic v0.5.7-v3refs // indirect github.com/google/go-cmp v0.6.0 // indirect github.com/google/gofuzz v1.1.0 // indirect @@ -50,14 +50,14 @@ require ( go.opentelemetry.io/otel/metric v1.32.0 // indirect go.opentelemetry.io/otel/sdk v1.32.0 // indirect go.opentelemetry.io/otel/trace v1.32.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.32.0 // indirect golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/term v0.27.0 // indirect golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.0.0-20220210224613-90d013bbcef8 // indirect google.golang.org/appengine v1.6.7 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/inf.v0 v0.9.1 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/contrib/config/kubecm/go.sum b/contrib/config/kubecm/go.sum index 3d3006f7c55..914341d2bed 100644 --- a/contrib/config/kubecm/go.sum +++ b/contrib/config/kubecm/go.sum @@ -105,8 +105,8 @@ github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QD github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54= @@ -294,8 +294,8 @@ golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81R golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= @@ -486,8 +486,8 @@ google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGj google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/contrib/config/nacos/go.mod b/contrib/config/nacos/go.mod index f3bd124899b..beb5ce58eb1 100644 --- a/contrib/config/nacos/go.mod +++ b/contrib/config/nacos/go.mod @@ -19,7 +19,7 @@ require ( github.com/aliyun/alibabacloud-dkms-transfer-go-sdk v0.1.7 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/buger/jsonparser v1.1.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/clbanning/mxj/v2 v2.7.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/fatih/color v1.18.0 // indirect @@ -27,7 +27,7 @@ require ( github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/golang/mock v1.6.0 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // indirect @@ -37,16 +37,16 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/prometheus/client_golang v1.12.2 // indirect - github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.32.1 // indirect - github.com/prometheus/procfs v0.7.3 // indirect + github.com/prometheus/client_golang v1.19.1 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel v1.32.0 // indirect go.opentelemetry.io/otel/metric v1.32.0 // indirect @@ -61,9 +61,9 @@ require ( golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.1.0 // indirect - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect - google.golang.org/grpc v1.56.3 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect + google.golang.org/grpc v1.59.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/ini.v1 v1.67.0 // indirect gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/contrib/config/nacos/go.sum b/contrib/config/nacos/go.sum index 53887b7c29b..4f40bf72e5d 100644 --- a/contrib/config/nacos/go.sum +++ b/contrib/config/nacos/go.sum @@ -1,47 +1,9 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 h1:NqugFkGxx1TXSh/pBcU00Y6bljgDPaFdh5MUSeJ7e50= github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68/go.mod h1:6pb/Qy8c+lqua8cFpEy7g39NRRqOWc3rOwAy8m5Y2BY= github.com/alibabacloud-go/tea v1.1.0/go.mod h1:IkGyUSX4Ba1V+k4pCtJUc6jDpZLFph9QMy2VUPTwukg= @@ -58,141 +20,57 @@ github.com/aliyun/alibabacloud-dkms-transfer-go-sdk v0.1.7 h1:olLiPI2iM8Hqq6vKnS github.com/aliyun/alibabacloud-dkms-transfer-go-sdk v0.1.7/go.mod h1:oDg1j4kFxnhgftaiLJABkGeSvuEvSF5Lo6UmRAMruX4= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= 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-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A= github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -210,8 +88,6 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -219,8 +95,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/nacos-group/nacos-sdk-go/v2 v2.2.5 h1:r0wwT7PayEjvEHzWXwr1ROi/JSqzujM4w+1L5ikThzQ= github.com/nacos-group/nacos-sdk-go/v2 v2.2.5/go.mod h1:OObBon0prVJVPoIbSZxpEkFiBfL0d1LcBtuAMiNn+8c= github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= @@ -228,48 +104,26 @@ github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b h1:FfH+VrHHk6Lxt9HdVS0PXzSXFyS2NbZKXv33FYPol0A= github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b/go.mod h1:AC62GU6hc0BrNm+9RK9VSiwa/EUe1bkIeFORAMcHvJU= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34= -github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= +github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= @@ -278,15 +132,7 @@ github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaO github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg= github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= @@ -305,198 +151,60 @@ go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= 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.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 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.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.1.0 h1:xYY+Bajn2a7VBmTM5GikTmnK8ZuX8YgnQCqZpbBNtmA= golang.org/x/time v0.1.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -507,106 +215,25 @@ gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJ gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= -google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= +google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= +google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= @@ -614,14 +241,4 @@ gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/contrib/config/polaris/go.mod b/contrib/config/polaris/go.mod index 4760ab8378f..0d11a9bed82 100644 --- a/contrib/config/polaris/go.mod +++ b/contrib/config/polaris/go.mod @@ -12,9 +12,9 @@ require ( require ( github.com/BurntSushi/toml v1.4.0 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/clbanning/mxj/v2 v2.7.0 // indirect - github.com/dlclark/regexp2 v1.7.0 // indirect + github.com/dlclark/regexp2 v1.11.2 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/fatih/color v1.18.0 // indirect github.com/fsnotify/fsnotify v1.7.0 // indirect @@ -24,23 +24,23 @@ require ( github.com/google/uuid v1.6.0 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // indirect - github.com/hashicorp/errwrap v1.0.0 // indirect + github.com/hashicorp/errwrap v1.1.0 // indirect github.com/hashicorp/go-multierror v1.1.1 // 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/mattn/go-runewidth v0.0.16 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/mitchellh/go-homedir v1.1.0 // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/natefinch/lumberjack v2.0.0+incompatible // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/polarismesh/specification v1.4.1 // indirect - github.com/prometheus/client_golang v1.12.2 // indirect - github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.32.1 // indirect - github.com/prometheus/procfs v0.7.3 // indirect + github.com/polarismesh/specification v1.5.1 // indirect + github.com/prometheus/client_golang v1.19.1 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect github.com/rivo/uniseg v0.4.7 // indirect github.com/spaolacci/murmur3 v1.1.0 // indirect go.opentelemetry.io/otel v1.32.0 // indirect @@ -54,8 +54,8 @@ require ( golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect - google.golang.org/grpc v1.56.3 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/grpc v1.59.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/contrib/config/polaris/go.sum b/contrib/config/polaris/go.sum index b2fe843811a..ebc40fcbec8 100644 --- a/contrib/config/polaris/go.sum +++ b/contrib/config/polaris/go.sum @@ -190,8 +190,8 @@ github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= @@ -210,8 +210,9 @@ github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWH github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dlclark/regexp2 v1.7.0 h1:7lJfhqlPssTb1WQx4yvTHN0uElPEv52sbaECrAQxjAo= github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= +github.com/dlclark/regexp2 v1.11.2 h1:/u628IuisSTwri5/UKloiIsH8+qF2Pu7xEQX+yIKg68= +github.com/dlclark/regexp2 v1.11.2/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= @@ -345,8 +346,9 @@ github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/ad github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/hashicorp/errwrap v1.0.0 h1:hLrqtEDnRye3+sgx6z4qVLNuviH3MR5aQ0ykNJa/UYA= github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= +github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= +github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -385,7 +387,6 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= @@ -395,6 +396,8 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM= @@ -409,30 +412,35 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/polarismesh/polaris-go v1.5.8 h1:zBZkZBa4wVxsG5Y/6U4PmY9dY/mddXdfNI65edVu6U8= github.com/polarismesh/polaris-go v1.5.8/go.mod h1:CuXO9bhHGjSoOIMWr4NXf3bJAkRBp5YoM7ibBzENC+c= -github.com/polarismesh/specification v1.4.1 h1:lTZqeyUhhWuKyr6NDKBwmUrNfcUDvKLxWT/uOq71T5A= github.com/polarismesh/specification v1.4.1/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= +github.com/polarismesh/specification v1.5.1 h1:cJ2m0RBepdopGo/e3UpKdsab3NpDZnw5IsVTB1sFc5I= +github.com/polarismesh/specification v1.5.1/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34= github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= +github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= +github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= +github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= @@ -967,8 +975,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= -google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= -google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= +google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= @@ -985,8 +993,8 @@ google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQ google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= diff --git a/contrib/drivers/clickhouse/go.mod b/contrib/drivers/clickhouse/go.mod index 83e2568aa93..06b84525680 100644 --- a/contrib/drivers/clickhouse/go.mod +++ b/contrib/drivers/clickhouse/go.mod @@ -34,7 +34,7 @@ require ( go.opentelemetry.io/otel/metric v1.32.0 // indirect go.opentelemetry.io/otel/sdk v1.32.0 // indirect go.opentelemetry.io/otel/trace v1.32.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.32.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/drivers/clickhouse/go.sum b/contrib/drivers/clickhouse/go.sum index b7b77aed56b..dc4fbd1c516 100644 --- a/contrib/drivers/clickhouse/go.sum +++ b/contrib/drivers/clickhouse/go.sum @@ -113,8 +113,8 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/contrib/drivers/dm/go.mod b/contrib/drivers/dm/go.mod index 168e8355ca4..5182d9399af 100644 --- a/contrib/drivers/dm/go.mod +++ b/contrib/drivers/dm/go.mod @@ -34,7 +34,7 @@ require ( go.opentelemetry.io/otel/metric v1.32.0 // indirect go.opentelemetry.io/otel/sdk v1.32.0 // indirect go.opentelemetry.io/otel/trace v1.32.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.32.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/drivers/dm/go.sum b/contrib/drivers/dm/go.sum index 335b8ca9eed..78ab2888972 100644 --- a/contrib/drivers/dm/go.sum +++ b/contrib/drivers/dm/go.sum @@ -61,8 +61,8 @@ go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5l go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/drivers/mssql/go.mod b/contrib/drivers/mssql/go.mod index 31526f8f36a..80b7e8a0bbb 100644 --- a/contrib/drivers/mssql/go.mod +++ b/contrib/drivers/mssql/go.mod @@ -33,8 +33,8 @@ require ( go.opentelemetry.io/otel/metric v1.32.0 // indirect go.opentelemetry.io/otel/sdk v1.32.0 // indirect go.opentelemetry.io/otel/trace v1.32.0 // indirect - golang.org/x/crypto v0.31.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/crypto v0.30.0 // indirect + golang.org/x/net v0.32.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/drivers/mssql/go.sum b/contrib/drivers/mssql/go.sum index 3b7bdd87631..c385394c417 100644 --- a/contrib/drivers/mssql/go.sum +++ b/contrib/drivers/mssql/go.sum @@ -81,10 +81,10 @@ go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5l go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= -golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= -golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/crypto v0.30.0 h1:RwoQn3GkWiMkzlX562cLB7OxWvjH1L8xutO2WoJcRoY= +golang.org/x/crypto v0.30.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/drivers/mysql/go.mod b/contrib/drivers/mysql/go.mod index a7fac312650..39f0c0f60d4 100644 --- a/contrib/drivers/mysql/go.mod +++ b/contrib/drivers/mysql/go.mod @@ -31,7 +31,7 @@ require ( go.opentelemetry.io/otel/metric v1.32.0 // indirect go.opentelemetry.io/otel/sdk v1.32.0 // indirect go.opentelemetry.io/otel/trace v1.32.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.32.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/drivers/mysql/go.sum b/contrib/drivers/mysql/go.sum index 7ea7cbdccf2..43343e25471 100644 --- a/contrib/drivers/mysql/go.sum +++ b/contrib/drivers/mysql/go.sum @@ -59,8 +59,8 @@ go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5l go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/drivers/oracle/go.mod b/contrib/drivers/oracle/go.mod index 3cd1c1464fe..39bb2f25971 100644 --- a/contrib/drivers/oracle/go.mod +++ b/contrib/drivers/oracle/go.mod @@ -31,7 +31,7 @@ require ( go.opentelemetry.io/otel/metric v1.32.0 // indirect go.opentelemetry.io/otel/sdk v1.32.0 // indirect go.opentelemetry.io/otel/trace v1.32.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.32.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/drivers/oracle/go.sum b/contrib/drivers/oracle/go.sum index 59510f06d3b..7444a9a7ee7 100644 --- a/contrib/drivers/oracle/go.sum +++ b/contrib/drivers/oracle/go.sum @@ -59,8 +59,8 @@ go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5l go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/drivers/pgsql/go.mod b/contrib/drivers/pgsql/go.mod index 19eaa9fc5c9..edbfa4ea18c 100644 --- a/contrib/drivers/pgsql/go.mod +++ b/contrib/drivers/pgsql/go.mod @@ -31,7 +31,7 @@ require ( go.opentelemetry.io/otel/metric v1.32.0 // indirect go.opentelemetry.io/otel/sdk v1.32.0 // indirect go.opentelemetry.io/otel/trace v1.32.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.32.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/drivers/pgsql/go.sum b/contrib/drivers/pgsql/go.sum index b2d17bae0e7..7f021fc7d60 100644 --- a/contrib/drivers/pgsql/go.sum +++ b/contrib/drivers/pgsql/go.sum @@ -59,8 +59,8 @@ go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5l go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/drivers/sqlite/go.mod b/contrib/drivers/sqlite/go.mod index 3efb2c2ea6c..60f434a7242 100644 --- a/contrib/drivers/sqlite/go.mod +++ b/contrib/drivers/sqlite/go.mod @@ -33,7 +33,7 @@ require ( go.opentelemetry.io/otel/metric v1.32.0 // indirect go.opentelemetry.io/otel/sdk v1.32.0 // indirect go.opentelemetry.io/otel/trace v1.32.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.32.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/drivers/sqlite/go.sum b/contrib/drivers/sqlite/go.sum index 0ac24f1872a..d49fc7a19b9 100644 --- a/contrib/drivers/sqlite/go.sum +++ b/contrib/drivers/sqlite/go.sum @@ -66,8 +66,8 @@ go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5l go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/drivers/sqlitecgo/go.mod b/contrib/drivers/sqlitecgo/go.mod index 8a209ce5c40..b806153942a 100644 --- a/contrib/drivers/sqlitecgo/go.mod +++ b/contrib/drivers/sqlitecgo/go.mod @@ -31,7 +31,7 @@ require ( go.opentelemetry.io/otel/metric v1.32.0 // indirect go.opentelemetry.io/otel/sdk v1.32.0 // indirect go.opentelemetry.io/otel/trace v1.32.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.32.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/drivers/sqlitecgo/go.sum b/contrib/drivers/sqlitecgo/go.sum index 5fda5b14af7..10aa8ae7166 100644 --- a/contrib/drivers/sqlitecgo/go.sum +++ b/contrib/drivers/sqlitecgo/go.sum @@ -59,8 +59,8 @@ go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5l go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/metric/otelmetric/go.mod b/contrib/metric/otelmetric/go.mod index 1a200a6bed5..f9c8a27466e 100644 --- a/contrib/metric/otelmetric/go.mod +++ b/contrib/metric/otelmetric/go.mod @@ -16,7 +16,7 @@ require ( require ( github.com/BurntSushi/toml v1.4.0 // indirect github.com/beorn7/perks v1.0.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/clbanning/mxj/v2 v2.7.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/fatih/color v1.18.0 // indirect @@ -37,7 +37,7 @@ require ( github.com/prometheus/procfs v0.15.1 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel/trace v1.32.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.32.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect google.golang.org/protobuf v1.34.2 // indirect diff --git a/contrib/metric/otelmetric/go.sum b/contrib/metric/otelmetric/go.sum index 948f0e8abf3..d6690b09413 100644 --- a/contrib/metric/otelmetric/go.sum +++ b/contrib/metric/otelmetric/go.sum @@ -2,8 +2,8 @@ github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0 github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= @@ -76,8 +76,8 @@ go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiy go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ= go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/nosql/redis/go.mod b/contrib/nosql/redis/go.mod index 71982d59783..aede72deca0 100644 --- a/contrib/nosql/redis/go.mod +++ b/contrib/nosql/redis/go.mod @@ -13,7 +13,7 @@ require ( require ( github.com/BurntSushi/toml v1.4.0 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/clbanning/mxj/v2 v2.7.0 // indirect github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect github.com/emirpasic/gods v1.18.1 // indirect @@ -33,7 +33,7 @@ require ( github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel/metric v1.32.0 // indirect go.opentelemetry.io/otel/sdk v1.32.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.32.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/nosql/redis/go.sum b/contrib/nosql/redis/go.sum index c161c83af3b..ce78638c5dd 100644 --- a/contrib/nosql/redis/go.sum +++ b/contrib/nosql/redis/go.sum @@ -4,8 +4,8 @@ github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= @@ -67,8 +67,8 @@ go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5l go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/registry/consul/go.sum b/contrib/registry/consul/go.sum index 397a152f397..0f8cc3f51ed 100644 --- a/contrib/registry/consul/go.sum +++ b/contrib/registry/consul/go.sum @@ -216,8 +216,8 @@ golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= diff --git a/contrib/registry/etcd/go.mod b/contrib/registry/etcd/go.mod index 294fcdd669f..8b7dacc217d 100644 --- a/contrib/registry/etcd/go.mod +++ b/contrib/registry/etcd/go.mod @@ -38,14 +38,14 @@ require ( go.opentelemetry.io/otel/trace v1.32.0 // indirect go.uber.org/atomic v1.7.0 // indirect go.uber.org/multierr v1.6.0 // indirect - go.uber.org/zap v1.17.0 // indirect - golang.org/x/net v0.33.0 // indirect + go.uber.org/zap v1.21.0 // indirect + golang.org/x/net v0.32.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect google.golang.org/genproto v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/genproto/googleapis/api v0.0.0-20230822172742-b8732ec3820d // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect ) diff --git a/contrib/registry/etcd/go.sum b/contrib/registry/etcd/go.sum index 3bded3e1d9b..cc8efbc0cd3 100644 --- a/contrib/registry/etcd/go.sum +++ b/contrib/registry/etcd/go.sum @@ -1,5 +1,7 @@ github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= +github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= +github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= @@ -36,8 +38,11 @@ github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtg github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= +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/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= @@ -68,6 +73,7 @@ github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOf github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= +github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= go.etcd.io/etcd/api/v3 v3.5.17 h1:cQB8eb8bxwuxOilBpMJAEo8fAONyrdXTHUNcMd8yT1w= go.etcd.io/etcd/api/v3 v3.5.17/go.mod h1:d1hvkRuXkts6PmaYk2Vrgqbv7H4ADfAKhyJqHNLJCB4= go.etcd.io/etcd/client/pkg/v3 v3.5.17 h1:XxnDXAWq2pnxqx76ljWwiQ9jylbpC4rvkAeRVOUKKVw= @@ -84,39 +90,52 @@ go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQD go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= go.uber.org/atomic v1.7.0 h1:ADUqmZGgLDDfbSL9ZmPxKTybcoEYHgpYfELNoN+7hsw= go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= +go.uber.org/goleak v1.1.11 h1:wy28qYRKZgnJTxGxvye5/wgWr1EKjmUDGYox5mGlRlI= +go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/zap v1.17.0 h1:MTjgFu6ZLKvY6Pvaqk97GlxNBuMpV4Hy/3P6tRGlI2U= -go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= +go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= +go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= +golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= +golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= +golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= 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.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= 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-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= +golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= @@ -129,9 +148,10 @@ google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1: google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= diff --git a/contrib/registry/file/go.mod b/contrib/registry/file/go.mod index 2f4ebe887a2..d2533732fa6 100644 --- a/contrib/registry/file/go.mod +++ b/contrib/registry/file/go.mod @@ -28,7 +28,7 @@ require ( go.opentelemetry.io/otel/metric v1.32.0 // indirect go.opentelemetry.io/otel/sdk v1.32.0 // indirect go.opentelemetry.io/otel/trace v1.32.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.32.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/file/go.sum b/contrib/registry/file/go.sum index 2a54a6c5ac4..4a2bcdc09a5 100644 --- a/contrib/registry/file/go.sum +++ b/contrib/registry/file/go.sum @@ -57,8 +57,8 @@ go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5l go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/registry/nacos/go.mod b/contrib/registry/nacos/go.mod index 8a2b216af41..768b3aa447b 100644 --- a/contrib/registry/nacos/go.mod +++ b/contrib/registry/nacos/go.mod @@ -19,7 +19,7 @@ require ( github.com/aliyun/alibabacloud-dkms-transfer-go-sdk v0.1.7 // indirect github.com/beorn7/perks v1.0.1 // indirect github.com/buger/jsonparser v1.1.1 // indirect - github.com/cespare/xxhash/v2 v2.2.0 // indirect + github.com/cespare/xxhash/v2 v2.3.0 // indirect github.com/clbanning/mxj/v2 v2.7.0 // indirect github.com/emirpasic/gods v1.18.1 // indirect github.com/fatih/color v1.18.0 // indirect @@ -27,7 +27,7 @@ require ( github.com/go-logr/logr v1.4.2 // indirect github.com/go-logr/stdr v1.2.2 // indirect github.com/golang/mock v1.6.0 // indirect - github.com/golang/protobuf v1.5.3 // indirect + github.com/golang/protobuf v1.5.4 // indirect github.com/google/uuid v1.6.0 // indirect github.com/gorilla/websocket v1.5.3 // indirect github.com/grokify/html-strip-tags-go v0.1.0 // indirect @@ -37,15 +37,15 @@ require ( github.com/mattn/go-colorable v0.1.13 // indirect github.com/mattn/go-isatty v0.0.20 // indirect github.com/mattn/go-runewidth v0.0.16 // indirect - github.com/matttproud/golang_protobuf_extensions v1.0.1 // indirect github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect github.com/modern-go/reflect2 v1.0.2 // indirect + github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect github.com/olekukonko/tablewriter v0.0.5 // indirect github.com/pkg/errors v0.9.1 // indirect - github.com/prometheus/client_golang v1.12.2 // indirect - github.com/prometheus/client_model v0.2.0 // indirect - github.com/prometheus/common v0.32.1 // indirect - github.com/prometheus/procfs v0.7.3 // indirect + github.com/prometheus/client_golang v1.19.1 // indirect + github.com/prometheus/client_model v0.6.1 // indirect + github.com/prometheus/common v0.55.0 // indirect + github.com/prometheus/procfs v0.15.1 // indirect github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel v1.32.0 // indirect go.opentelemetry.io/otel/metric v1.32.0 // indirect @@ -60,9 +60,9 @@ require ( golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect golang.org/x/time v0.1.0 // indirect - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect - google.golang.org/grpc v1.56.3 // indirect - google.golang.org/protobuf v1.33.0 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect + google.golang.org/grpc v1.59.0 // indirect + google.golang.org/protobuf v1.34.2 // indirect gopkg.in/ini.v1 v1.66.2 // indirect gopkg.in/natefinch/lumberjack.v2 v2.0.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/contrib/registry/nacos/go.sum b/contrib/registry/nacos/go.sum index 8a9cf9aae6b..e2e0523728e 100644 --- a/contrib/registry/nacos/go.sum +++ b/contrib/registry/nacos/go.sum @@ -1,45 +1,5 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68 h1:NqugFkGxx1TXSh/pBcU00Y6bljgDPaFdh5MUSeJ7e50= github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68/go.mod h1:6pb/Qy8c+lqua8cFpEy7g39NRRqOWc3rOwAy8m5Y2BY= github.com/alibabacloud-go/tea v1.1.0/go.mod h1:IkGyUSX4Ba1V+k4pCtJUc6jDpZLFph9QMy2VUPTwukg= @@ -55,137 +15,51 @@ github.com/aliyun/alibabacloud-dkms-transfer-go-sdk v0.1.7 h1:olLiPI2iM8Hqq6vKnS github.com/aliyun/alibabacloud-dkms-transfer-go-sdk v0.1.7/go.mod h1:oDg1j4kFxnhgftaiLJABkGeSvuEvSF5Lo6UmRAMruX4= github.com/benbjohnson/clock v1.1.0 h1:Q92kusRqC1XV2MjkWETPvjJVqKetz1OzxZB7mHJLju8= github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44= -github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= +github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= +github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c= github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= 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-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.3 h1:KhyjKVUg7Usr/dYsdSqoFveMYd5ko72D+zANwlG1mmg= -github.com/golang/protobuf v1.5.3/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= +github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= +github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af h1:pmfjZENx5imkbgOkpRUYLnmbU7UEFbjtDA2hxJ1ichM= github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= @@ -202,8 +76,6 @@ github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/matttproud/golang_protobuf_extensions v1.0.1 h1:4hp9jkHxhMHkqkrB3Ix0jegS5sx/RkqARlsWZ6pIwiU= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= @@ -211,67 +83,37 @@ github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lN github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= +github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= github.com/nacos-group/nacos-sdk-go/v2 v2.2.7 h1:wCC1f3/VzIR1WD30YKeJGZAOchYCK/35mLC8qWt6Q6o= github.com/nacos-group/nacos-sdk-go/v2 v2.2.7/go.mod h1:VYlyDPlQchPC31PmfBustu81vsOkdpCuO5k0dRdQcFc= github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.2 h1:51L9cDoUHVrXx4zWYlcLQIZ+d+VXHgqnYKkIuq4g/34= -github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0 h1:uq5h0d+GuxiXLJLNABMgp2qUWDPiLvgCzz2dUR+/W/M= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1 h1:hWIdL3N2HoUx3B8j3YN9mWor0qhY/NlEKZEaXxuIRh4= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3 h1:4jVXhlkAyzOScmCkXBTOLRLTz8EeU+eyjrwB/EPq0VU= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= +github.com/prometheus/client_golang v1.19.1 h1:wZWJDwK+NameRJuPGDhlnFgx8e8HN3XHQeLaYJFJBOE= +github.com/prometheus/client_golang v1.19.1/go.mod h1:mP78NwGzrVks5S2H6ab8+ZZGJLZUq1hoULYBAYBw1Ho= +github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= +github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= +github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= +github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= +github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= +github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= @@ -288,309 +130,71 @@ go.uber.org/multierr v1.6.0 h1:y6IPFStTAIT5Ytl7/XYmHvzXQ7S3g/IeZW9hyZ5thw4= go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= go.uber.org/zap v1.21.0 h1:WefMeulhovoZ2sYXz7st6K0sLj7bBhpiFaud4r4zST8= go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= 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.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= 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.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/time v0.1.0 h1:xYY+Bajn2a7VBmTM5GikTmnK8ZuX8YgnQCqZpbBNtmA= golang.org/x/time v0.1.0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= -google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= +google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= +google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.33.0 h1:uNO2rsAINq/JlFpSdYEKIZ0uKD/R9cpdv0T+yoGwGmI= -google.golang.org/protobuf v1.33.0/go.mod h1:c6P6GXX6sHbq/GpV6MGZEdwhWPcYBgnhAHhKbcUYpos= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= +google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= +google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= gopkg.in/ini.v1 v1.66.2 h1:XfR1dOYubytKy4Shzc2LHrrGhU0lDCfDGG1yLPmpgsI= gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= gopkg.in/natefinch/lumberjack.v2 v2.0.0 h1:1Lc07Kr7qY4U2YPouBjpCLxpiyxIVoxqXgkXLknAOE8= gopkg.in/natefinch/lumberjack.v2 v2.0.0/go.mod h1:l0ndWWf7gzL7RNwBG7wST/UCcT4T24xpD6X8LsfU/+k= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= diff --git a/contrib/registry/polaris/go.mod b/contrib/registry/polaris/go.mod index 757730573ea..cc7ac6c19d7 100644 --- a/contrib/registry/polaris/go.mod +++ b/contrib/registry/polaris/go.mod @@ -53,8 +53,8 @@ require ( golang.org/x/net v0.33.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect - google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 // indirect - google.golang.org/grpc v1.56.3 // indirect + google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d // indirect + google.golang.org/grpc v1.59.0 // indirect google.golang.org/protobuf v1.34.2 // indirect gopkg.in/yaml.v2 v2.4.0 // indirect gopkg.in/yaml.v3 v3.0.1 // indirect diff --git a/contrib/registry/polaris/go.sum b/contrib/registry/polaris/go.sum index f2e7fee852a..ebc40fcbec8 100644 --- a/contrib/registry/polaris/go.sum +++ b/contrib/registry/polaris/go.sum @@ -938,8 +938,8 @@ google.golang.org/genproto v0.0.0-20220920201722-2b89144ce006/go.mod h1:ht8XFiar google.golang.org/genproto v0.0.0-20220926165614-551eb538f295/go.mod h1:woMGP53BroOrRY3xTxlbr8Y3eB/nzAvvFM83q7kG2OI= google.golang.org/genproto v0.0.0-20220926220553-6981cbe3cfce/go.mod h1:woMGP53BroOrRY3xTxlbr8Y3eB/nzAvvFM83q7kG2OI= google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1 h1:KpwkzHKEF7B9Zxg18WzOa7djJ+Ha5DzthMyZYQfEn2A= -google.golang.org/genproto v0.0.0-20230410155749-daa745c078e1/go.mod h1:nKE/iIaLqn2bQwXBg8f1g2Ylh6r5MN5CmZvuzZCgsCU= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d h1:uvYuEyMHKNt+lT4K3bN6fGswmK8qSvcreM3BwjDh+y4= +google.golang.org/genproto/googleapis/rpc v0.0.0-20230822172742-b8732ec3820d/go.mod h1:+Bk1OCOj40wS2hwAMA+aCW9ypzm63QTBBHp6lQ3p+9M= google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= @@ -975,8 +975,8 @@ google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACu google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= -google.golang.org/grpc v1.56.3 h1:8I4C0Yq1EjstUzUJzpcRVbuYA2mODtEmpWiQoN/b2nc= -google.golang.org/grpc v1.56.3/go.mod h1:I9bI3vqKfayGqPUAwGdOSu7kt6oIJLixfffKrpXqQ9s= +google.golang.org/grpc v1.59.0 h1:Z5Iec2pjwb+LEOqzpB2MR12/eKFhDPhuqW91O+4bwUk= +google.golang.org/grpc v1.59.0/go.mod h1:aUPDwccQo6OTjy7Hct4AfBPD1GptF4fyUjIkQ9YtF98= google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= diff --git a/contrib/registry/zookeeper/go.mod b/contrib/registry/zookeeper/go.mod index f0cace7afe2..7f1f3466c22 100644 --- a/contrib/registry/zookeeper/go.mod +++ b/contrib/registry/zookeeper/go.mod @@ -32,7 +32,7 @@ require ( go.opentelemetry.io/otel/metric v1.32.0 // indirect go.opentelemetry.io/otel/sdk v1.32.0 // indirect go.opentelemetry.io/otel/trace v1.32.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.32.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/zookeeper/go.sum b/contrib/registry/zookeeper/go.sum index 240d6897dfb..e24c5df2400 100644 --- a/contrib/registry/zookeeper/go.sum +++ b/contrib/registry/zookeeper/go.sum @@ -59,8 +59,8 @@ go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5l go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= diff --git a/contrib/rpc/grpcx/go.mod b/contrib/rpc/grpcx/go.mod index 23b68cae562..9d9705297c2 100644 --- a/contrib/rpc/grpcx/go.mod +++ b/contrib/rpc/grpcx/go.mod @@ -32,7 +32,7 @@ require ( github.com/rivo/uniseg v0.4.7 // indirect go.opentelemetry.io/otel/metric v1.32.0 // indirect go.opentelemetry.io/otel/sdk v1.32.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.32.0 // indirect golang.org/x/sys v0.28.0 // indirect golang.org/x/text v0.21.0 // indirect google.golang.org/genproto/googleapis/rpc v0.0.0-20240318140521-94a12d6c2237 // indirect diff --git a/contrib/rpc/grpcx/go.sum b/contrib/rpc/grpcx/go.sum index d42369c7256..ed1149c8ba3 100644 --- a/contrib/rpc/grpcx/go.sum +++ b/contrib/rpc/grpcx/go.sum @@ -56,8 +56,8 @@ go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5l go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/contrib/sdk/httpclient/go.mod b/contrib/sdk/httpclient/go.mod index b52ccbd4b02..e2abac29eb4 100644 --- a/contrib/sdk/httpclient/go.mod +++ b/contrib/sdk/httpclient/go.mod @@ -28,7 +28,7 @@ require ( go.opentelemetry.io/otel/metric v1.32.0 // indirect go.opentelemetry.io/otel/sdk v1.32.0 // indirect go.opentelemetry.io/otel/trace v1.32.0 // indirect - golang.org/x/net v0.33.0 // indirect + golang.org/x/net v0.32.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/sdk/httpclient/go.sum b/contrib/sdk/httpclient/go.sum index 2a54a6c5ac4..4a2bcdc09a5 100644 --- a/contrib/sdk/httpclient/go.sum +++ b/contrib/sdk/httpclient/go.sum @@ -57,8 +57,8 @@ go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5l go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/example/balancer/http/client/client.go b/example/balancer/http/client/client.go deleted file mode 100644 index 38f9ea0e137..00000000000 --- a/example/balancer/http/client/client.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gsel" - "github.com/gogf/gf/v2/net/gsvc" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/registry/etcd/v2" -) - -func main() { - gsvc.SetRegistry(etcd.New(`127.0.0.1:2379`)) - gsel.SetBuilder(gsel.NewBuilderRoundRobin()) - - for i := 0; i < 10; i++ { - ctx := gctx.New() - res := g.Client().GetContent(ctx, `http://hello.svc/`) - g.Log().Info(ctx, res) - } -} diff --git a/example/balancer/http/server/server.go b/example/balancer/http/server/server.go deleted file mode 100644 index fa157d36ee3..00000000000 --- a/example/balancer/http/server/server.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/net/gsvc" - - "github.com/gogf/gf/contrib/registry/etcd/v2" -) - -func main() { - gsvc.SetRegistry(etcd.New(`127.0.0.1:2379`)) - - s := g.Server(`hello.svc`) - s.BindHandler("/", func(r *ghttp.Request) { - g.Log().Info(r.Context(), `request received`) - r.Response.Write(`Hello world`) - }) - s.Run() -} diff --git a/example/balancer/polaris/README.md b/example/balancer/polaris/README.md deleted file mode 100644 index 5c9fdcf6ef1..00000000000 --- a/example/balancer/polaris/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# Balancer Polaris -Balancer Polaris is a Balancer Protocol implementation on Polaris. - diff --git a/example/balancer/polaris/client/client.go b/example/balancer/polaris/client/client.go deleted file mode 100644 index d40fd3c719a..00000000000 --- a/example/balancer/polaris/client/client.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - "fmt" - "os" - "time" - - "github.com/polarismesh/polaris-go/api" - "github.com/polarismesh/polaris-go/pkg/config" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gsel" - "github.com/gogf/gf/v2/net/gsvc" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/registry/polaris/v2" -) - -func main() { - conf := config.NewDefaultConfiguration([]string{"127.0.0.1:8091"}) - conf.Consumer.LocalCache.SetPersistDir(os.TempDir() + "/polaris/backup") - if err := api.SetLoggersDir(os.TempDir() + "/polaris/log"); err != nil { - g.Log().Fatal(context.Background(), err) - } - - gsvc.SetRegistry(polaris.NewWithConfig(conf, polaris.WithTTL(10))) - gsel.SetBuilder(gsel.NewBuilderRoundRobin()) - - for i := 0; i < 100; i++ { - res, err := g.Client().Get(gctx.New(), `http://hello-world.svc/`) - if err != nil { - panic(err) - } - fmt.Println(res.ReadAllString(), " id: ", i, " time: ", time.Now().Format("2006-01-02 15:04:05"), " code: ", res.StatusCode) - res.Close() - time.Sleep(time.Second) - } -} diff --git a/example/balancer/polaris/server/server.go b/example/balancer/polaris/server/server.go deleted file mode 100644 index 6be2619ab21..00000000000 --- a/example/balancer/polaris/server/server.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - "os" - - "github.com/polarismesh/polaris-go/api" - "github.com/polarismesh/polaris-go/pkg/config" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/net/gsvc" - - "github.com/gogf/gf/contrib/registry/polaris/v2" -) - -func main() { - conf := config.NewDefaultConfiguration([]string{"127.0.0.1:8091"}) - conf.Consumer.LocalCache.SetPersistDir(os.TempDir() + "/polaris/backup") - if err := api.SetLoggersDir(os.TempDir() + "/polaris/log"); err != nil { - g.Log().Fatal(context.Background(), err) - } - - // TTL egt 2*time.Second - gsvc.SetRegistry(polaris.NewWithConfig(conf, polaris.WithTTL(10))) - - s := g.Server(`hello-world.svc`) - s.BindHandler("/", func(r *ghttp.Request) { - g.Log().Info(r.Context(), `request received`) - r.Response.Write(`Hello world`) - }) - s.Run() -} diff --git a/example/config/apollo/boot/boot.go b/example/config/apollo/boot/boot.go deleted file mode 100644 index 73428dce3fc..00000000000 --- a/example/config/apollo/boot/boot.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package boot - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/config/apollo/v2" -) - -func init() { - var ( - ctx = gctx.GetInitCtx() - appId = "SampleApp" - cluster = "default" - ip = "http://localhost:8080" - ) - // Create apollo Client that implements gcfg.Adapter. - adapter, err := apollo.New(ctx, apollo.Config{ - AppID: appId, - IP: ip, - Cluster: cluster, - }) - if err != nil { - g.Log().Fatalf(ctx, `%+v`, err) - } - // Change the adapter of default configuration instance. - g.Cfg().SetAdapter(adapter) -} diff --git a/example/config/apollo/main.go b/example/config/apollo/main.go deleted file mode 100644 index 7e300cfceca..00000000000 --- a/example/config/apollo/main.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - _ "github.com/gogf/gf/example/config/apollo/boot" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" -) - -func main() { - var ctx = gctx.GetInitCtx() - - // Available checks. - g.Dump(g.Cfg().Available(ctx)) - - // All key-value configurations. - g.Dump(g.Cfg().Data(ctx)) - - // Retrieve certain value by key. - g.Dump(g.Cfg().MustGet(ctx, "server.address")) -} diff --git a/example/config/consul/boot/boot.go b/example/config/consul/boot/boot.go deleted file mode 100644 index 996173bacf6..00000000000 --- a/example/config/consul/boot/boot.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package boot - -import ( - "github.com/hashicorp/consul/api" - "github.com/hashicorp/go-cleanhttp" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - - consul "github.com/gogf/gf/contrib/config/consul/v2" -) - -func init() { - var ( - ctx = gctx.GetInitCtx() - consulConfig = api.Config{ - Address: "127.0.0.1:8500", - Scheme: "http", - Datacenter: "dc1", - Transport: cleanhttp.DefaultPooledTransport(), - Token: "3f8aeba2-f1f7-42d0-b912-fcb041d4546d", - } - configPath = "server/message" - ) - - adapter, err := consul.New(ctx, consul.Config{ - ConsulConfig: consulConfig, - Path: configPath, - Watch: true, - }) - if err != nil { - g.Log().Fatalf(ctx, `New consul adapter error: %+v`, err) - } - - g.Cfg().SetAdapter(adapter) -} diff --git a/example/config/consul/main.go b/example/config/consul/main.go deleted file mode 100644 index 3967b15bc11..00000000000 --- a/example/config/consul/main.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - _ "github.com/gogf/gf/example/config/consul/boot" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" -) - -func main() { - var ctx = gctx.GetInitCtx() - - // Available checks. - g.Dump(g.Cfg().Available(ctx)) - - // All key-value configurations. - g.Dump(g.Cfg().Data(ctx)) - - // Retrieve certain value by key. - g.Dump(g.Cfg().MustGet(ctx, "redis.addr")) -} diff --git a/example/config/kubecm/boot_in_pod/boot.go b/example/config/kubecm/boot_in_pod/boot.go deleted file mode 100644 index 0836454424c..00000000000 --- a/example/config/kubecm/boot_in_pod/boot.go +++ /dev/null @@ -1,37 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package boot - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/config/kubecm/v2" -) - -const ( - configmapName = "test-configmap" - dataItemInConfigmap = "config.yaml" -) - -func init() { - var ( - err error - ctx = gctx.GetInitCtx() - ) - // Create kubecm Client that implements gcfg.Adapter. - adapter, err := kubecm.New(gctx.GetInitCtx(), kubecm.Config{ - ConfigMap: configmapName, - DataItem: dataItemInConfigmap, - }) - if err != nil { - g.Log().Fatalf(ctx, `%+v`, err) - } - - // Change the adapter of default configuration instance. - g.Cfg().SetAdapter(adapter) -} diff --git a/example/config/kubecm/boot_out_pod/boot.go b/example/config/kubecm/boot_out_pod/boot.go deleted file mode 100644 index 1be0210f581..00000000000 --- a/example/config/kubecm/boot_out_pod/boot.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package boot - -import ( - "k8s.io/client-go/kubernetes" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/config/kubecm/v2" -) - -const ( - namespace = "default" - configmapName = "test-configmap" - dataItemInConfigmap = "config.yaml" - kubeConfigFilePathJohn = `/Users/john/.kube/config` -) - -func init() { - var ( - err error - ctx = gctx.GetInitCtx() - kubeClient *kubernetes.Clientset - ) - // Create kubernetes client. - // It is optional creating kube client when its is running in pod. - kubeClient, err = kubecm.NewKubeClientFromPath(ctx, kubeConfigFilePathJohn) - if err != nil { - g.Log().Fatalf(ctx, `%+v`, err) - } - // Create kubecm Client that implements gcfg.Adapter. - adapter, err := kubecm.New(gctx.GetInitCtx(), kubecm.Config{ - ConfigMap: configmapName, - DataItem: dataItemInConfigmap, - Namespace: namespace, // It is optional specifying namespace when its is running in pod. - KubeClient: kubeClient, // It is optional specifying kube client when its is running in pod. - }) - if err != nil { - g.Log().Fatalf(ctx, `%+v`, err) - } - - // Change the adapter of default configuration instance. - g.Cfg().SetAdapter(adapter) - -} diff --git a/example/config/kubecm/main.go b/example/config/kubecm/main.go deleted file mode 100644 index 22d3cd10b39..00000000000 --- a/example/config/kubecm/main.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - _ "github.com/gogf/gf/example/config/kubecm/boot_in_pod" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" -) - -func main() { - var ctx = gctx.GetInitCtx() - - // Available checks. - g.Dump(g.Cfg().Available(ctx)) - - // All key-value configurations. - g.Dump(g.Cfg().Data(ctx)) - - // Retrieve certain value by key. - g.Dump(g.Cfg().MustGet(ctx, "server.address")) -} diff --git a/example/config/nacos/boot/boot.go b/example/config/nacos/boot/boot.go deleted file mode 100644 index f6e764540dc..00000000000 --- a/example/config/nacos/boot/boot.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package boot - -import ( - "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/contrib/config/nacos/v2" -) - -func init() { - var ( - ctx = gctx.GetInitCtx() - serverConfig = constant.ServerConfig{ - IpAddr: "localhost", - Port: 8848, - } - clientConfig = constant.ClientConfig{ - CacheDir: "/tmp/nacos", - LogDir: "/tmp/nacos", - } - configParam = vo.ConfigParam{ - DataId: "config.toml", - Group: "test", - } - ) - // Create nacos Client that implements gcfg.Adapter. - adapter, err := nacos.New(ctx, nacos.Config{ - ServerConfigs: []constant.ServerConfig{serverConfig}, - ClientConfig: clientConfig, - ConfigParam: configParam, - }) - if err != nil { - g.Log().Fatalf(ctx, `%+v`, err) - } - // Change the adapter of default configuration instance. - g.Cfg().SetAdapter(adapter) -} diff --git a/example/config/nacos/main.go b/example/config/nacos/main.go deleted file mode 100644 index 170369573f1..00000000000 --- a/example/config/nacos/main.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package nacos - -import ( - _ "github.com/gogf/gf/example/config/nacos/boot" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" -) - -func main() { - var ctx = gctx.GetInitCtx() - - // Available checks. - g.Dump(g.Cfg().Available(ctx)) - - // All key-value configurations. - g.Dump(g.Cfg().Data(ctx)) - - // Retrieve certain value by key. - g.Dump(g.Cfg().MustGet(ctx, "server.address")) -} diff --git a/example/config/polaris/boot/boot.go b/example/config/polaris/boot/boot.go deleted file mode 100644 index 405d902fd7a..00000000000 --- a/example/config/polaris/boot/boot.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package boot - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/config/polaris/v2" -) - -func init() { - var ( - ctx = gctx.GetInitCtx() - namespace = "default" - fileGroup = "TestGroup" - fileName = "config.yaml" - path = "manifest/config/polaris.yaml" - logDir = "/tmp/polaris/log" - ) - // Create polaris Client that implements gcfg.Adapter. - adapter, err := polaris.New(ctx, polaris.Config{ - Namespace: namespace, - FileGroup: fileGroup, - FileName: fileName, - Path: path, - LogDir: logDir, - Watch: true, - }) - if err != nil { - g.Log().Fatalf(ctx, `%+v`, err) - } - // Change the adapter of default configuration instance. - g.Cfg().SetAdapter(adapter) -} diff --git a/example/config/polaris/main.go b/example/config/polaris/main.go deleted file mode 100644 index 917c07dd7db..00000000000 --- a/example/config/polaris/main.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - _ "github.com/gogf/gf/example/config/polaris/boot" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" -) - -func main() { - var ctx = gctx.GetInitCtx() - - // Available checks. - g.Dump(g.Cfg().Available(ctx)) - - // All key-value configurations. - g.Dump(g.Cfg().Data(ctx)) - - // Retrieve certain value by key. - g.Dump(g.Cfg().MustGet(ctx, "server.address")) -} diff --git a/example/config/polaris/testdata/polaris.yaml b/example/config/polaris/testdata/polaris.yaml deleted file mode 100644 index 9f785c233f5..00000000000 --- a/example/config/polaris/testdata/polaris.yaml +++ /dev/null @@ -1,11 +0,0 @@ -global: - serverConnector: - addresses: - - 183.47.111.80:8091 -config: - configConnector: - addresses: - - 183.47.111.80:8093 -consumer: - localCache: - persistDir: "/tmp/polaris/backup" \ No newline at end of file diff --git a/example/converter/alias-type-convert-with-refer/main.go b/example/converter/alias-type-convert-with-refer/main.go deleted file mode 100644 index d8fa5586a99..00000000000 --- a/example/converter/alias-type-convert-with-refer/main.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "fmt" - - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/util/gconv" -) - -type MyTime = *gtime.Time - -type Src struct { - A MyTime -} - -type Dst struct { - B string -} - -type SrcWrap struct { - Value Src -} - -type DstWrap struct { - Value Dst -} - -// SrcToDstConverter is custom converting function for custom type. -func SrcToDstConverter(src Src) (dst *Dst, err error) { - return &Dst{B: src.A.Format("Y-m-d")}, nil -} - -// SrcToDstConverter is custom converting function for custom type. -func main() { - // register custom converter function. - err := gconv.RegisterConverter(SrcToDstConverter) - if err != nil { - panic(err) - } - - // custom struct converting. - var src = Src{A: gtime.Now()} - dst := gconv.ConvertWithRefer(src, &Dst{}) - fmt.Println("src:", src) - fmt.Println("dst:", dst) - - // custom struct attributes converting. - var srcWrap = SrcWrap{Src{A: gtime.Now()}} - dstWrap := gconv.ConvertWithRefer(srcWrap, &DstWrap{}) - fmt.Println("srcWrap:", srcWrap) - fmt.Println("dstWrap:", dstWrap) -} diff --git a/example/converter/alias-type-scan/main.go b/example/converter/alias-type-scan/main.go deleted file mode 100644 index c81d0506979..00000000000 --- a/example/converter/alias-type-scan/main.go +++ /dev/null @@ -1,72 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "fmt" - - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/util/gconv" -) - -type MyTime = *gtime.Time - -type Src struct { - A MyTime -} - -type Dst struct { - B string -} - -type SrcWrap struct { - Value Src -} - -type DstWrap struct { - Value Dst -} - -// SrcToDstConverter is custom converting function for custom type. -func SrcToDstConverter(src Src) (dst *Dst, err error) { - return &Dst{B: src.A.Format("Y-m-d")}, nil -} - -// SrcToDstConverter is custom converting function for custom type. -func main() { - // register custom converter function. - err := gconv.RegisterConverter(SrcToDstConverter) - if err != nil { - panic(err) - } - - // custom struct converting. - var ( - src = Src{A: gtime.Now()} - dst *Dst - ) - err = gconv.Scan(src, &dst) - if err != nil { - panic(err) - } - - fmt.Println("src:", src) - fmt.Println("dst:", dst) - - // custom struct attributes converting. - var ( - srcWrap = SrcWrap{Src{A: gtime.Now()}} - dstWrap *DstWrap - ) - err = gconv.Scan(srcWrap, &dstWrap) - if err != nil { - panic(err) - } - - fmt.Println("srcWrap:", srcWrap) - fmt.Println("dstWrap:", dstWrap) -} diff --git a/example/converter/struct-convert-with-refer/main.go b/example/converter/struct-convert-with-refer/main.go deleted file mode 100644 index bae8b1ca22a..00000000000 --- a/example/converter/struct-convert-with-refer/main.go +++ /dev/null @@ -1,54 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "fmt" - - "github.com/gogf/gf/v2/util/gconv" -) - -type Src struct { - A int -} - -type Dst struct { - B int -} - -type SrcWrap struct { - Value Src -} - -type DstWrap struct { - Value Dst -} - -// SrcToDstConverter is custom converting function for custom type. -func SrcToDstConverter(src Src) (dst *Dst, err error) { - return &Dst{B: src.A}, nil -} - -func main() { - // register custom converter function. - err := gconv.RegisterConverter(SrcToDstConverter) - if err != nil { - panic(err) - } - - // custom struct converting. - var src = Src{A: 1} - dst := gconv.ConvertWithRefer(src, Dst{}) - fmt.Println("src:", src) - fmt.Println("dst:", dst) - - // custom struct attributes converting. - var srcWrap = SrcWrap{Src{A: 1}} - dstWrap := gconv.ConvertWithRefer(srcWrap, &DstWrap{}) - fmt.Println("srcWrap:", srcWrap) - fmt.Println("dstWrap:", dstWrap) -} diff --git a/example/converter/struct-scan/main.go b/example/converter/struct-scan/main.go deleted file mode 100644 index 3bdc4bc3fd6..00000000000 --- a/example/converter/struct-scan/main.go +++ /dev/null @@ -1,68 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "fmt" - - "github.com/gogf/gf/v2/util/gconv" -) - -type Src struct { - A int -} - -type Dst struct { - B int -} - -type SrcWrap struct { - Value Src -} - -type DstWrap struct { - Value Dst -} - -func SrcToDstConverter(src Src) (dst *Dst, err error) { - return &Dst{B: src.A}, nil -} - -// SrcToDstConverter is custom converting function for custom type. -func main() { - // register custom converter function. - err := gconv.RegisterConverter(SrcToDstConverter) - if err != nil { - panic(err) - } - - // custom struct converting. - var ( - src = Src{A: 1} - dst *Dst - ) - err = gconv.Scan(src, &dst) - if err != nil { - panic(err) - } - - fmt.Println("src:", src) - fmt.Println("dst:", dst) - - // custom struct attributes converting. - var ( - srcWrap = SrcWrap{Src{A: 1}} - dstWrap *DstWrap - ) - err = gconv.Scan(srcWrap, &dstWrap) - if err != nil { - panic(err) - } - - fmt.Println("srcWrap:", srcWrap) - fmt.Println("dstWrap:", dstWrap) -} diff --git a/example/database/mysql/driver-encrypt-decrypt-password/config.yaml b/example/database/mysql/driver-encrypt-decrypt-password/config.yaml deleted file mode 100644 index ab56e68eb94..00000000000 --- a/example/database/mysql/driver-encrypt-decrypt-password/config.yaml +++ /dev/null @@ -1,3 +0,0 @@ -database: - default: - - link: "hellosql:root:cm9vdDEyMw==@tcp(127.0.0.1:3306)/focus" diff --git a/example/database/mysql/driver-encrypt-decrypt-password/main.go b/example/database/mysql/driver-encrypt-decrypt-password/main.go deleted file mode 100644 index 419eb6397c8..00000000000 --- a/example/database/mysql/driver-encrypt-decrypt-password/main.go +++ /dev/null @@ -1,83 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. -// - -package main - -import ( - "context" - "database/sql" - "fmt" - - "github.com/gogf/gf/v2/database/gdb" - "github.com/gogf/gf/v2/encoding/gbase64" - "github.com/gogf/gf/v2/frame/g" - - "github.com/gogf/gf/contrib/drivers/mysql/v2" -) - -const ( - mysqlDriverName = "hellosql" - quoteChar = "`" -) - -func init() { - var ( - err error - driverObj = &DriverMysql{ - Driver: mysql.Driver{}, - } - ) - if err = gdb.Register(mysqlDriverName, driverObj); err != nil { - panic(err) - } -} - -// New creates and returns a database object for mysql. -// It implements the interface of gdb.Driver for extra database driver installation. -func (d *DriverMysql) New(core *gdb.Core, node *gdb.ConfigNode) (gdb.DB, error) { - return &DriverMysql{ - Driver: mysql.Driver{Core: core}, - }, nil -} - -// GetChars returns the security char for this type of database. -func (d *DriverMysql) GetChars() (charLeft string, charRight string) { - return quoteChar, quoteChar -} - -func (d *DriverMysql) Open(config *gdb.ConfigNode) (db *sql.DB, err error) { - fmt.Println("DriverMysql.Open") - fmt.Println("config.Pass(encode):" + config.Pass) - // Decrypt the password if it is encrypted. - config.Pass, err = gbase64.DecodeToString(config.Pass) - if err != nil { - return nil, err - } - fmt.Println("config.Pass(decode):" + config.Pass) - return d.Driver.Open(config) -} - -func (d *DriverMysql) Tables(ctx context.Context, schema ...string) (tables []string, err error) { - return d.Driver.Tables(ctx, schema...) -} - -func (d *DriverMysql) TableFields(ctx context.Context, table string, schema ...string) (fields map[string]*gdb.TableField, err error) { - return d.Driver.TableFields(ctx, table, schema...) -} - -// DriverMysql is the driver for mysql database. -type DriverMysql struct { - mysql.Driver -} - -func main() { - list, err := g.DB().Tables(context.Background()) - if err != nil { - panic(err) - } - fmt.Println(list) -} diff --git a/example/go.mod b/example/go.mod deleted file mode 100644 index 4e3b002d1ac..00000000000 --- a/example/go.mod +++ /dev/null @@ -1,181 +0,0 @@ -module github.com/gogf/gf/example - -go 1.22 - -require ( - github.com/gogf/gf/contrib/config/apollo/v2 v2.8.3 - github.com/gogf/gf/contrib/config/consul/v2 v2.8.3 - github.com/gogf/gf/contrib/config/kubecm/v2 v2.8.3 - github.com/gogf/gf/contrib/config/nacos/v2 v2.8.3 - github.com/gogf/gf/contrib/config/polaris/v2 v2.8.3 - github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.3 - github.com/gogf/gf/contrib/metric/otelmetric/v2 v2.8.3 - github.com/gogf/gf/contrib/nosql/redis/v2 v2.8.3 - github.com/gogf/gf/contrib/registry/consul/v2 v2.8.3 - github.com/gogf/gf/contrib/registry/etcd/v2 v2.8.3 - github.com/gogf/gf/contrib/registry/file/v2 v2.8.3 - github.com/gogf/gf/contrib/registry/nacos/v2 v2.8.3 - github.com/gogf/gf/contrib/registry/polaris/v2 v2.8.3 - github.com/gogf/gf/contrib/rpc/grpcx/v2 v2.8.3 - github.com/gogf/gf/contrib/trace/otlpgrpc/v2 v2.8.3 - github.com/gogf/gf/contrib/trace/otlphttp/v2 v2.8.3 - github.com/gogf/gf/v2 v2.8.3 - github.com/hashicorp/consul/api v1.26.1 - github.com/hashicorp/go-cleanhttp v0.5.2 - github.com/nacos-group/nacos-sdk-go/v2 v2.2.7 - github.com/polarismesh/polaris-go v1.5.8 - github.com/prometheus/client_golang v1.20.2 - go.opentelemetry.io/otel v1.32.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.29.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.29.0 - go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.29.0 - go.opentelemetry.io/otel/exporters/prometheus v0.46.0 - go.opentelemetry.io/otel/sdk v1.32.0 - golang.org/x/time v0.6.0 - google.golang.org/grpc v1.68.1 - google.golang.org/protobuf v1.34.2 - k8s.io/client-go v0.27.4 -) - -require ( - github.com/BurntSushi/toml v1.4.0 // indirect - github.com/alibabacloud-go/darabonba-array v0.1.0 // indirect - github.com/alibabacloud-go/darabonba-encode-util v0.0.2 // indirect - github.com/alibabacloud-go/darabonba-map v0.0.2 // indirect - github.com/alibabacloud-go/darabonba-string v1.0.2 // indirect - github.com/alibabacloud-go/debug v1.0.1 // indirect - github.com/alibabacloud-go/openapi-util v0.1.0 // indirect - github.com/alibabacloud-go/tea v1.2.2 // indirect - github.com/alibabacloud-go/tea-utils v1.4.4 // indirect - github.com/alibabacloud-go/tea-utils/v2 v2.0.3 // indirect - github.com/aliyun/alibaba-cloud-sdk-go v1.63.7 // indirect - github.com/aliyun/alibabacloud-dkms-gcs-go-sdk v0.5.1 // indirect - github.com/aliyun/alibabacloud-dkms-transfer-go-sdk v0.1.9 // indirect - github.com/apolloconfig/agollo/v4 v4.3.1 // indirect - github.com/armon/go-metrics v0.4.1 // indirect - github.com/beorn7/perks v1.0.1 // indirect - github.com/buger/jsonparser v1.1.1 // indirect - github.com/cenkalti/backoff/v4 v4.3.0 // indirect - github.com/cespare/xxhash/v2 v2.3.0 // indirect - github.com/clbanning/mxj/v2 v2.7.0 // indirect - github.com/coreos/go-semver v0.3.0 // indirect - github.com/coreos/go-systemd/v22 v22.3.2 // indirect - github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc // indirect - github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f // indirect - github.com/dlclark/regexp2 v1.11.2 // indirect - github.com/emicklei/go-restful/v3 v3.9.0 // indirect - github.com/emirpasic/gods v1.18.1 // 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 - github.com/go-openapi/jsonpointer v0.19.6 // indirect - github.com/go-openapi/jsonreference v0.20.1 // indirect - github.com/go-openapi/swag v0.22.3 // indirect - github.com/go-sql-driver/mysql v1.7.1 // indirect - github.com/gogo/protobuf v1.3.2 // indirect - github.com/golang/mock v1.6.0 // indirect - github.com/golang/protobuf v1.5.4 // indirect - github.com/google/gnostic v0.5.7-v3refs // indirect - github.com/google/go-cmp v0.6.0 // indirect - github.com/google/gofuzz v1.1.0 // indirect - github.com/google/uuid v1.6.0 // indirect - github.com/gorilla/websocket v1.5.3 // indirect - github.com/grokify/html-strip-tags-go v0.1.0 // indirect - github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 // indirect - github.com/hashicorp/errwrap v1.1.0 // indirect - github.com/hashicorp/go-hclog v1.5.0 // indirect - github.com/hashicorp/go-immutable-radix v1.3.1 // indirect - github.com/hashicorp/go-multierror v1.1.1 // indirect - github.com/hashicorp/go-rootcerts v1.0.2 // indirect - github.com/hashicorp/golang-lru v1.0.2 // indirect - github.com/hashicorp/hcl v1.0.0 // indirect - github.com/hashicorp/serf v0.10.1 // indirect - github.com/imdario/mergo v0.3.6 // indirect - github.com/jmespath/go-jmespath v0.4.0 // indirect - github.com/josharian/intern v1.0.0 // indirect - github.com/json-iterator/go v1.1.12 // indirect - github.com/klauspost/compress v1.17.9 // indirect - github.com/magiconair/properties v1.8.9 // indirect - github.com/mailru/easyjson v0.7.7 // indirect - github.com/mattn/go-colorable v0.1.13 // indirect - github.com/mattn/go-isatty v0.0.20 // indirect - github.com/mattn/go-runewidth v0.0.16 // indirect - github.com/mitchellh/go-homedir v1.1.0 // indirect - github.com/mitchellh/mapstructure v1.5.0 // indirect - github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd // indirect - github.com/modern-go/reflect2 v1.0.2 // indirect - github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 // indirect - github.com/natefinch/lumberjack v2.0.0+incompatible // indirect - github.com/olekukonko/tablewriter v0.0.5 // indirect - github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b // indirect - github.com/pelletier/go-toml v1.9.3 // indirect - github.com/pkg/errors v0.9.1 // indirect - github.com/polarismesh/specification v1.5.1 // indirect - github.com/prometheus/client_model v0.6.1 // indirect - github.com/prometheus/common v0.55.0 // indirect - github.com/prometheus/procfs v0.15.1 // indirect - github.com/redis/go-redis/v9 v9.7.0 // indirect - github.com/rivo/uniseg v0.4.7 // indirect - github.com/spaolacci/murmur3 v1.1.0 // indirect - github.com/spf13/afero v1.6.0 // indirect - github.com/spf13/cast v1.3.1 // indirect - github.com/spf13/jwalterweatherman v1.1.0 // indirect - github.com/spf13/pflag v1.0.5 // indirect - github.com/spf13/viper v1.8.1 // indirect - github.com/subosito/gotenv v1.2.0 // indirect - github.com/tjfoc/gmsm v1.4.1 // indirect - go.etcd.io/etcd/api/v3 v3.5.17 // indirect - go.etcd.io/etcd/client/pkg/v3 v3.5.17 // indirect - go.etcd.io/etcd/client/v3 v3.5.17 // indirect - go.opentelemetry.io/contrib/instrumentation/runtime v0.49.0 // indirect - go.opentelemetry.io/otel/metric v1.32.0 // indirect - go.opentelemetry.io/otel/sdk/metric v1.32.0 // indirect - go.opentelemetry.io/otel/trace v1.32.0 // indirect - go.opentelemetry.io/proto/otlp v1.3.1 // indirect - go.uber.org/multierr v1.10.0 // indirect - go.uber.org/zap v1.26.0 // indirect - golang.org/x/crypto v0.31.0 // indirect - golang.org/x/exp v0.0.0-20231006140011-7918f672742d // indirect - golang.org/x/net v0.33.0 // indirect - golang.org/x/oauth2 v0.23.0 // indirect - golang.org/x/sync v0.10.0 // indirect - golang.org/x/sys v0.28.0 // indirect - golang.org/x/term v0.27.0 // indirect - golang.org/x/text v0.21.0 // indirect - google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 // indirect - google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 // indirect - gopkg.in/inf.v0 v0.9.1 // indirect - gopkg.in/ini.v1 v1.67.0 // indirect - gopkg.in/natefinch/lumberjack.v2 v2.2.1 // indirect - gopkg.in/yaml.v2 v2.4.0 // indirect - gopkg.in/yaml.v3 v3.0.1 // indirect - k8s.io/api v0.27.4 // indirect - k8s.io/apimachinery v0.27.4 // indirect - k8s.io/klog/v2 v2.90.1 // indirect - k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f // indirect - k8s.io/utils v0.0.0-20230209194617-a36077c30491 // indirect - sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect - sigs.k8s.io/structured-merge-diff/v4 v4.2.3 // indirect - sigs.k8s.io/yaml v1.3.0 // indirect -) - -replace ( - github.com/gogf/gf/contrib/config/apollo/v2 => ../contrib/config/apollo/ - github.com/gogf/gf/contrib/config/consul/v2 => ../contrib/config/consul/ - github.com/gogf/gf/contrib/config/kubecm/v2 => ../contrib/config/kubecm/ - github.com/gogf/gf/contrib/config/nacos/v2 => ../contrib/config/nacos/ - github.com/gogf/gf/contrib/config/polaris/v2 => ../contrib/config/polaris/ - github.com/gogf/gf/contrib/drivers/mysql/v2 => ../contrib/drivers/mysql/ - github.com/gogf/gf/contrib/metric/otelmetric/v2 => ../contrib/metric/otelmetric - github.com/gogf/gf/contrib/nosql/redis/v2 => ../contrib/nosql/redis/ - github.com/gogf/gf/contrib/registry/consul/v2 => ../contrib/registry/consul/ - github.com/gogf/gf/contrib/registry/etcd/v2 => ../contrib/registry/etcd/ - github.com/gogf/gf/contrib/registry/file/v2 => ../contrib/registry/file/ - github.com/gogf/gf/contrib/registry/nacos/v2 => ../contrib/registry/nacos/ - github.com/gogf/gf/contrib/registry/polaris/v2 => ../contrib/registry/polaris/ - github.com/gogf/gf/contrib/rpc/grpcx/v2 => ../contrib/rpc/grpcx/ - github.com/gogf/gf/contrib/trace/otlpgrpc/v2 => ../contrib/trace/otlpgrpc - github.com/gogf/gf/contrib/trace/otlphttp/v2 => ../contrib/trace/otlphttp - github.com/gogf/gf/v2 => ../ -) diff --git a/example/go.sum b/example/go.sum deleted file mode 100644 index 969185c9427..00000000000 --- a/example/go.sum +++ /dev/null @@ -1,1417 +0,0 @@ -cloud.google.com/go v0.26.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.34.0/go.mod h1:aQUYkXzVsufM+DwF1aE+0xfcU+56JwCaLick0ClmMTw= -cloud.google.com/go v0.38.0/go.mod h1:990N+gfupTy94rShfmMCWGDn0LpTmnzTp2qbd1dvSRU= -cloud.google.com/go v0.44.1/go.mod h1:iSa0KzasP4Uvy3f1mN/7PiObzGgflwredwwASm/v6AU= -cloud.google.com/go v0.44.2/go.mod h1:60680Gw3Yr4ikxnPRS/oxxkBccT6SA1yMk63TGekxKY= -cloud.google.com/go v0.45.1/go.mod h1:RpBamKRgapWJb87xiFSdk4g1CME7QZg3uwTez+TSTjc= -cloud.google.com/go v0.46.3/go.mod h1:a6bKKbmY7er1mI7TEI4lsAkts/mkhTSZK8w33B4RAg0= -cloud.google.com/go v0.50.0/go.mod h1:r9sluTvynVuxRIOHXQEHMFffphuXHOMZMycpNR5e6To= -cloud.google.com/go v0.52.0/go.mod h1:pXajvRH/6o3+F9jDHZWQ5PbGhn+o8w9qiu/CffaVdO4= -cloud.google.com/go v0.53.0/go.mod h1:fp/UouUEsRkN6ryDKNW/Upv/JBKnv6WDthjR6+vze6M= -cloud.google.com/go v0.54.0/go.mod h1:1rq2OEkV3YMf6n/9ZvGWI3GWw0VoqH/1x2nd8Is/bPc= -cloud.google.com/go v0.56.0/go.mod h1:jr7tqZxxKOVYizybht9+26Z/gUq7tiRzu+ACVAMbKVk= -cloud.google.com/go v0.57.0/go.mod h1:oXiQ6Rzq3RAkkY7N6t3TcE6jE+CIBBbA36lwQ1JyzZs= -cloud.google.com/go v0.62.0/go.mod h1:jmCYTdRCQuc1PHIIJ/maLInMho30T/Y0M4hTdTShOYc= -cloud.google.com/go v0.65.0/go.mod h1:O5N8zS7uWy9vkA9vayVHs65eM1ubvY4h553ofrNHObY= -cloud.google.com/go v0.72.0/go.mod h1:M+5Vjvlc2wnp6tjzE102Dw08nGShTscUx2nZMufOKPI= -cloud.google.com/go v0.74.0/go.mod h1:VV1xSbzvo+9QJOxLDaJfTjx5e+MePCpCWwvftOeQmWk= -cloud.google.com/go v0.78.0/go.mod h1:QjdrLG0uq+YwhjoVOLsS1t7TW8fs36kLs4XO5R5ECHg= -cloud.google.com/go v0.79.0/go.mod h1:3bzgcEeQlzbuEAYu4mrWhKqWjmpprinYgKJLgKHnbb8= -cloud.google.com/go v0.81.0/go.mod h1:mk/AM35KwGk/Nm2YSeZbxXdrNK3KZOYHmLkOqC2V6E0= -cloud.google.com/go v0.83.0/go.mod h1:Z7MJUsANfY0pYPdw0lbnivPx4/vhy/e2FEkSkF7vAVY= -cloud.google.com/go v0.84.0/go.mod h1:RazrYuxIK6Kb7YrzzhPoLmCVzl7Sup4NrbKPg8KHSUM= -cloud.google.com/go v0.87.0/go.mod h1:TpDYlFy7vuLzZMMZ+B6iRiELaY7z/gJPaqbMx6mlWcY= -cloud.google.com/go v0.90.0/go.mod h1:kRX0mNRHe0e2rC6oNakvwQqzyDmg57xJ+SZU1eT2aDQ= -cloud.google.com/go v0.93.3/go.mod h1:8utlLll2EF5XMAV15woO4lSbWQlk8rer9aLOfLh7+YI= -cloud.google.com/go v0.94.1/go.mod h1:qAlAugsXlC+JWO+Bke5vCtc9ONxjQT3drlTTnAplMW4= -cloud.google.com/go v0.97.0/go.mod h1:GF7l59pYBVlXQIBLx3a761cZ41F9bBH3JUlihCt2Udc= -cloud.google.com/go v0.99.0/go.mod h1:w0Xx2nLzqWJPuozYQX+hFfCSI8WioryfRDzkoI/Y2ZA= -cloud.google.com/go v0.100.2/go.mod h1:4Xra9TjzAeYHrl5+oeLlzbM2k3mjVhZh4UqTZ//w99A= -cloud.google.com/go v0.102.0/go.mod h1:oWcCzKlqJ5zgHQt9YsaeTY9KzIvjyy0ArmiBUgpQ+nc= -cloud.google.com/go v0.102.1/go.mod h1:XZ77E9qnTEnrgEOvr4xzfdX5TRo7fB4T2F4O6+34hIU= -cloud.google.com/go v0.104.0/go.mod h1:OO6xxXdJyvuJPcEPBLN9BJPD+jep5G1+2U5B5gkRYtA= -cloud.google.com/go/aiplatform v1.22.0/go.mod h1:ig5Nct50bZlzV6NvKaTwmplLLddFx0YReh9WfTO5jKw= -cloud.google.com/go/aiplatform v1.24.0/go.mod h1:67UUvRBKG6GTayHKV8DBv2RtR1t93YRu5B1P3x99mYY= -cloud.google.com/go/analytics v0.11.0/go.mod h1:DjEWCu41bVbYcKyvlws9Er60YE4a//bK6mnhWvQeFNI= -cloud.google.com/go/analytics v0.12.0/go.mod h1:gkfj9h6XRf9+TS4bmuhPEShsh3hH8PAZzm/41OOhQd4= -cloud.google.com/go/area120 v0.5.0/go.mod h1:DE/n4mp+iqVyvxHN41Vf1CR602GiHQjFPusMFW6bGR4= -cloud.google.com/go/area120 v0.6.0/go.mod h1:39yFJqWVgm0UZqWTOdqkLhjoC7uFfgXRC8g/ZegeAh0= -cloud.google.com/go/artifactregistry v1.6.0/go.mod h1:IYt0oBPSAGYj/kprzsBjZ/4LnG/zOcHyFHjWPCi6SAQ= -cloud.google.com/go/artifactregistry v1.7.0/go.mod h1:mqTOFOnGZx8EtSqK/ZWcsm/4U8B77rbcLP6ruDU2Ixk= -cloud.google.com/go/asset v1.5.0/go.mod h1:5mfs8UvcM5wHhqtSv8J1CtxxaQq3AdBxxQi2jGW/K4o= -cloud.google.com/go/asset v1.7.0/go.mod h1:YbENsRK4+xTiL+Ofoj5Ckf+O17kJtgp3Y3nn4uzZz5s= -cloud.google.com/go/assuredworkloads v1.5.0/go.mod h1:n8HOZ6pff6re5KYfBXcFvSViQjDwxFkAkmUFffJRbbY= -cloud.google.com/go/assuredworkloads v1.6.0/go.mod h1:yo2YOk37Yc89Rsd5QMVECvjaMKymF9OP+QXWlKXUkXw= -cloud.google.com/go/automl v1.5.0/go.mod h1:34EjfoFGMZ5sgJ9EoLsRtdPSNZLcfflJR39VbVNS2M0= -cloud.google.com/go/automl v1.6.0/go.mod h1:ugf8a6Fx+zP0D59WLhqgTDsQI9w07o64uf/Is3Nh5p8= -cloud.google.com/go/bigquery v1.0.1/go.mod h1:i/xbL2UlR5RvWAURpBYZTtm/cXjCha9lbfbpx4poX+o= -cloud.google.com/go/bigquery v1.3.0/go.mod h1:PjpwJnslEMmckchkHFfq+HTD2DmtT67aNFKH1/VBDHE= -cloud.google.com/go/bigquery v1.4.0/go.mod h1:S8dzgnTigyfTmLBfrtrhyYhwRxG72rYxvftPBK2Dvzc= -cloud.google.com/go/bigquery v1.5.0/go.mod h1:snEHRnqQbz117VIFhE8bmtwIDY80NLUZUMb4Nv6dBIg= -cloud.google.com/go/bigquery v1.7.0/go.mod h1://okPTzCYNXSlb24MZs83e2Do+h+VXtc4gLoIoXIAPc= -cloud.google.com/go/bigquery v1.8.0/go.mod h1:J5hqkt3O0uAFnINi6JXValWIb1v0goeZM77hZzJN/fQ= -cloud.google.com/go/bigquery v1.42.0/go.mod h1:8dRTJxhtG+vwBKzE5OseQn/hiydoQN3EedCaOdYmxRA= -cloud.google.com/go/billing v1.4.0/go.mod h1:g9IdKBEFlItS8bTtlrZdVLWSSdSyFUZKXNS02zKMOZY= -cloud.google.com/go/billing v1.5.0/go.mod h1:mztb1tBc3QekhjSgmpf/CV4LzWXLzCArwpLmP2Gm88s= -cloud.google.com/go/binaryauthorization v1.1.0/go.mod h1:xwnoWu3Y84jbuHa0zd526MJYmtnVXn0syOjaJgy4+dM= -cloud.google.com/go/binaryauthorization v1.2.0/go.mod h1:86WKkJHtRcv5ViNABtYMhhNWRrD1Vpi//uKEy7aYEfI= -cloud.google.com/go/cloudtasks v1.5.0/go.mod h1:fD92REy1x5woxkKEkLdvavGnPJGEn8Uic9nWuLzqCpY= -cloud.google.com/go/cloudtasks v1.6.0/go.mod h1:C6Io+sxuke9/KNRkbQpihnW93SWDU3uXt92nu85HkYI= -cloud.google.com/go/compute v0.1.0/go.mod h1:GAesmwr110a34z04OlxYkATPBEfVhkymfTBXtfbBFow= -cloud.google.com/go/compute v1.3.0/go.mod h1:cCZiE1NHEtai4wiufUhW8I8S1JKkAnhnQJWM7YD99wM= -cloud.google.com/go/compute v1.5.0/go.mod h1:9SMHyhJlzhlkJqrPAc839t2BZFTSk6Jdj6mkzQJeu0M= -cloud.google.com/go/compute v1.6.0/go.mod h1:T29tfhtVbq1wvAPo0E3+7vhgmkOYeXjhFvz/FMzPu0s= -cloud.google.com/go/compute v1.6.1/go.mod h1:g85FgpzFvNULZ+S8AYq87axRKuf2Kh7deLqV/jJ3thU= -cloud.google.com/go/compute v1.7.0/go.mod h1:435lt8av5oL9P3fv1OEzSbSUe+ybHXGMPQHHZWZxy9U= -cloud.google.com/go/containeranalysis v0.5.1/go.mod h1:1D92jd8gRR/c0fGMlymRgxWD3Qw9C1ff6/T7mLgVL8I= -cloud.google.com/go/containeranalysis v0.6.0/go.mod h1:HEJoiEIu+lEXM+k7+qLCci0h33lX3ZqoYFdmPcoO7s4= -cloud.google.com/go/datacatalog v1.3.0/go.mod h1:g9svFY6tuR+j+hrTw3J2dNcmI0dzmSiyOzm8kpLq0a0= -cloud.google.com/go/datacatalog v1.5.0/go.mod h1:M7GPLNQeLfWqeIm3iuiruhPzkt65+Bx8dAKvScX8jvs= -cloud.google.com/go/datacatalog v1.6.0/go.mod h1:+aEyF8JKg+uXcIdAmmaMUmZ3q1b/lKLtXCmXdnc0lbc= -cloud.google.com/go/dataflow v0.6.0/go.mod h1:9QwV89cGoxjjSR9/r7eFDqqjtvbKxAK2BaYU6PVk9UM= -cloud.google.com/go/dataflow v0.7.0/go.mod h1:PX526vb4ijFMesO1o202EaUmouZKBpjHsTlCtB4parQ= -cloud.google.com/go/dataform v0.3.0/go.mod h1:cj8uNliRlHpa6L3yVhDOBrUXH+BPAO1+KFMQQNSThKo= -cloud.google.com/go/dataform v0.4.0/go.mod h1:fwV6Y4Ty2yIFL89huYlEkwUPtS7YZinZbzzj5S9FzCE= -cloud.google.com/go/datalabeling v0.5.0/go.mod h1:TGcJ0G2NzcsXSE/97yWjIZO0bXj0KbVlINXMG9ud42I= -cloud.google.com/go/datalabeling v0.6.0/go.mod h1:WqdISuk/+WIGeMkpw/1q7bK/tFEZxsrFJOJdY2bXvTQ= -cloud.google.com/go/dataqna v0.5.0/go.mod h1:90Hyk596ft3zUQ8NkFfvICSIfHFh1Bc7C4cK3vbhkeo= -cloud.google.com/go/dataqna v0.6.0/go.mod h1:1lqNpM7rqNLVgWBJyk5NF6Uen2PHym0jtVJonplVsDA= -cloud.google.com/go/datastore v1.0.0/go.mod h1:LXYbyblFSglQ5pkeyhO+Qmw7ukd3C+pD7TKLgZqpHYE= -cloud.google.com/go/datastore v1.1.0/go.mod h1:umbIZjpQpHh4hmRpGhH4tLFup+FVzqBi1b3c64qFpCk= -cloud.google.com/go/datastream v1.2.0/go.mod h1:i/uTP8/fZwgATHS/XFu0TcNUhuA0twZxxQ3EyCUQMwo= -cloud.google.com/go/datastream v1.3.0/go.mod h1:cqlOX8xlyYF/uxhiKn6Hbv6WjwPPuI9W2M9SAXwaLLQ= -cloud.google.com/go/dialogflow v1.15.0/go.mod h1:HbHDWs33WOGJgn6rfzBW1Kv807BE3O1+xGbn59zZWI4= -cloud.google.com/go/dialogflow v1.16.1/go.mod h1:po6LlzGfK+smoSmTBnbkIZY2w8ffjz/RcGSS+sh1el0= -cloud.google.com/go/documentai v1.7.0/go.mod h1:lJvftZB5NRiFSX4moiye1SMxHx0Bc3x1+p9e/RfXYiU= -cloud.google.com/go/documentai v1.8.0/go.mod h1:xGHNEB7CtsnySCNrCFdCyyMz44RhFEEX2Q7UD0c5IhU= -cloud.google.com/go/domains v0.6.0/go.mod h1:T9Rz3GasrpYk6mEGHh4rymIhjlnIuB4ofT1wTxDeT4Y= -cloud.google.com/go/domains v0.7.0/go.mod h1:PtZeqS1xjnXuRPKE/88Iru/LdfoRyEHYA9nFQf4UKpg= -cloud.google.com/go/edgecontainer v0.1.0/go.mod h1:WgkZ9tp10bFxqO8BLPqv2LlfmQF1X8lZqwW4r1BTajk= -cloud.google.com/go/firestore v1.1.0/go.mod h1:ulACoGHTpvq5r8rxGJ4ddJZBZqakUQqClKRT5SZwBmk= -cloud.google.com/go/functions v1.6.0/go.mod h1:3H1UA3qiIPRWD7PeZKLvHZ9SaQhR26XIJcC0A5GbvAk= -cloud.google.com/go/functions v1.7.0/go.mod h1:+d+QBcWM+RsrgZfV9xo6KfA1GlzJfxcfZcRPEhDDfzg= -cloud.google.com/go/gaming v1.5.0/go.mod h1:ol7rGcxP/qHTRQE/RO4bxkXq+Fix0j6D4LFPzYTIrDM= -cloud.google.com/go/gaming v1.6.0/go.mod h1:YMU1GEvA39Qt3zWGyAVA9bpYz/yAhTvaQ1t2sK4KPUA= -cloud.google.com/go/gkeconnect v0.5.0/go.mod h1:c5lsNAg5EwAy7fkqX/+goqFsU1Da/jQFqArp+wGNr/o= -cloud.google.com/go/gkeconnect v0.6.0/go.mod h1:Mln67KyU/sHJEBY8kFZ0xTeyPtzbq9StAVvEULYK16A= -cloud.google.com/go/gkehub v0.9.0/go.mod h1:WYHN6WG8w9bXU0hqNxt8rm5uxnk8IH+lPY9J2TV7BK0= -cloud.google.com/go/gkehub v0.10.0/go.mod h1:UIPwxI0DsrpsVoWpLB0stwKCP+WFVG9+y977wO+hBH0= -cloud.google.com/go/grafeas v0.2.0/go.mod h1:KhxgtF2hb0P191HlY5besjYm6MqTSTj3LSI+M+ByZHc= -cloud.google.com/go/iam v0.3.0/go.mod h1:XzJPvDayI+9zsASAFO68Hk07u3z+f+JrT2xXNdp4bnY= -cloud.google.com/go/language v1.4.0/go.mod h1:F9dRpNFQmJbkaop6g0JhSBXCNlO90e1KWx5iDdxbWic= -cloud.google.com/go/language v1.6.0/go.mod h1:6dJ8t3B+lUYfStgls25GusK04NLh3eDLQnWM3mdEbhI= -cloud.google.com/go/lifesciences v0.5.0/go.mod h1:3oIKy8ycWGPUyZDR/8RNnTOYevhaMLqh5vLUXs9zvT8= -cloud.google.com/go/lifesciences v0.6.0/go.mod h1:ddj6tSX/7BOnhxCSd3ZcETvtNr8NZ6t/iPhY2Tyfu08= -cloud.google.com/go/mediatranslation v0.5.0/go.mod h1:jGPUhGTybqsPQn91pNXw0xVHfuJ3leR1wj37oU3y1f4= -cloud.google.com/go/mediatranslation v0.6.0/go.mod h1:hHdBCTYNigsBxshbznuIMFNe5QXEowAuNmmC7h8pu5w= -cloud.google.com/go/memcache v1.4.0/go.mod h1:rTOfiGZtJX1AaFUrOgsMHX5kAzaTQ8azHiuDoTPzNsE= -cloud.google.com/go/memcache v1.5.0/go.mod h1:dk3fCK7dVo0cUU2c36jKb4VqKPS22BTkf81Xq617aWM= -cloud.google.com/go/metastore v1.5.0/go.mod h1:2ZNrDcQwghfdtCwJ33nM0+GrBGlVuh8rakL3vdPY3XY= -cloud.google.com/go/metastore v1.6.0/go.mod h1:6cyQTls8CWXzk45G55x57DVQ9gWg7RiH65+YgPsNh9s= -cloud.google.com/go/networkconnectivity v1.4.0/go.mod h1:nOl7YL8odKyAOtzNX73/M5/mGZgqqMeryi6UPZTk/rA= -cloud.google.com/go/networkconnectivity v1.5.0/go.mod h1:3GzqJx7uhtlM3kln0+x5wyFvuVH1pIBJjhCpjzSt75o= -cloud.google.com/go/networksecurity v0.5.0/go.mod h1:xS6fOCoqpVC5zx15Z/MqkfDwH4+m/61A3ODiDV1xmiQ= -cloud.google.com/go/networksecurity v0.6.0/go.mod h1:Q5fjhTr9WMI5mbpRYEbiexTzROf7ZbDzvzCrNl14nyU= -cloud.google.com/go/notebooks v1.2.0/go.mod h1:9+wtppMfVPUeJ8fIWPOq1UnATHISkGXGqTkxeieQ6UY= -cloud.google.com/go/notebooks v1.3.0/go.mod h1:bFR5lj07DtCPC7YAAJ//vHskFBxA5JzYlH68kXVdk34= -cloud.google.com/go/osconfig v1.7.0/go.mod h1:oVHeCeZELfJP7XLxcBGTMBvRO+1nQ5tFG9VQTmYS2Fs= -cloud.google.com/go/osconfig v1.8.0/go.mod h1:EQqZLu5w5XA7eKizepumcvWx+m8mJUhEwiPqWiZeEdg= -cloud.google.com/go/oslogin v1.4.0/go.mod h1:YdgMXWRaElXz/lDk1Na6Fh5orF7gvmJ0FGLIs9LId4E= -cloud.google.com/go/oslogin v1.5.0/go.mod h1:D260Qj11W2qx/HVF29zBg+0fd6YCSjSqLUkY/qEenQU= -cloud.google.com/go/phishingprotection v0.5.0/go.mod h1:Y3HZknsK9bc9dMi+oE8Bim0lczMU6hrX0UpADuMefr0= -cloud.google.com/go/phishingprotection v0.6.0/go.mod h1:9Y3LBLgy0kDTcYET8ZH3bq/7qni15yVUoAxiFxnlSUA= -cloud.google.com/go/privatecatalog v0.5.0/go.mod h1:XgosMUvvPyxDjAVNDYxJ7wBW8//hLDDYmnsNcMGq1K0= -cloud.google.com/go/privatecatalog v0.6.0/go.mod h1:i/fbkZR0hLN29eEWiiwue8Pb+GforiEIBnV9yrRUOKI= -cloud.google.com/go/pubsub v1.0.1/go.mod h1:R0Gpsv3s54REJCy4fxDixWD93lHJMoZTyQ2kNxGRt3I= -cloud.google.com/go/pubsub v1.1.0/go.mod h1:EwwdRX2sKPjnvnqCa270oGRyludottCI76h+R3AArQw= -cloud.google.com/go/pubsub v1.2.0/go.mod h1:jhfEVHT8odbXTkndysNHCcx0awwzvfOlguIAii9o8iA= -cloud.google.com/go/pubsub v1.3.1/go.mod h1:i+ucay31+CNRpDW4Lu78I4xXG+O1r/MAHgjpRVR+TSU= -cloud.google.com/go/recaptchaenterprise v1.3.1/go.mod h1:OdD+q+y4XGeAlxRaMn1Y7/GveP6zmq76byL6tjPE7d4= -cloud.google.com/go/recaptchaenterprise/v2 v2.1.0/go.mod h1:w9yVqajwroDNTfGuhmOjPDN//rZGySaf6PtFVcSCa7o= -cloud.google.com/go/recaptchaenterprise/v2 v2.2.0/go.mod h1:/Zu5jisWGeERrd5HnlS3EUGb/D335f9k51B/FVil0jk= -cloud.google.com/go/recommendationengine v0.5.0/go.mod h1:E5756pJcVFeVgaQv3WNpImkFP8a+RptV6dDLGPILjvg= -cloud.google.com/go/recommendationengine v0.6.0/go.mod h1:08mq2umu9oIqc7tDy8sx+MNJdLG0fUi3vaSVbztHgJ4= -cloud.google.com/go/recommender v1.5.0/go.mod h1:jdoeiBIVrJe9gQjwd759ecLJbxCDED4A6p+mqoqDvTg= -cloud.google.com/go/recommender v1.6.0/go.mod h1:+yETpm25mcoiECKh9DEScGzIRyDKpZ0cEhWGo+8bo+c= -cloud.google.com/go/redis v1.7.0/go.mod h1:V3x5Jq1jzUcg+UNsRvdmsfuFnit1cfe3Z/PGyq/lm4Y= -cloud.google.com/go/redis v1.8.0/go.mod h1:Fm2szCDavWzBk2cDKxrkmWBqoCiL1+Ctwq7EyqBCA/A= -cloud.google.com/go/retail v1.8.0/go.mod h1:QblKS8waDmNUhghY2TI9O3JLlFk8jybHeV4BF19FrE4= -cloud.google.com/go/retail v1.9.0/go.mod h1:g6jb6mKuCS1QKnH/dpu7isX253absFl6iE92nHwlBUY= -cloud.google.com/go/scheduler v1.4.0/go.mod h1:drcJBmxF3aqZJRhmkHQ9b3uSSpQoltBPGPxGAWROx6s= -cloud.google.com/go/scheduler v1.5.0/go.mod h1:ri073ym49NW3AfT6DZi21vLZrG07GXr5p3H1KxN5QlI= -cloud.google.com/go/secretmanager v1.6.0/go.mod h1:awVa/OXF6IiyaU1wQ34inzQNc4ISIDIrId8qE5QGgKA= -cloud.google.com/go/security v1.5.0/go.mod h1:lgxGdyOKKjHL4YG3/YwIL2zLqMFCKs0UbQwgyZmfJl4= -cloud.google.com/go/security v1.7.0/go.mod h1:mZklORHl6Bg7CNnnjLH//0UlAlaXqiG7Lb9PsPXLfD0= -cloud.google.com/go/security v1.8.0/go.mod h1:hAQOwgmaHhztFhiQ41CjDODdWP0+AE1B3sX4OFlq+GU= -cloud.google.com/go/securitycenter v1.13.0/go.mod h1:cv5qNAqjY84FCN6Y9z28WlkKXyWsgLO832YiWwkCWcU= -cloud.google.com/go/securitycenter v1.14.0/go.mod h1:gZLAhtyKv85n52XYWt6RmeBdydyxfPeTrpToDPw4Auc= -cloud.google.com/go/servicedirectory v1.4.0/go.mod h1:gH1MUaZCgtP7qQiI+F+A+OpeKF/HQWgtAddhTbhL2bs= -cloud.google.com/go/servicedirectory v1.5.0/go.mod h1:QMKFL0NUySbpZJ1UZs3oFAmdvVxhhxB6eJ/Vlp73dfg= -cloud.google.com/go/speech v1.6.0/go.mod h1:79tcr4FHCimOp56lwC01xnt/WPJZc4v3gzyT7FoBkCM= -cloud.google.com/go/speech v1.7.0/go.mod h1:KptqL+BAQIhMsj1kOP2la5DSEEerPDuOP/2mmkhHhZQ= -cloud.google.com/go/storage v1.0.0/go.mod h1:IhtSnM/ZTZV8YYJWCY8RULGVqBDmpoyjwiyrjsg+URw= -cloud.google.com/go/storage v1.5.0/go.mod h1:tpKbwo567HUNpVclU5sGELwQWBDZ8gh0ZeosJ0Rtdos= -cloud.google.com/go/storage v1.6.0/go.mod h1:N7U0C8pVQ/+NIKOBQyamJIeKQKkZ+mxpohlUTyfDhBk= -cloud.google.com/go/storage v1.8.0/go.mod h1:Wv1Oy7z6Yz3DshWRJFhqM/UCfaWIRTdp0RXyy7KQOVs= -cloud.google.com/go/storage v1.10.0/go.mod h1:FLPqc6j+Ki4BU591ie1oL6qBQGu2Bl/tZ9ullr3+Kg0= -cloud.google.com/go/storage v1.22.1/go.mod h1:S8N1cAStu7BOeFfE8KAQzmyyLkK8p/vmRq6kuBTW58Y= -cloud.google.com/go/storage v1.23.0/go.mod h1:vOEEDNFnciUMhBeT6hsJIn3ieU5cFRmzeLgDvXzfIXc= -cloud.google.com/go/talent v1.1.0/go.mod h1:Vl4pt9jiHKvOgF9KoZo6Kob9oV4lwd/ZD5Cto54zDRw= -cloud.google.com/go/talent v1.2.0/go.mod h1:MoNF9bhFQbiJ6eFD3uSsg0uBALw4n4gaCaEjBw9zo8g= -cloud.google.com/go/videointelligence v1.6.0/go.mod h1:w0DIDlVRKtwPCn/C4iwZIJdvC69yInhW0cfi+p546uU= -cloud.google.com/go/videointelligence v1.7.0/go.mod h1:k8pI/1wAhjznARtVT9U1llUaFNPh7muw8QyOUpavru4= -cloud.google.com/go/vision v1.2.0/go.mod h1:SmNwgObm5DpFBme2xpyOyasvBc1aPdjvMk2bBk0tKD0= -cloud.google.com/go/vision/v2 v2.2.0/go.mod h1:uCdV4PpN1S0jyCyq8sIM42v2Y6zOLkZs+4R9LrGYwFo= -cloud.google.com/go/vision/v2 v2.3.0/go.mod h1:UO61abBx9QRMFkNBbf1D8B1LXdS2cGiiCRx0vSpZoUo= -cloud.google.com/go/webrisk v1.4.0/go.mod h1:Hn8X6Zr+ziE2aNd8SliSDWpEnSS1u4R9+xXZmFiHmGE= -cloud.google.com/go/webrisk v1.5.0/go.mod h1:iPG6fr52Tv7sGk0H6qUFzmL3HHZev1htXuWDEEsqMTg= -cloud.google.com/go/workflows v1.6.0/go.mod h1:6t9F5h/unJz41YqfBmqSASJSXccBLtD1Vwf+KmJENM0= -cloud.google.com/go/workflows v1.7.0/go.mod h1:JhSrZuVZWuiDfKEFxU0/F1PQjmpnpcoISEXH2bcHC3M= -dmitri.shuralyov.com/gpu/mtl v0.0.0-20190408044501-666a987793e9/go.mod h1:H6x//7gZCb22OMCxBHrMx7a5I7Hp++hsVxbQ4BYO7hU= -github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= -github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= -github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= -github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo= -github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ= -github.com/HdrHistogram/hdrhistogram-go v1.1.2/go.mod h1:yDgFjdqOqDEKOvasDdhWNXYg9BVp4O+o5f6V/ehm6Oo= -github.com/OneOfOne/xxhash v1.2.2/go.mod h1:HSdplMjZKSmBqAxg5vPj2TmRDmfkzw+cTzAElWljhcU= -github.com/agiledragon/gomonkey v2.0.2+incompatible h1:eXKi9/piiC3cjJD1658mEE2o3NjkJ5vDLgYjCQu0Xlw= -github.com/agiledragon/gomonkey v2.0.2+incompatible/go.mod h1:2NGfXu1a80LLr2cmWXGBDaHEjb1idR6+FVlX5T3D9hw= -github.com/ajstarks/svgo v0.0.0-20180226025133-644b8db467af/go.mod h1:K08gAheRH3/J6wwsYMMT4xOr94bZjxIelGM0+d/wbFw= -github.com/alecthomas/template v0.0.0-20160405071501-a0175ee3bccc/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/template v0.0.0-20190718012654-fb15b899a751/go.mod h1:LOuyumcjzFXgccqObfd/Ljyb9UuFJ6TxHnclSeseNhc= -github.com/alecthomas/units v0.0.0-20151022065526-2efee857e7cf/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190717042225-c3de453c63f4/go.mod h1:ybxpYRFXyAe+OPACYpWeL0wqObRcbAqCMya13uyzqw0= -github.com/alecthomas/units v0.0.0-20190924025748-f65c72e2690d/go.mod h1:rBZYJk541a8SKzHPHnH3zbiI+7dagKZ0cgpgrD7Fyho= -github.com/alibabacloud-go/darabonba-array v0.1.0 h1:vR8s7b1fWAQIjEjWnuF0JiKsCvclSRTfDzZHTYqfufY= -github.com/alibabacloud-go/darabonba-array v0.1.0/go.mod h1:BLKxr0brnggqOJPqT09DFJ8g3fsDshapUD3C3aOEFaI= -github.com/alibabacloud-go/darabonba-encode-util v0.0.2 h1:1uJGrbsGEVqWcWxrS9MyC2NG0Ax+GpOM5gtupki31XE= -github.com/alibabacloud-go/darabonba-encode-util v0.0.2/go.mod h1:JiW9higWHYXm7F4PKuMgEUETNZasrDM6vqVr/Can7H8= -github.com/alibabacloud-go/darabonba-map v0.0.2 h1:qvPnGB4+dJbJIxOOfawxzF3hzMnIpjmafa0qOTp6udc= -github.com/alibabacloud-go/darabonba-map v0.0.2/go.mod h1:28AJaX8FOE/ym8OUFWga+MtEzBunJwQGceGQlvaPGPc= -github.com/alibabacloud-go/darabonba-string v1.0.2 h1:E714wms5ibdzCqGeYJ9JCFywE5nDyvIXIIQbZVFkkqo= -github.com/alibabacloud-go/darabonba-string v1.0.2/go.mod h1:93cTfV3vuPhhEwGGpKKqhVW4jLe7tDpo3LUM0i0g6mA= -github.com/alibabacloud-go/debug v0.0.0-20190504072949-9472017b5c68/go.mod h1:6pb/Qy8c+lqua8cFpEy7g39NRRqOWc3rOwAy8m5Y2BY= -github.com/alibabacloud-go/debug v1.0.0/go.mod h1:8gfgZCCAC3+SCzjWtY053FrOcd4/qlH6IHTI4QyICOc= -github.com/alibabacloud-go/debug v1.0.1 h1:MsW9SmUtbb1Fnt3ieC6NNZi6aEwrXfDksD4QA6GSbPg= -github.com/alibabacloud-go/debug v1.0.1/go.mod h1:8gfgZCCAC3+SCzjWtY053FrOcd4/qlH6IHTI4QyICOc= -github.com/alibabacloud-go/openapi-util v0.1.0 h1:0z75cIULkDrdEhkLWgi9tnLe+KhAFE/r5Pb3312/eAY= -github.com/alibabacloud-go/openapi-util v0.1.0/go.mod h1:sQuElr4ywwFRlCCberQwKRFhRzIyG4QTP/P4y1CJ6Ws= -github.com/alibabacloud-go/tea v1.1.0/go.mod h1:IkGyUSX4Ba1V+k4pCtJUc6jDpZLFph9QMy2VUPTwukg= -github.com/alibabacloud-go/tea v1.1.7/go.mod h1:/tmnEaQMyb4Ky1/5D+SE1BAsa5zj/KeGOFfwYm3N/p4= -github.com/alibabacloud-go/tea v1.1.11/go.mod h1:/tmnEaQMyb4Ky1/5D+SE1BAsa5zj/KeGOFfwYm3N/p4= -github.com/alibabacloud-go/tea v1.1.17/go.mod h1:nXxjm6CIFkBhwW4FQkNrolwbfon8Svy6cujmKFUq98A= -github.com/alibabacloud-go/tea v1.2.1/go.mod h1:qbzof29bM/IFhLMtJPrgTGK3eauV5J2wSyEUo4OEmnA= -github.com/alibabacloud-go/tea v1.2.2 h1:aTsR6Rl3ANWPfqeQugPglfurloyBJY85eFy7Gc1+8oU= -github.com/alibabacloud-go/tea v1.2.2/go.mod h1:CF3vOzEMAG+bR4WOql8gc2G9H3EkH3ZLAQdpmpXMgwk= -github.com/alibabacloud-go/tea-utils v1.3.1/go.mod h1:EI/o33aBfj3hETm4RLiAxF/ThQdSngxrpF8rKUDJjPE= -github.com/alibabacloud-go/tea-utils v1.4.4 h1:lxCDvNCdTo9FaXKKq45+4vGETQUKNOW/qKTcX9Sk53o= -github.com/alibabacloud-go/tea-utils v1.4.4/go.mod h1:KNcT0oXlZZxOXINnZBs6YvgOd5aYp9U67G+E3R8fcQw= -github.com/alibabacloud-go/tea-utils/v2 v2.0.3 h1:6OM8vm/6pjQg1a7zc3QNMviaoumnhImRi5V84CnuFkc= -github.com/alibabacloud-go/tea-utils/v2 v2.0.3/go.mod h1:sj1PbjPodAVTqGTA3olprfeeqqmwD0A5OQz94o9EuXQ= -github.com/aliyun/alibaba-cloud-sdk-go v1.61.1800/go.mod h1:RcDobYh8k5VP6TNybz9m++gL3ijVI5wueVr0EM10VsU= -github.com/aliyun/alibaba-cloud-sdk-go v1.63.7 h1:MOFLOVlBI1MvP4I0cwb9cXf83GNcMss1btQqjbp11CM= -github.com/aliyun/alibaba-cloud-sdk-go v1.63.7/go.mod h1:SOSDHfe1kX91v3W5QiBsWSLqeLxImobbMX1mxrFHsVQ= -github.com/aliyun/alibabacloud-dkms-gcs-go-sdk v0.5.1 h1:nJYyoFP+aqGKgPs9JeZgS1rWQ4NndNR0Zfhh161ZltU= -github.com/aliyun/alibabacloud-dkms-gcs-go-sdk v0.5.1/go.mod h1:WzGOmFFTlUzXM03CJnHWMQ85UN6QGpOXZocCjwkiyOg= -github.com/aliyun/alibabacloud-dkms-transfer-go-sdk v0.1.9 h1:GCzdF5XjQ6LED6wdvEq2MKSlBQmQDkvYRw2S8Qnbo4Y= -github.com/aliyun/alibabacloud-dkms-transfer-go-sdk v0.1.9/go.mod h1:xP0KIZry6i7oGPF24vhAPr1Q8vLZRcMcxtft5xDKwCU= -github.com/antihax/optional v1.0.0/go.mod h1:uupD/76wgC+ih3iEmQUL+0Ugr19nfwCT1kdvxnR2qWY= -github.com/apolloconfig/agollo/v4 v4.3.1 h1:NHjd7KqOPmTvYwJidISc9MPBRO8m9UNrH3tijcEVNAY= -github.com/apolloconfig/agollo/v4 v4.3.1/go.mod h1:n/7qxpKOTbegygLmO5OKmFWCdy3T+S/zioBGlo457Dk= -github.com/armon/circbuf v0.0.0-20150827004946-bbbad097214e/go.mod h1:3U/XgcO3hCbHZ8TKRvWD2dDTCfh9M9ya+I9JpbB7O8o= -github.com/armon/go-metrics v0.0.0-20180917152333-f0300d1749da/go.mod h1:Q73ZrmVTwzkszR9V5SSuryQ31EELlFMUz1kKyl939pY= -github.com/armon/go-metrics v0.4.1 h1:hR91U9KYmb6bLBYLQjyM+3j+rcd/UhE+G78SFnF8gJA= -github.com/armon/go-metrics v0.4.1/go.mod h1:E6amYzXo6aW1tqzoZGT755KkbgrJsSdpwZ+3JqfkOG4= -github.com/armon/go-radix v0.0.0-20180808171621-7fddfc383310/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/armon/go-radix v1.0.0/go.mod h1:ufUuZ+zHj4x4TnLV4JWEpy2hxWSpsRywHrMgIH9cCH8= -github.com/benbjohnson/clock v1.1.0/go.mod h1:J11/hYXuz8f4ySSvYwY0FKfm+ezbsZBKZxNJlLklBHA= -github.com/beorn7/perks v0.0.0-20180321164747-3a771d992973/go.mod h1:Dwedo/Wpr24TaqPxmxbtue+5NUziq4I4S80YR8gNf3Q= -github.com/beorn7/perks v1.0.0/go.mod h1:KWe93zE9D1o94FZ5RNwFwVgaQK1VOXiVxmqh+CedLV8= -github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM= -github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw= -github.com/bgentry/speakeasy v0.1.0/go.mod h1:+zsyZBPWlz7T6j88CTgSN5bM796AkVf0kBD4zp0CCIs= -github.com/bketelsen/crypt v0.0.4/go.mod h1:aI6NrJ0pMGgvZKL1iVgXLnfIFJtfV+bKCoqOes/6LfM= -github.com/bsm/ginkgo/v2 v2.12.0 h1:Ny8MWAHyOepLGlLKYmXG4IEkioBysk6GpaRTLC8zwWs= -github.com/bsm/ginkgo/v2 v2.12.0/go.mod h1:SwYbGRRDovPVboqFv0tPTcG1sN61LM1Z4ARdbAV9g4c= -github.com/bsm/gomega v1.27.10 h1:yeMWxP2pV2fG3FgAODIY8EiRE3dy0aeFYt4l7wh6yKA= -github.com/bsm/gomega v1.27.10/go.mod h1:JyEr/xRbxbtgWNi8tIEVPUYZ5Dzef52k01W3YH0H+O0= -github.com/buger/jsonparser v1.1.1 h1:2PnMjfWD7wBILjqQbt530v576A/cAbQvEW9gGIpYMUs= -github.com/buger/jsonparser v1.1.1/go.mod h1:6RYKKt7H4d4+iWqouImQ9R2FZql3VbhNgx27UK13J/0= -github.com/cenkalti/backoff/v4 v4.3.0 h1:MyRJ/UdXutAwSAT+s3wNd7MfTIcy71VQueUuFK343L8= -github.com/cenkalti/backoff/v4 v4.3.0/go.mod h1:Y3VNntkOUPxTVeUxJ/G5vcM//AlwfmyYozVcomhLiZE= -github.com/census-instrumentation/opencensus-proto v0.2.1/go.mod h1:f6KPmirojxKA12rnyqOA5BBL4O983OfeGPqjHWSTneU= -github.com/cespare/xxhash v1.1.0/go.mod h1:XrSqR1VqqWfGrhpAt58auRo0WTKS1nRRg3ghfAqPWnc= -github.com/cespare/xxhash/v2 v2.1.1/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.1.2/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/cespare/xxhash/v2 v2.3.0 h1:UL815xU9SqsFlibzuggzjXhog7bL6oX9BbNZnL2UFvs= -github.com/cespare/xxhash/v2 v2.3.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs= -github.com/chzyer/logex v1.1.10/go.mod h1:+Ywpsq7O8HXn0nuIou7OrIPyXbp3wmkHB+jjWRnGsAI= -github.com/chzyer/readline v0.0.0-20180603132655-2972be24d48e/go.mod h1:nSuG5e5PlCu98SY8svDHJxuZscDgtXS6KTTbou5AhLI= -github.com/chzyer/test v0.0.0-20180213035817-a1ea475d72b1/go.mod h1:Q3SI9o4m/ZMnBNeIyt5eFwwo7qiLfzFZmjNmxjkiQlU= -github.com/circonus-labs/circonus-gometrics v2.3.1+incompatible/go.mod h1:nmEj6Dob7S7YxXgwXpfOuvO54S+tGdZdw9fuRZt25Ag= -github.com/circonus-labs/circonusllhist v0.1.3/go.mod h1:kMXHVDlOchFAehlya5ePtbp5jckzBHf4XRpQvBOLI+I= -github.com/clbanning/mxj/v2 v2.7.0 h1:WA/La7UGCanFe5NpHF0Q3DNtnCsVoxbPKuyBNHWRyME= -github.com/clbanning/mxj/v2 v2.7.0/go.mod h1:hNiWqW14h+kc+MdF9C6/YoRfjEJoR3ou6tn/Qo+ve2s= -github.com/client9/misspell v0.3.4/go.mod h1:qj6jICC3Q7zFZvVWo7KLAzC3yx5G7kyvSDkc90ppPyw= -github.com/cncf/udpa/go v0.0.0-20191209042840-269d4d468f6f/go.mod h1:M8M6+tZqaGXZJjfX53e64911xZQV5JYwmTeXPW+k8Sc= -github.com/cncf/udpa/go v0.0.0-20200629203442-efcf912fb354/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20201120205902-5459f2c99403/go.mod h1:WmhPx2Nbnhtbo57+VJT5O0JRkEi1Wbu0z5j0R8u5Hbk= -github.com/cncf/udpa/go v0.0.0-20210930031921-04548b0d99d4/go.mod h1:6pvJx4me5XPnfI9Z40ddWsdw2W/uZgQLFXToKeRcDiI= -github.com/cncf/xds/go v0.0.0-20210312221358-fbca930ec8ed/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210805033703-aa0b78936158/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20210922020428-25de7278fc84/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211001041855-01bcc9b48dfe/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/cncf/xds/go v0.0.0-20211011173535-cb28da3451f1/go.mod h1:eXthEFrGJvWHgFFCl3hGmgk+/aYT6PnTQLykKQRLhEs= -github.com/coreos/go-semver v0.3.0 h1:wkHLiw0WNATZnSG7epLsujiMCgPAc9xhjJ4tgnAxmfM= -github.com/coreos/go-semver v0.3.0/go.mod h1:nnelYz7RCh+5ahJtPPxZlU+153eP4D4r3EedlOD2RNk= -github.com/coreos/go-systemd/v22 v22.3.2 h1:D9/bQk5vlXQFZ6Kwuu6zaiXJ9oTPe68++AzAJc1DzSI= -github.com/coreos/go-systemd/v22 v22.3.2/go.mod h1:Y58oyj3AT4RCenI/lSvhwexgC+NSVTIJ3seZv2GcEnc= -github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E= -github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc h1:U9qPSI2PIWSS1VwoXQT9A3Wy9MM3WgvqSxFWenqJduM= -github.com/davecgh/go-spew v1.1.2-0.20180830191138-d8f796af33cc/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f h1:lO4WD4F/rVNCu3HqELle0jiPLLBs70cWOduZpkS1E78= -github.com/dgryski/go-rendezvous v0.0.0-20200823014737-9f7001d12a5f/go.mod h1:cuUVRXasLTGF7a8hSLbxyZXjz+1KgoB3wDUb6vlszIc= -github.com/dlclark/regexp2 v1.7.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/dlclark/regexp2 v1.11.2 h1:/u628IuisSTwri5/UKloiIsH8+qF2Pu7xEQX+yIKg68= -github.com/dlclark/regexp2 v1.11.2/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8= -github.com/docopt/docopt-go v0.0.0-20180111231733-ee0de3bc6815/go.mod h1:WwZ+bS3ebgob9U8Nd0kOddGdZWjyMGR8Wziv+TBNwSE= -github.com/emicklei/go-restful/v3 v3.9.0 h1:XwGDlfxEnQZzuopoqxwSEllNcCOM9DhhFyhFIIGKwxE= -github.com/emicklei/go-restful/v3 v3.9.0/go.mod h1:6n3XBCmQQb25CM2LCACGz8ukIrRry+4bhvbpWn3mrbc= -github.com/emirpasic/gods v1.18.1 h1:FXtiHYKDGKCW2KzwZKx0iC0PQmdlorYgdFG9jPXJ1Bc= -github.com/emirpasic/gods v1.18.1/go.mod h1:8tpGGwCnJ5H4r6BWwaV6OrWmMoPhUl5jm/FMNAnJvWQ= -github.com/envoyproxy/go-control-plane v0.9.0/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.1-0.20191026205805-5f8ba28d4473/go.mod h1:YTl/9mNaCwkRvm6d1a2C3ymFceY/DCBVvsKhRF0iEA4= -github.com/envoyproxy/go-control-plane v0.9.4/go.mod h1:6rpuAdCZL397s3pYoYcLgu1mIlRU8Am5FuJP05cCM98= -github.com/envoyproxy/go-control-plane v0.9.7/go.mod h1:cwu0lG7PUMfa9snN8LXBig5ynNVH9qI8YYLbd1fK2po= -github.com/envoyproxy/go-control-plane v0.9.9-0.20201210154907-fd9021fe5dad/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210217033140-668b12f5399d/go.mod h1:cXg6YxExXjJnVBQHBLXeUAgxn2UodCpnH306RInaBQk= -github.com/envoyproxy/go-control-plane v0.9.9-0.20210512163311-63b5d3c536b0/go.mod h1:hliV/p42l8fGbc6Y9bQ70uLwIvmJyVE5k4iMKlh8wCQ= -github.com/envoyproxy/go-control-plane v0.9.10-0.20210907150352-cf90f659a021/go.mod h1:AFq3mo9L8Lqqiid3OhADV3RfLJnjiw63cSpi+fDTRC0= -github.com/envoyproxy/go-control-plane v0.10.2-0.20220325020618-49ff273808a1/go.mod h1:KJwIaB5Mv44NWtYuAOFCVOjcI94vtpEz2JU/D2v6IjE= -github.com/envoyproxy/protoc-gen-validate v0.1.0/go.mod h1:iSmxcyjqTsJpI2R4NaDN7+kN2VEUnK/pcBlmesArF7c= -github.com/fatih/color v1.7.0/go.mod h1:Zm6kSWBoL9eyXnKyktHP6abPY2pDugNf5KwzbycvMj4= -github.com/fatih/color v1.9.0/go.mod h1:eQcE1qtQxscV5RaZvpXrrb8Drkc3/DdQ+uUYCNjL+zU= -github.com/fatih/color v1.13.0/go.mod h1:kLAiJbzzSOZDVNGyDpeOxJ47H46qBXwg5ILebYFFOfk= -github.com/fatih/color v1.18.0 h1:S8gINlzdQ840/4pfAwic/ZE0djQEH3wM94VfqLTZcOM= -github.com/fatih/color v1.18.0/go.mod h1:4FelSpRwEGDpQ12mAdzqdOukCy4u8WUtOY6lkT/6HfU= -github.com/fogleman/gg v1.2.1-0.20190220221249-0403632d5b90/go.mod h1:R/bRT+9gY/C5z7JzPU0zXsXHKM4/ayA+zqcVNZzPa1k= -github.com/fsnotify/fsnotify v1.4.9/go.mod h1:znqG4EE+3YCdAaPaxE2ZRY/06pZUdp0tY4IgpuI1SZQ= -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/ghodss/yaml v1.0.0/go.mod h1:4dBDuWmgqj2HViK6kFavaiC9ZROes6MMH2rRYeMEF04= -github.com/go-gl/glfw v0.0.0-20190409004039-e6da0acd62b1/go.mod h1:vR7hzQXu2zJy9AVAgeJqvqgH9Q5CA+iKCZ2gyEVpxRU= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20191125211704-12ad95a8df72/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-gl/glfw/v3.3/glfw v0.0.0-20200222043503-6f7a984d4dc4/go.mod h1:tQ2UAYgL5IevRw8kRxooKSPJfGvJ9fJQFa0TUsXzTg8= -github.com/go-kit/kit v0.8.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/kit v0.9.0/go.mod h1:xBxKIO96dXMWWy0MnWVtmwkA9/13aqxPnvrjFYMA2as= -github.com/go-kit/log v0.1.0/go.mod h1:zbhenjAZHb184qTLMA9ZjW7ThYL0H2mk7Q6pNt4vbaY= -github.com/go-logfmt/logfmt v0.3.0/go.mod h1:Qt1PoO58o5twSAckw1HlFXLmHsOX5/0LbT9GBnD5lWE= -github.com/go-logfmt/logfmt v0.4.0/go.mod h1:3RMwSq7FuexP4Kalkev3ejPJsZTpXXBr9+V4qmtdjCk= -github.com/go-logfmt/logfmt v0.5.0/go.mod h1:wCYkCAKZfumFQihp8CzCvQ3paCTfi41vtzG1KdI/P7A= -github.com/go-logr/logr v1.2.0/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.2.2/go.mod h1:jdQByPbusPIv2/zmleS9BjJVeZ6kBagPoEUsqbVz/1A= -github.com/go-logr/logr v1.4.2 h1:6pFjapn8bFcIbiKo3XT4j/BhANplGihG6tvd+8rYgrY= -github.com/go-logr/logr v1.4.2/go.mod h1:9T104GzyrTigFIr8wt5mBrctHMim0Nb2HLGrmQ40KvY= -github.com/go-logr/stdr v1.2.2 h1:hSWxHoqTgW2S2qGc0LTAI563KZ5YKYRhT3MFKZMbjag= -github.com/go-logr/stdr v1.2.2/go.mod h1:mMo/vtBO5dYbehREoey6XUKy/eSumjCCveDpRre4VKE= -github.com/go-openapi/jsonpointer v0.19.6 h1:eCs3fxoIi3Wh6vtgmLTOjdhSpiqphQ+DaPn38N2ZdrE= -github.com/go-openapi/jsonpointer v0.19.6/go.mod h1:osyAmYz/mB/C3I+WsTTSgw1ONzaLJoLCyoi6/zppojs= -github.com/go-openapi/jsonreference v0.20.1 h1:FBLnyygC4/IZZr893oiomc9XaghoveYTrLC1F86HID8= -github.com/go-openapi/jsonreference v0.20.1/go.mod h1:Bl1zwGIM8/wsvqjsOQLJ/SH+En5Ap4rVB5KVcIDZG2k= -github.com/go-openapi/swag v0.22.3 h1:yMBqmnQ0gyZvEb/+KzuWZOXgllrXT4SADYbvDaXHv/g= -github.com/go-openapi/swag v0.22.3/go.mod h1:UzaqsxGiab7freDnrUUra0MwWfN/q7tE4j+VcZ0yl14= -github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= -github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= -github.com/go-stack/stack v1.8.0/go.mod h1:v0f6uXyyMGvRgIKkXu+yp6POWl0qKG85gN/melR3HDY= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0 h1:p104kn46Q8WdvHunIJ9dAyjPVtrBPhSr3KT2yUst43I= -github.com/go-task/slim-sprig v0.0.0-20210107165309-348f09dbbbc0/go.mod h1:fyg7847qk6SyHyPtNmDHnmrv/HOrqktSC+C9fM+CJOE= -github.com/godbus/dbus/v5 v5.0.4/go.mod h1:xhWf0FNVPg57R7Z0UbKHbJfkEywrmjJnf7w5xrFpKfA= -github.com/gogo/protobuf v1.1.1/go.mod h1:r8qH/GZQm5c6nD/R0oafs1akxWv10x8SbQlK7atdtwQ= -github.com/gogo/protobuf v1.3.2 h1:Ov1cvc58UF3b5XjBnZv7+opcTcQFZebYjWzi34vdm4Q= -github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= -github.com/goji/httpauth v0.0.0-20160601135302-2da839ab0f4d/go.mod h1:nnjvkQ9ptGaCkuDUx6wNykzzlUixGxvkme+H/lnzb+A= -github.com/golang/freetype v0.0.0-20170609003504-e2365dfdc4a0/go.mod h1:E/TSTwGwJL78qG/PmXZO1EjYhfJinVAhrmmHX6Z8B9k= -github.com/golang/glog v0.0.0-20160126235308-23def4e6c14b/go.mod h1:SBH7ygxi8pfUlaOkMMuAQtPIUF8ecWP5IEl/CR7VP2Q= -github.com/golang/groupcache v0.0.0-20190702054246-869f871628b6/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20191227052852-215e87163ea7/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/groupcache v0.0.0-20200121045136-8c9f03a8e57e/go.mod h1:cIg4eruTrX1D+g88fzRXU5OdNfaM+9IcxsU14FzY7Hc= -github.com/golang/mock v1.1.1/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.2.0/go.mod h1:oTYuIxOrZwtPieC+H1uAHpcLFnEyAGVDL/k47Jfbm0A= -github.com/golang/mock v1.3.1/go.mod h1:sBzyDLLjw3U8JLTeZvSv8jJB+tU5PVekmnlKIyFUx0Y= -github.com/golang/mock v1.4.0/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.1/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.3/go.mod h1:UOMv5ysSaYNkG+OFQykRIcU/QvvxJf3p21QfJ2Bt3cw= -github.com/golang/mock v1.4.4/go.mod h1:l3mdAwkq5BuhzHwde/uurv3sEJeZMXNpwsxVWU71h+4= -github.com/golang/mock v1.5.0/go.mod h1:CWnOUgYIOo4TcNZ0wHX3YZCqsaM1I1Jvs6v3mP3KVu8= -github.com/golang/mock v1.6.0 h1:ErTB+efbowRARo13NNdxyJji2egdxLGQhRaY+DUumQc= -github.com/golang/mock v1.6.0/go.mod h1:p6yTPP+5HYm5mzsMV8JkE6ZKdX+/wYM6Hr+LicevLPs= -github.com/golang/protobuf v1.2.0/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.1/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.2/go.mod h1:6lQm79b+lXiMfvg/cZm0SGofjICqVBUtrP5yJMmIC1U= -github.com/golang/protobuf v1.3.3/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.4/go.mod h1:vzj43D7+SQXF/4pzW/hwtAqwc6iTitCiVSaWz5lYuqw= -github.com/golang/protobuf v1.3.5/go.mod h1:6O5/vntMXwX2lRkT1hjjk0nAC1IDOTvTlVgjlRvqsdk= -github.com/golang/protobuf v1.4.0-rc.1/go.mod h1:ceaxUfeHdC40wWswd/P6IGgMaK3YpKi5j83Wpe3EHw8= -github.com/golang/protobuf v1.4.0-rc.1.0.20200221234624-67d41d38c208/go.mod h1:xKAWHe0F5eneWXFV3EuXVDTCmh+JuBKY0li0aMyXATA= -github.com/golang/protobuf v1.4.0-rc.2/go.mod h1:LlEzMj4AhA7rCAGe4KMBDvJI+AwstrUpVNzEA03Pprs= -github.com/golang/protobuf v1.4.0-rc.4.0.20200313231945-b860323f09d0/go.mod h1:WU3c8KckQ9AFe+yFwt9sWVRKCVIyN9cPHBJSNnbL67w= -github.com/golang/protobuf v1.4.0/go.mod h1:jodUvKwWbYaEsadDk5Fwe5c77LiNKVO9IDvqG2KuDX0= -github.com/golang/protobuf v1.4.1/go.mod h1:U8fpvMrcmy5pZrNK1lt4xCsGvpyWQ/VVv6QDs8UjoX8= -github.com/golang/protobuf v1.4.2/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.4.3/go.mod h1:oDoupMAO8OvCJWAcko0GGGIgR6R6ocIYbsSw735rRwI= -github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaSAoJOfIk= -github.com/golang/protobuf v1.5.1/go.mod h1:DopwsBzvsk0Fs44TXzsVbJyPhcCPeIwnvohx4u74HPM= -github.com/golang/protobuf v1.5.2/go.mod h1:XVQd3VNwM+JqD3oG2Ue2ip4fOMUkwXdXDdiuN0vRsmY= -github.com/golang/protobuf v1.5.4 h1:i7eJL8qZTpSEXOPTxNKhASYpMn+8e5Q6AdndVa1dWek= -github.com/golang/protobuf v1.5.4/go.mod h1:lnTiLA8Wa4RWRcIUkrtSVa5nRhsEGBg48fD6rSs7xps= -github.com/golang/snappy v0.0.3/go.mod h1:/XxbfmMg8lxefKM7IXC3fBNl/7bRcc72aCRzEWrmP2Q= -github.com/gonum/blas v0.0.0-20181208220705-f22b278b28ac/go.mod h1:P32wAyui1PQ58Oce/KYkOqQv8cVw1zAapXOl+dRFGbc= -github.com/gonum/floats v0.0.0-20181209220543-c233463c7e82/go.mod h1:PxC8OnwL11+aosOB5+iEPoV3picfs8tUpkVd0pDo+Kg= -github.com/gonum/integrate v0.0.0-20181209220457-a422b5c0fdf2/go.mod h1:pDgmNM6seYpwvPos3q+zxlXMsbve6mOIPucUnUOrI7Y= -github.com/gonum/internal v0.0.0-20181124074243-f884aa714029/go.mod h1:Pu4dmpkhSyOzRwuXkOgAvijx4o+4YMUJJo9OvPYMkks= -github.com/gonum/lapack v0.0.0-20181123203213-e4cdc5a0bff9/go.mod h1:XA3DeT6rxh2EAE789SSiSJNqxPaC0aE9J8NTOI0Jo/A= -github.com/gonum/matrix v0.0.0-20181209220409-c518dec07be9/go.mod h1:0EXg4mc1CNP0HCqCz+K4ts155PXIlUywf0wqN+GfPZw= -github.com/gonum/stat v0.0.0-20181125101827-41a0da705a5b/go.mod h1:Z4GIJBJO3Wa4gD4vbwQxXXZ+WHmW6E9ixmNrwvs0iZs= -github.com/google/btree v0.0.0-20180813153112-4030bb1f1f0c/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.0/go.mod h1:lNA+9X1NB3Zf8V7Ke586lFgjr2dZNuvo3lPJSGZ5JPQ= -github.com/google/btree v1.0.1 h1:gK4Kx5IaGY9CD5sPJ36FHiBJ6ZXl0kilRiiCj+jdYp4= -github.com/google/btree v1.0.1/go.mod h1:xXMiIv4Fb/0kKde4SpL7qlzvu5cMJDRkFDxJfI9uaxA= -github.com/google/gnostic v0.5.7-v3refs h1:FhTMOKj2VhjpouxvWJAV1TL304uMlb9zcDqkl6cEI54= -github.com/google/gnostic v0.5.7-v3refs/go.mod h1:73MKFl6jIHelAJNaBGFzt3SPtZULs9dYrGFt8OiIsHQ= -github.com/google/go-cmp v0.2.0/go.mod h1:oXzfMopK8JAjlY9xF4vHSVASa0yLyX7SntLO5aqRK0M= -github.com/google/go-cmp v0.3.0/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.3.1/go.mod h1:8QqcDgzrUqlUb/G2PQTWiueGozuR1884gddMywk6iLU= -github.com/google/go-cmp v0.4.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.4.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.0/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.1/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.2/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.3/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.4/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.6/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= -github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= -github.com/google/go-cmp v0.5.8/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= -github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= -github.com/google/gofuzz v1.0.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/gofuzz v1.1.0 h1:Hsa8mG0dQ46ij8Sl2AYJDUv1oA9/d6Vk+3LG99Oe02g= -github.com/google/gofuzz v1.1.0/go.mod h1:dBl0BpW6vV/+mYPU4Po3pmUjxk6FQPldtuIdl/M65Eg= -github.com/google/martian v2.1.0+incompatible/go.mod h1:9I4somxYTbIHy5NJKHRl3wXiIaQGbYVAs8BPL6v8lEs= -github.com/google/martian/v3 v3.0.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.1.0/go.mod h1:y5Zk1BBys9G+gd6Jrk0W3cC1+ELVxBWuIGO+w/tUAp0= -github.com/google/martian/v3 v3.2.1/go.mod h1:oBOf6HBosgwRXnUGWUB05QECsc6uvmMiJ3+6W4l/CUk= -github.com/google/pprof v0.0.0-20181206194817-3ea8567a2e57/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20190515194954-54271f7e092f/go.mod h1:zfwlbNMJ+OItoe0UupaVj+oy1omPYYDuagoSzA8v9mc= -github.com/google/pprof v0.0.0-20191218002539-d4f498aebedc/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200212024743-f11f1df84d12/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200229191704-1ebb73c60ed3/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200430221834-fc25d7d30c6d/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20200708004538-1a94d8640e99/go.mod h1:ZgVRPoUq/hfqzAqh7sHMqb3I9Rq5C59dIz2SbBwJ4eM= -github.com/google/pprof v0.0.0-20201023163331-3e6fc7fc9c4c/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20201203190320-1bf35d6f28c2/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210122040257-d980be63207e/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210226084205-cbba55b83ad5/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210601050228-01bbb1931b22/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210609004039-a478d1d731e9/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1 h1:K6RDEckDVWvDI9JAJYCmNdQXq6neHJOYx3V6jnqNEec= -github.com/google/pprof v0.0.0-20210720184732-4bb14d4b1be1/go.mod h1:kpwsk12EmLew5upagYY7GY0pfYCcupk39gWOCRROcvE= -github.com/google/renameio v0.1.0/go.mod h1:KWCgfxg9yswjAJkECMjeO8J8rahYeXnNhOm40UhjYkI= -github.com/google/uuid v1.1.2/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= -github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= -github.com/googleapis/enterprise-certificate-proxy v0.0.0-20220520183353-fd19c99a87aa/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= -github.com/googleapis/enterprise-certificate-proxy v0.1.0/go.mod h1:17drOmN3MwGY7t0e+Ei9b45FFGA3fBs3x36SsCg1hq8= -github.com/googleapis/gax-go/v2 v2.0.4/go.mod h1:0Wqv26UfaUD9n4G6kQubkQ+KchISgw+vpHVxEJEs9eg= -github.com/googleapis/gax-go/v2 v2.0.5/go.mod h1:DWXyrwAJ9X0FpwwEdw+IPEYBICEFu5mhpdKc/us6bOk= -github.com/googleapis/gax-go/v2 v2.1.0/go.mod h1:Q3nei7sK6ybPYH7twZdmQpAd1MKb7pfu6SK+H1/DsU0= -github.com/googleapis/gax-go/v2 v2.1.1/go.mod h1:hddJymUZASv3XPyGkUpKj8pPO47Rmb0eJc8R6ouapiM= -github.com/googleapis/gax-go/v2 v2.2.0/go.mod h1:as02EH8zWkzwUoLbBaFeQ+arQaj/OthfcblKl4IGNaM= -github.com/googleapis/gax-go/v2 v2.3.0/go.mod h1:b8LNqSzNabLiUpXKkY7HAR5jr6bIT99EXz9pXxye9YM= -github.com/googleapis/gax-go/v2 v2.4.0/go.mod h1:XOTVJ59hdnfJLIP/dh8n5CGryZR2LxK9wbMD5+iXC6c= -github.com/googleapis/gax-go/v2 v2.5.1/go.mod h1:h6B0KMMFNtI2ddbGJn3T3ZbwkeT6yqEF02fYlzkUCyo= -github.com/googleapis/go-type-adapters v1.0.0/go.mod h1:zHW75FOG2aur7gAO2B+MLby+cLsWGBF62rFAi7WjWO4= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1 h1:EGx4pi6eqNxGaHF6qqu48+N2wcFQ5qg5FXgOdqsJ5d8= -github.com/gopherjs/gopherjs v0.0.0-20181017120253-0766667cb4d1/go.mod h1:wJfORRmW1u3UXTncJ5qlYoELFm8eSnnEO6hX4iZ3EWY= -github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg= -github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE= -github.com/grokify/html-strip-tags-go v0.1.0 h1:03UrQLjAny8xci+R+qjCce/MYnpNXCtgzltlQbOBae4= -github.com/grokify/html-strip-tags-go v0.1.0/go.mod h1:ZdzgfHEzAfz9X6Xe5eBLVblWIxXfYSQ40S/VKrAOGpc= -github.com/grpc-ecosystem/grpc-gateway v1.16.0/go.mod h1:BDjrQk3hbvj6Nolgz8mAMFbcEtjT1g+wF4CSlocrBnw= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0 h1:asbCHRVmodnJTuQ3qamDwqVOIjwqUPTYmYuemVOx+Ys= -github.com/grpc-ecosystem/grpc-gateway/v2 v2.22.0/go.mod h1:ggCgvZ2r7uOoQjOyu2Y1NhHmEPPzzuhWgcza5M1Ji1I= -github.com/hashicorp/consul/api v1.1.0/go.mod h1:VmuI/Lkw1nC05EYQWNKwWGbkg+FbDBtguAZLlVdkD9Q= -github.com/hashicorp/consul/api v1.26.1 h1:5oSXOO5fboPZeW5SN+TdGFP/BILDgBm19OrPZ/pICIM= -github.com/hashicorp/consul/api v1.26.1/go.mod h1:B4sQTeaSO16NtynqrAdwOlahJ7IUDZM9cj2420xYL8A= -github.com/hashicorp/consul/sdk v0.1.1/go.mod h1:VKf9jXwCTEY1QZP2MOLRhb5i/I/ssyNV1vwHyQBF0x8= -github.com/hashicorp/consul/sdk v0.15.0 h1:2qK9nDrr4tiJKRoxPGhm6B7xJjLVIQqkjiab2M4aKjU= -github.com/hashicorp/consul/sdk v0.15.0/go.mod h1:r/OmRRPbHOe0yxNahLw7G9x5WG17E1BIECMtCjcPSNo= -github.com/hashicorp/errwrap v1.0.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/errwrap v1.1.0 h1:OxrOeh75EUXMY8TBjag2fzXGZ40LB6IKw45YeGUDY2I= -github.com/hashicorp/errwrap v1.1.0/go.mod h1:YH+1FKiLXxHSkmPseP+kNlulaMuP3n2brvKWEqk/Jc4= -github.com/hashicorp/go-cleanhttp v0.5.0/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.1/go.mod h1:JpRdi6/HCYpAwUzNwuwqhbovhLtngrth3wmdIIUrZ80= -github.com/hashicorp/go-cleanhttp v0.5.2 h1:035FKYIWjmULyFRBKPs8TBQoi0x6d9G4xc9neXJWAZQ= -github.com/hashicorp/go-cleanhttp v0.5.2/go.mod h1:kO/YDlP8L1346E6Sodw+PrpBSV4/SoxCXGY6BqNFT48= -github.com/hashicorp/go-hclog v1.5.0 h1:bI2ocEMgcVlz55Oj1xZNBsVi900c7II+fWDyV9o+13c= -github.com/hashicorp/go-hclog v1.5.0/go.mod h1:W4Qnvbt70Wk/zYJryRzDRU/4r0kIg0PVHBcfoyhpF5M= -github.com/hashicorp/go-immutable-radix v1.0.0/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-immutable-radix v1.3.1 h1:DKHmCUm2hRBK510BaiZlwvpD40f8bJFeZnpfm2KLowc= -github.com/hashicorp/go-immutable-radix v1.3.1/go.mod h1:0y9vanUI8NX6FsYoO3zeMjhV/C5i9g4Q3DwcSNZ4P60= -github.com/hashicorp/go-msgpack v0.5.3/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-msgpack v0.5.5 h1:i9R9JSrqIz0QVLz3sz+i3YJdT7TTSLcfLLzJi9aZTuI= -github.com/hashicorp/go-msgpack v0.5.5/go.mod h1:ahLV/dePpqEmjfWmKiqvPkv/twdG7iPBM1vqhUKIvfM= -github.com/hashicorp/go-multierror v1.0.0/go.mod h1:dHtQlpGsu+cZNNAkkCN/P3hoUDHhCYQXV3UM06sGGrk= -github.com/hashicorp/go-multierror v1.1.0/go.mod h1:spPvp8C1qA32ftKqdAHm4hHTbPw+vmowP0z+KUhOZdA= -github.com/hashicorp/go-multierror v1.1.1 h1:H5DkEtf6CXdFp0N0Em5UCwQpXMWke8IA0+lD48awMYo= -github.com/hashicorp/go-multierror v1.1.1/go.mod h1:iw975J/qwKPdAO1clOe2L8331t/9/fmwbPZ6JB6eMoM= -github.com/hashicorp/go-retryablehttp v0.5.3/go.mod h1:9B5zBasrRhHXnJnui7y6sL7es7NDiJgTc6Er0maI1Xs= -github.com/hashicorp/go-rootcerts v1.0.0/go.mod h1:K6zTfqpRlCUIjkwsN4Z+hiSfzSTQa6eBIzfwKfwNnHU= -github.com/hashicorp/go-rootcerts v1.0.2 h1:jzhAVGtqPKbwpyCPELlgNWhE1znq+qwJtW5Oi2viEzc= -github.com/hashicorp/go-rootcerts v1.0.2/go.mod h1:pqUvnprVnM5bf7AOirdbb01K4ccR319Vf4pU3K5EGc8= -github.com/hashicorp/go-sockaddr v1.0.0/go.mod h1:7Xibr9yA9JjQq1JpNB2Vw7kxv8xerXegt+ozgdvDeDU= -github.com/hashicorp/go-sockaddr v1.0.2 h1:ztczhD1jLxIRjVejw8gFomI1BQZOe2WoVOu0SyteCQc= -github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjGlgmH/UkBUC97A= -github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= -github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-uuid v1.0.3 h1:2gKiV6YVmrJ1i2CKKa9obLvRieoRGviZFL26PcT/Co8= -github.com/hashicorp/go-uuid v1.0.3/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= -github.com/hashicorp/go-version v1.2.1 h1:zEfKbn2+PDgroKdiOzqiE8rsmLqU2uwi5PB5pBJ3TkI= -github.com/hashicorp/go-version v1.2.1/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= -github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= -github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v0.5.1/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= -github.com/hashicorp/golang-lru v1.0.2 h1:dV3g9Z/unq5DpblPpw+Oqcv4dU/1omnb4Ok8iPY6p1c= -github.com/hashicorp/golang-lru v1.0.2/go.mod h1:iADmTwqILo4mZ8BN3D2Q6+9jd8WM5uGBxy+E8yxSoD4= -github.com/hashicorp/hcl v1.0.0 h1:0Anlzjpi4vEasTeNFn2mLJgTSwt0+6sfsiTG8qcWGx4= -github.com/hashicorp/hcl v1.0.0/go.mod h1:E5yfLk+7swimpb2L/Alb/PJmXilQ/rhwaUYs4T20WEQ= -github.com/hashicorp/logutils v1.0.0/go.mod h1:QIAnNjmIWmVIIkWDTG1z5v++HQmx9WQRO+LraFDTW64= -github.com/hashicorp/mdns v1.0.0/go.mod h1:tL+uN++7HEJ6SQLQ2/p+z2pH24WQKWjBPkE0mNTz8vQ= -github.com/hashicorp/mdns v1.0.4/go.mod h1:mtBihi+LeNXGtG8L9dX59gAEa12BDtBQSp4v/YAJqrc= -github.com/hashicorp/memberlist v0.1.3/go.mod h1:ajVTdAv/9Im8oMAAj5G31PhhMCZJV2pPBoIllUwCN7I= -github.com/hashicorp/memberlist v0.5.0 h1:EtYPN8DpAURiapus508I4n9CzHs2W+8NZGbmmR/prTM= -github.com/hashicorp/memberlist v0.5.0/go.mod h1:yvyXLpo0QaGE59Y7hDTsTzDD25JYBZ4mHgHUZ8lrOI0= -github.com/hashicorp/serf v0.8.2/go.mod h1:6hOLApaqBFA1NXqRQAsxw9QxuDEvNxSQRwA/JwenrHc= -github.com/hashicorp/serf v0.10.1 h1:Z1H2J60yRKvfDYAOZLd2MU0ND4AH/WDz7xYHDWQsIPY= -github.com/hashicorp/serf v0.10.1/go.mod h1:yL2t6BqATOLGc5HF7qbFkTfXoPIY0WZdWHfEvMqbG+4= -github.com/ianlancetaylor/demangle v0.0.0-20181102032728-5e5cf60278f6/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/ianlancetaylor/demangle v0.0.0-20200824232613-28f6c0f3b639/go.mod h1:aSSvb/t6k1mPoxDqO4vJh6VOCGPwU4O0C2/Eqndh1Sc= -github.com/imdario/mergo v0.3.6 h1:xTNEAn+kxVO7dTZGu0CegyqKZmoWFI0rF8UxjlB2d28= -github.com/imdario/mergo v0.3.6/go.mod h1:2EnlNZ0deacrJVfApfmtdGgDfMuh/nq6Ok1EcJh5FfA= -github.com/jmespath/go-jmespath v0.0.0-20180206201540-c2b33e8439af/go.mod h1:Nht3zPeWKUH0NzdCt2Blrr5ys8VGpn0CEB0cQHVjt7k= -github.com/jmespath/go-jmespath v0.4.0 h1:BEgLn5cpjn8UN1mAw4NjwDrS35OdebyEtFe+9YPoQUg= -github.com/jmespath/go-jmespath v0.4.0/go.mod h1:T8mJZnbsbmF+m6zOOFylbeCJqk5+pHWvzYPziyZiYoo= -github.com/jmespath/go-jmespath/internal/testify v1.5.1 h1:shLQSRRSCCPj3f2gpwzGwWFoC7ycTf1rcQZHOlsJ6N8= -github.com/jmespath/go-jmespath/internal/testify v1.5.1/go.mod h1:L3OGu8Wl2/fWfCI6z80xFu9LTZmf1ZRjMHUOPmWr69U= -github.com/josharian/intern v1.0.0 h1:vlS4z54oSdjm0bgjRigI+G1HpF+tI+9rE5LLzOg8HmY= -github.com/josharian/intern v1.0.0/go.mod h1:5DoeVV0s6jJacbCEi61lwdGj/aVlrQvzHFFd8Hwg//Y= -github.com/jpillora/backoff v1.0.0/go.mod h1:J/6gKK9jxlEcS3zixgDgUAsiuZ7yrSoa/FX5e0EB2j4= -github.com/json-iterator/go v1.1.5/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.6/go.mod h1:+SdeFBvtyEkXs7REEP0seUULqWtbJapLOCVDaaPEHmU= -github.com/json-iterator/go v1.1.9/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.10/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.11/go.mod h1:KdQUCv79m/52Kvf8AW2vK1V8akMuk1QjK/uOdHXbAo4= -github.com/json-iterator/go v1.1.12 h1:PV8peI4a0ysnczrg+LtxykD8LfKY9ML6u2jnxaEnrnM= -github.com/json-iterator/go v1.1.12/go.mod h1:e30LSqwooZae/UwlEbR2852Gd8hjQvJoHmT4TnhNGBo= -github.com/jstemmer/go-junit-report v0.0.0-20190106144839-af01ea7f8024/go.mod h1:6v2b51hI/fHJwM22ozAgKL4VKDeJcHhJFhtBdhmNjmU= -github.com/jstemmer/go-junit-report v0.9.1/go.mod h1:Brl9GWCQeLvo8nXZwPNNblvFj/XSXhF0NWZEnDohbsk= -github.com/jtolds/gls v4.20.0+incompatible h1:xdiiI2gbIgH/gLH7ADydsJ1uDOEzR8yvV7C0MuV77Wo= -github.com/jtolds/gls v4.20.0+incompatible/go.mod h1:QJZ7F/aHp+rZTRtaJ1ow/lLfFfVYBRgL+9YlvaHOwJU= -github.com/julienschmidt/httprouter v1.2.0/go.mod h1:SYymIcj16QtmaHHD7aYtjjsJG7VTCxuUUipMqKk8s4w= -github.com/julienschmidt/httprouter v1.3.0/go.mod h1:JR6WtHb+2LUe8TCKY3cZOxFyyO8IZAc4RVcycCCAKdM= -github.com/jung-kurt/gofpdf v1.0.3-0.20190309125859-24315acbbda5/go.mod h1:7Id9E/uU8ce6rXgefFLlgrJj/GYY22cpxn+r32jIOes= -github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= -github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= -github.com/klauspost/compress v1.17.9 h1:6KIumPrER1LHsvBVuDa0r5xaG0Es51mhhB9BQB2qeMA= -github.com/klauspost/compress v1.17.9/go.mod h1:Di0epgTjJY877eYKx5yC51cX2A2Vl2ibi7bDH9ttBbw= -github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/konsorten/go-windows-terminal-sequences v1.0.3/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= -github.com/kr/fs v0.1.0/go.mod h1:FFnZGqtBN9Gxj7eW1uZ42v5BccTP0vu6NEaFoC2HwRg= -github.com/kr/logfmt v0.0.0-20140226030751-b84e30acd515/go.mod h1:+0opPa2QZZtGFBFZlji/RkVcI2GknAs/DXo4wKdlNEc= -github.com/kr/pretty v0.1.0/go.mod h1:dAy3ld7l9f0ibDNOQOHHMYYIIbhfbHSm3C4ZsoJORNo= -github.com/kr/pretty v0.2.0/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.2.1/go.mod h1:ipq/a2n7PKx3OHsz4KJII5eveXtPO4qwEXGdVfWzfnI= -github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= -github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= -github.com/kr/pty v1.1.1/go.mod h1:pFQYn66WHrOpPYNljwOMqo10TkYh1fy3cYio2l3bCsQ= -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/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= -github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= -github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= -github.com/magiconair/properties v1.8.5/go.mod h1:y3VJvCyxH9uVvJTWEGAELF3aiYNyPKd5NZ3oSwXrF60= -github.com/magiconair/properties v1.8.9 h1:nWcCbLq1N2v/cpNsy5WvQ37Fb+YElfq20WJ/a8RkpQM= -github.com/magiconair/properties v1.8.9/go.mod h1:Dhd985XPs7jluiymwWYZ0G4Z61jb3vdS329zhj2hYo0= -github.com/mailru/easyjson v0.7.7 h1:UGYAvKxe3sBsEDzO8ZeWOSlIQfWFlxbzLZe7hwFURr0= -github.com/mailru/easyjson v0.7.7/go.mod h1:xzfreul335JAWq5oZzymOObrkdz5UnU4kGfJJLY9Nlc= -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= -github.com/mattn/go-colorable v0.1.9/go.mod h1:u6P/XSegPjTcexA+o6vUJrdnUu04hMope9wVRipJSqc= -github.com/mattn/go-colorable v0.1.12/go.mod h1:u5H1YNBxpqRaxsYJYSkiCWKzEfiAb1Gb520KVy5xxl4= -github.com/mattn/go-colorable v0.1.13 h1:fFA4WZxdEF4tXPZVKMLwD8oUnCTTo08duU7wxecdEvA= -github.com/mattn/go-colorable v0.1.13/go.mod h1:7S9/ev0klgBDR4GtXTXX8a3vIGJpMovkB8vQcUbaXHg= -github.com/mattn/go-isatty v0.0.3/go.mod h1:M+lRXTBqGeGNdLjl/ufCoiOlB5xdOkqRJdNxMWT7Zi4= -github.com/mattn/go-isatty v0.0.8/go.mod h1:Iq45c/XA43vh69/j3iqttzPXn0bhXyGjM0Hdxcsrc5s= -github.com/mattn/go-isatty v0.0.11/go.mod h1:PhnuNfih5lzO57/f3n+odYbM4JtupLOxQOAqxQCu2WE= -github.com/mattn/go-isatty v0.0.12/go.mod h1:cbi8OIDigv2wuxKPP5vlRcQ1OAZbq2CE4Kysco4FUpU= -github.com/mattn/go-isatty v0.0.14/go.mod h1:7GGIvUiUoEMVVmxf/4nioHXj79iQHKdU27kJ6hsGG94= -github.com/mattn/go-isatty v0.0.16/go.mod h1:kYGgaQfpe5nmfYZH+SKPsOc2e4SrIfOl2e/yFXSvRLM= -github.com/mattn/go-isatty v0.0.20 h1:xfD0iDuEKnDkl03q4limB+vH+GxLEtL/jb4xVJSWWEY= -github.com/mattn/go-isatty v0.0.20/go.mod h1:W+V8PltTTMOvKvAeJH7IuucS94S2C6jfK/D7dTCTo3Y= -github.com/mattn/go-runewidth v0.0.9/go.mod h1:H031xJmbD/WCDINGzjvQ9THkh0rPKHF+m2gUSrubnMI= -github.com/mattn/go-runewidth v0.0.16 h1:E5ScNMtiwvlvB5paMFdw9p4kSQzbXFikJ5SQO6TULQc= -github.com/mattn/go-runewidth v0.0.16/go.mod h1:Jdepj2loyihRzMpdS35Xk/zdY8IAYHsh153qUoGf23w= -github.com/matttproud/golang_protobuf_extensions v1.0.1/go.mod h1:D8He9yQNgCq6Z5Ld7szi9bcBfOoFv/3dc6xSMkL2PC0= -github.com/miekg/dns v1.0.14/go.mod h1:W1PPwlIAgtquWBMBEV9nkV9Cazfe8ScdGz/Lj7v3Nrg= -github.com/miekg/dns v1.1.26/go.mod h1:bPDLeHnStXmXAq1m/Ch/hvfNHr14JKNPMBo3VZKjuso= -github.com/miekg/dns v1.1.41 h1:WMszZWJG0XmzbK9FEmzH2TVcqYzFesusSIB41b8KHxY= -github.com/miekg/dns v1.1.41/go.mod h1:p6aan82bvRIyn+zDIv9xYNUpwa73JcSh9BKwknJysuI= -github.com/mitchellh/cli v1.0.0/go.mod h1:hNIlj7HEI86fIcpObd7a0FcrxTWetlwJDGcceTlRvqc= -github.com/mitchellh/cli v1.1.0/go.mod h1:xcISNoH86gajksDmfB23e/pu+B+GeFRMYmoHXxx3xhI= -github.com/mitchellh/go-homedir v1.0.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-homedir v1.1.0 h1:lukF9ziXFxDFPkA1vsr5zpc1XuPDn/wFntq5mG+4E0Y= -github.com/mitchellh/go-homedir v1.1.0/go.mod h1:SfyaCUpYCn1Vlf4IUYiD9fPX4A5wJrkLzIz1N1q0pr0= -github.com/mitchellh/go-testing-interface v1.0.0/go.mod h1:kRemZodwjscx+RGhAo8eIhFbs2+BFgRtFPeD/KE+zxI= -github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= -github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= -github.com/mitchellh/mapstructure v0.0.0-20160808181253-ca63d7c062ee/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.1.2/go.mod h1:FVVH3fgwuzCH5S8UJGiWEs2h04kUh9fWfEaFds41c1Y= -github.com/mitchellh/mapstructure v1.4.1/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/mitchellh/mapstructure v1.5.0 h1:jeMsZIYE/09sWLaz43PL7Gy6RuMjD2eJVyuac5Z2hdY= -github.com/mitchellh/mapstructure v1.5.0/go.mod h1:bFUtVrKA4DC2yAKiSyO/QUcy7e+RRV2QTWOzhPopBRo= -github.com/modern-go/concurrent v0.0.0-20180228061459-e0a39a4cb421/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd h1:TRLaZ9cD/w8PVh93nsPXa1VrQ6jlwL5oN8l14QlcNfg= -github.com/modern-go/concurrent v0.0.0-20180306012644-bacd9c7ef1dd/go.mod h1:6dJC0mAP4ikYIbvyc7fijjWJddQyLn8Ig3JB5CqoB9Q= -github.com/modern-go/reflect2 v0.0.0-20180701023420-4b7aa43c6742/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.1/go.mod h1:bx2lNnkwVCuqBIxFjflWJWanXIb3RllmbCylyMrvgv0= -github.com/modern-go/reflect2 v1.0.2 h1:xBagoLtFs94CBntxluKeaWgTMpvLxC4ur3nMaC9Gz0M= -github.com/modern-go/reflect2 v1.0.2/go.mod h1:yWuevngMOJpCy52FWWMvUC8ws7m/LJsjYzDa0/r8luk= -github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822 h1:C3w9PqII01/Oq1c1nUAm88MOHcQC9l5mIlSMApZMrHA= -github.com/munnerz/goautoneg v0.0.0-20191010083416-a7dc8b61c822/go.mod h1:+n7T8mK8HuQTcFwEeznm/DIxMOiR9yIdICNftLE1DvQ= -github.com/mwitkow/go-conntrack v0.0.0-20161129095857-cc309e4a2223/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/mwitkow/go-conntrack v0.0.0-20190716064945-2f068394615f/go.mod h1:qRWi+5nqEBWmkhHvq77mSJWrCKwh8bxhgT7d/eI7P4U= -github.com/nacos-group/nacos-sdk-go/v2 v2.2.7 h1:wCC1f3/VzIR1WD30YKeJGZAOchYCK/35mLC8qWt6Q6o= -github.com/nacos-group/nacos-sdk-go/v2 v2.2.7/go.mod h1:VYlyDPlQchPC31PmfBustu81vsOkdpCuO5k0dRdQcFc= -github.com/natefinch/lumberjack v2.0.0+incompatible h1:4QJd3OLAMgj7ph+yZTuX13Ld4UpgHp07nNdFX7mqFfM= -github.com/natefinch/lumberjack v2.0.0+incompatible/go.mod h1:Wi9p2TTF5DG5oU+6YfsmYQpsTIOm0B1VNzQg9Mw6nPk= -github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno= -github.com/olekukonko/tablewriter v0.0.5 h1:P2Ga83D34wi1o9J6Wh1mRuqd4mF/x/lgBS7N7AbDhec= -github.com/olekukonko/tablewriter v0.0.5/go.mod h1:hPp6KlRPjbx+hW8ykQs1w3UBbZlj6HuIJcUGPhkA7kY= -github.com/onsi/ginkgo/v2 v2.9.1 h1:zie5Ly042PD3bsCvsSOPvRnFwyo3rKe64TJlD6nu0mk= -github.com/onsi/ginkgo/v2 v2.9.1/go.mod h1:FEcmzVcCHl+4o9bQZVab+4dC9+j+91t2FHSzmGAPfuo= -github.com/onsi/gomega v1.27.4 h1:Z2AnStgsdSayCMDiCU42qIz+HLqEPcgiOCXjAU/w+8E= -github.com/onsi/gomega v1.27.4/go.mod h1:riYq/GJKh8hhoM01HN6Vmuy93AarCXCBGpvFDK3q3fQ= -github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b h1:FfH+VrHHk6Lxt9HdVS0PXzSXFyS2NbZKXv33FYPol0A= -github.com/opentracing/opentracing-go v1.2.1-0.20220228012449-10b1cf09e00b/go.mod h1:AC62GU6hc0BrNm+9RK9VSiwa/EUe1bkIeFORAMcHvJU= -github.com/pascaldekloe/goe v0.0.0-20180627143212-57f6aae5913c/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pascaldekloe/goe v0.1.0 h1:cBOtyMzM9HTpWjXfbbunk26uA6nG3a8n06Wieeh0MwY= -github.com/pascaldekloe/goe v0.1.0/go.mod h1:lzWF7FIEvWOWxwDKqyGYQf6ZUaNfKdP144TG7ZOy1lc= -github.com/pelletier/go-toml v1.9.3 h1:zeC5b1GviRUyKYd6OJPvBU/mcVDVoL1OhT17FCt5dSQ= -github.com/pelletier/go-toml v1.9.3/go.mod h1:u1nR/EPcESfeI/szUZKdtJ0xRNbUoANCkoOuaOx1Y+c= -github.com/pkg/errors v0.8.0/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.8.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4= -github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0= -github.com/pkg/sftp v1.10.1/go.mod h1:lYOWFsE0bwd1+KfKJaKeuokY15vzFx25BLbzYYoAxZI= -github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2 h1:Jamvg5psRIccs7FGNTlIRMkT8wgtp5eCXdBlqhYGL6U= -github.com/pmezard/go-difflib v1.0.1-0.20181226105442-5d4384ee4fb2/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= -github.com/polarismesh/polaris-go v1.5.8 h1:zBZkZBa4wVxsG5Y/6U4PmY9dY/mddXdfNI65edVu6U8= -github.com/polarismesh/polaris-go v1.5.8/go.mod h1:CuXO9bhHGjSoOIMWr4NXf3bJAkRBp5YoM7ibBzENC+c= -github.com/polarismesh/specification v1.4.1/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= -github.com/polarismesh/specification v1.5.1 h1:cJ2m0RBepdopGo/e3UpKdsab3NpDZnw5IsVTB1sFc5I= -github.com/polarismesh/specification v1.5.1/go.mod h1:rDvMMtl5qebPmqiBLNa5Ps0XtwkP31ZLirbH4kXA0YU= -github.com/posener/complete v1.1.1/go.mod h1:em0nMJCgc9GFtwrmVmEMR/ZL6WyhyjMBndrE9hABlRI= -github.com/posener/complete v1.2.3/go.mod h1:WZIdtGGp+qx0sLrYKtIRAruyNpv6hFCicSgv7Sy7s/s= -github.com/prometheus/client_golang v0.9.1/go.mod h1:7SWBe2y4D6OKWSNQJUaRYU/AaXPKyh/dDVn+NZz0KFw= -github.com/prometheus/client_golang v1.0.0/go.mod h1:db9x61etRT2tGnBNRi70OPL5FsnadC4Ky3P0J6CfImo= -github.com/prometheus/client_golang v1.4.0/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= -github.com/prometheus/client_golang v1.7.1/go.mod h1:PY5Wy2awLA44sXw4AOSfFBetzPP4j5+D6mVACh+pe2M= -github.com/prometheus/client_golang v1.11.0/go.mod h1:Z6t4BnS23TR94PD6BsDNk8yVqroYurpAkEiz0P2BEV0= -github.com/prometheus/client_golang v1.12.2/go.mod h1:3Z9XVyYiZYEO+YQWt3RD2R3jrbd179Rt297l4aS6nDY= -github.com/prometheus/client_golang v1.20.2 h1:5ctymQzZlyOON1666svgwn3s6IKWgfbjsejTMiXIyjg= -github.com/prometheus/client_golang v1.20.2/go.mod h1:PIEt8X02hGcP8JWbeHyeZ53Y/jReSnHgO035n//V5WE= -github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= -github.com/prometheus/client_model v0.0.0-20190129233127-fd36f4220a90/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.0.0-20190812154241-14fe0d1b01d4/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.2.0/go.mod h1:xMI15A0UPsDsEKsMN9yxemIoYk6Tm2C1GtYGdfGttqA= -github.com/prometheus/client_model v0.6.1 h1:ZKSh/rekM+n3CeS952MLRAdFwIKqeY8b62p8ais2e9E= -github.com/prometheus/client_model v0.6.1/go.mod h1:OrxVMOVHjw3lKMa8+x6HeMGkHMQyHDk9E3jmP2AmGiY= -github.com/prometheus/common v0.4.1/go.mod h1:TNfzLD0ON7rHzMJeJkieUDPYmFC7Snx/y86RQel1bk4= -github.com/prometheus/common v0.9.1/go.mod h1:yhUN8i9wzaXS3w1O07YhxHEBxD+W35wd8bs7vj7HSQ4= -github.com/prometheus/common v0.10.0/go.mod h1:Tlit/dnDKsSWFlCLTWaA1cyBgKHSMdTB80sz/V91rCo= -github.com/prometheus/common v0.26.0/go.mod h1:M7rCNAaPfAosfx8veZJCuw84e35h3Cfd9VFqTh1DIvc= -github.com/prometheus/common v0.32.1/go.mod h1:vu+V0TpY+O6vW9J44gczi3Ap/oXXR10b+M/gUGO4Hls= -github.com/prometheus/common v0.55.0 h1:KEi6DK7lXW/m7Ig5i47x0vRzuBsHuvJdi5ee6Y3G1dc= -github.com/prometheus/common v0.55.0/go.mod h1:2SECS4xJG1kd8XF9IcM1gMX6510RAEL65zxzNImwdc8= -github.com/prometheus/procfs v0.0.0-20181005140218-185b4288413d/go.mod h1:c3At6R/oaqEKCNdg8wHV1ftS6bRYblBhIjjI8uT2IGk= -github.com/prometheus/procfs v0.0.2/go.mod h1:TjEm7ze935MbeOT/UhFTIMYKhuLP4wbCsTZCD3I8kEA= -github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= -github.com/prometheus/procfs v0.1.3/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= -github.com/prometheus/procfs v0.6.0/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.7.3/go.mod h1:cz+aTbrPOrUb4q7XlbU9ygM+/jj0fzG6c1xBZuNvfVA= -github.com/prometheus/procfs v0.15.1 h1:YagwOFzUgYfKKHX6Dr+sHT7km/hxC76UB0learggepc= -github.com/prometheus/procfs v0.15.1/go.mod h1:fB45yRUv8NstnjriLhBQLuOUt+WW4BsoGhij/e3PBqk= -github.com/redis/go-redis/v9 v9.7.0 h1:HhLSs+B6O021gwzl+locl0zEDnyNkxMtf/Z3NNBMa9E= -github.com/redis/go-redis/v9 v9.7.0/go.mod h1:f6zhXITC7JUJIlPEiBOTXxJgPLdZcA93GewI7inzyWw= -github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= -github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= -github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= -github.com/rogpeppe/fastuuid v1.2.0/go.mod h1:jVj6XXZzXRy/MSR5jhDC/2q6DgLz+nrA6LYCDYWNEvQ= -github.com/rogpeppe/go-internal v1.3.0/go.mod h1:M8bDsm7K2OlrFYOpmOWEs/qY81heoFRclV5y23lUDJ4= -github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= -github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= -github.com/ryanuber/columnize v0.0.0-20160712163229-9b3edd62028f/go.mod h1:sm1tb6uqfes/u+d4ooFouqFdy9/2g9QGwK3SQygK0Ts= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529 h1:nn5Wsu0esKSJiIVhscUtVbo7ada43DJhG55ua/hjS5I= -github.com/sean-/seed v0.0.0-20170313163322-e2103e2c3529/go.mod h1:DxrIzT+xaE7yg65j358z/aeFdxmN0P9QXhEzd20vsDc= -github.com/sirupsen/logrus v1.2.0/go.mod h1:LxeOpSwHxABJmUn/MG1IvRgCAasNZTLOkJPxbbu5VWo= -github.com/sirupsen/logrus v1.4.2/go.mod h1:tLMulIdttU9McNUspp0xgXVQah82FyeX6MwdIuYE2rE= -github.com/sirupsen/logrus v1.6.0/go.mod h1:7uNnSEd1DgxDLC74fIahvMZmmYsHGZGEOFrfsX/uA88= -github.com/smartystreets/assertions v0.0.0-20180927180507-b2de0cb4f26d/go.mod h1:OnSkiWE9lh6wB0YB77sQom3nweQdgAjqCqsofrRNTgc= -github.com/smartystreets/assertions v1.2.0 h1:42S6lae5dvLc7BrLu/0ugRtcFVjoJNMC/N3yZFZkDFs= -github.com/smartystreets/assertions v1.2.0/go.mod h1:tcbTF8ujkAEcZ8TElKY+i30BzYlVhC/LOxJk7iOWnoo= -github.com/smartystreets/goconvey v1.6.4/go.mod h1:syvi0/a8iFYH4r/RixwvyeAJjdLS9QV7WQ/tjFTllLA= -github.com/smartystreets/goconvey v1.7.2 h1:9RBaZCeXEQ3UselpuwUQHltGVXvdwm6cv1hgR6gDIPg= -github.com/smartystreets/goconvey v1.7.2/go.mod h1:Vw0tHAZW6lzCRk3xgdin6fKYcG+G3Pg9vgXWeJpQFMM= -github.com/spaolacci/murmur3 v0.0.0-20180118202830-f09979ecbc72/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spaolacci/murmur3 v1.1.0 h1:7c1g84S4BPRrfL5Xrdp6fOJ206sU9y293DDHaoy0bLI= -github.com/spaolacci/murmur3 v1.1.0/go.mod h1:JwIasOWyU6f++ZhiEuf87xNszmSA2myDM2Kzu9HwQUA= -github.com/spf13/afero v1.6.0 h1:xoax2sJ2DT8S8xA2paPFjDCScCNeWsg75VG0DLRreiY= -github.com/spf13/afero v1.6.0/go.mod h1:Ai8FlHk4v/PARR026UzYexafAt9roJ7LcLMAmO6Z93I= -github.com/spf13/cast v1.3.1 h1:nFm6S0SMdyzrzcmThSipiEubIDy8WEXKNZ0UOgiRpng= -github.com/spf13/cast v1.3.1/go.mod h1:Qx5cxh0v+4UWYiBimWS+eyWzqEqokIECu5etghLkUJE= -github.com/spf13/jwalterweatherman v1.1.0 h1:ue6voC5bR5F8YxI5S67j9i582FU4Qvo2bmqnqMYADFk= -github.com/spf13/jwalterweatherman v1.1.0/go.mod h1:aNWZUN0dPAAO/Ljvb5BEdw96iTZ0EXowPYD95IqWIGo= -github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA= -github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg= -github.com/spf13/viper v1.8.1 h1:Kq1fyeebqsBfbjZj4EL7gj2IO0mMaiyjYUWcUsl2O44= -github.com/spf13/viper v1.8.1/go.mod h1:o0Pch8wJ9BVSWGQMbra6iw0oQ5oktSIBaujf1rJH9Ns= -github.com/stoewer/go-strcase v1.2.0/go.mod h1:IBiWB2sKIp3wVVQ3Y035++gc+knqhUQag1KpM8ahLw8= -github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= -github.com/stretchr/objx v0.4.0/go.mod h1:YvHI0jy2hoMjB+UWwv71VJQ9isScKT/TqJzVSSt89Yw= -github.com/stretchr/objx v0.5.0 h1:1zr/of2m5FGMsad5YfcqgdqdWrIhu+EBEJRhR1U7z/c= -github.com/stretchr/objx v0.5.0/go.mod h1:Yh+to48EsGEfYuaHDzXPcE3xhTkx73EhmCGUpEOglKo= -github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= -github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI= -github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= -github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA= -github.com/stretchr/testify v1.6.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= -github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.0/go.mod h1:yNjHg4UonilssWZ8iaSj1OCr/vHnekPRkoO+kdMU+MU= -github.com/stretchr/testify v1.8.1/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.8.2/go.mod h1:w2LPCIKwWwSfY2zedu0+kehJoqGctiVI29o6fzry7u4= -github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= -github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= -github.com/subosito/gotenv v1.2.0 h1:Slr1R9HxAlEKefgq5jn9U+DnETlIUa6HfgEzj0g5d7s= -github.com/subosito/gotenv v1.2.0/go.mod h1:N0PQaV/YGNqwC0u51sEeR/aUtSLEXKX9iv69rRypqCw= -github.com/tevid/gohamcrest v1.1.1 h1:ou+xSqlIw1xfGTg1uq1nif/htZ2S3EzRqLm2BP+tYU0= -github.com/tevid/gohamcrest v1.1.1/go.mod h1:3UvtWlqm8j5JbwYZh80D/PVBt0mJ1eJiYgZMibh0H/k= -github.com/tjfoc/gmsm v1.3.2/go.mod h1:HaUcFuY0auTiaHB9MHFGCPx5IaLhTUd2atbCFBQXn9w= -github.com/tjfoc/gmsm v1.4.1 h1:aMe1GlZb+0bLjn+cKTPEvvn9oUEBlJitaZiiBwsbgho= -github.com/tjfoc/gmsm v1.4.1/go.mod h1:j4INPkHWMrhJb38G+J6W4Tw0AbuN8Thu3PbdVYhVcTE= -github.com/tv42/httpunix v0.0.0-20150427012821-b75d8614f926/go.mod h1:9ESjWnEqriFuLhtthL60Sar/7RFoluCcXsuvEwTV5KM= -github.com/uber/jaeger-client-go v2.30.0+incompatible h1:D6wyKGCecFaSRUpo8lCVbaOOb6ThwMmTEbhRwtKR97o= -github.com/uber/jaeger-client-go v2.30.0+incompatible/go.mod h1:WVhlPFC8FDjOFMMWRy2pZqQJSXxYSwNYOkTr/Z6d3Kk= -github.com/uber/jaeger-lib v2.4.1+incompatible h1:td4jdvLcExb4cBISKIpHuGoVXh+dVKhn2Um6rjCsSsg= -github.com/uber/jaeger-lib v2.4.1+incompatible/go.mod h1:ComeNDZlWwrWnDv8aPp0Ba6+uUTzImX/AauajbLI56U= -github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.30/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= -github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k= -github.com/yuin/goldmark v1.4.13/go.mod h1:6yULJ656Px+3vBD8DxQVa3kxgyrAnzto9xy5taEt/CY= -go.etcd.io/etcd/api/v3 v3.5.0/go.mod h1:cbVKeC6lCfl7j/8jBhAK6aIYO9XOjdptoxU/nLQcPvs= -go.etcd.io/etcd/api/v3 v3.5.17 h1:cQB8eb8bxwuxOilBpMJAEo8fAONyrdXTHUNcMd8yT1w= -go.etcd.io/etcd/api/v3 v3.5.17/go.mod h1:d1hvkRuXkts6PmaYk2Vrgqbv7H4ADfAKhyJqHNLJCB4= -go.etcd.io/etcd/client/pkg/v3 v3.5.0/go.mod h1:IJHfcCEKxYu1Os13ZdwCwIUTUVGYTSAM3YSwc9/Ac1g= -go.etcd.io/etcd/client/pkg/v3 v3.5.17 h1:XxnDXAWq2pnxqx76ljWwiQ9jylbpC4rvkAeRVOUKKVw= -go.etcd.io/etcd/client/pkg/v3 v3.5.17/go.mod h1:4DqK1TKacp/86nJk4FLQqo6Mn2vvQFBmruW3pP14H/w= -go.etcd.io/etcd/client/v2 v2.305.0/go.mod h1:h9puh54ZTgAKtEbut2oe9P4L/oqKCVB6xsXlzd7alYQ= -go.etcd.io/etcd/client/v3 v3.5.17 h1:o48sINNeWz5+pjy/Z0+HKpj/xSnBkuVhVvXkjEXbqZY= -go.etcd.io/etcd/client/v3 v3.5.17/go.mod h1:j2d4eXTHWkT2ClBgnnEPm/Wuu7jsqku41v9DZ3OtjQo= -go.opencensus.io v0.21.0/go.mod h1:mSImk1erAIZhrmZN+AvHh14ztQfjbGwt4TtuofqLduU= -go.opencensus.io v0.22.0/go.mod h1:+kGneAE2xo2IficOXnaByMWTGM9T73dGwxeWcUqIpI8= -go.opencensus.io v0.22.2/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.3/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.4/go.mod h1:yxeiOL68Rb0Xd1ddK5vPZ/oVn4vY4Ynel7k9FzqtOIw= -go.opencensus.io v0.22.5/go.mod h1:5pWMHQbX5EPX2/62yrJeAkowc+lfs/XD7Uxpq3pI6kk= -go.opencensus.io v0.23.0/go.mod h1:XItmlyltB5F7CS4xOC1DcqMoFqwtC6OG2xF7mCv7P7E= -go.opentelemetry.io/contrib/instrumentation/runtime v0.49.0 h1:dg9y+7ArpumB6zwImJv47RHfdgOGQ1EMkzP5vLkEnTU= -go.opentelemetry.io/contrib/instrumentation/runtime v0.49.0/go.mod h1:Ul4MtXqu/hJBM+v7a6dCF0nHwckPMLpIpLeCi4+zfdw= -go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= -go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.29.0 h1:dIIDULZJpgdiHz5tXrTgKIMLkus6jEFa7x5SOKcyR7E= -go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.29.0/go.mod h1:jlRVBe7+Z1wyxFSUs48L6OBQZ5JwH2Hg/Vbl+t9rAgI= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.29.0 h1:nSiV3s7wiCam610XcLbYOmMfJxB9gO4uK3Xgv5gmTgg= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.29.0/go.mod h1:hKn/e/Nmd19/x1gvIHwtOwVWM+VhuITSWip3JUDghj0= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.29.0 h1:JAv0Jwtl01UFiyWZEMiJZBiTlv5A50zNs8lsthXqIio= -go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.29.0/go.mod h1:QNKLmUEAq2QUbPQUfvw4fmv0bgbK7UlOSFCnXyfvSNc= -go.opentelemetry.io/otel/exporters/prometheus v0.46.0 h1:I8WIFXR351FoLJYuloU4EgXbtNX2URfU/85pUPheIEQ= -go.opentelemetry.io/otel/exporters/prometheus v0.46.0/go.mod h1:ztwVUHe5DTR/1v7PeuGRnU5Bbd4QKYwApWmuutKsJSs= -go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= -go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8= -go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4= -go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= -go.opentelemetry.io/otel/sdk/metric v1.32.0 h1:rZvFnvmvawYb0alrYkjraqJq0Z4ZUJAiyYCU9snn1CU= -go.opentelemetry.io/otel/sdk/metric v1.32.0/go.mod h1:PWeZlq0zt9YkYAp3gjKZ0eicRYvOh1Gd+X99x6GHpCQ= -go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= -go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= -go.opentelemetry.io/proto/otlp v0.7.0/go.mod h1:PqfVotwruBrMGOCsRd/89rSnXhoiJIqeYNgFYFoEGnI= -go.opentelemetry.io/proto/otlp v1.3.1 h1:TrMUixzpM0yuc/znrFTP9MMRh8trP93mkCiDVeXrui0= -go.opentelemetry.io/proto/otlp v1.3.1/go.mod h1:0X1WI4de4ZsLrrJNLAQbFeLCm3T7yBkR0XqQ7niQU+8= -go.uber.org/atomic v1.7.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.9.0/go.mod h1:fEN4uk6kAWBTFdckzkM89CLk9XfWZrxpCo0nPH17wJc= -go.uber.org/atomic v1.10.0 h1:9qC72Qh0+3MqyJbAn8YU5xVq1frD8bn3JtD2oXtafVQ= -go.uber.org/atomic v1.10.0/go.mod h1:LUxbIzbOniOlMKjJjyPfpl4v+PKK2cNJn91OQbhoJI0= -go.uber.org/goleak v1.1.11/go.mod h1:cwTWslyiVhfpKIDGSZEM2HlOvcqm+tG4zioyIeLoqMQ= -go.uber.org/goleak v1.3.0 h1:2K3zAYmnTNqV73imy9J1T3WC+gmCePx2hEGkimedGto= -go.uber.org/goleak v1.3.0/go.mod h1:CoHD4mav9JJNrW/WLlf7HGZPjdw8EucARQHekz1X6bE= -go.uber.org/multierr v1.6.0/go.mod h1:cdWPpRnG4AhwMwsgIHip0KRBQjJy5kYEpYjJxpXp9iU= -go.uber.org/multierr v1.10.0 h1:S0h4aNzvfcFsC3dRF1jLoaov7oRaKqRGC/pUEJ2yvPQ= -go.uber.org/multierr v1.10.0/go.mod h1:20+QtiLqy0Nd6FdQB9TLXag12DsQkrbs3htMFfDN80Y= -go.uber.org/zap v1.17.0/go.mod h1:MXVU+bhUf/A7Xi2HNOnopQOrmycQ5Ih87HtOu4q5SSo= -go.uber.org/zap v1.21.0/go.mod h1:wjWOCqI0f2ZZrJF/UufIOkiC8ii6tm1iqIsLo76RfJw= -go.uber.org/zap v1.26.0 h1:sI7k6L95XOKS281NhVKOFCUNIvv9e0w4BF8N3u+tCRo= -go.uber.org/zap v1.26.0/go.mod h1:dtElttAiwGvoJ/vj4IwHBS/gXsEu/pZ50mUIRWuG0so= -golang.org/x/crypto v0.0.0-20180904163835-0709b304e793/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20181029021203-45a5f77698d3/go.mod h1:6SG95UA2DQfeDnfUPMdvaQW0Q7yPrPDi9nlGo2tz2b4= -golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= -golang.org/x/crypto v0.0.0-20190510104115-cbcb75029529/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190605123033-f99c8df09eb5/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190820162420-60c769a6c586/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20190923035154-9ee001bba392/go.mod h1:/lpIB1dKB+9EgE3H3cr1v9wB50oz8l4C4h62xy7jSTY= -golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= -golang.org/x/crypto v0.0.0-20191219195013-becbf705a915/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200510223506-06a226fb4e37/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20201012173705-84dcc777aaee/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= -golang.org/x/crypto v0.0.0-20210921155107-089bfa567519/go.mod h1:GvvjBRRGRdwPK5ydBHafDWAxML/pGHZbMvKqRZ5+Abc= -golang.org/x/crypto v0.10.0/go.mod h1:o4eNf7Ede1fv+hwOwZsTHl9EsPFO6q6ZvYR8vYfY45I= -golang.org/x/crypto v0.18.0/go.mod h1:R0j02AL6hcrfOiy9T4ZYp/rcWeMxM3L6QYxlOuEG1mg= -golang.org/x/crypto v0.31.0 h1:ihbySMvVjLAeSH1IbfcRTkD/iNscyz8rGzjF/E5hV6U= -golang.org/x/crypto v0.31.0/go.mod h1:kDsLvtWBEx7MV9tJOj9bnXsPbxwJQ6csT/x4KIN4Ssk= -golang.org/x/exp v0.0.0-20180321215751-8460e604b9de/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20180807140117-3d87b88a115f/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190121172915-509febef88a4/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190125153040-c74c464bbbf2/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190306152737-a1d7652674e8/go.mod h1:CJ0aWSM057203Lf6IL+f9T1iT9GByDxfZKAQTCR3kQA= -golang.org/x/exp v0.0.0-20190510132918-efd6b22b2522/go.mod h1:ZjyILWgesfNpC6sMxTJOJm9Kp84zZh5NQWvqDGG3Qr8= -golang.org/x/exp v0.0.0-20190829153037-c13cbed26979/go.mod h1:86+5VVa7VpoJ4kLfm080zCjGlMRFzhUhsZKEZO7MGek= -golang.org/x/exp v0.0.0-20191030013958-a1ab85dbe136/go.mod h1:JXzH8nQsPlswgeRAPE3MuO9GYsAcnJvJ4vnMwN/5qkY= -golang.org/x/exp v0.0.0-20191129062945-2f5052295587/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20191227195350-da58074b4299/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200119233911-0405dc783f0a/go.mod h1:2RIsYlXP63K8oxa1u096TMicItID8zy7Y6sNkU49FU4= -golang.org/x/exp v0.0.0-20200207192155-f17229e696bd/go.mod h1:J/WKrq2StrnmMY6+EHIKF9dgMWnmCNThgcyBT1FY9mM= -golang.org/x/exp v0.0.0-20200224162631-6cc2880d07d6/go.mod h1:3jZMyOhIsHpP37uCMkUooju7aAi5cS1Q23tOzKc+0MU= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d h1:jtJma62tbqLibJ5sFQz8bKtEM8rJBtfilJ2qTU199MI= -golang.org/x/exp v0.0.0-20231006140011-7918f672742d/go.mod h1:ldy0pHrwJyGW56pPQzzkH36rKxoZW1tw7ZJpeKx+hdo= -golang.org/x/image v0.0.0-20180708004352-c73c2afc3b81/go.mod h1:ux5Hcp/YLpHSI86hEcLt0YII63i6oz57MZXIpbrjZUs= -golang.org/x/image v0.0.0-20190227222117-0694c2d4d067/go.mod h1:kZ7UVZpmo3dzQBMxlp+ypCbDeSB+sBbTgSJuh5dn5js= -golang.org/x/image v0.0.0-20190802002840-cff245a6509b/go.mod h1:FeLwcggjj3mMvU+oOTbSwawSJRM1uh48EjtB4UJZlP0= -golang.org/x/lint v0.0.0-20181026193005-c67002cb31c3/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190227174305-5b3e6a55c961/go.mod h1:wehouNa3lNwaWXcvxsM5YxQ5yQlVC4a0KAMCusXpPoU= -golang.org/x/lint v0.0.0-20190301231843-5614ed5bae6f/go.mod h1:UVdnD1Gm6xHRNCYTkRU2/jEulfH38KcIWyp/GAMgvoE= -golang.org/x/lint v0.0.0-20190313153728-d0100b6bd8b3/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190409202823-959b441ac422/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190909230951-414d861bb4ac/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20190930215403-16217165b5de/go.mod h1:6SW0HCj/g11FgYtHlgUYUwCkIfeOF89ocIRzGO/8vkc= -golang.org/x/lint v0.0.0-20191125180803-fdd1cda4f05f/go.mod h1:5qLYkcX4OjUUV8bRuDixDT3tpyyb+LUpUlRWLxfhWrs= -golang.org/x/lint v0.0.0-20200130185559-910be7a94367/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20200302205851-738671d3881b/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20201208152925-83fdc39ff7b5/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/lint v0.0.0-20210508222113-6edffad5e616/go.mod h1:3xt1FjdF8hUf6vQPIChWIBhFzV8gjjsPE/fR3IyQdNY= -golang.org/x/mobile v0.0.0-20190312151609-d3739f865fa6/go.mod h1:z+o9i4GpDbdi3rU15maQ/Ox0txvL9dWGYEHz965HBQE= -golang.org/x/mobile v0.0.0-20190719004257-d2bd2a29d028/go.mod h1:E/iHnbuqvinMTCcRqshq8CkpyQDoeVncDDYHnLhea+o= -golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKGUJ2LatrhH/nqhxcFungHvyanc= -golang.org/x/mod v0.1.0/go.mod h1:0QHyrYULN0/3qlju5TqG8bIK38QM8yzMo5ekMj3DlcY= -golang.org/x/mod v0.1.1-0.20191105210325-c90efee705ee/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.1.1-0.20191107180719-034126e5016b/go.mod h1:QqPTAvyqsEbceGzBzNggFXnrqF1CaUcvgkdR5Ot7KZg= -golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.3.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= -golang.org/x/mod v0.6.0-dev.0.20220419223038-86c51ed26bb4/go.mod h1:jJ57K6gSWd91VN4djpZkiMVwK6gcyfeH4XE8wZrZaV4= -golang.org/x/mod v0.8.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= -golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20180826012351-8a410e7b638d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181023162649-9b4f9f5ad519/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181114220301-adae6a3d119a/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20181201002055-351d144fa1fc/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190108225652-1e06a53dbb7e/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190213061140-3a22650c66bd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= -golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190501004415-9ce7a6920f09/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190503192946-f4e77d36d62c/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= -golang.org/x/net v0.0.0-20190603091049-60506f45cf65/go.mod h1:HSz+uSET+XFnRR8LxR5pz3Of3rY3CfYBVs4xY44aLks= -golang.org/x/net v0.0.0-20190613194153-d28f0bde5980/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190628185345-da137c7871d7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190724013045-ca1201d0de80/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190923162816-aa69164e4478/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20191209160850-c0dbc17a3553/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200114155413-6afb5195e5aa/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200202094626-16171245cfb2/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200513185701-a91f0712d120/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= -golang.org/x/net v0.0.0-20200625001655-4c5254603344/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200707034311-ab3426394381/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20200822124328-c89045814202/go.mod h1:/O7V0waA8r7cgGh81Ro3o1hOxt32SMVPicZroKQ2sZA= -golang.org/x/net v0.0.0-20201010224723-4f7140c49acb/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201031054903-ff519b6c9102/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201110031124-69a78807bb2b/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU= -golang.org/x/net v0.0.0-20201209123823-ac852fbbde11/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210119194325-5f4716e94777/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= -golang.org/x/net v0.0.0-20210316092652-d523dce5a7f4/go.mod h1:RBQZq4jEuRlivfhVLdyRGr576XBO4/greRjx4P4O3yc= -golang.org/x/net v0.0.0-20210405180319-a5a99cb37ef4/go.mod h1:p54w0d4576C0XHj96bSt6lcn1PtDYWL6XObtHCRCNQM= -golang.org/x/net v0.0.0-20210410081132-afb366fc7cd1/go.mod h1:9tjilg8BloeKEkVJvy7fQ90B1CfIiPueXVOjqfkSzI8= -golang.org/x/net v0.0.0-20210503060351-7fd8e65b6420/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20210525063256-abc453219eb5/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y= -golang.org/x/net v0.0.0-20220127200216-cd36cc0744dd/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220225172249-27dd8689420f/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220325170049-de3da57026de/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220412020605-290c469a71a5/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220425223048-2871e0cb64e4/go.mod h1:CfG3xpIq0wQ8r1q4Su4UZFWDARRcnwPjda9FqA0JpMk= -golang.org/x/net v0.0.0-20220607020251-c690dde0001d/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220617184016-355a448f1bc9/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220624214902-1bab6f366d9e/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220722155237-a158d28d115b/go.mod h1:XRhObCWvk6IyKnWLug+ECip1KBveYUHfp+8e9klMJ9c= -golang.org/x/net v0.0.0-20220909164309-bea034e7d591/go.mod h1:YDH+HFinaLZZlnHAfSS6ZXJJ9M9t4Dl22yv3iI2vPwk= -golang.org/x/net v0.2.0/go.mod h1:KqCZLdyyvdV855qA2rE3GC2aiw5xGR5TEjj8smXukLY= -golang.org/x/net v0.6.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.7.0/go.mod h1:2Tu9+aMcznHK/AK1HMvgo6xiTLG5rD5rZLDS+rp2Bjs= -golang.org/x/net v0.10.0/go.mod h1:0qNGK6F8kojg2nk9dLZ2mShWaEBan6FAoqfSigmmuDg= -golang.org/x/net v0.11.0/go.mod h1:2L/ixqYpgIVXmeoSA/4Lu7BzTG4KIyPIryS4IsOd1oQ= -golang.org/x/net v0.20.0/go.mod h1:z8BVo6PvndSri0LbOE3hAn0apkU+1YvI6E70E9jsnvY= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= -golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= -golang.org/x/oauth2 v0.0.0-20190226205417-e64efc72b421/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20190604053449-0f29369cfe45/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20191202225959-858c2ad4c8b6/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200107190931-bf48bf16ab8d/go.mod h1:gOpvHmFTYa4IltrdGE7lF6nIHvwfUNPOp7c8zoXwtLw= -golang.org/x/oauth2 v0.0.0-20200902213428-5d25da1a8d43/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201109201403-9fd604954f58/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20201208152858-08078c50e5b5/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210218202405-ba52d332ba99/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210220000619-9bb904979d93/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210313182246-cd4f82c27b84/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210402161424-2e8d93401602/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210514164344-f6687ab2804c/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210628180205-a41e5a781914/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210805134026-6f1e6394065a/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20210819190943-2bc19b11175f/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20211104180415-d3ed0bb246c8/go.mod h1:KelEdhl1UZF7XfJ4dDtk6s++YSgaE7mD/BuKKDLBl4A= -golang.org/x/oauth2 v0.0.0-20220223155221-ee480838109b/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220309155454-6242fa91716a/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220411215720-9780585627b5/go.mod h1:DAh4E804XQdzx2j+YRIaUnCqCV2RuMz24cGBJ5QYIrc= -golang.org/x/oauth2 v0.0.0-20220608161450-d0670ef3b1eb/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= -golang.org/x/oauth2 v0.0.0-20220622183110-fd043fe589d2/go.mod h1:jaDAt6Dkxork7LmZnYtzbRWj0W47D86a3TGe0YHBvmE= -golang.org/x/oauth2 v0.0.0-20220822191816-0ebed06d0094/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.0.0-20220909003341-f21342109be1/go.mod h1:h4gKUeWbJ4rQPri7E0u6Gs4e9Ri2zaLxzw5DI5XGrYg= -golang.org/x/oauth2 v0.23.0 h1:PbgcYx2W7i4LvjJWEbf0ngHV6qJYr86PkAV3bXdLEbs= -golang.org/x/oauth2 v0.23.0/go.mod h1:XYTD2NtWslqkgxebSiOHnXEap4TF09sJSc7H1sXbhtI= -golang.org/x/sync v0.0.0-20180314180146-1d60e4601c6f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181108010431-42b317875d0f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20181221193216-37e7f081c4d4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190227155943-e225da77a7e6/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190423024810-112230192c58/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20190911185100-cd5d95a43a6e/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200317015054-43a5402ce75a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20200625203802-6e8e738ad208/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201020160332-67f06af15bc9/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20201207232520-09787c993a3a/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20210220032951-036812b2e83c/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220601150217-0de741cfad7f/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.0.0-20220722155255-886fb9371eb4/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.1.0/go.mod h1:RxMgew5VJxzue5/jJTE5uejpjVlOe/izrB70Jof72aM= -golang.org/x/sync v0.10.0 h1:3NQrjDixjgGwUOCaF8w2+VYHv0Ve/vGYSbdkTa98gmQ= -golang.org/x/sync v0.10.0/go.mod h1:Czt+wKu1gCyEFDUtn0jG5QVvpJ6rzVqr5aXyt9drQfk= -golang.org/x/sys v0.0.0-20180823144017-11551d06cbcc/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180830151530-49385e6e1522/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181026203630-95b1ffbd15a5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20181116152217-5ac8a444bdc5/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190222072716-a9d3bda3a223/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= -golang.org/x/sys v0.0.0-20190312061237-fead79001313/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190422165155-953cdadca894/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190502145724-3ef323f4f1fd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190507160741-ecd444e8653b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190606165138-5da285871e9c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190624142023-c5567b49c5d0/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190726091711-fc99dfbffb4e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190922100055-0a153f010e69/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20190924154521-2837fb4f24fe/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191001151750-bb3f8db39f24/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191026070338-33540a1f6037/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191204072324-ce4227a45e2e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20191228213918-04cbcbbfeed8/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200113162924-86b910548bc1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200212091648-12a6c2dcc1e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200331124033-c3d80250170d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200501052902-10377860bb8e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200509044756-6aff5f38e54f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200511232937-7e40ca221e25/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200515095857-1151b9dac4a9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200615200032-f1bc736245b1/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200625212154-ddb9806d33ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200803210538-64077c9b5642/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200905004654-be1d3432aa8f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20201201145000-ef89a241ccb3/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210119212857-b64e53b001e4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210124154548-22da62e12c0c/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210220050731-9a76102bfb43/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210305230114-8fe3ee5dd75b/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210315160823-c6e025ad8005/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210320140829-1e4c9ba3b0c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210330210617-4fbd30eecc44/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210403161142-5e06dd20ab57/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210510120138-977fb7262007/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210514084401-e8d321eab015/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603081109-ebe580a85c40/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210603125802-9665404d3644/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210616094352-59db8d763f22/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210630005230-0f9fa26af87c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210806184541-e5e7981a1069/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210823070655-63515b42dcdf/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210908233432-aa78b53d3365/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20210927094055-39ccf1dd6fa6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211124211545-fe61309f8881/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211210111614-af8b64212486/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20211216021012-1d35b9e2eb4e/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220114195835-da31bd327af9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220128215802-99c3d69c2c27/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220209214540-3681064d5158/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220227234510-4e6760a101f9/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220328115105-d36c6a25d886/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220412211240-33da011f77ad/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220502124256-b6088ccd6cba/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220503163025-988cb79eb6c6/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220520151302-bc2c85ada10a/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220610221304-9f5ed59c137d/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220615213510-4f61da869c0c/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220624220833-87e55d714810/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220722155257-8c9f86f7a55f/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220728004956-3c1f35247d10/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.2.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.5.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.8.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.9.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= -golang.org/x/sys v0.16.0/go.mod h1:/VUhepiaJMQUp4+oa/7Zr1D23ma6VTLIYjOOTFZPUcA= -golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= -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/term v0.0.0-20210927222741-03fcf44c2211/go.mod h1:jbD1KX2456YbFQfuXm/mYQcufACuNUgVhRMnK/tPxf8= -golang.org/x/term v0.2.0/go.mod h1:TVmDHMZPmdnySmBfhjOoOdhjzdE1h4u1VwSiw2l1Nuc= -golang.org/x/term v0.5.0/go.mod h1:jMB1sMXY+tzblOD4FWmEbocvup2/aLOaQEp7JmGp78k= -golang.org/x/term v0.8.0/go.mod h1:xPskH00ivmX89bAKVGSKKtLOWNx2+17Eiy94tnKShWo= -golang.org/x/term v0.9.0/go.mod h1:M6DEAAIenWoTxdKrOltXcmDY3rSplQUkrvaDU5FcQyo= -golang.org/x/term v0.16.0/go.mod h1:yn7UURbUtPyrVJPGPq404EukNFxcm/foM+bV/bfcDsY= -golang.org/x/term v0.27.0 h1:WP60Sv1nlK1T6SupCHbXzSaN0b9wUmsPoRS9b61A23Q= -golang.org/x/term v0.27.0/go.mod h1:iMsnZpn0cago0GOrHO2+Y7u7JPn5AylBrcoWkElMTSM= -golang.org/x/text v0.0.0-20170915032832-14c0d48ead0c/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.1-0.20180807135948-17ff2d5776d2/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= -golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= -golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.4/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.5/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ= -golang.org/x/text v0.3.7/go.mod h1:u+2+/6zg+i71rQMx5EYifcz6MCKuco9NR6JIITiCfzQ= -golang.org/x/text v0.4.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.7.0/go.mod h1:mrYo+phRRbMaCq/xk9113O4dZlRixOauAjOtrjsXDZ8= -golang.org/x/text v0.9.0/go.mod h1:e1OnstbJyHTd6l/uOt8jFFHp6TRDWZR/bV3emEE/zU8= -golang.org/x/text v0.10.0/go.mod h1:TvPlkZtksWOMsz7fbANvkp4WM8x/WCo/om8BMLbz+aE= -golang.org/x/text v0.14.0/go.mod h1:18ZOQIKpY8NJVqYksKHtTdi31H5itFRjB5/qKTNYzSU= -golang.org/x/text v0.21.0 h1:zyQAAkrwaneQ066sspRyJaG9VNi/YJ1NfzcGB3hZ/qo= -golang.org/x/text v0.21.0/go.mod h1:4IBbMaMmOPCJ8SecivzSH54+73PCFmPWxNTLm+vZkEQ= -golang.org/x/time v0.0.0-20181108054448-85acf8d2951c/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20190308202827-9d24e82272b4/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.0.0-20191024005414-555d28b269f0/go.mod h1:tRJNPiyCQ0inRvYxbN9jk5I+vvW/OXSQhTDSoE431IQ= -golang.org/x/time v0.6.0 h1:eTDhh4ZXt5Qf0augr54TN6suAUudPcawVZeIAPU7D4U= -golang.org/x/time v0.6.0/go.mod h1:3BpzKBy/shNhVucY/MWOyx10tF3SFh9QdLuxbVysPQM= -golang.org/x/tools v0.0.0-20180525024113-a5b4c53f6e8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20180917221912-90fa682c2a6e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190114222345-bf090417da8b/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190206041539-40960b6deb8e/go.mod h1:n7NCudcB/nEzxVGmLbDWY5pfWTLqBcC2KZ6jyYvM4mQ= -golang.org/x/tools v0.0.0-20190226205152-f727befe758c/go.mod h1:9Yl7xja0Znq3iFh3HoIrodX9oNMXvdceNzlUR8zjMvY= -golang.org/x/tools v0.0.0-20190311212946-11955173bddd/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312151545-0bb0c0a6e846/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190312170243-e65039ee4138/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190328211700-ab21143f2384/go.mod h1:LCzVGOaR6xXOjkQ3onu1FJEFr0SW1gC7cKk1uF8kGRs= -golang.org/x/tools v0.0.0-20190425150028-36563e24a262/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190506145303-2d16b83fe98c/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190524140312-2c0ae7006135/go.mod h1:RgjU9mgBXZiqYHBnxXauZ1Gv1EHHAz9KjViQ78xBX0Q= -golang.org/x/tools v0.0.0-20190606124116-d0a3d012864b/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190621195816-6e04913cbbac/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190628153133-6cdbf07be9d0/go.mod h1:/rFqwRUd4F7ZHNgwSSTFct+R/Kf4OFW1sUzUTQQTgfc= -golang.org/x/tools v0.0.0-20190816200558-6889da9d5479/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190907020128-2ca718005c18/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20190911174233-4f2ddba30aff/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191012152004-8de300cfc20a/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191112195655-aa38f8e97acc/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191113191852-77e3bb0ad9e7/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191115202509-3a792d9c32b2/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191119224855-298f0cb1881e/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191125144606-a911d9008d1f/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191130070609-6e064ea0cf2d/go.mod h1:b+2E5dAYhXwXZwtnZ6UAqBI28+e2cm9otk0dWdXHAEo= -golang.org/x/tools v0.0.0-20191216173652-a0e659d51361/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20191227053925-7b8e75db28f4/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200117161641-43d50277825c/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200122220014-bf1340f18c4a/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200130002326-2f3ba24bd6e7/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200204074204-1cc6d1ef6c74/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200207183749-b753a1ba74fa/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200212150539-ea181f53ac56/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200224181240-023911ca70b2/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200227222343-706bc42d1f0d/go.mod h1:TB2adYChydJhpapKDTa4BR/hXlZSLoq2Wpct/0txZ28= -golang.org/x/tools v0.0.0-20200304193943-95d2e580d8eb/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200312045724-11d5b4c81c7d/go.mod h1:o4KQGtdN14AW+yjsvvwRTJJuXz8XRtIHtEnmAXLyFUw= -golang.org/x/tools v0.0.0-20200331025713-a30bf2db82d4/go.mod h1:Sl4aGygMT6LrqrWclx+PTx3U+LnKx/seiNR+3G19Ar8= -golang.org/x/tools v0.0.0-20200501065659-ab2804fb9c9d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200509030707-2212a7e161a5/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200512131952-2bc93b1c0c88/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200515010526-7d3b6ebf133d/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200618134242-20370b0cb4b2/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200619180055-7c47624df98f/go.mod h1:EkVYQZoAsY45+roYkvgYkIh4xh/qjgUK9TdY2XT94GE= -golang.org/x/tools v0.0.0-20200729194436-6467de6f59a7/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200804011535-6c149bb5ef0d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200825202427-b303f430e36d/go.mod h1:njjCfa9FT2d7l9Bc6FUM5FLjQPp3cFF28FI3qnDFljA= -golang.org/x/tools v0.0.0-20200904185747-39188db58858/go.mod h1:Cj7w3i3Rnn0Xh82ur9kSqwfTHTeVxaDqrfMjpcNT6bE= -golang.org/x/tools v0.0.0-20201110124207-079ba7bd75cd/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201201161351-ac6f37ff4c2a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20201208233053-a543418bbed2/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210105154028-b0ab187a4818/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.0.0-20210106214847-113979e3529a/go.mod h1:emZCQorbCU4vsT4fOWvOPXz4eW1wZW4PmDk9uLelYpA= -golang.org/x/tools v0.1.0/go.mod h1:xkSsbof2nBLbhDlRMhhhyNLN/zl3eTqcnHD5viDpcZ0= -golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.2/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.4/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= -golang.org/x/tools v0.1.12/go.mod h1:hNGJHUnrk76NpqgfD5Aqm5Crs+Hm0VOH/i9J2+nxYbc= -golang.org/x/tools v0.6.0/go.mod h1:Xwgl3UAJ/d3gWutnCtw505GrjyAbvKui8lOU390QaIU= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d h1:vU5i/LfpvrRCpgM/VPfJLg5KjxD3E+hfT1SH+d9zLwg= -golang.org/x/tools v0.21.1-0.20240508182429-e35e4ccd0d2d/go.mod h1:aiJjzUbINMkxbQROHiO6hDPo2LHcIPhhQsa9DLh0yGk= -golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220411194840-2f41105eb62f/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= -golang.org/x/xerrors v0.0.0-20220517211312-f3a8303e98df/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -golang.org/x/xerrors v0.0.0-20220609144429-65e65417b02f/go.mod h1:K8+ghG5WaK9qNqU5K3HdILfMLy1f3aNYFI/wnl100a8= -gonum.org/v1/gonum v0.0.0-20180816165407-929014505bf4/go.mod h1:Y+Yx5eoAFn32cQvJDxZx5Dpnq+c3wtXuadVZAcxbbBo= -gonum.org/v1/gonum v0.8.2/go.mod h1:oe/vMfY3deqTw+1EZJhuvEW2iwGF1bW9wwu7XCu0+v0= -gonum.org/v1/netlib v0.0.0-20190313105609-8cb42192e0e0/go.mod h1:wa6Ws7BG/ESfp6dHfk7C6KdzKA7wR7u/rKwOGE66zvw= -gonum.org/v1/plot v0.0.0-20190515093506-e2840ee46a6b/go.mod h1:Wt8AAjI+ypCyYX3nZBvf6cAIx93T+c/OS2HFAYskSZc= -google.golang.org/api v0.4.0/go.mod h1:8k5glujaEP+g9n7WNsDg8QP6cUVNI86fCNMcbazEtwE= -google.golang.org/api v0.7.0/go.mod h1:WtwebWUNSVBH/HAw79HIFXZNqEvBhG+Ra+ax0hx3E3M= -google.golang.org/api v0.8.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.9.0/go.mod h1:o4eAsZoiT+ibD93RtjEohWalFOjRDx6CVaqeizhEnKg= -google.golang.org/api v0.13.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.14.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.15.0/go.mod h1:iLdEw5Ide6rF15KTC1Kkl0iskquN2gFfn9o9XIsbkAI= -google.golang.org/api v0.17.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.18.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.19.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.20.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.22.0/go.mod h1:BwFmGc8tA3vsd7r/7kR8DY7iEEGSU04BFxCo5jP/sfE= -google.golang.org/api v0.24.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.28.0/go.mod h1:lIXQywCXRcnZPGlsd8NbLnOjtAoL6em04bJ9+z0MncE= -google.golang.org/api v0.29.0/go.mod h1:Lcubydp8VUV7KeIHD9z2Bys/sm/vGKnG1UHuDBSrHWM= -google.golang.org/api v0.30.0/go.mod h1:QGmEvQ87FHZNiUVJkT14jQNYJ4ZJjdRF23ZXz5138Fc= -google.golang.org/api v0.35.0/go.mod h1:/XrVsuzM0rZmrsbjJutiuftIzeuTQcEeaYcSk/mQ1dg= -google.golang.org/api v0.36.0/go.mod h1:+z5ficQTmoYpPn8LCUNVpK5I7hwkpjbcgqA7I34qYtE= -google.golang.org/api v0.40.0/go.mod h1:fYKFpnQN0DsDSKRVRcQSDQNtqWPfM9i+zNPxepjRCQ8= -google.golang.org/api v0.41.0/go.mod h1:RkxM5lITDfTzmyKFPt+wGrCJbVfniCr2ool8kTBzRTU= -google.golang.org/api v0.43.0/go.mod h1:nQsDGjRXMo4lvh5hP0TKqF244gqhGcr/YSIykhUk/94= -google.golang.org/api v0.44.0/go.mod h1:EBOGZqzyhtvMDoxwS97ctnh0zUmYY6CxqXsc1AvkYD8= -google.golang.org/api v0.47.0/go.mod h1:Wbvgpq1HddcWVtzsVLyfLp8lDg6AA241LmgIL59tHXo= -google.golang.org/api v0.48.0/go.mod h1:71Pr1vy+TAZRPkPs/xlCf5SsU8WjuAWv1Pfjbtukyy4= -google.golang.org/api v0.50.0/go.mod h1:4bNT5pAuq5ji4SRZm+5QIkjny9JAyVD/3gaSihNefaw= -google.golang.org/api v0.51.0/go.mod h1:t4HdrdoNgyN5cbEfm7Lum0lcLDLiise1F8qDKX00sOU= -google.golang.org/api v0.54.0/go.mod h1:7C4bFFOvVDGXjfDTAsgGwDgAxRDeQ4X8NvUedIt6z3k= -google.golang.org/api v0.55.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.56.0/go.mod h1:38yMfeP1kfjsl8isn0tliTjIb1rJXcQi4UXlbqivdVE= -google.golang.org/api v0.57.0/go.mod h1:dVPlbZyBo2/OjBpmvNdpn2GRm6rPy75jyU7bmhdrMgI= -google.golang.org/api v0.61.0/go.mod h1:xQRti5UdCmoCEqFxcz93fTl338AVqDgyaDRuOZ3hg9I= -google.golang.org/api v0.63.0/go.mod h1:gs4ij2ffTRXwuzzgJl/56BdwJaA194ijkfn++9tDuPo= -google.golang.org/api v0.67.0/go.mod h1:ShHKP8E60yPsKNw/w8w+VYaj9H6buA5UqDp8dhbQZ6g= -google.golang.org/api v0.70.0/go.mod h1:Bs4ZM2HGifEvXwd50TtW70ovgJffJYw2oRCOFU/SkfA= -google.golang.org/api v0.71.0/go.mod h1:4PyU6e6JogV1f9eA4voyrTY2batOLdgZ5qZ5HOCc4j8= -google.golang.org/api v0.74.0/go.mod h1:ZpfMZOVRMywNyvJFeqL9HRWBgAuRfSjJFpe9QtRRyDs= -google.golang.org/api v0.75.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= -google.golang.org/api v0.77.0/go.mod h1:pU9QmyHLnzlpar1Mjt4IbapUCy8J+6HD6GeELN69ljA= -google.golang.org/api v0.78.0/go.mod h1:1Sg78yoMLOhlQTeF+ARBoytAcH1NNyyl390YMy6rKmw= -google.golang.org/api v0.80.0/go.mod h1:xY3nI94gbvBrE0J6NHXhxOmW97HG7Khjkku6AFB3Hyg= -google.golang.org/api v0.84.0/go.mod h1:NTsGnUFJMYROtiquksZHBWtHfeMC7iYthki7Eq3pa8o= -google.golang.org/api v0.85.0/go.mod h1:AqZf8Ep9uZ2pyTvgL+x0D3Zt0eoT9b5E8fmzfu6FO2g= -google.golang.org/api v0.90.0/go.mod h1:+Sem1dnrKlrXMR/X0bPnMWyluQe4RsNoYfmNLhOIkzw= -google.golang.org/api v0.93.0/go.mod h1:+Sem1dnrKlrXMR/X0bPnMWyluQe4RsNoYfmNLhOIkzw= -google.golang.org/api v0.95.0/go.mod h1:eADj+UBuxkh5zlrSntJghuNeg8HwQ1w5lTKkuqaETEI= -google.golang.org/api v0.96.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= -google.golang.org/api v0.97.0/go.mod h1:w7wJQLTM+wvQpNf5JyEcBoxK0RH7EDrh/L4qfsuJ13s= -google.golang.org/appengine v1.1.0/go.mod h1:EbEs0AVv82hx2wNQdGPgUI5lhzA/G0D9YwlJXL52JkM= -google.golang.org/appengine v1.4.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.5.0/go.mod h1:xpcJRLb0r/rnEns0DIKYYv+WjYCduHsrkT7/EB5XEv4= -google.golang.org/appengine v1.6.1/go.mod h1:i06prIuMbXzDqacNJfV5OdTW448YApPu5ww/cMBSeb0= -google.golang.org/appengine v1.6.5/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.6/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/appengine v1.6.7/go.mod h1:8WjMMxjGQR8xUklV/ARdw2HLXBOI7O7uCIDZVag1xfc= -google.golang.org/genproto v0.0.0-20180817151627-c66870c02cf8/go.mod h1:JiN7NxoALGmiZfu7CAH4rXhgtRTLTxftemlI0sWmxmc= -google.golang.org/genproto v0.0.0-20190307195333-5fe7a883aa19/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190418145605-e7d98fc518a7/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190425155659-357c62f0e4bb/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190502173448-54afdca5d873/go.mod h1:VzzqZJRnGkLBvHegQrXjBqPurQTc5/KpmUdxsrq26oE= -google.golang.org/genproto v0.0.0-20190801165951-fa694d86fc64/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190819201941-24fa4b261c55/go.mod h1:DMBHOl98Agz4BDEuKkezgsaosCRResVns1a3J2ZsMNc= -google.golang.org/genproto v0.0.0-20190911173649-1774047e7e51/go.mod h1:IbNlFCBrqXvoKpeg0TB2l7cyZUmoaFKYIwrEpbDKLA8= -google.golang.org/genproto v0.0.0-20191108220845-16a3f7862a1a/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191115194625-c23dd37a84c9/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191216164720-4f79533eabd1/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20191230161307-f3c370f40bfb/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200115191322-ca5a22157cba/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200122232147-0452cf42e150/go.mod h1:n3cpQtvxv34hfy77yVDNjmbRyujviMdxYliBSkLhpCc= -google.golang.org/genproto v0.0.0-20200204135345-fa8e72b47b90/go.mod h1:GmwEX6Z4W5gMy59cAlVYjN9JhxgbQH6Gn+gFDQe2lzA= -google.golang.org/genproto v0.0.0-20200212174721-66ed5ce911ce/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200224152610-e50cd9704f63/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200228133532-8c2c7df3a383/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200305110556-506484158171/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200312145019-da6875a35672/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200331122359-1ee6d9798940/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200430143042-b979b6f78d84/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200511104702-f5ebc3bea380/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200513103714-09dca8ec2884/go.mod h1:55QSHmfGQM9UVYDPBsyGGes0y52j32PQ3BqQfXhyH3c= -google.golang.org/genproto v0.0.0-20200515170657-fc4c6c6a6587/go.mod h1:YsZOwe1myG/8QRHRsmBRE1LrgQY60beZKjly0O1fX9U= -google.golang.org/genproto v0.0.0-20200526211855-cb27e3aa2013/go.mod h1:NbSheEEYHJ7i3ixzK3sjbqSGDJWnxyFXZblF3eUsNvo= -google.golang.org/genproto v0.0.0-20200618031413-b414f8b61790/go.mod h1:jDfRM7FcilCzHH/e9qn6dsT145K34l5v+OpcnNgKAAA= -google.golang.org/genproto v0.0.0-20200729003335-053ba62fc06f/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200804131852-c06518451d9c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200825200019-8632dd797987/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20200904004341-0bd0a958aa1d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201019141844-1ed22bb0c154/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201109203340-2640f1f9cdfb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201201144952-b05cb90ed32e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201210142538-e3217bee35cc/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20201214200347-8c77b98c765d/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210222152913-aa3ee6e6a81c/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210303154014-9728d6b83eeb/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210310155132-4ce2db91004e/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210319143718-93e7006c17a6/go.mod h1:FWY/as6DDZQgahTzZj3fqbO1CbirC29ZNUFHwi0/+no= -google.golang.org/genproto v0.0.0-20210329143202-679c6ae281ee/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210402141018-6c239bbf2bb1/go.mod h1:9lPAdzaEmUacj36I+k7YKbEc5CXzPIeORRgDAUOu28A= -google.golang.org/genproto v0.0.0-20210513213006-bf773b8c8384/go.mod h1:P3QM42oQyzQSnHPnZ/vqoCdDmzH28fzWByN9asMeM8A= -google.golang.org/genproto v0.0.0-20210602131652-f16073e35f0c/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210604141403-392c879c8b08/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210608205507-b6d2f5bf0d7d/go.mod h1:UODoCrxHCcBojKKwX1terBiRUaqAsFqJiF615XL43r0= -google.golang.org/genproto v0.0.0-20210624195500-8bfb893ecb84/go.mod h1:SzzZ/N+nwJDaO1kznhnlzqS8ocJICar6hYhVyhi++24= -google.golang.org/genproto v0.0.0-20210713002101-d411969a0d9a/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210716133855-ce7ef5c701ea/go.mod h1:AxrInvYm1dci+enl5hChSFPOmmUF1+uAa/UsgNRWd7k= -google.golang.org/genproto v0.0.0-20210728212813-7823e685a01f/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210805201207-89edb61ffb67/go.mod h1:ob2IJxKrgPT52GcgX759i1sleT07tiKowYBGbczaW48= -google.golang.org/genproto v0.0.0-20210813162853-db860fec028c/go.mod h1:cFeNkxwySK631ADgubI+/XFU/xp8FD5KIVV4rj8UC5w= -google.golang.org/genproto v0.0.0-20210821163610-241b8fcbd6c8/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210828152312-66f60bf46e71/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210831024726-fe130286e0e2/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210903162649-d08c68adba83/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210909211513-a8c4777a87af/go.mod h1:eFjDcFEctNawg4eG61bRv87N7iHBWyVhJu7u1kqDUXY= -google.golang.org/genproto v0.0.0-20210924002016-3dee208752a0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211118181313-81c1377c94b1/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211206160659-862468c7d6e0/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211208223120-3a66f561d7aa/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20211221195035-429b39de9b1c/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220126215142-9970aeb2e350/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220207164111-0872dc986b00/go.mod h1:5CzLGKJ67TSI2B9POpiiyGha0AjJvZIUgRMt1dSmuhc= -google.golang.org/genproto v0.0.0-20220218161850-94dd64e39d7c/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220222213610-43724f9ea8cf/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220304144024-325a89244dc8/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220310185008-1973136f34c6/go.mod h1:kGP+zUP2Ddo0ayMi4YuN7C3WZyJvGLZRh8Z5wnAqvEI= -google.golang.org/genproto v0.0.0-20220324131243-acbaeb5b85eb/go.mod h1:hAL49I2IFola2sVEjAn7MEwsja0xp51I0tlGAf9hz4E= -google.golang.org/genproto v0.0.0-20220407144326-9054f6ed7bac/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220413183235-5e96e2839df9/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220414192740-2d67ff6cf2b4/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220421151946-72621c1f0bd3/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220429170224-98d788798c3e/go.mod h1:8w6bsBMX6yCPbAVTeqQHvzxW0EIFigd5lZyahWgyfDo= -google.golang.org/genproto v0.0.0-20220502173005-c8bf987b8c21/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220505152158-f39f71e6c8f3/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220518221133-4f43b3371335/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220523171625-347a074981d8/go.mod h1:RAyBrSAP7Fh3Nc84ghnVLDPuV51xc9agzmm4Ph6i0Q4= -google.golang.org/genproto v0.0.0-20220608133413-ed9918b62aac/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220616135557-88e70c0c3a90/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220617124728-180714bec0ad/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220624142145-8cd45d7dbd1f/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220628213854-d9e0b6570c03/go.mod h1:KEWEmljWE5zPzLBa/oHl6DaEt9LmfH6WtH1OHIvleBA= -google.golang.org/genproto v0.0.0-20220722212130-b98a9ff5e252/go.mod h1:GkXuJDJ6aQ7lnJcRF+SJVgFdQhypqgl3LB1C9vabdRE= -google.golang.org/genproto v0.0.0-20220801145646-83ce21fca29f/go.mod h1:iHe1svFLAZg9VWz891+QbRMwUv9O/1Ww+/mngYeThbc= -google.golang.org/genproto v0.0.0-20220815135757-37a418bb8959/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220817144833-d7fd3f11b9b1/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220822174746-9e6da59bd2fc/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220829144015-23454907ede3/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220829175752-36a9c930ecbf/go.mod h1:dbqgFATTzChvnt+ujMdZwITVAJHFtfyN1qUhDqEiIlk= -google.golang.org/genproto v0.0.0-20220913154956-18f8339a66a5/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220914142337-ca0e39ece12f/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220915135415-7fd63a7952de/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220916172020-2692e8806bfa/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220919141832-68c03719ef51/go.mod h1:0Nb8Qy+Sk5eDzHnzlStwW3itdNaWoZA5XeSG+R3JHSo= -google.golang.org/genproto v0.0.0-20220920201722-2b89144ce006/go.mod h1:ht8XFiar2npT/g4vkk7O0WYS1sHOHbdujxbEp7CJWbw= -google.golang.org/genproto v0.0.0-20220926165614-551eb538f295/go.mod h1:woMGP53BroOrRY3xTxlbr8Y3eB/nzAvvFM83q7kG2OI= -google.golang.org/genproto v0.0.0-20220926220553-6981cbe3cfce/go.mod h1:woMGP53BroOrRY3xTxlbr8Y3eB/nzAvvFM83q7kG2OI= -google.golang.org/genproto v0.0.0-20221014213838-99cd37c6964a/go.mod h1:1vXfmgAz9N9Jx0QA82PqRVauvCz1SGSz739p0f183jM= -google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1 h1:hjSy6tcFQZ171igDaN5QHOw2n6vx40juYbC/x67CEhc= -google.golang.org/genproto/googleapis/api v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:qpvKtACPCQhAdu3PyQgV4l3LMXZEtft7y8QcarRsp9I= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1 h1:pPJltXNxVzT4pK9yD8vR9X75DaWYYmLGMsEvBfFQZzQ= -google.golang.org/genproto/googleapis/rpc v0.0.0-20240903143218-8af14fe29dc1/go.mod h1:UqMtugtsSgubUsoxbuAoiCXvqvErP7Gf0so0mK9tHxU= -google.golang.org/grpc v1.19.0/go.mod h1:mqu4LbDTu4XGKhr4mRzUsmM4RtVoemTSY81AxZiDr8c= -google.golang.org/grpc v1.20.1/go.mod h1:10oTOabMzJvdu6/UiuZezV6QK5dSlG84ov/aaiqXj38= -google.golang.org/grpc v1.21.1/go.mod h1:oYelfM1adQP15Ek0mdvEgi9Df8B9CZIaU1084ijfRaM= -google.golang.org/grpc v1.23.0/go.mod h1:Y5yQAOtifL1yxbo5wqy6BxZv8vAUGQwXBOALyacEbxg= -google.golang.org/grpc v1.25.1/go.mod h1:c3i+UQWmh7LiEpx4sFZnkU36qjEYZ0imhYfXVyQciAY= -google.golang.org/grpc v1.26.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.0/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.27.1/go.mod h1:qbnxyOmOxrQa7FizSgH+ReBfzJrCY1pSN7KXBS8abTk= -google.golang.org/grpc v1.28.0/go.mod h1:rpkK4SK4GF4Ach/+MFLZUBavHOvF2JJB5uozKKal+60= -google.golang.org/grpc v1.29.1/go.mod h1:itym6AZVZYACWQqET3MqgPpjcuV5QH3BxFS3IjizoKk= -google.golang.org/grpc v1.30.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.0/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.31.1/go.mod h1:N36X2cJ7JwdamYAgDz+s+rVMFjt3numwzf/HckM8pak= -google.golang.org/grpc v1.33.1/go.mod h1:fr5YgcSWrqhRRxogOsw7RzIpsmvOZ6IcH4kBYTpR3n0= -google.golang.org/grpc v1.33.2/go.mod h1:JMHMWHQWaTccqQQlmk3MJZS+GWXOdAesneDmEnv2fbc= -google.golang.org/grpc v1.34.0/go.mod h1:WotjhfgOW/POjDeRt8vscBtXq+2VjORFy659qA51WJ8= -google.golang.org/grpc v1.35.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.0/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.36.1/go.mod h1:qjiiYl8FncCW8feJPdyg3v6XW24KsRHe+dy9BAGRRjU= -google.golang.org/grpc v1.37.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.37.1/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.38.0/go.mod h1:NREThFqKR1f3iQ6oBuvc5LadQuXVGo9rkm5ZGrQdJfM= -google.golang.org/grpc v1.39.0/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.39.1/go.mod h1:PImNr+rS9TWYb2O4/emRugxiyHZ5JyHW5F+RPnDzfrE= -google.golang.org/grpc v1.40.0/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.40.1/go.mod h1:ogyxbiOoUXAkP+4+xa6PZSE9DZgIHtSpzjDTB9KAK34= -google.golang.org/grpc v1.44.0/go.mod h1:k+4IHHFw41K8+bbowsex27ge2rCb65oeWqe4jJ590SU= -google.golang.org/grpc v1.45.0/go.mod h1:lN7owxKUQEqMfSyQikvvk5tf/6zMPsrK+ONuO11+0rQ= -google.golang.org/grpc v1.46.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.46.2/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.47.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.48.0/go.mod h1:vN9eftEi1UMyUsIF80+uQXhHjbXYbm0uXoFCACuMGWk= -google.golang.org/grpc v1.49.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.50.0/go.mod h1:ZgQEeidpAuNRZ8iRrlBKXZQP1ghovWIVhdJRyCDK+GI= -google.golang.org/grpc v1.51.0/go.mod h1:wgNDFcnuBGmxLKI/qn4T+m5BtEBYXJPvibbUPsAIPww= -google.golang.org/grpc v1.68.1 h1:oI5oTa11+ng8r8XMMN7jAOmWfPZWbYpCFaMUTACxkM0= -google.golang.org/grpc v1.68.1/go.mod h1:+q1XYFJjShcqn0QZHvCyeR4CXPA+llXIeUIfIe00waw= -google.golang.org/grpc/cmd/protoc-gen-go-grpc v1.1.0/go.mod h1:6Kw0yEErY5E/yWrBtf03jp27GLLJujG4z/JK95pnjjw= -google.golang.org/protobuf v0.0.0-20200109180630-ec00e32a8dfd/go.mod h1:DFci5gLYBciE7Vtevhsrf46CRTquxDuWsQurQQe4oz8= -google.golang.org/protobuf v0.0.0-20200221191635-4d8936d0db64/go.mod h1:kwYJMbMJ01Woi6D6+Kah6886xMZcty6N08ah7+eCXa0= -google.golang.org/protobuf v0.0.0-20200228230310-ab0ca4ff8a60/go.mod h1:cfTl7dwQJ+fmap5saPgwCLgHXTUD7jkjRqWcaiX5VyM= -google.golang.org/protobuf v1.20.1-0.20200309200217-e05f789c0967/go.mod h1:A+miEFZTKqfCUM6K7xSMQL9OKL/b6hQv+e19PK+JZNE= -google.golang.org/protobuf v1.21.0/go.mod h1:47Nbq4nVaFHyn7ilMalzfO3qCViNmqZ2kzikPIcrTAo= -google.golang.org/protobuf v1.22.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.0/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.23.1-0.20200526195155-81db48ad09cc/go.mod h1:EGpADcykh3NcUnDUJcl1+ZksZNG86OlYog2l/sGQquU= -google.golang.org/protobuf v1.24.0/go.mod h1:r/3tXBNzIEhYS9I1OUVjXDlt8tc493IdKGjtUeSXeh4= -google.golang.org/protobuf v1.25.0/go.mod h1:9JNX74DMeImyA3h4bdi1ymwjUzf21/xIlbajtzgsN7c= -google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= -google.golang.org/protobuf v1.26.0/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -google.golang.org/protobuf v1.28.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.28.1/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.31.0/go.mod h1:HV8QOd/L58Z+nl8r43ehVNZIU/HEI6OcFqwMG9pJV4I= -google.golang.org/protobuf v1.34.2 h1:6xV6lTsCfpGD21XK49h7MhtcApnLqkfYgPcdHftf6hg= -google.golang.org/protobuf v1.34.2/go.mod h1:qYOHts0dSfpeUzUFpOMr/WGzszTmLH+DiWniOlNbLDw= -gopkg.in/alecthomas/kingpin.v2 v2.2.6/go.mod h1:FMv+mEhP44yOT+4EoQTLFTRgOQ1FBLkstjWtayDeSgw= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20180628173108-788fd7840127/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20190902080502-41f04d3bba15/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20200227125254-8fa46927fb4f/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= -gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= -gopkg.in/errgo.v2 v2.1.0/go.mod h1:hNsd1EY+bozCKY1Ytp96fpM3vjJbqLJn88ws8XvfDNI= -gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc= -gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw= -gopkg.in/ini.v1 v1.62.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.66.2/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/ini.v1 v1.67.0 h1:Dgnx+6+nfE+IfzjUEISNeydPJh9AXNNsWbGP9KzCsOA= -gopkg.in/ini.v1 v1.67.0/go.mod h1:pNLf8WUiyNEtQjuu5G5vTm06TEv9tsIgeAvK8hOrP4k= -gopkg.in/natefinch/lumberjack.v2 v2.2.1 h1:bBRl1b0OH9s/DuPhuXpNl+VtCaJXFZ5/uEFST95x9zc= -gopkg.in/natefinch/lumberjack.v2 v2.2.1/go.mod h1:YD8tP3GAjkrDg1eZH7EGmyESg/lsYskCTPBJVb9jqSc= -gopkg.in/yaml.v2 v2.2.1/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.3/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.4/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.5/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.2.8/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.3.0/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= -gopkg.in/yaml.v2 v2.4.0 h1:D8xgwECY7CYvx+Y2n4sBz93Jn9JRvxdiyyo8CTfuKaY= -gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ= -gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20200615113413-eeeca48fe776/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0-20210107192922-496545a6307b/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.0/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= -gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= -honnef.co/go/tools v0.0.0-20190102054323-c2f93a96b099/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190106161140-3f1c8253044a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190418001031-e561f6794a2a/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.0-20190523083050-ea95bdfd59fc/go.mod h1:rf3lG4BRIbNafJWhAfAdb/ePZxsR/4RtNHQocxwk9r4= -honnef.co/go/tools v0.0.1-2019.2.3/go.mod h1:a3bituU0lyd329TUQxRnasdCoJDkEUEAqEt0JzvZhAg= -honnef.co/go/tools v0.0.1-2020.1.3/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -honnef.co/go/tools v0.0.1-2020.1.4/go.mod h1:X/FiERA/W4tHapMX5mGpAtMSVEeEUOyHaw9vFzvIQ3k= -k8s.io/api v0.27.4 h1:0pCo/AN9hONazBKlNUdhQymmnfLRbSZjd5H5H3f0bSs= -k8s.io/api v0.27.4/go.mod h1:O3smaaX15NfxjzILfiln1D8Z3+gEYpjEpiNA/1EVK1Y= -k8s.io/apimachinery v0.27.4 h1:CdxflD4AF61yewuid0fLl6bM4a3q04jWel0IlP+aYjs= -k8s.io/apimachinery v0.27.4/go.mod h1:XNfZ6xklnMCOGGFNqXG7bUrQCoR04dh/E7FprV6pb+E= -k8s.io/client-go v0.27.4 h1:vj2YTtSJ6J4KxaC88P4pMPEQECWMY8gqPqsTgUKzvjk= -k8s.io/client-go v0.27.4/go.mod h1:ragcly7lUlN0SRPk5/ZkGnDjPknzb37TICq07WhI6Xc= -k8s.io/klog/v2 v2.90.1 h1:m4bYOKall2MmOiRaR1J+We67Do7vm9KiQVlT96lnHUw= -k8s.io/klog/v2 v2.90.1/go.mod h1:y1WjHnz7Dj687irZUWR/WLkLc5N1YHtjLdmgWjndZn0= -k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f h1:2kWPakN3i/k81b0gvD5C5FJ2kxm1WrQFanWchyKuqGg= -k8s.io/kube-openapi v0.0.0-20230501164219-8b0f38b5fd1f/go.mod h1:byini6yhqGC14c3ebc/QwanvYwhuMWF6yz2F8uwW8eg= -k8s.io/utils v0.0.0-20230209194617-a36077c30491 h1:r0BAOLElQnnFhE/ApUsg3iHdVYYPBjNSSOMowRZxxsY= -k8s.io/utils v0.0.0-20230209194617-a36077c30491/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0= -rsc.io/binaryregexp v0.2.0/go.mod h1:qTv7/COck+e2FymRvadv62gMdZztPaShugOCi3I+8D8= -rsc.io/pdf v0.1.1/go.mod h1:n8OzWcQ6Sp37PL01nO98y4iUCRdTGarVfzxY20ICaU4= -rsc.io/quote/v3 v3.1.0/go.mod h1:yEA65RcK8LyAZtP9Kv3t0HmxON59tX3rD+tICJqUlj0= -rsc.io/sampler v1.3.0/go.mod h1:T1hPZKmBbMNahiBKFy5HrXp6adAjACjK9JXDnKaTXpA= -sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo= -sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3 h1:PRbqxJClWWYMNV1dhaG4NsibJbArud9kFxnAMREiWFE= -sigs.k8s.io/structured-merge-diff/v4 v4.2.3/go.mod h1:qjx8mGObPmV2aSZepjQjbmb2ihdVs8cGKBraizNC69E= -sigs.k8s.io/yaml v1.3.0 h1:a2VclLzOGrwOHDiV8EfBGhvjHvP46CtW5j6POvhYGGo= -sigs.k8s.io/yaml v1.3.0/go.mod h1:GeOyir5tyXNByN85N/dRIT9es5UQNerPYEKK56eTBm8= diff --git a/example/httpserver/default-value/main.go b/example/httpserver/default-value/main.go deleted file mode 100644 index 59712fa773e..00000000000 --- a/example/httpserver/default-value/main.go +++ /dev/null @@ -1,47 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" -) - -type GetListReq struct { - g.Meta `path:"/" method:"get"` - Type string `v:"required#请选择内容模型" dc:"内容模型"` - Page int `v:"min:0#分页号码错误" dc:"分页号码" d:"1"` - Size int `v:"max:50#分页数量最大50条" dc:"分页数量,最大50" d:"10"` - Sort int `v:"in:0,1,2#排序类型不合法" dc:"排序类型(0:最新, 默认。1:活跃, 2:热度)"` -} -type GetListRes struct { - Items []Item `dc:"内容列表"` -} - -type Item struct { - Id int64 `dc:"内容ID"` - Title string `dc:"内容标题"` -} - -type Controller struct{} - -func (Controller) GetList(ctx context.Context, req *GetListReq) (res *GetListRes, err error) { - g.Log().Info(ctx, req) - return -} - -func main() { - s := g.Server() - s.Group("/content", func(group *ghttp.RouterGroup) { - group.Middleware(ghttp.MiddlewareHandlerResponse) - group.Bind(&Controller{}) - }) - s.SetPort(8199) - s.Run() -} diff --git a/example/httpserver/proxy/main.go b/example/httpserver/proxy/main.go deleted file mode 100644 index 520e0dbedb5..00000000000 --- a/example/httpserver/proxy/main.go +++ /dev/null @@ -1,63 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "net/http" - "net/http/httputil" - "net/url" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" -) - -const ( - PortOfServerBackend = 8198 - PortOfServerProxy = 8199 - UpStream = "http://127.0.0.1:8198" -) - -// StartServerBackend starts `backend`: A simple http server for demo. -func StartServerBackend() { - s := g.Server("backend") - s.BindHandler("/*", func(r *ghttp.Request) { - r.Response.Write("response from server backend") - }) - s.BindHandler("/user/1", func(r *ghttp.Request) { - r.Response.Write("user info from server backend") - }) - s.SetPort(PortOfServerBackend) - s.Run() -} - -// StartServerProxy starts `proxy`: -// All requests to `proxy` of route `/proxy/*` are directly redirected to `backend`. -func StartServerProxy() { - s := g.Server("proxy") - u, _ := url.Parse(UpStream) - proxy := httputil.NewSingleHostReverseProxy(u) - proxy.ErrorHandler = func(writer http.ResponseWriter, request *http.Request, e error) { - writer.WriteHeader(http.StatusBadGateway) - } - s.BindHandler("/proxy/*url", func(r *ghttp.Request) { - var ( - originalPath = r.Request.URL.Path - proxyToPath = "/" + r.Get("url").String() - ) - r.Request.URL.Path = proxyToPath - g.Log().Infof(r.Context(), `proxy:"%s" -> backend:"%s"`, originalPath, proxyToPath) - r.MakeBodyRepeatableRead(false) - proxy.ServeHTTP(r.Response.Writer, r.Request) - }) - s.SetPort(PortOfServerProxy) - s.Run() -} - -func main() { - go StartServerBackend() - StartServerProxy() -} diff --git a/example/httpserver/rate/main.go b/example/httpserver/rate/main.go deleted file mode 100644 index 88a7c15a7fe..00000000000 --- a/example/httpserver/rate/main.go +++ /dev/null @@ -1,59 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - "fmt" - - "golang.org/x/time/rate" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" -) - -type HelloReq struct { - g.Meta `path:"/hello" method:"get" sort:"1"` - Name string `v:"required" dc:"Your name"` -} - -type HelloRes struct { - Reply string `dc:"Reply content"` -} - -type Hello struct{} - -func (Hello) Say(ctx context.Context, req *HelloReq) (res *HelloRes, err error) { - g.Log().Debugf(ctx, `receive say: %+v`, req) - res = &HelloRes{ - Reply: fmt.Sprintf(`Hi %s`, req.Name), - } - return -} - -var limiter = rate.NewLimiter(rate.Limit(10), 1) // 10 request per second - -func Limiter(r *ghttp.Request) { - if !limiter.Allow() { - r.Response.WriteStatusExit(429) - r.ExitAll() - } - r.Middleware.Next() -} - -// curl "http://127.0.0.1:8080/hello?name=world" -func main() { - s := g.Server() - s.Use(Limiter, ghttp.MiddlewareHandlerResponse) - s.Group("/", func(group *ghttp.RouterGroup) { - group.Bind( - new(Hello), - ) - }) - s.SetPort(8080) - s.Run() -} diff --git a/example/httpserver/response-with-json-array/controller.go b/example/httpserver/response-with-json-array/controller.go deleted file mode 100644 index 2455cfa0280..00000000000 --- a/example/httpserver/response-with-json-array/controller.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "github.com/gogf/gf/v2/frame/g" -) - -type Req struct { - g.Meta `path:"/user" method:"get"` -} - -type Res []Item - -type Item struct { - Id int64 - Name string -} - -var ( - User = cUser{} -) - -type cUser struct{} - -func (c *cUser) GetList(ctx context.Context, req *Req) (res *Res, err error) { - res = &Res{ - {Id: 1, Name: "john"}, - {Id: 2, Name: "smith"}, - {Id: 3, Name: "alice"}, - {Id: 4, Name: "katyusha"}, - } - return -} diff --git a/example/httpserver/response-with-json-array/main.go b/example/httpserver/response-with-json-array/main.go deleted file mode 100644 index 95f96cadcce..00000000000 --- a/example/httpserver/response-with-json-array/main.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" -) - -func main() { - s := g.Server() - s.Group("/", func(group *ghttp.RouterGroup) { - group.Middleware(ghttp.MiddlewareHandlerResponse) - group.Bind( - User, - ) - }) - oai := s.GetOpenApi() - oai.Config.CommonResponse = ghttp.DefaultHandlerResponse{} - oai.Config.CommonResponseDataField = "Data" - s.SetOpenApiPath("/api") - s.SetSwaggerPath("/swagger") - s.SetPort(8199) - s.Run() -} diff --git a/example/httpserver/serve-file/main.go b/example/httpserver/serve-file/main.go deleted file mode 100644 index 0b8e1372b3f..00000000000 --- a/example/httpserver/serve-file/main.go +++ /dev/null @@ -1,45 +0,0 @@ -package main - -import ( - "net/http" - "strings" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" -) - -// pathMap is used for URL mapping -var pathMap = map[string]string{ - "/aaa/": "/tmp/", -} - -// ServeFile serves the file to the response. -func ServeFile(r *ghttp.Request) { - truePath := r.URL.Path - hasPrefix := false - // Replace the path prefix. - for k, v := range pathMap { - if strings.HasPrefix(truePath, k) { - truePath = strings.Replace(truePath, k, v, 1) // Replace only once. - hasPrefix = true - break - } - } - - if !hasPrefix { - r.Response.WriteStatus(http.StatusForbidden) - return - } - - r.Response.ServeFile(truePath) -} - -func main() { - s := g.Server() - s.Use(ghttp.MiddlewareHandlerResponse) - s.BindHandler("/*", ServeFile) - s.SetPort(8080) - s.Run() -} - -// http://127.0.0.1:8080/aaa/main.go diff --git a/example/httpserver/swagger-set-template/config.yaml b/example/httpserver/swagger-set-template/config.yaml deleted file mode 100644 index b15f8d00786..00000000000 --- a/example/httpserver/swagger-set-template/config.yaml +++ /dev/null @@ -1,4 +0,0 @@ -server: - address: ":8199" - openapiPath: "/api.json" - swaggerPath: "/swagger" \ No newline at end of file diff --git a/example/httpserver/swagger-set-template/main.go b/example/httpserver/swagger-set-template/main.go deleted file mode 100644 index d14988b86a7..00000000000 --- a/example/httpserver/swagger-set-template/main.go +++ /dev/null @@ -1,121 +0,0 @@ -package main - -import ( - "context" - "fmt" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" -) - -// HelloReq hello request -type HelloReq struct { - g.Meta `path:"/hello" method:"get" sort:"1"` - Name string `v:"required" dc:"Your name"` -} - -// HelloRes hello response -type HelloRes struct { - Reply string `dc:"Reply content"` -} - -// Hello Controller -type Hello struct{} - -// Say function -func (Hello) Say(ctx context.Context, req *HelloReq) (res *HelloRes, err error) { - g.Log().Debugf(ctx, `receive say: %+v`, req) - res = &HelloRes{ - Reply: fmt.Sprintf(`Hi %s`, req.Name), - } - return -} - -// upload file request -type UploadReq struct { - g.Meta `path:"/upload" method:"POST" tags:"Upload" mime:"multipart/form-data" summary:"上传文件"` - Files []*ghttp.UploadFile `json:"files" type:"file" dc:"选择上传多文件"` - File *ghttp.UploadFile `p:"file" type:"file" dc:"选择上传文件"` - Msg string `dc:"消息"` -} - -// upload file response -type UploadRes struct { - FilesName []string `json:"files_name"` - FileName string `json:"file_name"` - Msg string `json:"msg"` -} - -// upload file -func (Hello) Upload(ctx context.Context, req *UploadReq) (res *UploadRes, err error) { - g.Log().Debugf(ctx, `receive say: %+v`, req) - res = &UploadRes{ - Msg: req.Msg, - } - if req.File != nil { - res.FileName = req.File.Filename - } - if len(req.Files) > 0 { - var filesName []string - for _, file := range req.Files { - filesName = append(filesName, file.Filename) - } - res.FilesName = filesName - } - return -} - -const ( - // MySwaggerUITemplate is the custom Swagger UI template. - MySwaggerUITemplate = ` - - - - - - - SwaggerUI - - - -
- - - - -` - // OpenapiUITemplate is the OpenAPI UI template. - OpenapiUITemplate = ` - - - - - test - - -
- - - -` -) - -func main() { - s := g.Server() - s.Use(ghttp.MiddlewareHandlerResponse) - s.Group("/", func(group *ghttp.RouterGroup) { - group.Bind( - new(Hello), - ) - }) - s.SetSwaggerUITemplate(MySwaggerUITemplate) - // s.SetSwaggerUITemplate(OpenapiUITemplate) // files support - s.Run() -} diff --git a/example/httpserver/swagger/config.yaml b/example/httpserver/swagger/config.yaml deleted file mode 100644 index b15f8d00786..00000000000 --- a/example/httpserver/swagger/config.yaml +++ /dev/null @@ -1,4 +0,0 @@ -server: - address: ":8199" - openapiPath: "/api.json" - swaggerPath: "/swagger" \ No newline at end of file diff --git a/example/httpserver/swagger/main.go b/example/httpserver/swagger/main.go deleted file mode 100644 index 3d934352c86..00000000000 --- a/example/httpserver/swagger/main.go +++ /dev/null @@ -1,58 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - "fmt" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" -) - -// HelloReq hello request -type HelloReq struct { - g.Meta `path:"/hello" method:"get" sort:"1"` - Name string `v:"required" dc:"Your name"` -} - -// HelloRes hello response -type HelloRes struct { - Reply string `dc:"Reply content"` -} - -// Hello Controller -type Hello struct{} - -// Say function -func (Hello) Say(ctx context.Context, req *HelloReq) (res *HelloRes, err error) { - g.Log().Debugf(ctx, `receive say: %+v`, req) - res = &HelloRes{ - Reply: fmt.Sprintf(`Hi %s`, req.Name), - } - return -} - -func main() { - s := g.Server() - s.Use(ghttp.MiddlewareHandlerResponse) - s.Group("/", func(group *ghttp.RouterGroup) { - group.Bind( - new(Hello), - ) - }) - // if api.json requires authentication, add openApiBasicAuth handler - s.BindHookHandler(s.GetOpenApiPath(), ghttp.HookBeforeServe, openApiBasicAuth) - s.Run() -} - -func openApiBasicAuth(r *ghttp.Request) { - if !r.BasicAuth("OpenApiAuthUserName", "OpenApiAuthPass", "Restricted") { - r.ExitAll() - return - } -} diff --git a/example/httpserver/upload-file/main.go b/example/httpserver/upload-file/main.go deleted file mode 100644 index e103a572560..00000000000 --- a/example/httpserver/upload-file/main.go +++ /dev/null @@ -1,44 +0,0 @@ -package main - -import ( - "context" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" -) - -type UploadReq struct { - g.Meta `path:"/upload" method:"POST" tags:"Upload" mime:"multipart/form-data" summary:"上传文件"` - File *ghttp.UploadFile `p:"file" type:"file" dc:"选择上传文件"` - Msg string `dc:"消息"` -} -type UploadRes struct { - FileName string `json:"fileName"` -} - -type cUpload struct{} - -func (u cUpload) Upload(ctx context.Context, req *UploadReq) (*UploadRes, error) { - if req.File != nil { - return &UploadRes{ - FileName: req.File.Filename, - }, nil - } - return nil, nil -} - -func main() { - s := g.Server() - s.Group("/", func(group *ghttp.RouterGroup) { - group.Middleware(ghttp.MiddlewareHandlerResponse) - group.Bind(cUpload{}) - }) - s.SetClientMaxBodySize(600 * 1024 * 1024) // 600M - s.SetPort(8199) - s.SetAccessLogEnabled(true) - s.Run() -} - -// curl --location 'http://127.0.0.1:8199/upload' \ -// --form 'file=@"/D:/下载/goframe-v2.5.pdf"' \ -// --form 'msg="666"' diff --git a/example/metric/basic/main.go b/example/metric/basic/main.go deleted file mode 100644 index dd77a6aa867..00000000000 --- a/example/metric/basic/main.go +++ /dev/null @@ -1,137 +0,0 @@ -// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "go.opentelemetry.io/otel/exporters/prometheus" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/os/gmetric" - - "github.com/gogf/gf/contrib/metric/otelmetric/v2" -) - -var ( - meter = gmetric.GetGlobalProvider().Meter(gmetric.MeterOption{ - Instrument: "github.com/gogf/gf/example/metric/basic", - InstrumentVersion: "v1.0", - }) - counter = meter.MustCounter( - "goframe.metric.demo.counter", - gmetric.MetricOption{ - Help: "This is a simple demo for Counter usage", - Unit: "bytes", - Attributes: gmetric.Attributes{ - gmetric.NewAttribute("const_attr_1", 1), - }, - }, - ) - upDownCounter = meter.MustUpDownCounter( - "goframe.metric.demo.updown_counter", - gmetric.MetricOption{ - Help: "This is a simple demo for UpDownCounter usage", - Unit: "%", - Attributes: gmetric.Attributes{ - gmetric.NewAttribute("const_attr_2", 2), - }, - }, - ) - histogram = meter.MustHistogram( - "goframe.metric.demo.histogram", - gmetric.MetricOption{ - Help: "This is a simple demo for histogram usage", - Unit: "ms", - Attributes: gmetric.Attributes{ - gmetric.NewAttribute("const_attr_3", 3), - }, - Buckets: []float64{0, 10, 20, 50, 100, 500, 1000, 2000, 5000, 10000}, - }, - ) - observableCounter = meter.MustObservableCounter( - "goframe.metric.demo.observable_counter", - gmetric.MetricOption{ - Help: "This is a simple demo for ObservableCounter usage", - Unit: "%", - Attributes: gmetric.Attributes{ - gmetric.NewAttribute("const_attr_4", 4), - }, - }, - ) - observableUpDownCounter = meter.MustObservableUpDownCounter( - "goframe.metric.demo.observable_updown_counter", - gmetric.MetricOption{ - Help: "This is a simple demo for ObservableUpDownCounter usage", - Unit: "%", - Attributes: gmetric.Attributes{ - gmetric.NewAttribute("const_attr_5", 5), - }, - }, - ) - observableGauge = meter.MustObservableGauge( - "goframe.metric.demo.observable_gauge", - gmetric.MetricOption{ - Help: "This is a simple demo for ObservableGauge usage", - Unit: "%", - Attributes: gmetric.Attributes{ - gmetric.NewAttribute("const_attr_6", 6), - }, - }, - ) -) - -func main() { - var ctx = gctx.New() - - // Callback for observable metrics. - meter.MustRegisterCallback(func(ctx context.Context, obs gmetric.Observer) error { - obs.Observe(observableCounter, 10) - obs.Observe(observableUpDownCounter, 20) - obs.Observe(observableGauge, 30) - return nil - }, observableCounter, observableUpDownCounter, observableGauge) - - // Prometheus exporter to export metrics as Prometheus format. - exporter, err := prometheus.New( - prometheus.WithoutCounterSuffixes(), - prometheus.WithoutUnits(), - ) - if err != nil { - g.Log().Fatal(ctx, err) - } - - // OpenTelemetry provider. - provider := otelmetric.MustProvider( - otelmetric.WithReader(exporter), - otelmetric.WithBuiltInMetrics(), - ) - provider.SetAsGlobal() - defer provider.Shutdown(ctx) - - // Counter. - counter.Inc(ctx) - counter.Add(ctx, 10) - - // UpDownCounter. - upDownCounter.Inc(ctx) - upDownCounter.Add(ctx, 10) - upDownCounter.Dec(ctx) - - // Record values for histogram. - histogram.Record(1) - histogram.Record(20) - histogram.Record(30) - histogram.Record(101) - histogram.Record(2000) - histogram.Record(9000) - histogram.Record(20000) - - // HTTP Server for metrics exporting. - otelmetric.StartPrometheusMetricsServer(8000, "/metrics") -} diff --git a/example/metric/callback/main.go b/example/metric/callback/main.go deleted file mode 100644 index f64931f04f9..00000000000 --- a/example/metric/callback/main.go +++ /dev/null @@ -1,79 +0,0 @@ -// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "go.opentelemetry.io/otel/exporters/prometheus" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/os/gmetric" - - "github.com/gogf/gf/contrib/metric/otelmetric/v2" -) - -var ( - meter = gmetric.GetGlobalProvider().Meter(gmetric.MeterOption{ - Instrument: "github.com/gogf/gf/example/metric/basic", - InstrumentVersion: "v1.0", - }) - counter = meter.MustCounter( - "goframe.metric.demo.counter", - gmetric.MetricOption{ - Help: "This is a simple demo for Counter usage", - Unit: "%", - Attributes: gmetric.Attributes{ - gmetric.NewAttribute("const_attr_1", 1), - }, - }, - ) - - _ = meter.MustObservableCounter( - "goframe.metric.demo.observable_counter", - gmetric.MetricOption{ - Help: "This is a simple demo for ObservableCounter usage", - Unit: "%", - Attributes: gmetric.Attributes{ - gmetric.NewAttribute("const_attr_3", 3), - }, - Callback: func(ctx context.Context, obs gmetric.MetricObserver) error { - obs.Observe(10) - return nil - }, - }, - ) -) - -func main() { - var ctx = gctx.New() - - // Prometheus exporter to export metrics as Prometheus format. - exporter, err := prometheus.New( - prometheus.WithoutCounterSuffixes(), - prometheus.WithoutUnits(), - ) - if err != nil { - g.Log().Fatal(ctx, err) - } - - // OpenTelemetry provider. - provider := otelmetric.MustProvider( - otelmetric.WithReader(exporter), - otelmetric.WithBuiltInMetrics(), - ) - provider.SetAsGlobal() - defer provider.Shutdown(ctx) - - // Add value for counter. - counter.Inc(ctx) - counter.Add(ctx, 10) - - // HTTP Server for metrics exporting. - otelmetric.StartPrometheusMetricsServer(8000, "/metrics") -} diff --git a/example/metric/dynamic_attributes/main.go b/example/metric/dynamic_attributes/main.go deleted file mode 100644 index 6c0661e380b..00000000000 --- a/example/metric/dynamic_attributes/main.go +++ /dev/null @@ -1,88 +0,0 @@ -// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "go.opentelemetry.io/otel/exporters/prometheus" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/os/gmetric" - - "github.com/gogf/gf/contrib/metric/otelmetric/v2" -) - -var ( - meter = gmetric.GetGlobalProvider().Meter(gmetric.MeterOption{ - Instrument: "github.com/gogf/gf/example/metric/basic", - InstrumentVersion: "v1.0", - }) - counter = meter.MustCounter( - "goframe.metric.demo.counter", - gmetric.MetricOption{ - Help: "This is a simple demo for Counter usage", - Unit: "bytes", - Attributes: gmetric.Attributes{ - gmetric.NewAttribute("const_attr_1", 1), - }, - }, - ) - observableCounter = meter.MustObservableCounter( - "goframe.metric.demo.observable_counter", - gmetric.MetricOption{ - Help: "This is a simple demo for ObservableCounter usage", - Unit: "%", - Attributes: gmetric.Attributes{ - gmetric.NewAttribute("const_attr_4", 4), - }, - }, - ) -) - -func main() { - var ctx = gctx.New() - - // Callback for observable metrics. - meter.MustRegisterCallback(func(ctx context.Context, obs gmetric.Observer) error { - obs.Observe(observableCounter, 10, gmetric.Option{ - Attributes: gmetric.Attributes{ - gmetric.NewAttribute("dynamic_attr_1", 1), - }, - }) - return nil - }, observableCounter) - - // Prometheus exporter to export metrics as Prometheus format. - exporter, err := prometheus.New( - prometheus.WithoutCounterSuffixes(), - prometheus.WithoutUnits(), - ) - if err != nil { - g.Log().Fatal(ctx, err) - } - - // OpenTelemetry provider. - provider := otelmetric.MustProvider( - otelmetric.WithReader(exporter), - otelmetric.WithBuiltInMetrics(), - ) - provider.SetAsGlobal() - defer provider.Shutdown(ctx) - - // Counter. - counter.Inc(ctx) - counter.Add(ctx, 10, gmetric.Option{ - Attributes: gmetric.Attributes{ - gmetric.NewAttribute("dynamic_attr_2", 2), - }, - }) - - // HTTP Server for metrics exporting. - otelmetric.StartPrometheusMetricsServer(8000, "/metrics") -} diff --git a/example/metric/global_attributes/main.go b/example/metric/global_attributes/main.go deleted file mode 100644 index f57de3396fb..00000000000 --- a/example/metric/global_attributes/main.go +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "go.opentelemetry.io/otel/exporters/prometheus" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/os/gmetric" - - "github.com/gogf/gf/contrib/metric/otelmetric/v2" -) - -const ( - instrument = "github.com/gogf/gf/example/metric/basic" - instrumentVersion = "v1.0" -) - -var ( - meter = gmetric.GetGlobalProvider().Meter(gmetric.MeterOption{ - Instrument: instrument, - InstrumentVersion: instrumentVersion, - }) - counter = meter.MustCounter( - "goframe.metric.demo.counter", - gmetric.MetricOption{ - Help: "This is a simple demo for Counter usage", - Unit: "bytes", - Attributes: gmetric.Attributes{ - gmetric.NewAttribute("const_attr_1", 1), - }, - }, - ) - observableCounter = meter.MustObservableCounter( - "goframe.metric.demo.observable_counter", - gmetric.MetricOption{ - Help: "This is a simple demo for ObservableCounter usage", - Unit: "%", - Attributes: gmetric.Attributes{ - gmetric.NewAttribute("const_attr_2", 2), - }, - }, - ) -) - -func main() { - var ctx = gctx.New() - - gmetric.SetGlobalAttributes(gmetric.Attributes{ - gmetric.NewAttribute("global_attr_1", 1), - }, gmetric.SetGlobalAttributesOption{ - Instrument: instrument, - InstrumentVersion: instrumentVersion, - InstrumentPattern: "", - }) - - // Callback for observable metrics. - meter.MustRegisterCallback(func(ctx context.Context, obs gmetric.Observer) error { - obs.Observe(observableCounter, 10) - return nil - }, observableCounter) - - // Prometheus exporter to export metrics as Prometheus format. - exporter, err := prometheus.New( - prometheus.WithoutCounterSuffixes(), - prometheus.WithoutUnits(), - ) - if err != nil { - g.Log().Fatal(ctx, err) - } - - // OpenTelemetry provider. - provider := otelmetric.MustProvider( - otelmetric.WithReader(exporter), - otelmetric.WithBuiltInMetrics(), - ) - provider.SetAsGlobal() - defer provider.Shutdown(ctx) - - // Counter. - counter.Inc(ctx) - counter.Add(ctx, 10) - - // HTTP Server for metrics exporting. - otelmetric.StartPrometheusMetricsServer(8000, "/metrics") -} diff --git a/example/metric/http_client/main.go b/example/metric/http_client/main.go deleted file mode 100644 index 4c61c640e3f..00000000000 --- a/example/metric/http_client/main.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "go.opentelemetry.io/otel/exporters/prometheus" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/metric/otelmetric/v2" -) - -func main() { - var ctx = gctx.New() - - // Prometheus exporter to export metrics as Prometheus format. - exporter, err := prometheus.New( - prometheus.WithoutCounterSuffixes(), - prometheus.WithoutUnits(), - ) - if err != nil { - g.Log().Fatal(ctx, err) - } - - // OpenTelemetry provider. - provider := otelmetric.MustProvider( - otelmetric.WithReader(exporter), - otelmetric.WithBuiltInMetrics(), - ) - provider.SetAsGlobal() - defer provider.Shutdown(ctx) - - // A simple http client request for demonstration purpose only. - url := `https://github.com/gogf/gf` - content := g.Client().GetContent(ctx, url) - g.Log().Infof(ctx, `content length from "%s": %d`, url, len(content)) - - // A simple http server for metrics export. - otelmetric.StartPrometheusMetricsServer(8000, "/metrics") -} diff --git a/example/metric/http_server/main.go b/example/metric/http_server/main.go deleted file mode 100644 index be3879506c1..00000000000 --- a/example/metric/http_server/main.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "time" - - "go.opentelemetry.io/otel/exporters/prometheus" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/metric/otelmetric/v2" -) - -func main() { - var ctx = gctx.New() - - // Prometheus exporter to export metrics as Prometheus format. - exporter, err := prometheus.New( - prometheus.WithoutCounterSuffixes(), - prometheus.WithoutUnits(), - ) - if err != nil { - g.Log().Fatal(ctx, err) - } - - // OpenTelemetry provider. - provider := otelmetric.MustProvider( - otelmetric.WithReader(exporter), - otelmetric.WithBuiltInMetrics(), - ) - provider.SetAsGlobal() - defer provider.Shutdown(ctx) - - s := g.Server() - s.BindHandler("/", func(r *ghttp.Request) { - r.Response.Write("ok") - }) - s.BindHandler("/error", func(r *ghttp.Request) { - panic("error") - }) - s.BindHandler("/sleep", func(r *ghttp.Request) { - time.Sleep(time.Second * 5) - r.Response.Write("ok") - }) - s.BindHandler("/metrics", otelmetric.PrometheusHandler) - s.SetPort(8000) - s.Run() -} diff --git a/example/metric/meter_attributes/main.go b/example/metric/meter_attributes/main.go deleted file mode 100644 index ad029d1f8d3..00000000000 --- a/example/metric/meter_attributes/main.go +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "go.opentelemetry.io/otel/exporters/prometheus" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/os/gmetric" - - "github.com/gogf/gf/contrib/metric/otelmetric/v2" -) - -const ( - instrument = "github.com/gogf/gf/example/metric/basic" - instrumentVersion = "v1.0" -) - -var ( - meter = gmetric.GetGlobalProvider().Meter(gmetric.MeterOption{ - Instrument: instrument, - InstrumentVersion: instrumentVersion, - Attributes: gmetric.Attributes{ - gmetric.NewAttribute("meter_label_1", 1), - gmetric.NewAttribute("meter_label_2", 2), - }, - }) - counter = meter.MustCounter( - "goframe.metric.demo.counter", - gmetric.MetricOption{ - Help: "This is a simple demo for Counter usage", - Unit: "bytes", - Attributes: gmetric.Attributes{ - gmetric.NewAttribute("const_attr_1", 1), - }, - }, - ) - observableCounter = meter.MustObservableCounter( - "goframe.metric.demo.observable_counter", - gmetric.MetricOption{ - Help: "This is a simple demo for ObservableCounter usage", - Unit: "%", - Attributes: gmetric.Attributes{ - gmetric.NewAttribute("const_attr_2", 2), - }, - }, - ) -) - -func main() { - var ctx = gctx.New() - - // Callback for observable metrics. - meter.MustRegisterCallback(func(ctx context.Context, obs gmetric.Observer) error { - obs.Observe(observableCounter, 10) - return nil - }, observableCounter) - - // Prometheus exporter to export metrics as Prometheus format. - exporter, err := prometheus.New( - prometheus.WithoutCounterSuffixes(), - prometheus.WithoutUnits(), - ) - if err != nil { - g.Log().Fatal(ctx, err) - } - - // OpenTelemetry provider. - provider := otelmetric.MustProvider( - otelmetric.WithReader(exporter), - otelmetric.WithBuiltInMetrics(), - ) - provider.SetAsGlobal() - defer provider.Shutdown(ctx) - - // Counter. - counter.Inc(ctx) - counter.Add(ctx, 10) - - // HTTP Server for metrics exporting. - otelmetric.StartPrometheusMetricsServer(8000, "/metrics") -} diff --git a/example/metric/prometheus/prometheus.go b/example/metric/prometheus/prometheus.go deleted file mode 100644 index 6eff369c5cb..00000000000 --- a/example/metric/prometheus/prometheus.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright GoFrame gf Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/prometheus/client_golang/prometheus" - "github.com/prometheus/client_golang/prometheus/promauto" - "github.com/prometheus/client_golang/prometheus/promhttp" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/util/grand" -) - -// Demo metric type Counter -var metricCounter = promauto.NewCounter( - prometheus.CounterOpts{ - Name: "demo_counter", - Help: "A demo counter.", - }, -) - -// Demo metric type Gauge. -var metricGauge = promauto.NewGauge( - prometheus.GaugeOpts{ - Name: "demo_gauge", - Help: "A demo gauge.", - }, -) - -func main() { - // Create prometheus metric registry. - registry := prometheus.NewRegistry() - registry.MustRegister( - metricCounter, - metricGauge, - ) - - // Start metric http server. - s := g.Server() - // Fake metric values. - // http://127.0.0.1:8000/ - s.BindHandler("/", func(r *ghttp.Request) { - metricCounter.Add(1) - metricGauge.Set(float64(grand.N(1, 100))) - r.Response.Write("fake ok") - }) - // Export metric values. - // You can view http://127.0.0.1:8000/metrics to see all metric values. - s.BindHandler("/metrics", ghttp.WrapH(promhttp.Handler())) - s.SetPort(8000) - s.Run() -} diff --git a/example/nosql/redis/adapter/main.go b/example/nosql/redis/adapter/main.go deleted file mode 100644 index 490317efc76..00000000000 --- a/example/nosql/redis/adapter/main.go +++ /dev/null @@ -1,52 +0,0 @@ -package main - -import ( - "context" - "fmt" - - "github.com/gogf/gf/v2/container/gvar" - "github.com/gogf/gf/v2/database/gredis" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/nosql/redis/v2" -) - -var ( - ctx = gctx.New() - group = "cache" - config = gredis.Config{ - Address: "127.0.0.1:6379", - Db: 1, - } -) - -// MyRedis description -type MyRedis struct { - *redis.Redis -} - -// Do implements and overwrites the underlying function Do from Adapter. -func (r *MyRedis) Do(ctx context.Context, command string, args ...interface{}) (*gvar.Var, error) { - fmt.Println("MyRedis Do:", command, args) - return r.Redis.Do(ctx, command, args...) -} - -func main() { - gredis.RegisterAdapterFunc(func(config *gredis.Config) gredis.Adapter { - r := &MyRedis{redis.New(config)} - r.AdapterOperation = r // This is necessary. - return r - }) - gredis.SetConfig(&config, group) - - _, err := g.Redis(group).Set(ctx, "key", "value") - if err != nil { - g.Log().Fatal(ctx, err) - } - value, err := g.Redis(group).Get(ctx, "key") - if err != nil { - g.Log().Fatal(ctx, err) - } - fmt.Println(value.String()) -} diff --git a/example/nosql/redis/configuration/basic/config.yaml b/example/nosql/redis/configuration/basic/config.yaml deleted file mode 100644 index 5c74fba3b86..00000000000 --- a/example/nosql/redis/configuration/basic/config.yaml +++ /dev/null @@ -1,4 +0,0 @@ -redis: - default: - address: 127.0.0.1:6379 - db: 1 \ No newline at end of file diff --git a/example/nosql/redis/configuration/basic/main.go b/example/nosql/redis/configuration/basic/main.go deleted file mode 100644 index 360a7b276fd..00000000000 --- a/example/nosql/redis/configuration/basic/main.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "fmt" - - _ "github.com/gogf/gf/contrib/nosql/redis/v2" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" -) - -func main() { - var ctx = gctx.New() - _, err := g.Redis().Set(ctx, "key", "value") - if err != nil { - g.Log().Fatal(ctx, err) - } - value, err := g.Redis().Get(ctx, "key") - if err != nil { - g.Log().Fatal(ctx, err) - } - fmt.Println(value.String()) -} diff --git a/example/nosql/redis/configuration/senior/main.go b/example/nosql/redis/configuration/senior/main.go deleted file mode 100644 index 35c27816eaa..00000000000 --- a/example/nosql/redis/configuration/senior/main.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "fmt" - - _ "github.com/gogf/gf/contrib/nosql/redis/v2" - - "github.com/gogf/gf/v2/database/gredis" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" -) - -var ( - config = gredis.Config{ - Address: "127.0.0.1:6379", - Db: 1, - } - group = "cache" - ctx = gctx.New() -) - -func main() { - gredis.SetConfig(&config, group) - - _, err := g.Redis(group).Set(ctx, "key", "value") - if err != nil { - g.Log().Fatal(ctx, err) - } - value, err := g.Redis(group).Get(ctx, "key") - if err != nil { - g.Log().Fatal(ctx, err) - } - fmt.Println(value.String()) -} diff --git a/example/nosql/redis/expire/config.yaml b/example/nosql/redis/expire/config.yaml deleted file mode 100644 index 5c74fba3b86..00000000000 --- a/example/nosql/redis/expire/config.yaml +++ /dev/null @@ -1,4 +0,0 @@ -redis: - default: - address: 127.0.0.1:6379 - db: 1 \ No newline at end of file diff --git a/example/nosql/redis/expire/main.go b/example/nosql/redis/expire/main.go deleted file mode 100644 index c3b71fef71e..00000000000 --- a/example/nosql/redis/expire/main.go +++ /dev/null @@ -1,40 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "fmt" - "time" - - _ "github.com/gogf/gf/contrib/nosql/redis/v2" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" -) - -func main() { - var ctx = gctx.New() - err := g.Redis().SetEX(ctx, "key", "value", 1) - if err != nil { - g.Log().Fatal(ctx, err) - } - value, err := g.Redis().Get(ctx, "key") - if err != nil { - g.Log().Fatal(ctx, err) - } - fmt.Println(value.IsNil()) - fmt.Println(value.String()) - - time.Sleep(time.Second) - - value, err = g.Redis().Get(ctx, "key") - if err != nil { - g.Log().Fatal(ctx, err) - } - fmt.Println(value.IsNil()) - fmt.Println(value.Val()) -} diff --git a/example/nosql/redis/hmset/config.yaml b/example/nosql/redis/hmset/config.yaml deleted file mode 100644 index 5c74fba3b86..00000000000 --- a/example/nosql/redis/hmset/config.yaml +++ /dev/null @@ -1,4 +0,0 @@ -redis: - default: - address: 127.0.0.1:6379 - db: 1 \ No newline at end of file diff --git a/example/nosql/redis/hmset/main.go b/example/nosql/redis/hmset/main.go deleted file mode 100644 index c417e58d414..00000000000 --- a/example/nosql/redis/hmset/main.go +++ /dev/null @@ -1,36 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "fmt" - - _ "github.com/gogf/gf/contrib/nosql/redis/v2" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" -) - -func main() { - var ( - ctx = gctx.New() - channel = "channel" - ) - conn, _ := g.Redis().Conn(ctx) - defer conn.Close(ctx) - _, err := conn.Subscribe(ctx, channel) - if err != nil { - g.Log().Fatal(ctx, err) - } - for { - msg, err := conn.ReceiveMessage(ctx) - if err != nil { - g.Log().Fatal(ctx, err) - } - fmt.Println(msg.Payload) - } -} diff --git a/example/nosql/redis/hset/config.yaml b/example/nosql/redis/hset/config.yaml deleted file mode 100644 index 5c74fba3b86..00000000000 --- a/example/nosql/redis/hset/config.yaml +++ /dev/null @@ -1,4 +0,0 @@ -redis: - default: - address: 127.0.0.1:6379 - db: 1 \ No newline at end of file diff --git a/example/nosql/redis/hset/main.go b/example/nosql/redis/hset/main.go deleted file mode 100644 index fc7889b4562..00000000000 --- a/example/nosql/redis/hset/main.go +++ /dev/null @@ -1,50 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "fmt" - - _ "github.com/gogf/gf/contrib/nosql/redis/v2" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" -) - -func main() { - var ( - ctx = gctx.New() - key = "key" - ) - _, err := g.Redis().HSet(ctx, key, g.Map{ - "id": 1, - "name": "john", - "score": 100, - }) - if err != nil { - g.Log().Fatal(ctx, err) - } - - // retrieve hash map - value, err := g.Redis().HGetAll(ctx, key) - if err != nil { - g.Log().Fatal(ctx, err) - } - fmt.Println(value.Map()) - - // scan to struct - type User struct { - Id uint64 - Name string - Score float64 - } - var user *User - if err = value.Scan(&user); err != nil { - g.Log().Fatal(ctx, err) - } - g.Dump(user) -} diff --git a/example/nosql/redis/key-value/config.yaml b/example/nosql/redis/key-value/config.yaml deleted file mode 100644 index 5c74fba3b86..00000000000 --- a/example/nosql/redis/key-value/config.yaml +++ /dev/null @@ -1,4 +0,0 @@ -redis: - default: - address: 127.0.0.1:6379 - db: 1 \ No newline at end of file diff --git a/example/nosql/redis/key-value/main.go b/example/nosql/redis/key-value/main.go deleted file mode 100644 index 360a7b276fd..00000000000 --- a/example/nosql/redis/key-value/main.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "fmt" - - _ "github.com/gogf/gf/contrib/nosql/redis/v2" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" -) - -func main() { - var ctx = gctx.New() - _, err := g.Redis().Set(ctx, "key", "value") - if err != nil { - g.Log().Fatal(ctx, err) - } - value, err := g.Redis().Get(ctx, "key") - if err != nil { - g.Log().Fatal(ctx, err) - } - fmt.Println(value.String()) -} diff --git a/example/os/cron/linux-crontab/main.go b/example/os/cron/linux-crontab/main.go deleted file mode 100644 index 89260c19494..00000000000 --- a/example/os/cron/linux-crontab/main.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - "fmt" - - "github.com/gogf/gf/v2/os/gcron" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/os/gtime" -) - -func main() { - fmt.Println("start:", gtime.Now()) - var ( - err error - pattern1 = "# * * * * *" - pattern2 = "# */2 * * * *" - ) - _, err = gcron.Add(gctx.New(), pattern1, func(ctx context.Context) { - fmt.Println(pattern1, gtime.Now()) - }) - if err != nil { - panic(err) - } - _, err = gcron.Add(gctx.New(), pattern2, func(ctx context.Context) { - fmt.Println(pattern2, gtime.Now()) - }) - if err != nil { - panic(err) - } - - select {} -} diff --git a/example/os/log/ctx-keys/config.yaml b/example/os/log/ctx-keys/config.yaml deleted file mode 100644 index 80f8fc3024f..00000000000 --- a/example/os/log/ctx-keys/config.yaml +++ /dev/null @@ -1,4 +0,0 @@ -logger: - Level: "all" - Stdout: true - CtxKeys: ["RequestId", "UserId"] \ No newline at end of file diff --git a/example/os/log/ctx-keys/main.go b/example/os/log/ctx-keys/main.go deleted file mode 100644 index fcb4875a8fe..00000000000 --- a/example/os/log/ctx-keys/main.go +++ /dev/null @@ -1,20 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "github.com/gogf/gf/v2/frame/g" -) - -func main() { - var ctx = context.Background() - ctx = context.WithValue(ctx, "RequestId", "123456789") - ctx = context.WithValue(ctx, "UserId", "10000") - g.Log().Error(ctx, "runtime error") -} diff --git a/example/os/log/rotate/config.toml b/example/os/log/rotate/config.toml deleted file mode 100644 index 623e47935c5..00000000000 --- a/example/os/log/rotate/config.toml +++ /dev/null @@ -1,8 +0,0 @@ -[logger] -path = "./log" -file = "{Y-m-d-H-i}.log" -level = "all" -stdout = true -rotateExpire = "1m" -rotateBackupLimit = 4 -rotateCheckInterval = "5s" diff --git a/example/os/log/rotate/main.go b/example/os/log/rotate/main.go deleted file mode 100644 index 72e9a8cc1b2..00000000000 --- a/example/os/log/rotate/main.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - "time" - - "github.com/gogf/gf/v2/frame/g" -) - -func main() { - ctx := context.Background() - mylog := g.Log() - for { - mylog.Debug(ctx, "debug") - time.Sleep(time.Second) - mylog.Info(ctx, "info") - time.Sleep(time.Second) - mylog.Warning(ctx, "warning") - time.Sleep(time.Second) - mylog.Error(ctx, "error") - time.Sleep(time.Second) - } -} diff --git a/example/pack/hack/config.yaml b/example/pack/hack/config.yaml deleted file mode 100644 index 9dec998f1b7..00000000000 --- a/example/pack/hack/config.yaml +++ /dev/null @@ -1,9 +0,0 @@ -gfcli: - build: - name: "pack" - arch: "amd64" - system: "darwin" - packSrc: "resource/public,manifest/i18n" - packDst: "packed/build_packed_data.go" - mod: "" - cgo: 0 \ No newline at end of file diff --git a/example/pack/main.go b/example/pack/main.go deleted file mode 100644 index bde6d1a09ec..00000000000 --- a/example/pack/main.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - _ "github.com/gogf/gf/example/pack/packed" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/i18n/gi18n" - "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/os/gres" -) - -func main() { - gres.Dump() - - s := g.Server() - s.SetPort(8199) - s.SetServerRoot("resource/public") - s.BindHandler("/i18n", func(r *ghttp.Request) { - var ( - lang = r.Get("lang", "zh-CN").String() - ctx = gi18n.WithLanguage(r.Context(), lang) - content string - ) - content = g.I18n().T(ctx, `{#hello} {#world}!`) - r.Response.Write(content) - }) - s.SetErrorLogEnabled(true) - s.SetAccessLogEnabled(true) - s.Run() - // gf pack resource packed/packed.go - // http://127.0.0.1:8199/index.html -} diff --git a/example/pack/manifest/i18n/ja.yaml b/example/pack/manifest/i18n/ja.yaml deleted file mode 100644 index a8abe1be114..00000000000 --- a/example/pack/manifest/i18n/ja.yaml +++ /dev/null @@ -1,2 +0,0 @@ -hello: "こんにちは" -world: "世界" \ No newline at end of file diff --git a/example/pack/manifest/i18n/ru.yaml b/example/pack/manifest/i18n/ru.yaml deleted file mode 100644 index 182ec5eecfd..00000000000 --- a/example/pack/manifest/i18n/ru.yaml +++ /dev/null @@ -1,2 +0,0 @@ -hello: "Привет" -world: "мир" \ No newline at end of file diff --git a/example/pack/manifest/i18n/zh-CN.yaml b/example/pack/manifest/i18n/zh-CN.yaml deleted file mode 100644 index 38f96cc1f6f..00000000000 --- a/example/pack/manifest/i18n/zh-CN.yaml +++ /dev/null @@ -1,2 +0,0 @@ -hello: "你好" -world: "世界" \ No newline at end of file diff --git a/example/pack/packed/packed.go b/example/pack/packed/packed.go deleted file mode 100644 index 4a9a958566b..00000000000 --- a/example/pack/packed/packed.go +++ /dev/null @@ -1,7 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package packed diff --git a/example/pack/resource/public/index.html b/example/pack/resource/public/index.html deleted file mode 100644 index 6d19072283a..00000000000 --- a/example/pack/resource/public/index.html +++ /dev/null @@ -1,8 +0,0 @@ - - - Hello World - - -

Hello World!

- - \ No newline at end of file diff --git a/example/registry/consul/grpc/client/client.go b/example/registry/consul/grpc/client/client.go deleted file mode 100644 index 9799c3d62e0..00000000000 --- a/example/registry/consul/grpc/client/client.go +++ /dev/null @@ -1,39 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/registry/consul/v2" - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/registry/consul/grpc/protobuf" -) - -func main() { - registry, err := consul.New(consul.WithAddress("127.0.0.1:8500")) - if err != nil { - g.Log().Fatal(context.Background(), err) - } - grpcx.Resolver.Register(registry) - - var ( - ctx = gctx.New() - conn = grpcx.Client.MustNewGrpcClientConn("demo") - client = protobuf.NewGreeterClient(conn) - ) - res, err := client.SayHello(ctx, &protobuf.HelloRequest{Name: "World"}) - if err != nil { - g.Log().Error(ctx, err) - return - } - g.Log().Debug(ctx, "Response:", res.Message) -} diff --git a/example/registry/consul/grpc/controller/helloworld.go b/example/registry/consul/grpc/controller/helloworld.go deleted file mode 100644 index b6f849cd79b..00000000000 --- a/example/registry/consul/grpc/controller/helloworld.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package controller - -import ( - "context" - - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/registry/consul/grpc/protobuf" -) - -type Controller struct { - protobuf.UnimplementedGreeterServer -} - -func Register(s *grpcx.GrpcServer) { - protobuf.RegisterGreeterServer(s.Server, &Controller{}) -} - -// SayHello implements helloworld.GreeterServer -func (s *Controller) SayHello(ctx context.Context, in *protobuf.HelloRequest) (*protobuf.HelloReply, error) { - return &protobuf.HelloReply{Message: "Hello " + in.GetName()}, nil -} diff --git a/example/registry/consul/grpc/protobuf/helloworld.pb.go b/example/registry/consul/grpc/protobuf/helloworld.pb.go deleted file mode 100644 index 8af3b213b5f..00000000000 --- a/example/registry/consul/grpc/protobuf/helloworld.pb.go +++ /dev/null @@ -1,217 +0,0 @@ -// protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. *.proto - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 -// source: helloworld.proto - -package protobuf - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// The request message containing the user's name. -type HelloRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *HelloRequest) Reset() { - *x = HelloRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_helloworld_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloRequest) ProtoMessage() {} - -func (x *HelloRequest) ProtoReflect() protoreflect.Message { - mi := &file_helloworld_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead. -func (*HelloRequest) Descriptor() ([]byte, []int) { - return file_helloworld_proto_rawDescGZIP(), []int{0} -} - -func (x *HelloRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// The response message containing the greetings -type HelloReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *HelloReply) Reset() { - *x = HelloReply{} - if protoimpl.UnsafeEnabled { - mi := &file_helloworld_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloReply) ProtoMessage() {} - -func (x *HelloReply) ProtoReflect() protoreflect.Message { - mi := &file_helloworld_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead. -func (*HelloReply) Descriptor() ([]byte, []int) { - return file_helloworld_proto_rawDescGZIP(), []int{1} -} - -func (x *HelloReply) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -var File_helloworld_proto protoreflect.FileDescriptor - -var file_helloworld_proto_rawDesc = []byte{ - 0x0a, 0x10, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, 0x22, 0x0a, 0x0c, - 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x22, 0x26, 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, - 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x45, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, - 0x74, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, - 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, - 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, - 0x67, 0x66, 0x2f, 0x67, 0x66, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_helloworld_proto_rawDescOnce sync.Once - file_helloworld_proto_rawDescData = file_helloworld_proto_rawDesc -) - -func file_helloworld_proto_rawDescGZIP() []byte { - file_helloworld_proto_rawDescOnce.Do(func() { - file_helloworld_proto_rawDescData = protoimpl.X.CompressGZIP(file_helloworld_proto_rawDescData) - }) - return file_helloworld_proto_rawDescData -} - -var file_helloworld_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_helloworld_proto_goTypes = []interface{}{ - (*HelloRequest)(nil), // 0: protobuf.HelloRequest - (*HelloReply)(nil), // 1: protobuf.HelloReply -} -var file_helloworld_proto_depIdxs = []int32{ - 0, // 0: protobuf.Greeter.SayHello:input_type -> protobuf.HelloRequest - 1, // 1: protobuf.Greeter.SayHello:output_type -> protobuf.HelloReply - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_helloworld_proto_init() } -func file_helloworld_proto_init() { - if File_helloworld_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_helloworld_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_helloworld_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_helloworld_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_helloworld_proto_goTypes, - DependencyIndexes: file_helloworld_proto_depIdxs, - MessageInfos: file_helloworld_proto_msgTypes, - }.Build() - File_helloworld_proto = out.File - file_helloworld_proto_rawDesc = nil - file_helloworld_proto_goTypes = nil - file_helloworld_proto_depIdxs = nil -} diff --git a/example/registry/consul/grpc/protobuf/helloworld.proto b/example/registry/consul/grpc/protobuf/helloworld.proto deleted file mode 100644 index 9f4f4864fc8..00000000000 --- a/example/registry/consul/grpc/protobuf/helloworld.proto +++ /dev/null @@ -1,24 +0,0 @@ -// protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. *.proto - -syntax = "proto3"; - -package protobuf; - -option go_package = "github.com/gogf/gf/grpc/example/helloworld/protobuf"; - - -// The greeting service definition. -service Greeter { - // Sends a greeting - rpc SayHello (HelloRequest) returns (HelloReply) {} -} - -// The request message containing the user's name. -message HelloRequest { - string name = 1; -} - -// The response message containing the greetings -message HelloReply { - string message = 1; -} diff --git a/example/registry/consul/grpc/protobuf/helloworld_grpc.pb.go b/example/registry/consul/grpc/protobuf/helloworld_grpc.pb.go deleted file mode 100644 index af29539f4ee..00000000000 --- a/example/registry/consul/grpc/protobuf/helloworld_grpc.pb.go +++ /dev/null @@ -1,107 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.12 -// source: helloworld.proto - -package protobuf - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -// GreeterClient is the client API for Greeter service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type GreeterClient interface { - // Sends a greeting - SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) -} - -type greeterClient struct { - cc grpc.ClientConnInterface -} - -func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { - return &greeterClient{cc} -} - -func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { - out := new(HelloReply) - err := c.cc.Invoke(ctx, "/protobuf.Greeter/SayHello", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// GreeterServer is the server API for Greeter service. -// All implementations must embed UnimplementedGreeterServer -// for forward compatibility -type GreeterServer interface { - // Sends a greeting - SayHello(context.Context, *HelloRequest) (*HelloReply, error) - mustEmbedUnimplementedGreeterServer() -} - -// UnimplementedGreeterServer must be embedded to have forward compatible implementations. -type UnimplementedGreeterServer struct { -} - -func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") -} -func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {} - -// UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to GreeterServer will -// result in compilation errors. -type UnsafeGreeterServer interface { - mustEmbedUnimplementedGreeterServer() -} - -func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) { - s.RegisterService(&Greeter_ServiceDesc, srv) -} - -func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HelloRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GreeterServer).SayHello(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/protobuf.Greeter/SayHello", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Greeter_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "protobuf.Greeter", - HandlerType: (*GreeterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _Greeter_SayHello_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "helloworld.proto", -} diff --git a/example/registry/consul/grpc/server/config.yaml b/example/registry/consul/grpc/server/config.yaml deleted file mode 100644 index 071b62623ed..00000000000 --- a/example/registry/consul/grpc/server/config.yaml +++ /dev/null @@ -1,8 +0,0 @@ -grpc: - name: "demo" - logPath: "./log" - logStdout: true - errorLogEnabled: true - accessLogEnabled: true - errorStack: true - diff --git a/example/registry/consul/grpc/server/server.go b/example/registry/consul/grpc/server/server.go deleted file mode 100644 index ef26a750a7a..00000000000 --- a/example/registry/consul/grpc/server/server.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "github.com/gogf/gf/v2/frame/g" - - "github.com/gogf/gf/contrib/registry/consul/v2" - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/registry/consul/grpc/controller" -) - -func main() { - registry, err := consul.New(consul.WithAddress("127.0.0.1:8500")) - if err != nil { - g.Log().Fatal(context.Background(), err) - } - grpcx.Resolver.Register(registry) - - s := grpcx.Server.New() - controller.Register(s) - s.Run() -} diff --git a/example/registry/consul/http/client/client.go b/example/registry/consul/http/client/client.go deleted file mode 100644 index 9a948bc03f9..00000000000 --- a/example/registry/consul/http/client/client.go +++ /dev/null @@ -1,29 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gsvc" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/registry/consul/v2" -) - -func main() { - registry, err := consul.New(consul.WithAddress("127.0.0.1:8500")) - if err != nil { - g.Log().Fatal(context.Background(), err) - } - gsvc.SetRegistry(registry) - - ctx := gctx.New() - res := g.Client().GetContent(ctx, `http://hello.svc/`) - g.Log().Info(ctx, res) -} diff --git a/example/registry/consul/http/server/server.go b/example/registry/consul/http/server/server.go deleted file mode 100644 index badc5ce64e1..00000000000 --- a/example/registry/consul/http/server/server.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/net/gsvc" - - "github.com/gogf/gf/contrib/registry/consul/v2" -) - -func main() { - registry, err := consul.New(consul.WithAddress("127.0.0.1:8500")) - if err != nil { - g.Log().Fatal(context.Background(), err) - } - gsvc.SetRegistry(registry) - - s := g.Server(`hello.svc`) - s.BindHandler("/", func(r *ghttp.Request) { - g.Log().Info(r.Context(), `request received`) - r.Response.Write(`Hello world`) - }) - s.Run() -} diff --git a/example/registry/etcd/grpc/client/client.go b/example/registry/etcd/grpc/client/client.go deleted file mode 100644 index 3d8a3077f9a..00000000000 --- a/example/registry/etcd/grpc/client/client.go +++ /dev/null @@ -1,44 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - "time" - - "github.com/gogf/gf/v2/frame/g" - - "github.com/gogf/gf/contrib/registry/etcd/v2" - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/registry/etcd/grpc/protobuf" -) - -func main() { - grpcx.Resolver.Register(etcd.New("127.0.0.1:2379")) - - var ( - conn = grpcx.Client.MustNewGrpcClientConn("demo") - client = protobuf.NewGreeterClient(conn) - ) - - for { - func() { - ctx, cancel := context.WithTimeout(context.Background(), time.Second*3) - defer cancel() - res, err := client.SayHello(ctx, &protobuf.HelloRequest{Name: "World"}) - if err != nil { - g.Log().Errorf(ctx, `%+v`, err) - } else { - g.Log().Debug(ctx, "Response:", res.Message) - } - }() - - time.Sleep(time.Second) - } - -} diff --git a/example/registry/etcd/grpc/controller/helloworld.go b/example/registry/etcd/grpc/controller/helloworld.go deleted file mode 100644 index c112a004e1f..00000000000 --- a/example/registry/etcd/grpc/controller/helloworld.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package controller - -import ( - "context" - - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/registry/etcd/grpc/protobuf" -) - -type Controller struct { - protobuf.UnimplementedGreeterServer -} - -func Register(s *grpcx.GrpcServer) { - protobuf.RegisterGreeterServer(s.Server, &Controller{}) -} - -// SayHello implements helloworld.GreeterServer -func (s *Controller) SayHello(ctx context.Context, in *protobuf.HelloRequest) (*protobuf.HelloReply, error) { - return &protobuf.HelloReply{Message: "Hello " + in.GetName()}, nil -} diff --git a/example/registry/etcd/grpc/protobuf/helloworld.pb.go b/example/registry/etcd/grpc/protobuf/helloworld.pb.go deleted file mode 100644 index 8af3b213b5f..00000000000 --- a/example/registry/etcd/grpc/protobuf/helloworld.pb.go +++ /dev/null @@ -1,217 +0,0 @@ -// protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. *.proto - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 -// source: helloworld.proto - -package protobuf - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// The request message containing the user's name. -type HelloRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *HelloRequest) Reset() { - *x = HelloRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_helloworld_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloRequest) ProtoMessage() {} - -func (x *HelloRequest) ProtoReflect() protoreflect.Message { - mi := &file_helloworld_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead. -func (*HelloRequest) Descriptor() ([]byte, []int) { - return file_helloworld_proto_rawDescGZIP(), []int{0} -} - -func (x *HelloRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// The response message containing the greetings -type HelloReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *HelloReply) Reset() { - *x = HelloReply{} - if protoimpl.UnsafeEnabled { - mi := &file_helloworld_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloReply) ProtoMessage() {} - -func (x *HelloReply) ProtoReflect() protoreflect.Message { - mi := &file_helloworld_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead. -func (*HelloReply) Descriptor() ([]byte, []int) { - return file_helloworld_proto_rawDescGZIP(), []int{1} -} - -func (x *HelloReply) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -var File_helloworld_proto protoreflect.FileDescriptor - -var file_helloworld_proto_rawDesc = []byte{ - 0x0a, 0x10, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, 0x22, 0x0a, 0x0c, - 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x22, 0x26, 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, - 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x45, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, - 0x74, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, - 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, - 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, - 0x67, 0x66, 0x2f, 0x67, 0x66, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_helloworld_proto_rawDescOnce sync.Once - file_helloworld_proto_rawDescData = file_helloworld_proto_rawDesc -) - -func file_helloworld_proto_rawDescGZIP() []byte { - file_helloworld_proto_rawDescOnce.Do(func() { - file_helloworld_proto_rawDescData = protoimpl.X.CompressGZIP(file_helloworld_proto_rawDescData) - }) - return file_helloworld_proto_rawDescData -} - -var file_helloworld_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_helloworld_proto_goTypes = []interface{}{ - (*HelloRequest)(nil), // 0: protobuf.HelloRequest - (*HelloReply)(nil), // 1: protobuf.HelloReply -} -var file_helloworld_proto_depIdxs = []int32{ - 0, // 0: protobuf.Greeter.SayHello:input_type -> protobuf.HelloRequest - 1, // 1: protobuf.Greeter.SayHello:output_type -> protobuf.HelloReply - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_helloworld_proto_init() } -func file_helloworld_proto_init() { - if File_helloworld_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_helloworld_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_helloworld_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_helloworld_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_helloworld_proto_goTypes, - DependencyIndexes: file_helloworld_proto_depIdxs, - MessageInfos: file_helloworld_proto_msgTypes, - }.Build() - File_helloworld_proto = out.File - file_helloworld_proto_rawDesc = nil - file_helloworld_proto_goTypes = nil - file_helloworld_proto_depIdxs = nil -} diff --git a/example/registry/etcd/grpc/protobuf/helloworld.proto b/example/registry/etcd/grpc/protobuf/helloworld.proto deleted file mode 100644 index 9f4f4864fc8..00000000000 --- a/example/registry/etcd/grpc/protobuf/helloworld.proto +++ /dev/null @@ -1,24 +0,0 @@ -// protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. *.proto - -syntax = "proto3"; - -package protobuf; - -option go_package = "github.com/gogf/gf/grpc/example/helloworld/protobuf"; - - -// The greeting service definition. -service Greeter { - // Sends a greeting - rpc SayHello (HelloRequest) returns (HelloReply) {} -} - -// The request message containing the user's name. -message HelloRequest { - string name = 1; -} - -// The response message containing the greetings -message HelloReply { - string message = 1; -} diff --git a/example/registry/etcd/grpc/protobuf/helloworld_grpc.pb.go b/example/registry/etcd/grpc/protobuf/helloworld_grpc.pb.go deleted file mode 100644 index af29539f4ee..00000000000 --- a/example/registry/etcd/grpc/protobuf/helloworld_grpc.pb.go +++ /dev/null @@ -1,107 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.12 -// source: helloworld.proto - -package protobuf - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -// GreeterClient is the client API for Greeter service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type GreeterClient interface { - // Sends a greeting - SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) -} - -type greeterClient struct { - cc grpc.ClientConnInterface -} - -func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { - return &greeterClient{cc} -} - -func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { - out := new(HelloReply) - err := c.cc.Invoke(ctx, "/protobuf.Greeter/SayHello", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// GreeterServer is the server API for Greeter service. -// All implementations must embed UnimplementedGreeterServer -// for forward compatibility -type GreeterServer interface { - // Sends a greeting - SayHello(context.Context, *HelloRequest) (*HelloReply, error) - mustEmbedUnimplementedGreeterServer() -} - -// UnimplementedGreeterServer must be embedded to have forward compatible implementations. -type UnimplementedGreeterServer struct { -} - -func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") -} -func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {} - -// UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to GreeterServer will -// result in compilation errors. -type UnsafeGreeterServer interface { - mustEmbedUnimplementedGreeterServer() -} - -func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) { - s.RegisterService(&Greeter_ServiceDesc, srv) -} - -func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HelloRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GreeterServer).SayHello(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/protobuf.Greeter/SayHello", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Greeter_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "protobuf.Greeter", - HandlerType: (*GreeterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _Greeter_SayHello_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "helloworld.proto", -} diff --git a/example/registry/etcd/grpc/server/config.yaml b/example/registry/etcd/grpc/server/config.yaml deleted file mode 100644 index 071b62623ed..00000000000 --- a/example/registry/etcd/grpc/server/config.yaml +++ /dev/null @@ -1,8 +0,0 @@ -grpc: - name: "demo" - logPath: "./log" - logStdout: true - errorLogEnabled: true - accessLogEnabled: true - errorStack: true - diff --git a/example/registry/etcd/grpc/server/server.go b/example/registry/etcd/grpc/server/server.go deleted file mode 100644 index d3a893dffd4..00000000000 --- a/example/registry/etcd/grpc/server/server.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/contrib/registry/etcd/v2" - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/registry/etcd/grpc/controller" -) - -func main() { - grpcx.Resolver.Register(etcd.New("127.0.0.1:2379")) - - s := grpcx.Server.New() - controller.Register(s) - s.Run() -} diff --git a/example/registry/etcd/http/client/client.go b/example/registry/etcd/http/client/client.go deleted file mode 100644 index b0f260fc860..00000000000 --- a/example/registry/etcd/http/client/client.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gsvc" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/registry/etcd/v2" -) - -func main() { - gsvc.SetRegistry(etcd.New(`127.0.0.1:2379`)) - ctx := gctx.New() - res := g.Client().GetContent(ctx, `http://hello.svc/`) - g.Log().Info(ctx, res) -} diff --git a/example/registry/etcd/http/server/server.go b/example/registry/etcd/http/server/server.go deleted file mode 100644 index fa157d36ee3..00000000000 --- a/example/registry/etcd/http/server/server.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/net/gsvc" - - "github.com/gogf/gf/contrib/registry/etcd/v2" -) - -func main() { - gsvc.SetRegistry(etcd.New(`127.0.0.1:2379`)) - - s := g.Server(`hello.svc`) - s.BindHandler("/", func(r *ghttp.Request) { - g.Log().Info(r.Context(), `request received`) - r.Response.Write(`Hello world`) - }) - s.Run() -} diff --git a/example/registry/file/client/client.go b/example/registry/file/client/client.go deleted file mode 100644 index d6357593991..00000000000 --- a/example/registry/file/client/client.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "time" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gsvc" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/os/gfile" - - "github.com/gogf/gf/contrib/registry/file/v2" -) - -func main() { - gsvc.SetRegistry(file.New(gfile.Temp("gsvc"))) - - client := g.Client() - for i := 0; i < 10; i++ { - ctx := gctx.New() - res, err := client.Get(ctx, `http://hello.svc/`) - if err != nil { - panic(err) - } - g.Log().Debug(ctx, res.ReadAllString()) - res.Close() - time.Sleep(time.Second) - } -} diff --git a/example/registry/file/server/server.go b/example/registry/file/server/server.go deleted file mode 100644 index 6da9a374025..00000000000 --- a/example/registry/file/server/server.go +++ /dev/null @@ -1,27 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/net/gsvc" - "github.com/gogf/gf/v2/os/gfile" - - "github.com/gogf/gf/contrib/registry/file/v2" -) - -func main() { - gsvc.SetRegistry(file.New(gfile.Temp("gsvc"))) - - s := g.Server(`hello.svc`) - s.BindHandler("/", func(r *ghttp.Request) { - g.Log().Info(r.Context(), `request received`) - r.Response.Write(`Hello world`) - }) - s.Run() -} diff --git a/example/registry/nacos/grpc/client/client.go b/example/registry/nacos/grpc/client/client.go deleted file mode 100644 index f41329e9628..00000000000 --- a/example/registry/nacos/grpc/client/client.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/registry/nacos/v2" - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/registry/etcd/grpc/protobuf" -) - -func main() { - grpcx.Resolver.Register(nacos.New("127.0.0.1:8848")) - - var ( - ctx = gctx.New() - conn = grpcx.Client.MustNewGrpcClientConn("demo") - client = protobuf.NewGreeterClient(conn) - ) - res, err := client.SayHello(ctx, &protobuf.HelloRequest{Name: "World"}) - if err != nil { - g.Log().Error(ctx, err) - return - } - g.Log().Debug(ctx, "Response:", res.Message) -} diff --git a/example/registry/nacos/grpc/controller/helloworld.go b/example/registry/nacos/grpc/controller/helloworld.go deleted file mode 100644 index c112a004e1f..00000000000 --- a/example/registry/nacos/grpc/controller/helloworld.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package controller - -import ( - "context" - - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/registry/etcd/grpc/protobuf" -) - -type Controller struct { - protobuf.UnimplementedGreeterServer -} - -func Register(s *grpcx.GrpcServer) { - protobuf.RegisterGreeterServer(s.Server, &Controller{}) -} - -// SayHello implements helloworld.GreeterServer -func (s *Controller) SayHello(ctx context.Context, in *protobuf.HelloRequest) (*protobuf.HelloReply, error) { - return &protobuf.HelloReply{Message: "Hello " + in.GetName()}, nil -} diff --git a/example/registry/nacos/grpc/protobuf/helloworld.pb.go b/example/registry/nacos/grpc/protobuf/helloworld.pb.go deleted file mode 100644 index 8af3b213b5f..00000000000 --- a/example/registry/nacos/grpc/protobuf/helloworld.pb.go +++ /dev/null @@ -1,217 +0,0 @@ -// protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. *.proto - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 -// source: helloworld.proto - -package protobuf - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// The request message containing the user's name. -type HelloRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *HelloRequest) Reset() { - *x = HelloRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_helloworld_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloRequest) ProtoMessage() {} - -func (x *HelloRequest) ProtoReflect() protoreflect.Message { - mi := &file_helloworld_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead. -func (*HelloRequest) Descriptor() ([]byte, []int) { - return file_helloworld_proto_rawDescGZIP(), []int{0} -} - -func (x *HelloRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// The response message containing the greetings -type HelloReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *HelloReply) Reset() { - *x = HelloReply{} - if protoimpl.UnsafeEnabled { - mi := &file_helloworld_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloReply) ProtoMessage() {} - -func (x *HelloReply) ProtoReflect() protoreflect.Message { - mi := &file_helloworld_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead. -func (*HelloReply) Descriptor() ([]byte, []int) { - return file_helloworld_proto_rawDescGZIP(), []int{1} -} - -func (x *HelloReply) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -var File_helloworld_proto protoreflect.FileDescriptor - -var file_helloworld_proto_rawDesc = []byte{ - 0x0a, 0x10, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, 0x22, 0x0a, 0x0c, - 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x22, 0x26, 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, - 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x45, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, - 0x74, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, - 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, - 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, - 0x67, 0x66, 0x2f, 0x67, 0x66, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_helloworld_proto_rawDescOnce sync.Once - file_helloworld_proto_rawDescData = file_helloworld_proto_rawDesc -) - -func file_helloworld_proto_rawDescGZIP() []byte { - file_helloworld_proto_rawDescOnce.Do(func() { - file_helloworld_proto_rawDescData = protoimpl.X.CompressGZIP(file_helloworld_proto_rawDescData) - }) - return file_helloworld_proto_rawDescData -} - -var file_helloworld_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_helloworld_proto_goTypes = []interface{}{ - (*HelloRequest)(nil), // 0: protobuf.HelloRequest - (*HelloReply)(nil), // 1: protobuf.HelloReply -} -var file_helloworld_proto_depIdxs = []int32{ - 0, // 0: protobuf.Greeter.SayHello:input_type -> protobuf.HelloRequest - 1, // 1: protobuf.Greeter.SayHello:output_type -> protobuf.HelloReply - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_helloworld_proto_init() } -func file_helloworld_proto_init() { - if File_helloworld_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_helloworld_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_helloworld_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_helloworld_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_helloworld_proto_goTypes, - DependencyIndexes: file_helloworld_proto_depIdxs, - MessageInfos: file_helloworld_proto_msgTypes, - }.Build() - File_helloworld_proto = out.File - file_helloworld_proto_rawDesc = nil - file_helloworld_proto_goTypes = nil - file_helloworld_proto_depIdxs = nil -} diff --git a/example/registry/nacos/grpc/protobuf/helloworld.proto b/example/registry/nacos/grpc/protobuf/helloworld.proto deleted file mode 100644 index 9f4f4864fc8..00000000000 --- a/example/registry/nacos/grpc/protobuf/helloworld.proto +++ /dev/null @@ -1,24 +0,0 @@ -// protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. *.proto - -syntax = "proto3"; - -package protobuf; - -option go_package = "github.com/gogf/gf/grpc/example/helloworld/protobuf"; - - -// The greeting service definition. -service Greeter { - // Sends a greeting - rpc SayHello (HelloRequest) returns (HelloReply) {} -} - -// The request message containing the user's name. -message HelloRequest { - string name = 1; -} - -// The response message containing the greetings -message HelloReply { - string message = 1; -} diff --git a/example/registry/nacos/grpc/protobuf/helloworld_grpc.pb.go b/example/registry/nacos/grpc/protobuf/helloworld_grpc.pb.go deleted file mode 100644 index af29539f4ee..00000000000 --- a/example/registry/nacos/grpc/protobuf/helloworld_grpc.pb.go +++ /dev/null @@ -1,107 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.12 -// source: helloworld.proto - -package protobuf - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -// GreeterClient is the client API for Greeter service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type GreeterClient interface { - // Sends a greeting - SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) -} - -type greeterClient struct { - cc grpc.ClientConnInterface -} - -func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { - return &greeterClient{cc} -} - -func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { - out := new(HelloReply) - err := c.cc.Invoke(ctx, "/protobuf.Greeter/SayHello", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// GreeterServer is the server API for Greeter service. -// All implementations must embed UnimplementedGreeterServer -// for forward compatibility -type GreeterServer interface { - // Sends a greeting - SayHello(context.Context, *HelloRequest) (*HelloReply, error) - mustEmbedUnimplementedGreeterServer() -} - -// UnimplementedGreeterServer must be embedded to have forward compatible implementations. -type UnimplementedGreeterServer struct { -} - -func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") -} -func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {} - -// UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to GreeterServer will -// result in compilation errors. -type UnsafeGreeterServer interface { - mustEmbedUnimplementedGreeterServer() -} - -func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) { - s.RegisterService(&Greeter_ServiceDesc, srv) -} - -func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HelloRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GreeterServer).SayHello(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/protobuf.Greeter/SayHello", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Greeter_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "protobuf.Greeter", - HandlerType: (*GreeterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _Greeter_SayHello_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "helloworld.proto", -} diff --git a/example/registry/nacos/grpc/server/config.yaml b/example/registry/nacos/grpc/server/config.yaml deleted file mode 100644 index 071b62623ed..00000000000 --- a/example/registry/nacos/grpc/server/config.yaml +++ /dev/null @@ -1,8 +0,0 @@ -grpc: - name: "demo" - logPath: "./log" - logStdout: true - errorLogEnabled: true - accessLogEnabled: true - errorStack: true - diff --git a/example/registry/nacos/grpc/server/server.go b/example/registry/nacos/grpc/server/server.go deleted file mode 100644 index cab827b28ac..00000000000 --- a/example/registry/nacos/grpc/server/server.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/contrib/registry/nacos/v2" - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/registry/etcd/grpc/controller" -) - -func main() { - grpcx.Resolver.Register(nacos.New("127.0.0.1:8848"). - SetClusterName("DEFAULT"). - SetGroupName("DEFAULT_GROUP")) - - s := grpcx.Server.New() - controller.Register(s) - s.Run() -} diff --git a/example/registry/nacos/http/client/client.go b/example/registry/nacos/http/client/client.go deleted file mode 100644 index f2bf8635ce1..00000000000 --- a/example/registry/nacos/http/client/client.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gsvc" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/registry/nacos/v2" -) - -func main() { - gsvc.SetRegistry(nacos.New(`127.0.0.1:8848`)) - ctx := gctx.New() - res := g.Client().GetContent(ctx, `http://hello.svc/`) - g.Log().Info(ctx, res) -} diff --git a/example/registry/nacos/http/server/server.go b/example/registry/nacos/http/server/server.go deleted file mode 100644 index a7abece7617..00000000000 --- a/example/registry/nacos/http/server/server.go +++ /dev/null @@ -1,26 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/net/gsvc" - - "github.com/gogf/gf/contrib/registry/nacos/v2" -) - -func main() { - gsvc.SetRegistry(nacos.New(`127.0.0.1:8848`)) - - s := g.Server(`hello.svc`) - s.BindHandler("/", func(r *ghttp.Request) { - g.Log().Info(r.Context(), `request received`) - r.Response.Write(`Hello world`) - }) - s.Run() -} diff --git a/example/registry/polaris/client/client.go b/example/registry/polaris/client/client.go deleted file mode 100644 index 183e1a6b4a9..00000000000 --- a/example/registry/polaris/client/client.go +++ /dev/null @@ -1,42 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - "fmt" - "time" - - "github.com/polarismesh/polaris-go/api" - "github.com/polarismesh/polaris-go/pkg/config" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gsvc" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/registry/polaris/v2" -) - -func main() { - conf := config.NewDefaultConfiguration([]string{"183.47.111.80:8091"}) - conf.Consumer.LocalCache.SetPersistDir("/tmp/polaris/backup") - if err := api.SetLoggersDir("/tmp/polaris/log"); err != nil { - g.Log().Fatal(context.Background(), err) - } - - gsvc.SetRegistry(polaris.NewWithConfig(conf, polaris.WithTTL(10))) - - for i := 0; i < 100; i++ { - res, err := g.Client().Get(gctx.New(), `http://hello-world.svc/`) - if err != nil { - panic(err) - } - fmt.Println(res.ReadAllString()) - res.Close() - time.Sleep(time.Second) - } -} diff --git a/example/registry/polaris/server/server.go b/example/registry/polaris/server/server.go deleted file mode 100644 index 5a15ebb1bfd..00000000000 --- a/example/registry/polaris/server/server.go +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "github.com/polarismesh/polaris-go/api" - "github.com/polarismesh/polaris-go/pkg/config" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/net/gsvc" - - "github.com/gogf/gf/contrib/registry/polaris/v2" -) - -func main() { - conf := config.NewDefaultConfiguration([]string{"183.47.111.80:8091"}) - conf.Consumer.LocalCache.SetPersistDir("/tmp/polaris/backup") - if err := api.SetLoggersDir("/tmp/polaris/log"); err != nil { - g.Log().Fatal(context.Background(), err) - } - - // TTL egt 2*time.Second - gsvc.SetRegistry(polaris.NewWithConfig(conf, polaris.WithTTL(10))) - - s := g.Server(`hello-world.svc`) - s.BindHandler("/", func(r *ghttp.Request) { - g.Log().Info(r.Context(), `request received`) - r.Response.Write(`Hello world`) - }) - s.Run() -} diff --git a/example/rpc/grpcx/balancer/client/client.go b/example/rpc/grpcx/balancer/client/client.go deleted file mode 100644 index 99d78534147..00000000000 --- a/example/rpc/grpcx/balancer/client/client.go +++ /dev/null @@ -1,35 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/rpc/grpcx/balancer/protobuf" -) - -func main() { - var ( - ctx context.Context - conn = grpcx.Client.MustNewGrpcClientConn("demo", grpcx.Balancer.WithRandom()) - client = protobuf.NewGreeterClient(conn) - ) - for i := 0; i < 10; i++ { - ctx = gctx.New() - res, err := client.SayHello(ctx, &protobuf.HelloRequest{Name: "World"}) - if err != nil { - g.Log().Error(ctx, err) - return - } - g.Log().Debug(ctx, "Response:", res.Message) - } -} diff --git a/example/rpc/grpcx/balancer/controller/helloworld.go b/example/rpc/grpcx/balancer/controller/helloworld.go deleted file mode 100644 index 0dc0bbad1bf..00000000000 --- a/example/rpc/grpcx/balancer/controller/helloworld.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package controller - -import ( - "context" - - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/rpc/grpcx/balancer/protobuf" -) - -type Controller struct { - protobuf.UnimplementedGreeterServer -} - -func Register(s *grpcx.GrpcServer) { - protobuf.RegisterGreeterServer(s.Server, &Controller{}) -} - -// SayHello implements helloworld.GreeterServer -func (s *Controller) SayHello(ctx context.Context, in *protobuf.HelloRequest) (*protobuf.HelloReply, error) { - return &protobuf.HelloReply{Message: "Hello " + in.GetName()}, nil -} diff --git a/example/rpc/grpcx/balancer/protobuf/helloworld.pb.go b/example/rpc/grpcx/balancer/protobuf/helloworld.pb.go deleted file mode 100644 index 8af3b213b5f..00000000000 --- a/example/rpc/grpcx/balancer/protobuf/helloworld.pb.go +++ /dev/null @@ -1,217 +0,0 @@ -// protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. *.proto - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 -// source: helloworld.proto - -package protobuf - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// The request message containing the user's name. -type HelloRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *HelloRequest) Reset() { - *x = HelloRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_helloworld_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloRequest) ProtoMessage() {} - -func (x *HelloRequest) ProtoReflect() protoreflect.Message { - mi := &file_helloworld_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead. -func (*HelloRequest) Descriptor() ([]byte, []int) { - return file_helloworld_proto_rawDescGZIP(), []int{0} -} - -func (x *HelloRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// The response message containing the greetings -type HelloReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *HelloReply) Reset() { - *x = HelloReply{} - if protoimpl.UnsafeEnabled { - mi := &file_helloworld_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloReply) ProtoMessage() {} - -func (x *HelloReply) ProtoReflect() protoreflect.Message { - mi := &file_helloworld_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead. -func (*HelloReply) Descriptor() ([]byte, []int) { - return file_helloworld_proto_rawDescGZIP(), []int{1} -} - -func (x *HelloReply) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -var File_helloworld_proto protoreflect.FileDescriptor - -var file_helloworld_proto_rawDesc = []byte{ - 0x0a, 0x10, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, 0x22, 0x0a, 0x0c, - 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x22, 0x26, 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, - 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x45, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, - 0x74, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, - 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, - 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, - 0x67, 0x66, 0x2f, 0x67, 0x66, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_helloworld_proto_rawDescOnce sync.Once - file_helloworld_proto_rawDescData = file_helloworld_proto_rawDesc -) - -func file_helloworld_proto_rawDescGZIP() []byte { - file_helloworld_proto_rawDescOnce.Do(func() { - file_helloworld_proto_rawDescData = protoimpl.X.CompressGZIP(file_helloworld_proto_rawDescData) - }) - return file_helloworld_proto_rawDescData -} - -var file_helloworld_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_helloworld_proto_goTypes = []interface{}{ - (*HelloRequest)(nil), // 0: protobuf.HelloRequest - (*HelloReply)(nil), // 1: protobuf.HelloReply -} -var file_helloworld_proto_depIdxs = []int32{ - 0, // 0: protobuf.Greeter.SayHello:input_type -> protobuf.HelloRequest - 1, // 1: protobuf.Greeter.SayHello:output_type -> protobuf.HelloReply - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_helloworld_proto_init() } -func file_helloworld_proto_init() { - if File_helloworld_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_helloworld_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_helloworld_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_helloworld_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_helloworld_proto_goTypes, - DependencyIndexes: file_helloworld_proto_depIdxs, - MessageInfos: file_helloworld_proto_msgTypes, - }.Build() - File_helloworld_proto = out.File - file_helloworld_proto_rawDesc = nil - file_helloworld_proto_goTypes = nil - file_helloworld_proto_depIdxs = nil -} diff --git a/example/rpc/grpcx/balancer/protobuf/helloworld.proto b/example/rpc/grpcx/balancer/protobuf/helloworld.proto deleted file mode 100644 index 9f4f4864fc8..00000000000 --- a/example/rpc/grpcx/balancer/protobuf/helloworld.proto +++ /dev/null @@ -1,24 +0,0 @@ -// protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. *.proto - -syntax = "proto3"; - -package protobuf; - -option go_package = "github.com/gogf/gf/grpc/example/helloworld/protobuf"; - - -// The greeting service definition. -service Greeter { - // Sends a greeting - rpc SayHello (HelloRequest) returns (HelloReply) {} -} - -// The request message containing the user's name. -message HelloRequest { - string name = 1; -} - -// The response message containing the greetings -message HelloReply { - string message = 1; -} diff --git a/example/rpc/grpcx/balancer/protobuf/helloworld_grpc.pb.go b/example/rpc/grpcx/balancer/protobuf/helloworld_grpc.pb.go deleted file mode 100644 index af29539f4ee..00000000000 --- a/example/rpc/grpcx/balancer/protobuf/helloworld_grpc.pb.go +++ /dev/null @@ -1,107 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.12 -// source: helloworld.proto - -package protobuf - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -// GreeterClient is the client API for Greeter service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type GreeterClient interface { - // Sends a greeting - SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) -} - -type greeterClient struct { - cc grpc.ClientConnInterface -} - -func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { - return &greeterClient{cc} -} - -func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { - out := new(HelloReply) - err := c.cc.Invoke(ctx, "/protobuf.Greeter/SayHello", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// GreeterServer is the server API for Greeter service. -// All implementations must embed UnimplementedGreeterServer -// for forward compatibility -type GreeterServer interface { - // Sends a greeting - SayHello(context.Context, *HelloRequest) (*HelloReply, error) - mustEmbedUnimplementedGreeterServer() -} - -// UnimplementedGreeterServer must be embedded to have forward compatible implementations. -type UnimplementedGreeterServer struct { -} - -func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") -} -func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {} - -// UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to GreeterServer will -// result in compilation errors. -type UnsafeGreeterServer interface { - mustEmbedUnimplementedGreeterServer() -} - -func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) { - s.RegisterService(&Greeter_ServiceDesc, srv) -} - -func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HelloRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GreeterServer).SayHello(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/protobuf.Greeter/SayHello", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Greeter_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "protobuf.Greeter", - HandlerType: (*GreeterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _Greeter_SayHello_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "helloworld.proto", -} diff --git a/example/rpc/grpcx/balancer/server/config.yaml b/example/rpc/grpcx/balancer/server/config.yaml deleted file mode 100644 index 071b62623ed..00000000000 --- a/example/rpc/grpcx/balancer/server/config.yaml +++ /dev/null @@ -1,8 +0,0 @@ -grpc: - name: "demo" - logPath: "./log" - logStdout: true - errorLogEnabled: true - accessLogEnabled: true - errorStack: true - diff --git a/example/rpc/grpcx/balancer/server/server.go b/example/rpc/grpcx/balancer/server/server.go deleted file mode 100644 index df1c276d1dc..00000000000 --- a/example/rpc/grpcx/balancer/server/server.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/rpc/grpcx/balancer/controller" -) - -func main() { - s := grpcx.Server.New() - controller.Register(s) - s.Run() -} diff --git a/example/rpc/grpcx/basic/client/client.go b/example/rpc/grpcx/basic/client/client.go deleted file mode 100644 index e224d601aa1..00000000000 --- a/example/rpc/grpcx/basic/client/client.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/rpc/grpcx/basic/protobuf" -) - -func main() { - var ( - ctx = gctx.New() - conn = grpcx.Client.MustNewGrpcClientConn("demo") - client = protobuf.NewGreeterClient(conn) - ) - res, err := client.SayHello(ctx, &protobuf.HelloRequest{Name: "World"}) - if err != nil { - g.Log().Error(ctx, err) - return - } - g.Log().Debug(ctx, "Response:", res.Message) -} diff --git a/example/rpc/grpcx/basic/controller/helloworld.go b/example/rpc/grpcx/basic/controller/helloworld.go deleted file mode 100644 index 10b5e900f80..00000000000 --- a/example/rpc/grpcx/basic/controller/helloworld.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package controller - -import ( - "context" - - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/rpc/grpcx/basic/protobuf" -) - -type Controller struct { - protobuf.UnimplementedGreeterServer -} - -func Register(s *grpcx.GrpcServer) { - protobuf.RegisterGreeterServer(s.Server, &Controller{}) -} - -// SayHello implements helloworld.GreeterServer -func (s *Controller) SayHello(ctx context.Context, in *protobuf.HelloRequest) (*protobuf.HelloReply, error) { - return &protobuf.HelloReply{Message: "Hello " + in.GetName()}, nil -} diff --git a/example/rpc/grpcx/basic/protobuf/helloworld.pb.go b/example/rpc/grpcx/basic/protobuf/helloworld.pb.go deleted file mode 100644 index 8af3b213b5f..00000000000 --- a/example/rpc/grpcx/basic/protobuf/helloworld.pb.go +++ /dev/null @@ -1,217 +0,0 @@ -// protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. *.proto - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 -// source: helloworld.proto - -package protobuf - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// The request message containing the user's name. -type HelloRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *HelloRequest) Reset() { - *x = HelloRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_helloworld_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloRequest) ProtoMessage() {} - -func (x *HelloRequest) ProtoReflect() protoreflect.Message { - mi := &file_helloworld_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead. -func (*HelloRequest) Descriptor() ([]byte, []int) { - return file_helloworld_proto_rawDescGZIP(), []int{0} -} - -func (x *HelloRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// The response message containing the greetings -type HelloReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *HelloReply) Reset() { - *x = HelloReply{} - if protoimpl.UnsafeEnabled { - mi := &file_helloworld_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloReply) ProtoMessage() {} - -func (x *HelloReply) ProtoReflect() protoreflect.Message { - mi := &file_helloworld_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead. -func (*HelloReply) Descriptor() ([]byte, []int) { - return file_helloworld_proto_rawDescGZIP(), []int{1} -} - -func (x *HelloReply) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -var File_helloworld_proto protoreflect.FileDescriptor - -var file_helloworld_proto_rawDesc = []byte{ - 0x0a, 0x10, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, 0x22, 0x0a, 0x0c, - 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x22, 0x26, 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, - 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x45, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, - 0x74, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, - 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, - 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, - 0x67, 0x66, 0x2f, 0x67, 0x66, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_helloworld_proto_rawDescOnce sync.Once - file_helloworld_proto_rawDescData = file_helloworld_proto_rawDesc -) - -func file_helloworld_proto_rawDescGZIP() []byte { - file_helloworld_proto_rawDescOnce.Do(func() { - file_helloworld_proto_rawDescData = protoimpl.X.CompressGZIP(file_helloworld_proto_rawDescData) - }) - return file_helloworld_proto_rawDescData -} - -var file_helloworld_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_helloworld_proto_goTypes = []interface{}{ - (*HelloRequest)(nil), // 0: protobuf.HelloRequest - (*HelloReply)(nil), // 1: protobuf.HelloReply -} -var file_helloworld_proto_depIdxs = []int32{ - 0, // 0: protobuf.Greeter.SayHello:input_type -> protobuf.HelloRequest - 1, // 1: protobuf.Greeter.SayHello:output_type -> protobuf.HelloReply - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_helloworld_proto_init() } -func file_helloworld_proto_init() { - if File_helloworld_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_helloworld_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_helloworld_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_helloworld_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_helloworld_proto_goTypes, - DependencyIndexes: file_helloworld_proto_depIdxs, - MessageInfos: file_helloworld_proto_msgTypes, - }.Build() - File_helloworld_proto = out.File - file_helloworld_proto_rawDesc = nil - file_helloworld_proto_goTypes = nil - file_helloworld_proto_depIdxs = nil -} diff --git a/example/rpc/grpcx/basic/protobuf/helloworld.proto b/example/rpc/grpcx/basic/protobuf/helloworld.proto deleted file mode 100644 index 9f4f4864fc8..00000000000 --- a/example/rpc/grpcx/basic/protobuf/helloworld.proto +++ /dev/null @@ -1,24 +0,0 @@ -// protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. *.proto - -syntax = "proto3"; - -package protobuf; - -option go_package = "github.com/gogf/gf/grpc/example/helloworld/protobuf"; - - -// The greeting service definition. -service Greeter { - // Sends a greeting - rpc SayHello (HelloRequest) returns (HelloReply) {} -} - -// The request message containing the user's name. -message HelloRequest { - string name = 1; -} - -// The response message containing the greetings -message HelloReply { - string message = 1; -} diff --git a/example/rpc/grpcx/basic/protobuf/helloworld_grpc.pb.go b/example/rpc/grpcx/basic/protobuf/helloworld_grpc.pb.go deleted file mode 100644 index af29539f4ee..00000000000 --- a/example/rpc/grpcx/basic/protobuf/helloworld_grpc.pb.go +++ /dev/null @@ -1,107 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.12 -// source: helloworld.proto - -package protobuf - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -// GreeterClient is the client API for Greeter service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type GreeterClient interface { - // Sends a greeting - SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) -} - -type greeterClient struct { - cc grpc.ClientConnInterface -} - -func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { - return &greeterClient{cc} -} - -func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { - out := new(HelloReply) - err := c.cc.Invoke(ctx, "/protobuf.Greeter/SayHello", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// GreeterServer is the server API for Greeter service. -// All implementations must embed UnimplementedGreeterServer -// for forward compatibility -type GreeterServer interface { - // Sends a greeting - SayHello(context.Context, *HelloRequest) (*HelloReply, error) - mustEmbedUnimplementedGreeterServer() -} - -// UnimplementedGreeterServer must be embedded to have forward compatible implementations. -type UnimplementedGreeterServer struct { -} - -func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") -} -func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {} - -// UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to GreeterServer will -// result in compilation errors. -type UnsafeGreeterServer interface { - mustEmbedUnimplementedGreeterServer() -} - -func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) { - s.RegisterService(&Greeter_ServiceDesc, srv) -} - -func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HelloRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GreeterServer).SayHello(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/protobuf.Greeter/SayHello", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Greeter_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "protobuf.Greeter", - HandlerType: (*GreeterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _Greeter_SayHello_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "helloworld.proto", -} diff --git a/example/rpc/grpcx/basic/server/config.yaml b/example/rpc/grpcx/basic/server/config.yaml deleted file mode 100644 index 071b62623ed..00000000000 --- a/example/rpc/grpcx/basic/server/config.yaml +++ /dev/null @@ -1,8 +0,0 @@ -grpc: - name: "demo" - logPath: "./log" - logStdout: true - errorLogEnabled: true - accessLogEnabled: true - errorStack: true - diff --git a/example/rpc/grpcx/basic/server/server.go b/example/rpc/grpcx/basic/server/server.go deleted file mode 100644 index 524ee1b4ee8..00000000000 --- a/example/rpc/grpcx/basic/server/server.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/rpc/grpcx/basic/controller" -) - -func main() { - s := grpcx.Server.New() - controller.Register(s) - s.Run() -} diff --git a/example/rpc/grpcx/ctx/client/client.go b/example/rpc/grpcx/ctx/client/client.go deleted file mode 100644 index 2a50869080b..00000000000 --- a/example/rpc/grpcx/ctx/client/client.go +++ /dev/null @@ -1,34 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/rpc/grpcx/ctx/protobuf" -) - -func main() { - var ( - conn = grpcx.Client.MustNewGrpcClientConn("demo") - client = protobuf.NewGreeterClient(conn) - ctx = grpcx.Ctx.NewOutgoing(gctx.New(), g.Map{ - "UserId": "1000", - "UserName": "john", - }) - ) - g.Log().Infof(ctx, `outgoing data: %v`, grpcx.Ctx.OutgoingMap(ctx).Map()) - res, err := client.SayHello(ctx, &protobuf.HelloRequest{Name: "World"}) - if err != nil { - g.Log().Error(ctx, err) - return - } - g.Log().Debug(ctx, "Response:", res.Message) -} diff --git a/example/rpc/grpcx/ctx/controller/helloworld.go b/example/rpc/grpcx/ctx/controller/helloworld.go deleted file mode 100644 index 839f0b8e563..00000000000 --- a/example/rpc/grpcx/ctx/controller/helloworld.go +++ /dev/null @@ -1,32 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package controller - -import ( - "context" - - "github.com/gogf/gf/v2/frame/g" - - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/rpc/grpcx/ctx/protobuf" -) - -type Controller struct { - protobuf.UnimplementedGreeterServer -} - -func Register(s *grpcx.GrpcServer) { - protobuf.RegisterGreeterServer(s.Server, &Controller{}) -} - -// SayHello implements helloworld.GreeterServer -func (s *Controller) SayHello(ctx context.Context, in *protobuf.HelloRequest) (*protobuf.HelloReply, error) { - m := grpcx.Ctx.IncomingMap(ctx) - g.Log().Infof(ctx, `incoming data: %v`, m.Map()) - return &protobuf.HelloReply{Message: "Hello " + in.GetName()}, nil -} diff --git a/example/rpc/grpcx/ctx/protobuf/helloworld.pb.go b/example/rpc/grpcx/ctx/protobuf/helloworld.pb.go deleted file mode 100644 index 8af3b213b5f..00000000000 --- a/example/rpc/grpcx/ctx/protobuf/helloworld.pb.go +++ /dev/null @@ -1,217 +0,0 @@ -// protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. *.proto - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 -// source: helloworld.proto - -package protobuf - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// The request message containing the user's name. -type HelloRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *HelloRequest) Reset() { - *x = HelloRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_helloworld_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloRequest) ProtoMessage() {} - -func (x *HelloRequest) ProtoReflect() protoreflect.Message { - mi := &file_helloworld_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead. -func (*HelloRequest) Descriptor() ([]byte, []int) { - return file_helloworld_proto_rawDescGZIP(), []int{0} -} - -func (x *HelloRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// The response message containing the greetings -type HelloReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *HelloReply) Reset() { - *x = HelloReply{} - if protoimpl.UnsafeEnabled { - mi := &file_helloworld_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloReply) ProtoMessage() {} - -func (x *HelloReply) ProtoReflect() protoreflect.Message { - mi := &file_helloworld_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead. -func (*HelloReply) Descriptor() ([]byte, []int) { - return file_helloworld_proto_rawDescGZIP(), []int{1} -} - -func (x *HelloReply) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -var File_helloworld_proto protoreflect.FileDescriptor - -var file_helloworld_proto_rawDesc = []byte{ - 0x0a, 0x10, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, 0x22, 0x0a, 0x0c, - 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x22, 0x26, 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, - 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x45, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, - 0x74, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, - 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, - 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, - 0x67, 0x66, 0x2f, 0x67, 0x66, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_helloworld_proto_rawDescOnce sync.Once - file_helloworld_proto_rawDescData = file_helloworld_proto_rawDesc -) - -func file_helloworld_proto_rawDescGZIP() []byte { - file_helloworld_proto_rawDescOnce.Do(func() { - file_helloworld_proto_rawDescData = protoimpl.X.CompressGZIP(file_helloworld_proto_rawDescData) - }) - return file_helloworld_proto_rawDescData -} - -var file_helloworld_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_helloworld_proto_goTypes = []interface{}{ - (*HelloRequest)(nil), // 0: protobuf.HelloRequest - (*HelloReply)(nil), // 1: protobuf.HelloReply -} -var file_helloworld_proto_depIdxs = []int32{ - 0, // 0: protobuf.Greeter.SayHello:input_type -> protobuf.HelloRequest - 1, // 1: protobuf.Greeter.SayHello:output_type -> protobuf.HelloReply - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_helloworld_proto_init() } -func file_helloworld_proto_init() { - if File_helloworld_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_helloworld_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_helloworld_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_helloworld_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_helloworld_proto_goTypes, - DependencyIndexes: file_helloworld_proto_depIdxs, - MessageInfos: file_helloworld_proto_msgTypes, - }.Build() - File_helloworld_proto = out.File - file_helloworld_proto_rawDesc = nil - file_helloworld_proto_goTypes = nil - file_helloworld_proto_depIdxs = nil -} diff --git a/example/rpc/grpcx/ctx/protobuf/helloworld.proto b/example/rpc/grpcx/ctx/protobuf/helloworld.proto deleted file mode 100644 index 9f4f4864fc8..00000000000 --- a/example/rpc/grpcx/ctx/protobuf/helloworld.proto +++ /dev/null @@ -1,24 +0,0 @@ -// protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. *.proto - -syntax = "proto3"; - -package protobuf; - -option go_package = "github.com/gogf/gf/grpc/example/helloworld/protobuf"; - - -// The greeting service definition. -service Greeter { - // Sends a greeting - rpc SayHello (HelloRequest) returns (HelloReply) {} -} - -// The request message containing the user's name. -message HelloRequest { - string name = 1; -} - -// The response message containing the greetings -message HelloReply { - string message = 1; -} diff --git a/example/rpc/grpcx/ctx/protobuf/helloworld_grpc.pb.go b/example/rpc/grpcx/ctx/protobuf/helloworld_grpc.pb.go deleted file mode 100644 index af29539f4ee..00000000000 --- a/example/rpc/grpcx/ctx/protobuf/helloworld_grpc.pb.go +++ /dev/null @@ -1,107 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.12 -// source: helloworld.proto - -package protobuf - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -// GreeterClient is the client API for Greeter service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type GreeterClient interface { - // Sends a greeting - SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) -} - -type greeterClient struct { - cc grpc.ClientConnInterface -} - -func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { - return &greeterClient{cc} -} - -func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { - out := new(HelloReply) - err := c.cc.Invoke(ctx, "/protobuf.Greeter/SayHello", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// GreeterServer is the server API for Greeter service. -// All implementations must embed UnimplementedGreeterServer -// for forward compatibility -type GreeterServer interface { - // Sends a greeting - SayHello(context.Context, *HelloRequest) (*HelloReply, error) - mustEmbedUnimplementedGreeterServer() -} - -// UnimplementedGreeterServer must be embedded to have forward compatible implementations. -type UnimplementedGreeterServer struct { -} - -func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") -} -func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {} - -// UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to GreeterServer will -// result in compilation errors. -type UnsafeGreeterServer interface { - mustEmbedUnimplementedGreeterServer() -} - -func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) { - s.RegisterService(&Greeter_ServiceDesc, srv) -} - -func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HelloRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GreeterServer).SayHello(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/protobuf.Greeter/SayHello", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Greeter_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "protobuf.Greeter", - HandlerType: (*GreeterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _Greeter_SayHello_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "helloworld.proto", -} diff --git a/example/rpc/grpcx/ctx/server/config.yaml b/example/rpc/grpcx/ctx/server/config.yaml deleted file mode 100644 index 071b62623ed..00000000000 --- a/example/rpc/grpcx/ctx/server/config.yaml +++ /dev/null @@ -1,8 +0,0 @@ -grpc: - name: "demo" - logPath: "./log" - logStdout: true - errorLogEnabled: true - accessLogEnabled: true - errorStack: true - diff --git a/example/rpc/grpcx/ctx/server/server.go b/example/rpc/grpcx/ctx/server/server.go deleted file mode 100644 index 401e2319dbf..00000000000 --- a/example/rpc/grpcx/ctx/server/server.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/rpc/grpcx/ctx/controller" -) - -func main() { - s := grpcx.Server.New() - controller.Register(s) - s.Run() -} diff --git a/example/rpc/grpcx/rawgrpc/client/client.go b/example/rpc/grpcx/rawgrpc/client/client.go deleted file mode 100644 index e240d52afdb..00000000000 --- a/example/rpc/grpcx/rawgrpc/client/client.go +++ /dev/null @@ -1,55 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "fmt" - "time" - - "google.golang.org/grpc" - "google.golang.org/grpc/credentials/insecure" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gsvc" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/os/gfile" - - "github.com/gogf/gf/contrib/registry/file/v2" - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - pb "github.com/gogf/gf/example/rpc/grpcx/rawgrpc/helloworld" -) - -func main() { - grpcx.Resolver.Register(file.New(gfile.Temp("gsvc"))) - - var ( - ctx = gctx.GetInitCtx() - service = gsvc.NewServiceWithName(`hello`) - ) - // Set up a connection to the server. - conn, err := grpc.Dial( - fmt.Sprintf(`%s://%s`, gsvc.Schema, service.GetKey()), - grpcx.Balancer.WithRandom(), - grpc.WithTransportCredentials(insecure.NewCredentials()), - ) - if err != nil { - g.Log().Fatalf(ctx, "did not connect: %v", err) - } - defer conn.Close() - - // Send requests. - client := pb.NewGreeterClient(conn) - for i := 0; i < 10; i++ { - res, err := client.SayHello(ctx, &pb.HelloRequest{Name: `GoFrame`}) - if err != nil { - g.Log().Fatalf(ctx, "could not greet: %+v", err) - } - g.Log().Printf(ctx, "Greeting: %s", res.Message) - time.Sleep(time.Second) - } -} diff --git a/example/rpc/grpcx/rawgrpc/helloworld/helloworld.pb.go b/example/rpc/grpcx/rawgrpc/helloworld/helloworld.pb.go deleted file mode 100644 index 1d7cc808b41..00000000000 --- a/example/rpc/grpcx/rawgrpc/helloworld/helloworld.pb.go +++ /dev/null @@ -1,234 +0,0 @@ -// Copyright 2015 gRPC authors. -// -// Licensed under the Apache License, Version 2.0 (the "License"); -// you may not use this file except in compliance with the License. -// You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, software -// distributed under the License is distributed on an "AS IS" BASIS, -// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -// See the License for the specific language governing permissions and -// limitations under the License. - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 -// source: helloworld/helloworld.proto - -package helloworld - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// The request message containing the user's name. -type HelloRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *HelloRequest) Reset() { - *x = HelloRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_helloworld_helloworld_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloRequest) ProtoMessage() {} - -func (x *HelloRequest) ProtoReflect() protoreflect.Message { - mi := &file_helloworld_helloworld_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead. -func (*HelloRequest) Descriptor() ([]byte, []int) { - return file_helloworld_helloworld_proto_rawDescGZIP(), []int{0} -} - -func (x *HelloRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// The response message containing the greetings -type HelloReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *HelloReply) Reset() { - *x = HelloReply{} - if protoimpl.UnsafeEnabled { - mi := &file_helloworld_helloworld_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloReply) ProtoMessage() {} - -func (x *HelloReply) ProtoReflect() protoreflect.Message { - mi := &file_helloworld_helloworld_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead. -func (*HelloReply) Descriptor() ([]byte, []int) { - return file_helloworld_helloworld_proto_rawDescGZIP(), []int{1} -} - -func (x *HelloReply) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -var File_helloworld_helloworld_proto protoreflect.FileDescriptor - -var file_helloworld_helloworld_proto_rawDesc = []byte{ - 0x0a, 0x1b, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x68, 0x65, 0x6c, - 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x0a, 0x68, - 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x22, 0x22, 0x0a, 0x0c, 0x48, 0x65, 0x6c, - 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, 0x6e, 0x61, 0x6d, - 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, 0x22, 0x26, 0x0a, - 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, 0x0a, 0x07, 0x6d, - 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x6d, 0x65, - 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x49, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, 0x74, 0x65, 0x72, - 0x12, 0x3e, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, 0x18, 0x2e, 0x68, - 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, - 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x16, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, - 0x72, 0x6c, 0x64, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, - 0x42, 0x67, 0x0a, 0x1b, 0x69, 0x6f, 0x2e, 0x67, 0x72, 0x70, 0x63, 0x2e, 0x65, 0x78, 0x61, 0x6d, - 0x70, 0x6c, 0x65, 0x73, 0x2e, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x42, - 0x0f, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x57, 0x6f, 0x72, 0x6c, 0x64, 0x50, 0x72, 0x6f, 0x74, 0x6f, - 0x50, 0x01, 0x5a, 0x35, 0x67, 0x6f, 0x6f, 0x67, 0x6c, 0x65, 0x2e, 0x67, 0x6f, 0x6c, 0x61, 0x6e, - 0x67, 0x2e, 0x6f, 0x72, 0x67, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x73, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x68, - 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, - 0x33, -} - -var ( - file_helloworld_helloworld_proto_rawDescOnce sync.Once - file_helloworld_helloworld_proto_rawDescData = file_helloworld_helloworld_proto_rawDesc -) - -func file_helloworld_helloworld_proto_rawDescGZIP() []byte { - file_helloworld_helloworld_proto_rawDescOnce.Do(func() { - file_helloworld_helloworld_proto_rawDescData = protoimpl.X.CompressGZIP(file_helloworld_helloworld_proto_rawDescData) - }) - return file_helloworld_helloworld_proto_rawDescData -} - -var file_helloworld_helloworld_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_helloworld_helloworld_proto_goTypes = []interface{}{ - (*HelloRequest)(nil), // 0: helloworld.HelloRequest - (*HelloReply)(nil), // 1: helloworld.HelloReply -} -var file_helloworld_helloworld_proto_depIdxs = []int32{ - 0, // 0: helloworld.Greeter.SayHello:input_type -> helloworld.HelloRequest - 1, // 1: helloworld.Greeter.SayHello:output_type -> helloworld.HelloReply - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_helloworld_helloworld_proto_init() } -func file_helloworld_helloworld_proto_init() { - if File_helloworld_helloworld_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_helloworld_helloworld_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_helloworld_helloworld_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_helloworld_helloworld_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_helloworld_helloworld_proto_goTypes, - DependencyIndexes: file_helloworld_helloworld_proto_depIdxs, - MessageInfos: file_helloworld_helloworld_proto_msgTypes, - }.Build() - File_helloworld_helloworld_proto = out.File - file_helloworld_helloworld_proto_rawDesc = nil - file_helloworld_helloworld_proto_goTypes = nil - file_helloworld_helloworld_proto_depIdxs = nil -} diff --git a/example/rpc/grpcx/rawgrpc/helloworld/helloworld.proto b/example/rpc/grpcx/rawgrpc/helloworld/helloworld.proto deleted file mode 100644 index a8eb37bdc41..00000000000 --- a/example/rpc/grpcx/rawgrpc/helloworld/helloworld.proto +++ /dev/null @@ -1,25 +0,0 @@ -// protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. *.proto - -syntax = "proto3"; - - -package helloworld; - -option go_package = "github.com/gogf/gf/grpc/example/helloworld"; - - -// The greeting service definition. -service Greeter { - // Sends a greeting - rpc SayHello (HelloRequest) returns (HelloReply) {} -} - -// The request message containing the user's name. -message HelloRequest { - string name = 1; -} - -// The response message containing the greetings -message HelloReply { - string message = 1; -} diff --git a/example/rpc/grpcx/rawgrpc/helloworld/helloworld_grpc.pb.go b/example/rpc/grpcx/rawgrpc/helloworld/helloworld_grpc.pb.go deleted file mode 100644 index cebcffbcedc..00000000000 --- a/example/rpc/grpcx/rawgrpc/helloworld/helloworld_grpc.pb.go +++ /dev/null @@ -1,107 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.12 -// source: helloworld/helloworld.proto - -package helloworld - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -// GreeterClient is the client API for Greeter service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type GreeterClient interface { - // Sends a greeting - SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) -} - -type greeterClient struct { - cc grpc.ClientConnInterface -} - -func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { - return &greeterClient{cc} -} - -func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { - out := new(HelloReply) - err := c.cc.Invoke(ctx, "/helloworld.Greeter/SayHello", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// GreeterServer is the server API for Greeter service. -// All implementations must embed UnimplementedGreeterServer -// for forward compatibility -type GreeterServer interface { - // Sends a greeting - SayHello(context.Context, *HelloRequest) (*HelloReply, error) - mustEmbedUnimplementedGreeterServer() -} - -// UnimplementedGreeterServer must be embedded to have forward compatible implementations. -type UnimplementedGreeterServer struct { -} - -func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") -} -func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {} - -// UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to GreeterServer will -// result in compilation errors. -type UnsafeGreeterServer interface { - mustEmbedUnimplementedGreeterServer() -} - -func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) { - s.RegisterService(&Greeter_ServiceDesc, srv) -} - -func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HelloRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GreeterServer).SayHello(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/helloworld.Greeter/SayHello", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Greeter_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "helloworld.Greeter", - HandlerType: (*GreeterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _Greeter_SayHello_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "helloworld/helloworld.proto", -} diff --git a/example/rpc/grpcx/rawgrpc/server/server.go b/example/rpc/grpcx/rawgrpc/server/server.go deleted file mode 100644 index 3000a6aa995..00000000000 --- a/example/rpc/grpcx/rawgrpc/server/server.go +++ /dev/null @@ -1,71 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - "fmt" - "net" - - "google.golang.org/grpc" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gipv4" - "github.com/gogf/gf/v2/net/gsvc" - "github.com/gogf/gf/v2/net/gtcp" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/os/gfile" - - "github.com/gogf/gf/contrib/registry/file/v2" - - "github.com/gogf/gf/example/rpc/grpcx/rawgrpc/helloworld" -) - -type GreetingServer struct { - helloworld.UnimplementedGreeterServer -} - -// SayHello implements helloworld.GreeterServer -func (s *GreetingServer) SayHello(ctx context.Context, in *helloworld.HelloRequest) (*helloworld.HelloReply, error) { - return &helloworld.HelloReply{Message: "Hello " + in.GetName()}, nil -} - -func main() { - gsvc.SetRegistry(file.New(gfile.Temp("gsvc"))) - - var ( - err error - ctx = gctx.GetInitCtx() - address = fmt.Sprintf("%s:%d", gipv4.MustGetIntranetIp(), gtcp.MustGetFreePort()) - service = &gsvc.LocalService{ - Name: "hello", - Endpoints: gsvc.NewEndpoints(address), - } - ) - - // Service registry. - _, err = gsvc.Register(ctx, service) - if err != nil { - panic(err) - } - defer func() { - _ = gsvc.Deregister(ctx, service) - }() - - // Server listening. - listen, err := net.Listen("tcp", address) - if err != nil { - g.Log().Fatalf(ctx, "failed to listen: %v", err) - } - - s := grpc.NewServer() - helloworld.RegisterGreeterServer(s, &GreetingServer{}) - g.Log().Printf(ctx, "server listening at %v", listen.Addr()) - if err = s.Serve(listen); err != nil { - g.Log().Fatalf(ctx, "failed to serve: %v", err) - } -} diff --git a/example/rpc/grpcx/resolver/client/client.go b/example/rpc/grpcx/resolver/client/client.go deleted file mode 100644 index 3623852f58d..00000000000 --- a/example/rpc/grpcx/resolver/client/client.go +++ /dev/null @@ -1,33 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/registry/etcd/v2" - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/rpc/grpcx/resolver/protobuf" -) - -func main() { - grpcx.Resolver.Register(etcd.New("127.0.0.1:2379")) - - var ( - ctx = gctx.New() - conn = grpcx.Client.MustNewGrpcClientConn("demo") - client = protobuf.NewGreeterClient(conn) - ) - res, err := client.SayHello(ctx, &protobuf.HelloRequest{Name: "World"}) - if err != nil { - g.Log().Error(ctx, err) - return - } - g.Log().Debug(ctx, "Response:", res.Message) -} diff --git a/example/rpc/grpcx/resolver/controller/helloworld.go b/example/rpc/grpcx/resolver/controller/helloworld.go deleted file mode 100644 index 08bb90fc2d8..00000000000 --- a/example/rpc/grpcx/resolver/controller/helloworld.go +++ /dev/null @@ -1,28 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package controller - -import ( - "context" - - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/rpc/grpcx/resolver/protobuf" -) - -type Controller struct { - protobuf.UnimplementedGreeterServer -} - -func Register(s *grpcx.GrpcServer) { - protobuf.RegisterGreeterServer(s.Server, &Controller{}) -} - -// SayHello implements helloworld.GreeterServer -func (s *Controller) SayHello(ctx context.Context, in *protobuf.HelloRequest) (*protobuf.HelloReply, error) { - return &protobuf.HelloReply{Message: "Hello " + in.GetName()}, nil -} diff --git a/example/rpc/grpcx/resolver/protobuf/helloworld.pb.go b/example/rpc/grpcx/resolver/protobuf/helloworld.pb.go deleted file mode 100644 index 8af3b213b5f..00000000000 --- a/example/rpc/grpcx/resolver/protobuf/helloworld.pb.go +++ /dev/null @@ -1,217 +0,0 @@ -// protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. *.proto - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 -// source: helloworld.proto - -package protobuf - -import ( - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" - reflect "reflect" - sync "sync" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -// The request message containing the user's name. -type HelloRequest struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=name,proto3" json:"name,omitempty"` -} - -func (x *HelloRequest) Reset() { - *x = HelloRequest{} - if protoimpl.UnsafeEnabled { - mi := &file_helloworld_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloRequest) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloRequest) ProtoMessage() {} - -func (x *HelloRequest) ProtoReflect() protoreflect.Message { - mi := &file_helloworld_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloRequest.ProtoReflect.Descriptor instead. -func (*HelloRequest) Descriptor() ([]byte, []int) { - return file_helloworld_proto_rawDescGZIP(), []int{0} -} - -func (x *HelloRequest) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -// The response message containing the greetings -type HelloReply struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Message string `protobuf:"bytes,1,opt,name=message,proto3" json:"message,omitempty"` -} - -func (x *HelloReply) Reset() { - *x = HelloReply{} - if protoimpl.UnsafeEnabled { - mi := &file_helloworld_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *HelloReply) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*HelloReply) ProtoMessage() {} - -func (x *HelloReply) ProtoReflect() protoreflect.Message { - mi := &file_helloworld_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use HelloReply.ProtoReflect.Descriptor instead. -func (*HelloReply) Descriptor() ([]byte, []int) { - return file_helloworld_proto_rawDescGZIP(), []int{1} -} - -func (x *HelloReply) GetMessage() string { - if x != nil { - return x.Message - } - return "" -} - -var File_helloworld_proto protoreflect.FileDescriptor - -var file_helloworld_proto_rawDesc = []byte{ - 0x0a, 0x10, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2e, 0x70, 0x72, 0x6f, - 0x74, 0x6f, 0x12, 0x08, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x22, 0x22, 0x0a, 0x0c, - 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x12, 0x0a, 0x04, - 0x6e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x6e, 0x61, 0x6d, 0x65, - 0x22, 0x26, 0x0a, 0x0a, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x12, 0x18, - 0x0a, 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, - 0x07, 0x6d, 0x65, 0x73, 0x73, 0x61, 0x67, 0x65, 0x32, 0x45, 0x0a, 0x07, 0x47, 0x72, 0x65, 0x65, - 0x74, 0x65, 0x72, 0x12, 0x3a, 0x0a, 0x08, 0x53, 0x61, 0x79, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x12, - 0x16, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, - 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x1a, 0x14, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2e, 0x48, 0x65, 0x6c, 0x6c, 0x6f, 0x52, 0x65, 0x70, 0x6c, 0x79, 0x22, 0x00, 0x42, - 0x35, 0x5a, 0x33, 0x67, 0x69, 0x74, 0x68, 0x75, 0x62, 0x2e, 0x63, 0x6f, 0x6d, 0x2f, 0x67, 0x6f, - 0x67, 0x66, 0x2f, 0x67, 0x66, 0x2f, 0x67, 0x72, 0x70, 0x63, 0x2f, 0x65, 0x78, 0x61, 0x6d, 0x70, - 0x6c, 0x65, 0x2f, 0x68, 0x65, 0x6c, 0x6c, 0x6f, 0x77, 0x6f, 0x72, 0x6c, 0x64, 0x2f, 0x70, 0x72, - 0x6f, 0x74, 0x6f, 0x62, 0x75, 0x66, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_helloworld_proto_rawDescOnce sync.Once - file_helloworld_proto_rawDescData = file_helloworld_proto_rawDesc -) - -func file_helloworld_proto_rawDescGZIP() []byte { - file_helloworld_proto_rawDescOnce.Do(func() { - file_helloworld_proto_rawDescData = protoimpl.X.CompressGZIP(file_helloworld_proto_rawDescData) - }) - return file_helloworld_proto_rawDescData -} - -var file_helloworld_proto_msgTypes = make([]protoimpl.MessageInfo, 2) -var file_helloworld_proto_goTypes = []interface{}{ - (*HelloRequest)(nil), // 0: protobuf.HelloRequest - (*HelloReply)(nil), // 1: protobuf.HelloReply -} -var file_helloworld_proto_depIdxs = []int32{ - 0, // 0: protobuf.Greeter.SayHello:input_type -> protobuf.HelloRequest - 1, // 1: protobuf.Greeter.SayHello:output_type -> protobuf.HelloReply - 1, // [1:2] is the sub-list for method output_type - 0, // [0:1] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_helloworld_proto_init() } -func file_helloworld_proto_init() { - if File_helloworld_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_helloworld_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloRequest); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_helloworld_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*HelloReply); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_helloworld_proto_rawDesc, - NumEnums: 0, - NumMessages: 2, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_helloworld_proto_goTypes, - DependencyIndexes: file_helloworld_proto_depIdxs, - MessageInfos: file_helloworld_proto_msgTypes, - }.Build() - File_helloworld_proto = out.File - file_helloworld_proto_rawDesc = nil - file_helloworld_proto_goTypes = nil - file_helloworld_proto_depIdxs = nil -} diff --git a/example/rpc/grpcx/resolver/protobuf/helloworld.proto b/example/rpc/grpcx/resolver/protobuf/helloworld.proto deleted file mode 100644 index 9f4f4864fc8..00000000000 --- a/example/rpc/grpcx/resolver/protobuf/helloworld.proto +++ /dev/null @@ -1,24 +0,0 @@ -// protoc --go_out=paths=source_relative:. --go-grpc_out=paths=source_relative:. *.proto - -syntax = "proto3"; - -package protobuf; - -option go_package = "github.com/gogf/gf/grpc/example/helloworld/protobuf"; - - -// The greeting service definition. -service Greeter { - // Sends a greeting - rpc SayHello (HelloRequest) returns (HelloReply) {} -} - -// The request message containing the user's name. -message HelloRequest { - string name = 1; -} - -// The response message containing the greetings -message HelloReply { - string message = 1; -} diff --git a/example/rpc/grpcx/resolver/protobuf/helloworld_grpc.pb.go b/example/rpc/grpcx/resolver/protobuf/helloworld_grpc.pb.go deleted file mode 100644 index af29539f4ee..00000000000 --- a/example/rpc/grpcx/resolver/protobuf/helloworld_grpc.pb.go +++ /dev/null @@ -1,107 +0,0 @@ -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.2.0 -// - protoc v3.21.12 -// source: helloworld.proto - -package protobuf - -import ( - context "context" - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -// GreeterClient is the client API for Greeter service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type GreeterClient interface { - // Sends a greeting - SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) -} - -type greeterClient struct { - cc grpc.ClientConnInterface -} - -func NewGreeterClient(cc grpc.ClientConnInterface) GreeterClient { - return &greeterClient{cc} -} - -func (c *greeterClient) SayHello(ctx context.Context, in *HelloRequest, opts ...grpc.CallOption) (*HelloReply, error) { - out := new(HelloReply) - err := c.cc.Invoke(ctx, "/protobuf.Greeter/SayHello", in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// GreeterServer is the server API for Greeter service. -// All implementations must embed UnimplementedGreeterServer -// for forward compatibility -type GreeterServer interface { - // Sends a greeting - SayHello(context.Context, *HelloRequest) (*HelloReply, error) - mustEmbedUnimplementedGreeterServer() -} - -// UnimplementedGreeterServer must be embedded to have forward compatible implementations. -type UnimplementedGreeterServer struct { -} - -func (UnimplementedGreeterServer) SayHello(context.Context, *HelloRequest) (*HelloReply, error) { - return nil, status.Errorf(codes.Unimplemented, "method SayHello not implemented") -} -func (UnimplementedGreeterServer) mustEmbedUnimplementedGreeterServer() {} - -// UnsafeGreeterServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to GreeterServer will -// result in compilation errors. -type UnsafeGreeterServer interface { - mustEmbedUnimplementedGreeterServer() -} - -func RegisterGreeterServer(s grpc.ServiceRegistrar, srv GreeterServer) { - s.RegisterService(&Greeter_ServiceDesc, srv) -} - -func _Greeter_SayHello_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(HelloRequest) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(GreeterServer).SayHello(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: "/protobuf.Greeter/SayHello", - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(GreeterServer).SayHello(ctx, req.(*HelloRequest)) - } - return interceptor(ctx, in, info, handler) -} - -// Greeter_ServiceDesc is the grpc.ServiceDesc for Greeter service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var Greeter_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "protobuf.Greeter", - HandlerType: (*GreeterServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "SayHello", - Handler: _Greeter_SayHello_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "helloworld.proto", -} diff --git a/example/rpc/grpcx/resolver/server/config.yaml b/example/rpc/grpcx/resolver/server/config.yaml deleted file mode 100644 index 071b62623ed..00000000000 --- a/example/rpc/grpcx/resolver/server/config.yaml +++ /dev/null @@ -1,8 +0,0 @@ -grpc: - name: "demo" - logPath: "./log" - logStdout: true - errorLogEnabled: true - accessLogEnabled: true - errorStack: true - diff --git a/example/rpc/grpcx/resolver/server/server.go b/example/rpc/grpcx/resolver/server/server.go deleted file mode 100644 index dc1fe080b12..00000000000 --- a/example/rpc/grpcx/resolver/server/server.go +++ /dev/null @@ -1,22 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/contrib/registry/etcd/v2" - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - - "github.com/gogf/gf/example/rpc/grpcx/resolver/controller" -) - -func main() { - grpcx.Resolver.Register(etcd.New("127.0.0.1:2379")) - - s := grpcx.Server.New() - controller.Register(s) - s.Run() -} diff --git a/example/tcp/server/proxy/main.go b/example/tcp/server/proxy/main.go deleted file mode 100644 index 92d617107ef..00000000000 --- a/example/tcp/server/proxy/main.go +++ /dev/null @@ -1,99 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - "fmt" - "io" - "time" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gtcp" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/os/gtimer" -) - -const ( - AddressOfServer1 = ":8198" - AddressOfServer2 = ":8199" - UpStream = "127.0.0.1:8198" -) - -var ( - ctx = gctx.GetInitCtx() -) - -// StartTCPServer1 starts Server1: A simple tcp server for demo. -// It reads the content from client connect and write it back to client. -func StartTCPServer1() { - s := g.TCPServer(1) - s.SetHandler(func(conn *gtcp.Conn) { - defer conn.Close() - for { - data, err := conn.Recv(-1) - if err != nil { - g.Log().Errorf(ctx, `%+v`, err) - break - } - if len(data) > 0 { - err = conn.Send([]byte(fmt.Sprintf(`received: %s`, data))) - if err != nil { - g.Log().Errorf(ctx, `%+v`, err) - break - } - } - } - }) - s.SetAddress(AddressOfServer1) - s.Run() -} - -// StartTCPServer2 starts Server2: -// All requests to Server2 are directly redirected to Server1. -func StartTCPServer2() { - s := g.TCPServer(2) - s.SetHandler(func(conn *gtcp.Conn) { - defer conn.Close() - // Each client connection associates an upstream connection. - upstreamClient, err := gtcp.NewConn(UpStream) - if err != nil { - _, _ = conn.Write([]byte(fmt.Sprintf( - `cannot connect to upstream "%s": %s`, UpStream, err.Error(), - ))) - return - } - // Redirect the client connection reading and writing to upstream connection. - for { - go io.Copy(upstreamClient, conn) - _, err = io.Copy(conn, upstreamClient) - if err != nil { - _, _ = conn.Write([]byte(fmt.Sprintf( - `io.Copy to upstream "%s" failed: %s`, UpStream, err.Error(), - ))) - } - } - }) - s.SetAddress(AddressOfServer2) - s.Run() -} - -func main() { - go StartTCPServer1() - go StartTCPServer2() - time.Sleep(time.Second) - gtimer.Add(ctx, time.Second, func(ctx context.Context) { - address := fmt.Sprintf(`127.0.0.1%s`, AddressOfServer2) - result, err := gtcp.SendRecv(address, []byte(gtime.Now().String()), -1) - if err != nil { - g.Log().Errorf(ctx, `send data failed: %+v`, err) - } - g.Log().Info(ctx, result) - }) - g.Listen() -} diff --git a/example/trace/README.MD b/example/trace/README.MD deleted file mode 100644 index 3fc728b3d84..00000000000 --- a/example/trace/README.MD +++ /dev/null @@ -1,80 +0,0 @@ -# OpenTelemetry Protocol (stable) - -Since v1.35, the Jaeger backend can receive trace data from the OpenTelemetry SDKs in their native OpenTelemetry Protocol (OTLP)  . It is no longer necessary to configure the OpenTelemetry SDKs with Jaeger exporters, nor deploy the OpenTelemetry Collector between the OpenTelemetry SDKs and the Jaeger backend. - -The OTLP data is accepted in these formats: (1) binary gRPC, (2) Protobuf over HTTP, (3) JSON over HTTP. For more details on the OTLP receiver see the official documentation  . Note that not all configuration options are supported in jaeger-collector (see --collector.otlp.* CLI Flags ), and only tracing data is accepted, since Jaeger does not store other telemetry types. - -|Port |Protocol |Endpoint |Format| -|---|---|---|---| -|4317 |gRPC |n/a |Protobuf| -|4318 |HTTP |/v1/traces |Protobuf or JSON| - -Two ports, 4317 and 4318, have also been added to the export list, which are used by OTLP receivers to listen for gRPC and HTTP connections. - -## All in One -all-in-one is an executable designed for quick local testing. It includes the Jaeger UI, jaeger-collector, jaeger-query, and jaeger-agent, with an in memory storage component. - -The simplest way to start the all-in-one is to use the pre-built image published to DockerHub (a single command line). - -```shell -docker run --rm --name jaeger \ - -e COLLECTOR_ZIPKIN_HOST_PORT=:9411 \ - -p 6831:6831/udp \ - -p 6832:6832/udp \ - -p 5778:5778 \ - -p 16686:16686 \ - -p 4317:4317 \ - -p 4318:4318 \ - -p 14250:14250 \ - -p 14268:14268 \ - -p 14269:14269 \ - -p 9411:9411 \ - jaegertracing/all-in-one:1.55 - -``` - -Or run the `jaeger-all-in-one(.exe)` executable from the [binary distribution archives][download]: - -```bash -jaeger-all-in-one --collector.zipkin.host-port=:9411 -``` - -You can then navigate to `http://localhost:16686` to access the Jaeger UI. - -The container exposes the following ports: - -Port | Protocol | Component | Function ------ | ------- | --------- | --- -6831 | UDP | agent | accept `jaeger.thrift` over Thrift-compact protocol (used by most SDKs) -6832 | UDP | agent | accept `jaeger.thrift` over Thrift-binary protocol (used by Node.js SDK) -5775 | UDP | agent | (deprecated) accept `zipkin.thrift` over compact Thrift protocol (used by legacy clients only) -5778 | HTTP | agent | serve configs (sampling, etc.) -16686 | HTTP | query | serve frontend -4317 | HTTP | collector | accept OpenTelemetry Protocol (OTLP) over gRPC -4318 | HTTP | collector | accept OpenTelemetry Protocol (OTLP) over HTTP -14268 | HTTP | collector | accept `jaeger.thrift` directly from clients -14250 | HTTP | collector | accept `model.proto` -9411 | HTTP | collector | Zipkin compatible endpoint (optional) - -https://www.jaegertracing.io/docs/1.55/apis/#opentelemetry-protocol-stable - -Read more details: - -Introducing native support for OpenTelemetry in Jaeger - -https://medium.com/jaegertracing/introducing-native-support-for-opentelemetry-in-jaeger-eb661be8183c - -Better alignment with OpenTelemetry by focusing on OTLP - -https://medium.com/jaegertracing/better-alignment-with-opentelemetry-by-focusing-on-otlp-f3688939073f - - - -# Jaeger - -Open Source, End-to-End Distributed Tracing. Hosted by Cloud Native Computing Foundation. - -https://medium.com/jaegertracing - - -## For more information on distributed tracing initialization, please refer to the content in the [provider](./provider) directory \ No newline at end of file diff --git a/example/trace/grpc-with-db/client/client.go b/example/trace/grpc-with-db/client/client.go deleted file mode 100644 index f5a286ba3a3..00000000000 --- a/example/trace/grpc-with-db/client/client.go +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gtrace" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/registry/etcd/v2" - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - "github.com/gogf/gf/contrib/trace/otlpgrpc/v2" - - "github.com/gogf/gf/example/trace/grpc-with-db/protobuf/user" -) - -const ( - serviceName = "otlp-grpc-client" - endpoint = "tracing-analysis-dc-bj.aliyuncs.com:8090" - traceToken = "******_******" -) - -func main() { - grpcx.Resolver.Register(etcd.New("127.0.0.1:2379")) - - var ( - ctx = gctx.New() - shutdown, err = otlpgrpc.Init(serviceName, endpoint, traceToken) - ) - - if err != nil { - g.Log().Fatal(ctx, err) - } - defer shutdown(ctx) - - StartRequests() -} - -// StartRequests is a demo for tracing. -func StartRequests() { - ctx, span := gtrace.NewSpan(gctx.New(), "StartRequests") - defer span.End() - - client := user.NewUserClient(grpcx.Client.MustNewGrpcClientConn("demo")) - - // Baggage. - ctx = gtrace.SetBaggageValue(ctx, "uid", 100) - - // Insert. - insertRes, err := client.Insert(ctx, &user.InsertReq{ - Name: "john", - }) - if err != nil { - g.Log().Fatalf(ctx, `%+v`, err) - } - g.Log().Info(ctx, "insert id:", insertRes.Id) - - // Query. - queryRes, err := client.Query(ctx, &user.QueryReq{ - Id: insertRes.Id, - }) - if err != nil { - g.Log().Errorf(ctx, `%+v`, err) - return - } - g.Log().Info(ctx, "query result:", queryRes) - - // Delete. - if _, err = client.Delete(ctx, &user.DeleteReq{ - Id: insertRes.Id, - }); err != nil { - g.Log().Errorf(ctx, `%+v`, err) - return - } - g.Log().Info(ctx, "delete id:", insertRes.Id) - - // Delete with error. - if _, err = client.Delete(ctx, &user.DeleteReq{ - Id: -1, - }); err != nil { - g.Log().Errorf(ctx, `%+v`, err) - return - } - g.Log().Info(ctx, "delete id:", -1) -} diff --git a/example/trace/grpc-with-db/protobuf/user/user.pb.go b/example/trace/grpc-with-db/protobuf/user/user.pb.go deleted file mode 100644 index 5b24ba189c1..00000000000 --- a/example/trace/grpc-with-db/protobuf/user/user.pb.go +++ /dev/null @@ -1,469 +0,0 @@ -// protoc --gofast_out=plugins=grpc:. \ -// protocol/user/*.proto \ -// -I/Users/john/Workspace/Go/GOPATH/src - -// Code generated by protoc-gen-go. DO NOT EDIT. -// versions: -// protoc-gen-go v1.28.1 -// protoc v3.21.12 -// source: user.proto - -package user - -import ( - reflect "reflect" - sync "sync" - - protoreflect "google.golang.org/protobuf/reflect/protoreflect" - protoimpl "google.golang.org/protobuf/runtime/protoimpl" -) - -const ( - // Verify that this generated code is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(20 - protoimpl.MinVersion) - // Verify that runtime/protoimpl is sufficiently up-to-date. - _ = protoimpl.EnforceVersion(protoimpl.MaxVersion - 20) -) - -type InsertReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Name string `protobuf:"bytes,1,opt,name=Name,proto3" json:"Name,omitempty" v:"required#Please input user name."` // v: required#Please input user name. -} - -func (x *InsertReq) Reset() { - *x = InsertReq{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[0] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *InsertReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*InsertReq) ProtoMessage() {} - -func (x *InsertReq) ProtoReflect() protoreflect.Message { - mi := &file_user_proto_msgTypes[0] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use InsertReq.ProtoReflect.Descriptor instead. -func (*InsertReq) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{0} -} - -func (x *InsertReq) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -type InsertRes struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` -} - -func (x *InsertRes) Reset() { - *x = InsertRes{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[1] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *InsertRes) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*InsertRes) ProtoMessage() {} - -func (x *InsertRes) ProtoReflect() protoreflect.Message { - mi := &file_user_proto_msgTypes[1] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use InsertRes.ProtoReflect.Descriptor instead. -func (*InsertRes) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{1} -} - -func (x *InsertRes) GetId() int32 { - if x != nil { - return x.Id - } - return 0 -} - -type QueryReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty" v:"min:1#User id is required for querying."` // v: min:1#User id is required for querying. -} - -func (x *QueryReq) Reset() { - *x = QueryReq{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[2] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *QueryReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*QueryReq) ProtoMessage() {} - -func (x *QueryReq) ProtoReflect() protoreflect.Message { - mi := &file_user_proto_msgTypes[2] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use QueryReq.ProtoReflect.Descriptor instead. -func (*QueryReq) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{2} -} - -func (x *QueryReq) GetId() int32 { - if x != nil { - return x.Id - } - return 0 -} - -type QueryRes struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty"` - Name string `protobuf:"bytes,2,opt,name=Name,proto3" json:"Name,omitempty"` -} - -func (x *QueryRes) Reset() { - *x = QueryRes{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[3] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *QueryRes) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*QueryRes) ProtoMessage() {} - -func (x *QueryRes) ProtoReflect() protoreflect.Message { - mi := &file_user_proto_msgTypes[3] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use QueryRes.ProtoReflect.Descriptor instead. -func (*QueryRes) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{3} -} - -func (x *QueryRes) GetId() int32 { - if x != nil { - return x.Id - } - return 0 -} - -func (x *QueryRes) GetName() string { - if x != nil { - return x.Name - } - return "" -} - -type DeleteReq struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields - - Id int32 `protobuf:"varint,1,opt,name=Id,proto3" json:"Id,omitempty" v:"min:1#User id is required for deleting."` // v:min:1#User id is required for deleting. -} - -func (x *DeleteReq) Reset() { - *x = DeleteReq{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[4] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeleteReq) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteReq) ProtoMessage() {} - -func (x *DeleteReq) ProtoReflect() protoreflect.Message { - mi := &file_user_proto_msgTypes[4] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DeleteReq.ProtoReflect.Descriptor instead. -func (*DeleteReq) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{4} -} - -func (x *DeleteReq) GetId() int32 { - if x != nil { - return x.Id - } - return 0 -} - -type DeleteRes struct { - state protoimpl.MessageState - sizeCache protoimpl.SizeCache - unknownFields protoimpl.UnknownFields -} - -func (x *DeleteRes) Reset() { - *x = DeleteRes{} - if protoimpl.UnsafeEnabled { - mi := &file_user_proto_msgTypes[5] - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - ms.StoreMessageInfo(mi) - } -} - -func (x *DeleteRes) String() string { - return protoimpl.X.MessageStringOf(x) -} - -func (*DeleteRes) ProtoMessage() {} - -func (x *DeleteRes) ProtoReflect() protoreflect.Message { - mi := &file_user_proto_msgTypes[5] - if protoimpl.UnsafeEnabled && x != nil { - ms := protoimpl.X.MessageStateOf(protoimpl.Pointer(x)) - if ms.LoadMessageInfo() == nil { - ms.StoreMessageInfo(mi) - } - return ms - } - return mi.MessageOf(x) -} - -// Deprecated: Use DeleteRes.ProtoReflect.Descriptor instead. -func (*DeleteRes) Descriptor() ([]byte, []int) { - return file_user_proto_rawDescGZIP(), []int{5} -} - -var File_user_proto protoreflect.FileDescriptor - -var file_user_proto_rawDesc = []byte{ - 0x0a, 0x0a, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x12, 0x04, 0x75, 0x73, - 0x65, 0x72, 0x22, 0x1f, 0x0a, 0x09, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x52, 0x65, 0x71, 0x12, - 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, - 0x61, 0x6d, 0x65, 0x22, 0x1b, 0x0a, 0x09, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x52, 0x65, 0x73, - 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x49, 0x64, - 0x22, 0x1a, 0x0a, 0x08, 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, 0x02, - 0x49, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x49, 0x64, 0x22, 0x2e, 0x0a, 0x08, - 0x51, 0x75, 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, 0x01, - 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x49, 0x64, 0x12, 0x12, 0x0a, 0x04, 0x4e, 0x61, 0x6d, 0x65, - 0x18, 0x02, 0x20, 0x01, 0x28, 0x09, 0x52, 0x04, 0x4e, 0x61, 0x6d, 0x65, 0x22, 0x1b, 0x0a, 0x09, - 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, 0x52, 0x65, 0x71, 0x12, 0x0e, 0x0a, 0x02, 0x49, 0x64, 0x18, - 0x01, 0x20, 0x01, 0x28, 0x05, 0x52, 0x02, 0x49, 0x64, 0x22, 0x0b, 0x0a, 0x09, 0x44, 0x65, 0x6c, - 0x65, 0x74, 0x65, 0x52, 0x65, 0x73, 0x32, 0x8d, 0x01, 0x0a, 0x04, 0x55, 0x73, 0x65, 0x72, 0x12, - 0x2c, 0x0a, 0x06, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x12, 0x0f, 0x2e, 0x75, 0x73, 0x65, 0x72, - 0x2e, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x75, 0x73, 0x65, - 0x72, 0x2e, 0x49, 0x6e, 0x73, 0x65, 0x72, 0x74, 0x52, 0x65, 0x73, 0x22, 0x00, 0x12, 0x29, 0x0a, - 0x05, 0x51, 0x75, 0x65, 0x72, 0x79, 0x12, 0x0e, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x51, 0x75, - 0x65, 0x72, 0x79, 0x52, 0x65, 0x71, 0x1a, 0x0e, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x51, 0x75, - 0x65, 0x72, 0x79, 0x52, 0x65, 0x73, 0x22, 0x00, 0x12, 0x2c, 0x0a, 0x06, 0x44, 0x65, 0x6c, 0x65, - 0x74, 0x65, 0x12, 0x0f, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, 0x65, - 0x52, 0x65, 0x71, 0x1a, 0x0f, 0x2e, 0x75, 0x73, 0x65, 0x72, 0x2e, 0x44, 0x65, 0x6c, 0x65, 0x74, - 0x65, 0x52, 0x65, 0x73, 0x22, 0x00, 0x42, 0x0f, 0x5a, 0x0d, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x62, - 0x75, 0x66, 0x2f, 0x75, 0x73, 0x65, 0x72, 0x62, 0x06, 0x70, 0x72, 0x6f, 0x74, 0x6f, 0x33, -} - -var ( - file_user_proto_rawDescOnce sync.Once - file_user_proto_rawDescData = file_user_proto_rawDesc -) - -func file_user_proto_rawDescGZIP() []byte { - file_user_proto_rawDescOnce.Do(func() { - file_user_proto_rawDescData = protoimpl.X.CompressGZIP(file_user_proto_rawDescData) - }) - return file_user_proto_rawDescData -} - -var file_user_proto_msgTypes = make([]protoimpl.MessageInfo, 6) -var file_user_proto_goTypes = []interface{}{ - (*InsertReq)(nil), // 0: user.InsertReq - (*InsertRes)(nil), // 1: user.InsertRes - (*QueryReq)(nil), // 2: user.QueryReq - (*QueryRes)(nil), // 3: user.QueryRes - (*DeleteReq)(nil), // 4: user.DeleteReq - (*DeleteRes)(nil), // 5: user.DeleteRes -} -var file_user_proto_depIdxs = []int32{ - 0, // 0: user.User.Insert:input_type -> user.InsertReq - 2, // 1: user.User.Query:input_type -> user.QueryReq - 4, // 2: user.User.Delete:input_type -> user.DeleteReq - 1, // 3: user.User.Insert:output_type -> user.InsertRes - 3, // 4: user.User.Query:output_type -> user.QueryRes - 5, // 5: user.User.Delete:output_type -> user.DeleteRes - 3, // [3:6] is the sub-list for method output_type - 0, // [0:3] is the sub-list for method input_type - 0, // [0:0] is the sub-list for extension type_name - 0, // [0:0] is the sub-list for extension extendee - 0, // [0:0] is the sub-list for field type_name -} - -func init() { file_user_proto_init() } -func file_user_proto_init() { - if File_user_proto != nil { - return - } - if !protoimpl.UnsafeEnabled { - file_user_proto_msgTypes[0].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*InsertReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[1].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*InsertRes); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[2].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*QueryReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[3].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*QueryRes); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[4].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteReq); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - file_user_proto_msgTypes[5].Exporter = func(v interface{}, i int) interface{} { - switch v := v.(*DeleteRes); i { - case 0: - return &v.state - case 1: - return &v.sizeCache - case 2: - return &v.unknownFields - default: - return nil - } - } - } - type x struct{} - out := protoimpl.TypeBuilder{ - File: protoimpl.DescBuilder{ - GoPackagePath: reflect.TypeOf(x{}).PkgPath(), - RawDescriptor: file_user_proto_rawDesc, - NumEnums: 0, - NumMessages: 6, - NumExtensions: 0, - NumServices: 1, - }, - GoTypes: file_user_proto_goTypes, - DependencyIndexes: file_user_proto_depIdxs, - MessageInfos: file_user_proto_msgTypes, - }.Build() - File_user_proto = out.File - file_user_proto_rawDesc = nil - file_user_proto_goTypes = nil - file_user_proto_depIdxs = nil -} diff --git a/example/trace/grpc-with-db/protobuf/user/user.proto b/example/trace/grpc-with-db/protobuf/user/user.proto deleted file mode 100644 index bc9ad4dd460..00000000000 --- a/example/trace/grpc-with-db/protobuf/user/user.proto +++ /dev/null @@ -1,35 +0,0 @@ -// protoc --gofast_out=plugins=grpc:. \ -// protocol/user/*.proto \ -// -I/Users/john/Workspace/Go/GOPATH/src -syntax = "proto3"; - -package user; - -option go_package = "protobuf/user"; - -// User service for tracing demo. -service User { - rpc Insert(InsertReq) returns (InsertRes) {} - rpc Query(QueryReq) returns (QueryRes) {} - rpc Delete(DeleteReq) returns (DeleteRes) {} -} - -message InsertReq { - string Name = 1; // v: required#Please input user name. -} -message InsertRes { - int32 Id = 1; -} - -message QueryReq { - int32 Id = 1; // v: min:1#User id is required for querying. -} -message QueryRes { - int32 Id = 1; - string Name = 2; -} - -message DeleteReq { - int32 Id = 1; // v:min:1#User id is required for deleting. -} -message DeleteRes {} \ No newline at end of file diff --git a/example/trace/grpc-with-db/protobuf/user/user_grpc.pb.go b/example/trace/grpc-with-db/protobuf/user/user_grpc.pb.go deleted file mode 100644 index 3bdd9b34eef..00000000000 --- a/example/trace/grpc-with-db/protobuf/user/user_grpc.pb.go +++ /dev/null @@ -1,188 +0,0 @@ -// protoc --gofast_out=plugins=grpc:. \ -// protocol/user/*.proto \ -// -I/Users/john/Workspace/Go/GOPATH/src - -// Code generated by protoc-gen-go-grpc. DO NOT EDIT. -// versions: -// - protoc-gen-go-grpc v1.3.0 -// - protoc v3.21.12 -// source: user.proto - -package user - -import ( - context "context" - - grpc "google.golang.org/grpc" - codes "google.golang.org/grpc/codes" - status "google.golang.org/grpc/status" -) - -// This is a compile-time assertion to ensure that this generated file -// is compatible with the grpc package it is being compiled against. -// Requires gRPC-Go v1.32.0 or later. -const _ = grpc.SupportPackageIsVersion7 - -const ( - User_Insert_FullMethodName = "/user.User/Insert" - User_Query_FullMethodName = "/user.User/Query" - User_Delete_FullMethodName = "/user.User/Delete" -) - -// UserClient is the client API for User service. -// -// For semantics around ctx use and closing/ending streaming RPCs, please refer to https://pkg.go.dev/google.golang.org/grpc/?tab=doc#ClientConn.NewStream. -type UserClient interface { - Insert(ctx context.Context, in *InsertReq, opts ...grpc.CallOption) (*InsertRes, error) - Query(ctx context.Context, in *QueryReq, opts ...grpc.CallOption) (*QueryRes, error) - Delete(ctx context.Context, in *DeleteReq, opts ...grpc.CallOption) (*DeleteRes, error) -} - -type userClient struct { - cc grpc.ClientConnInterface -} - -func NewUserClient(cc grpc.ClientConnInterface) UserClient { - return &userClient{cc} -} - -func (c *userClient) Insert(ctx context.Context, in *InsertReq, opts ...grpc.CallOption) (*InsertRes, error) { - out := new(InsertRes) - err := c.cc.Invoke(ctx, User_Insert_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userClient) Query(ctx context.Context, in *QueryReq, opts ...grpc.CallOption) (*QueryRes, error) { - out := new(QueryRes) - err := c.cc.Invoke(ctx, User_Query_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -func (c *userClient) Delete(ctx context.Context, in *DeleteReq, opts ...grpc.CallOption) (*DeleteRes, error) { - out := new(DeleteRes) - err := c.cc.Invoke(ctx, User_Delete_FullMethodName, in, out, opts...) - if err != nil { - return nil, err - } - return out, nil -} - -// UserServer is the server API for User service. -// All implementations must embed UnimplementedUserServer -// for forward compatibility -type UserServer interface { - Insert(context.Context, *InsertReq) (*InsertRes, error) - Query(context.Context, *QueryReq) (*QueryRes, error) - Delete(context.Context, *DeleteReq) (*DeleteRes, error) - mustEmbedUnimplementedUserServer() -} - -// UnimplementedUserServer must be embedded to have forward compatible implementations. -type UnimplementedUserServer struct { -} - -func (UnimplementedUserServer) Insert(context.Context, *InsertReq) (*InsertRes, error) { - return nil, status.Errorf(codes.Unimplemented, "method Insert not implemented") -} -func (UnimplementedUserServer) Query(context.Context, *QueryReq) (*QueryRes, error) { - return nil, status.Errorf(codes.Unimplemented, "method Query not implemented") -} -func (UnimplementedUserServer) Delete(context.Context, *DeleteReq) (*DeleteRes, error) { - return nil, status.Errorf(codes.Unimplemented, "method Delete not implemented") -} -func (UnimplementedUserServer) mustEmbedUnimplementedUserServer() {} - -// UnsafeUserServer may be embedded to opt out of forward compatibility for this service. -// Use of this interface is not recommended, as added methods to UserServer will -// result in compilation errors. -type UnsafeUserServer interface { - mustEmbedUnimplementedUserServer() -} - -func RegisterUserServer(s grpc.ServiceRegistrar, srv UserServer) { - s.RegisterService(&User_ServiceDesc, srv) -} - -func _User_Insert_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(InsertReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServer).Insert(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: User_Insert_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServer).Insert(ctx, req.(*InsertReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _User_Query_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(QueryReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServer).Query(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: User_Query_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServer).Query(ctx, req.(*QueryReq)) - } - return interceptor(ctx, in, info, handler) -} - -func _User_Delete_Handler(srv interface{}, ctx context.Context, dec func(interface{}) error, interceptor grpc.UnaryServerInterceptor) (interface{}, error) { - in := new(DeleteReq) - if err := dec(in); err != nil { - return nil, err - } - if interceptor == nil { - return srv.(UserServer).Delete(ctx, in) - } - info := &grpc.UnaryServerInfo{ - Server: srv, - FullMethod: User_Delete_FullMethodName, - } - handler := func(ctx context.Context, req interface{}) (interface{}, error) { - return srv.(UserServer).Delete(ctx, req.(*DeleteReq)) - } - return interceptor(ctx, in, info, handler) -} - -// User_ServiceDesc is the grpc.ServiceDesc for User service. -// It's only intended for direct use with grpc.RegisterService, -// and not to be introspected or modified (even as a copy) -var User_ServiceDesc = grpc.ServiceDesc{ - ServiceName: "user.User", - HandlerType: (*UserServer)(nil), - Methods: []grpc.MethodDesc{ - { - MethodName: "Insert", - Handler: _User_Insert_Handler, - }, - { - MethodName: "Query", - Handler: _User_Query_Handler, - }, - { - MethodName: "Delete", - Handler: _User_Delete_Handler, - }, - }, - Streams: []grpc.StreamDesc{}, - Metadata: "user.proto", -} diff --git a/example/trace/grpc-with-db/server/config.yaml b/example/trace/grpc-with-db/server/config.yaml deleted file mode 100644 index aae30f16876..00000000000 --- a/example/trace/grpc-with-db/server/config.yaml +++ /dev/null @@ -1,31 +0,0 @@ - - -grpc: - name: "demo" - logStdout: true - errorLogEnabled: true - accessLogEnabled: true - errorStack: true - -# MySQL. -database: - logger: - level: "all" - stdout: true - default: - link: "mysql:root:12345678@tcp(127.0.0.1:3306)/test" - debug: true - -# Redis. -redis: - default: - address: 127.0.0.1:6379 - db: 0 - cache: - address: 127.0.0.1:6379 - db: 1 - - - - - diff --git a/example/trace/grpc-with-db/server/server.go b/example/trace/grpc-with-db/server/server.go deleted file mode 100644 index 3c11655f2a8..00000000000 --- a/example/trace/grpc-with-db/server/server.go +++ /dev/null @@ -1,101 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - "fmt" - "time" - - _ "github.com/gogf/gf/contrib/drivers/mysql/v2" - _ "github.com/gogf/gf/contrib/nosql/redis/v2" - - "github.com/gogf/gf/v2/database/gdb" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gcache" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/registry/etcd/v2" - "github.com/gogf/gf/contrib/rpc/grpcx/v2" - "github.com/gogf/gf/contrib/trace/otlpgrpc/v2" - - "github.com/gogf/gf/example/trace/grpc-with-db/protobuf/user" -) - -// Controller is the gRPC controller for user management. -type Controller struct { - user.UnimplementedUserServer -} - -const ( - serviceName = "otlp-grpc-server" - endpoint = "tracing-analysis-dc-bj.aliyuncs.com:8090" - traceToken = "******_******" -) - -func main() { - grpcx.Resolver.Register(etcd.New("127.0.0.1:2379")) - - var ( - ctx = gctx.New() - shutdown, err = otlpgrpc.Init(serviceName, endpoint, traceToken) - ) - - if err != nil { - g.Log().Fatal(ctx, err) - } - defer shutdown(ctx) - - // Set ORM cache adapter with redis. - g.DB().GetCache().SetAdapter(gcache.NewAdapterRedis(g.Redis())) - - s := grpcx.Server.New() - user.RegisterUserServer(s.Server, &Controller{}) - s.Run() -} - -// Insert is a route handler for inserting user info into database. -func (s *Controller) Insert(ctx context.Context, req *user.InsertReq) (res *user.InsertRes, err error) { - result, err := g.Model("user").Ctx(ctx).Insert(g.Map{ - "name": req.Name, - }) - if err != nil { - return nil, err - } - id, _ := result.LastInsertId() - res = &user.InsertRes{ - Id: int32(id), - } - return -} - -// Query is a route handler for querying user info. It firstly retrieves the info from redis, -// if there's nothing in the redis, it then does db select. -func (s *Controller) Query(ctx context.Context, req *user.QueryReq) (res *user.QueryRes, err error) { - if err = g.Model("user").Ctx(ctx).Cache(gdb.CacheOption{ - Duration: 5 * time.Second, - Name: s.userCacheKey(req.Id), - Force: false, - }).WherePri(req.Id).Scan(&res); err != nil { - return nil, err - } - return -} - -// Delete is a route handler for deleting specified user info. -func (s *Controller) Delete(ctx context.Context, req *user.DeleteReq) (res *user.DeleteRes, err error) { - err = g.Model("user").Ctx(ctx).Cache(gdb.CacheOption{ - Duration: -1, - Name: s.userCacheKey(req.Id), - Force: false, - }).WherePri(req.Id).Scan(&res) - return -} - -func (s *Controller) userCacheKey(id int32) string { - return fmt.Sprintf(`userInfo:%d`, id) -} diff --git a/example/trace/grpc-with-db/sql.sql b/example/trace/grpc-with-db/sql.sql deleted file mode 100644 index f763143c5fc..00000000000 --- a/example/trace/grpc-with-db/sql.sql +++ /dev/null @@ -1,6 +0,0 @@ -DROP TABLE IF EXISTS `user`; -CREATE TABLE `user` ( - `uid` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(45) NOT NULL, - PRIMARY KEY (`uid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file diff --git a/example/trace/http-with-db/client/client.go b/example/trace/http-with-db/client/client.go deleted file mode 100644 index 393ed3e95de..00000000000 --- a/example/trace/http-with-db/client/client.go +++ /dev/null @@ -1,89 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/database/gdb" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/net/gtrace" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/trace/otlphttp/v2" -) - -const ( - serviceName = "otlp-http-client-with-db" - endpoint = "tracing-analysis-dc-hz.aliyuncs.com" - path = "adapt_******_******/api/otlp/traces" -) - -func main() { - var ( - ctx = gctx.New() - shutdown, err = otlphttp.Init(serviceName, endpoint, path) - ) - - if err != nil { - g.Log().Fatal(ctx, err) - } - defer shutdown(ctx) - - StartRequests() -} - -// StartRequests starts requests. -func StartRequests() { - ctx, span := gtrace.NewSpan(gctx.New(), "StartRequests") - defer span.End() - - var ( - err error - client = g.Client() - ) - // Add user info. - var insertRes = struct { - ghttp.DefaultHandlerResponse - Data struct{ ID int64 } `json:"data"` - }{} - err = client.PostVar(ctx, "http://127.0.0.1:8199/user/insert", g.Map{ - "name": "john", - }).Scan(&insertRes) - if err != nil { - panic(err) - } - g.Log().Info(ctx, "insert result:", insertRes) - if insertRes.Data.ID == 0 { - g.Log().Error(ctx, "retrieve empty id string") - return - } - - // Query user info. - var queryRes = struct { - ghttp.DefaultHandlerResponse - Data struct{ User gdb.Record } `json:"data"` - }{} - err = client.GetVar(ctx, "http://127.0.0.1:8199/user/query", g.Map{ - "id": insertRes.Data.ID, - }).Scan(&queryRes) - if err != nil { - panic(err) - } - g.Log().Info(ctx, "query result:", queryRes) - - // Delete user info. - var deleteRes = struct { - ghttp.DefaultHandlerResponse - }{} - err = client.PostVar(ctx, "http://127.0.0.1:8199/user/delete", g.Map{ - "id": insertRes.Data.ID, - }).Scan(&deleteRes) - if err != nil { - panic(err) - } - g.Log().Info(ctx, "delete result:", deleteRes) -} diff --git a/example/trace/http-with-db/server/config.yaml b/example/trace/http-with-db/server/config.yaml deleted file mode 100644 index e010ebcaa5e..00000000000 --- a/example/trace/http-with-db/server/config.yaml +++ /dev/null @@ -1,23 +0,0 @@ - -# MySQL. -database: - logger: - level: "all" - stdout: true - default: - link: "mysql:root:12345678@tcp(127.0.0.1:3306)/test" - debug: true - -# Redis. -redis: - default: - address: 127.0.0.1:6379 - db: 0 - cache: - address: 127.0.0.1:6379 - db: 1 - - - - - diff --git a/example/trace/http-with-db/server/server.go b/example/trace/http-with-db/server/server.go deleted file mode 100644 index ce467e10904..00000000000 --- a/example/trace/http-with-db/server/server.go +++ /dev/null @@ -1,130 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - "fmt" - "time" - - _ "github.com/gogf/gf/contrib/drivers/mysql/v2" - - "github.com/gogf/gf/v2/database/gdb" - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/os/gcache" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/trace/otlphttp/v2" -) - -type cTrace struct{} - -const ( - serviceName = "otlp-http-server-with-db" - endpoint = "tracing-analysis-dc-hz.aliyuncs.com" - path = "adapt_******_******/api/otlp/traces" -) - -func main() { - var ( - ctx = gctx.New() - shutdown, err = otlphttp.Init(serviceName, endpoint, path) - ) - - if err != nil { - g.Log().Fatal(ctx, err) - } - defer shutdown(ctx) - - // Set ORM cache adapter with redis. - g.DB().GetCache().SetAdapter(gcache.NewAdapterRedis(g.Redis())) - - // Start HTTP server. - s := g.Server() - s.Use(ghttp.MiddlewareHandlerResponse) - s.Group("/", func(group *ghttp.RouterGroup) { - group.ALL("/user", new(cTrace)) - }) - s.SetPort(8199) - s.Run() -} - -// InsertReq is the input parameter for inserting user info. -type InsertReq struct { - Name string `v:"required#Please input user name."` -} - -// InsertRes is the output parameter for inserting user info. -type InsertRes struct { - ID int64 -} - -// Insert is a route handler for inserting user info into database. -func (c *cTrace) Insert(ctx context.Context, req *InsertReq) (res *InsertRes, err error) { - result, err := g.Model("user").Ctx(ctx).Insert(req) - if err != nil { - return nil, err - } - id, _ := result.LastInsertId() - res = &InsertRes{ - ID: id, - } - return -} - -// QueryReq is the input parameter for querying user info. -type QueryReq struct { - ID int `v:"min:1#User id is required for querying"` -} - -// QueryRes is the output parameter for querying user info. -type QueryRes struct { - User gdb.Record -} - -// Query is a route handler for querying user info. It firstly retrieves the info from redis, -// if there's nothing in the redis, it then does db select. -func (c *cTrace) Query(ctx context.Context, req *QueryReq) (res *QueryRes, err error) { - one, err := g.Model("user").Ctx(ctx).Cache(gdb.CacheOption{ - Duration: 5 * time.Second, - Name: c.userCacheKey(req.ID), - Force: false, - }).WherePri(req.ID).One() - if err != nil { - return nil, err - } - res = &QueryRes{ - User: one, - } - return -} - -// DeleteReq is the input parameter for deleting user info. -type DeleteReq struct { - Id int `v:"min:1#User id is required for deleting."` -} - -// DeleteRes is the output parameter for deleting user info. -type DeleteRes struct{} - -// Delete is a route handler for deleting specified user info. -func (c *cTrace) Delete(ctx context.Context, req *DeleteReq) (res *DeleteRes, err error) { - _, err = g.Model("user").Ctx(ctx).Cache(gdb.CacheOption{ - Duration: -1, - Name: c.userCacheKey(req.Id), - Force: false, - }).WherePri(req.Id).Delete() - if err != nil { - return nil, err - } - return -} - -func (c *cTrace) userCacheKey(id int) string { - return fmt.Sprintf(`userInfo:%d`, id) -} diff --git a/example/trace/http-with-db/sql.sql b/example/trace/http-with-db/sql.sql deleted file mode 100644 index f763143c5fc..00000000000 --- a/example/trace/http-with-db/sql.sql +++ /dev/null @@ -1,6 +0,0 @@ -DROP TABLE IF EXISTS `user`; -CREATE TABLE `user` ( - `uid` int(10) unsigned NOT NULL AUTO_INCREMENT, - `name` varchar(45) NOT NULL, - PRIMARY KEY (`uid`) -) ENGINE=InnoDB DEFAULT CHARSET=utf8; \ No newline at end of file diff --git a/example/trace/http/client/client.go b/example/trace/http/client/client.go deleted file mode 100644 index 8dd74683011..00000000000 --- a/example/trace/http/client/client.go +++ /dev/null @@ -1,45 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gtrace" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/trace/otlphttp/v2" -) - -const ( - serviceName = "otlp-http-client" - endpoint = "tracing-analysis-dc-hz.aliyuncs.com" - path = "adapt_******_******/api/otlp/traces" -) - -func main() { - var ( - ctx = gctx.New() - shutdown, err = otlphttp.Init(serviceName, endpoint, path) - ) - if err != nil { - g.Log().Fatal(ctx, err) - } - defer shutdown(ctx) - - StartRequests() -} - -// StartRequests is a demo for tracing. -func StartRequests() { - ctx, span := gtrace.NewSpan(gctx.New(), "StartRequests") - defer span.End() - - ctx = gtrace.SetBaggageValue(ctx, "name", "john") - - content := g.Client().GetContent(ctx, "http://127.0.0.1:8199/hello") - g.Log().Print(ctx, content) -} diff --git a/example/trace/http/server/server.go b/example/trace/http/server/server.go deleted file mode 100644 index de3114eac0b..00000000000 --- a/example/trace/http/server/server.go +++ /dev/null @@ -1,51 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/ghttp" - "github.com/gogf/gf/v2/net/gtrace" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/trace/otlphttp/v2" -) - -const ( - serviceName = "otlp-http-server" - endpoint = "tracing-analysis-dc-hz.aliyuncs.com" - path = "adapt_******_******/api/otlp/traces" -) - -func main() { - var ( - ctx = gctx.New() - shutdown, err = otlphttp.Init(serviceName, endpoint, path) - ) - - if err != nil { - g.Log().Fatal(ctx, err) - } - defer shutdown(ctx) - - s := g.Server() - s.Group("/", func(group *ghttp.RouterGroup) { - group.GET("/hello", HelloHandler) - }) - s.SetPort(8199) - s.Run() -} - -// HelloHandler is a demo handler for tracing. -func HelloHandler(r *ghttp.Request) { - ctx, span := gtrace.NewSpan(r.Context(), "HelloHandler") - defer span.End() - - value := gtrace.GetBaggageVar(ctx, "name").String() - - r.Response.Write("hello:", value) -} diff --git a/example/trace/inprocess-grpc/main.go b/example/trace/inprocess-grpc/main.go deleted file mode 100644 index 1e084b16c8f..00000000000 --- a/example/trace/inprocess-grpc/main.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gtrace" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/util/gutil" - - "github.com/gogf/gf/contrib/trace/otlpgrpc/v2" -) - -const ( - serviceName = "inprocess-grpc" - endpoint = "tracing-analysis-dc-bj.aliyuncs.com:8090" - traceToken = "******_******" -) - -func main() { - var ( - ctx = gctx.New() - shutdown, err = otlpgrpc.Init(serviceName, endpoint, traceToken) - ) - - if err != nil { - g.Log().Fatal(ctx, err) - } - defer shutdown(ctx) - - ctx, span := gtrace.NewSpan(ctx, "main") - defer span.End() - - // Trace 1. - user1 := GetUser(ctx, 1) - g.Dump(user1) - - // Trace 2. - user100 := GetUser(ctx, 100) - g.Dump(user100) -} - -// GetUser retrieves and returns hard coded user data for demonstration. -func GetUser(ctx context.Context, id int) g.Map { - ctx, span := gtrace.NewSpan(ctx, "GetUser") - defer span.End() - m := g.Map{} - gutil.MapMerge( - m, - GetInfo(ctx, id), - GetDetail(ctx, id), - GetScores(ctx, id), - ) - return m -} - -// GetInfo retrieves and returns hard coded user info for demonstration. -func GetInfo(ctx context.Context, id int) g.Map { - ctx, span := gtrace.NewSpan(ctx, "GetInfo") - defer span.End() - if id == 100 { - return g.Map{ - "id": 100, - "name": "john", - "gender": 1, - } - } - return nil -} - -// GetDetail retrieves and returns hard coded user detail for demonstration. -func GetDetail(ctx context.Context, id int) g.Map { - ctx, span := gtrace.NewSpan(ctx, "GetDetail") - defer span.End() - if id == 100 { - return g.Map{ - "site": "https://goframe.org", - "email": "john@goframe.org", - } - } - return nil -} - -// GetScores retrieves and returns hard coded user scores for demonstration. -func GetScores(ctx context.Context, id int) g.Map { - ctx, span := gtrace.NewSpan(ctx, "GetScores") - defer span.End() - if id == 100 { - return g.Map{ - "math": 100, - "english": 60, - "chinese": 50, - } - } - return nil -} diff --git a/example/trace/inprocess/main.go b/example/trace/inprocess/main.go deleted file mode 100644 index c7e7ffbda9c..00000000000 --- a/example/trace/inprocess/main.go +++ /dev/null @@ -1,102 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gtrace" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/util/gutil" - - "github.com/gogf/gf/contrib/trace/otlphttp/v2" -) - -const ( - serviceName = "inprocess" - endpoint = "localhost:6831" - path = "adapt_******_******/api/otlp/traces" -) - -func main() { - var ( - ctx = gctx.New() - shutdown, err = otlphttp.Init(serviceName, endpoint, path) - ) - - if err != nil { - g.Log().Fatal(ctx, err) - } - defer shutdown(ctx) - - ctx, span := gtrace.NewSpan(ctx, "main") - defer span.End() - - // Trace 1. - user1 := GetUser(ctx, 1) - g.Dump(user1) - - // Trace 2. - user100 := GetUser(ctx, 100) - g.Dump(user100) -} - -// GetUser retrieves and returns hard coded user data for demonstration. -func GetUser(ctx context.Context, id int) g.Map { - ctx, span := gtrace.NewSpan(ctx, "GetUser") - defer span.End() - m := g.Map{} - gutil.MapMerge( - m, - GetInfo(ctx, id), - GetDetail(ctx, id), - GetScores(ctx, id), - ) - return m -} - -// GetInfo retrieves and returns hard coded user info for demonstration. -func GetInfo(ctx context.Context, id int) g.Map { - ctx, span := gtrace.NewSpan(ctx, "GetInfo") - defer span.End() - if id == 100 { - return g.Map{ - "id": 100, - "name": "john", - "gender": 1, - } - } - return nil -} - -// GetDetail retrieves and returns hard coded user detail for demonstration. -func GetDetail(ctx context.Context, id int) g.Map { - ctx, span := gtrace.NewSpan(ctx, "GetDetail") - defer span.End() - if id == 100 { - return g.Map{ - "site": "https://goframe.org", - "email": "john@goframe.org", - } - } - return nil -} - -// GetScores retrieves and returns hard coded user scores for demonstration. -func GetScores(ctx context.Context, id int) g.Map { - ctx, span := gtrace.NewSpan(ctx, "GetScores") - defer span.End() - if id == 100 { - return g.Map{ - "math": 100, - "english": 60, - "chinese": 50, - } - } - return nil -} diff --git a/example/trace/otlp/README.md b/example/trace/otlp/README.md deleted file mode 100644 index d3d28e07e8f..00000000000 --- a/example/trace/otlp/README.md +++ /dev/null @@ -1,21 +0,0 @@ -# OTLP Exporter For OpenTelemetry - -## Usage - - -### Note: - All you need is the domain name and port, no need for 'http://' or 'https://', or path. - -## GRPC - -```html -endpoint: tracing-analysis-dc-hz.aliyuncs.com:8090 -traceToken: xxxxxxxxxx -``` - -## HTTP - -```html -endpoint: tracing-analysis-dc-hz.aliyuncs.com -path: /adapt_xxxxx/api/otlp/traces -``` diff --git a/example/trace/otlp/grpc/main.go b/example/trace/otlp/grpc/main.go deleted file mode 100644 index a20e63dba7b..00000000000 --- a/example/trace/otlp/grpc/main.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gtrace" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/trace/otlpgrpc/v2" -) - -const ( - serviceName = "otlp-grpc-client" - endpoint = "tracing-analysis-dc-bj.aliyuncs.com:8090" - traceToken = "******_******" -) - -func main() { - var ( - ctx = gctx.New() - shutdown, err = otlpgrpc.Init(serviceName, endpoint, traceToken) - ) - - if err != nil { - g.Log().Fatal(ctx, err) - } - defer shutdown(ctx) - - StartRequests() -} - -// StartRequests starts requests. -func StartRequests() { - ctx, span := gtrace.NewSpan(gctx.New(), "StartRequests") - defer span.End() - - ctx = gtrace.SetBaggageValue(ctx, "name", "john") - - content := g.Client().GetContent(ctx, "http://127.0.0.1:8199/hello") - g.Log().Print(ctx, content) -} diff --git a/example/trace/otlp/http/main.go b/example/trace/otlp/http/main.go deleted file mode 100644 index aa1454ebaf5..00000000000 --- a/example/trace/otlp/http/main.go +++ /dev/null @@ -1,46 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gtrace" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/contrib/trace/otlphttp/v2" -) - -const ( - serviceName = "otlp-http-client" - endpoint = "tracing-analysis-dc-hz.aliyuncs.com" - path = "adapt_******_******/api/otlp/traces" -) - -func main() { - var ( - ctx = gctx.New() - shutdown, err = otlphttp.Init(serviceName, endpoint, path) - ) - - if err != nil { - g.Log().Fatal(ctx, err) - } - defer shutdown(ctx) - - StartRequests() -} - -// StartRequests starts requests. -func StartRequests() { - ctx, span := gtrace.NewSpan(gctx.New(), "StartRequests") - defer span.End() - - ctx = gtrace.SetBaggageValue(ctx, "name", "john") - - content := g.Client().GetContent(ctx, "http://127.0.0.1:8199/hello") - g.Log().Print(ctx, content) -} diff --git a/example/trace/processes/gcmd/main.go b/example/trace/processes/gcmd/main.go deleted file mode 100644 index 8bf4faaf18f..00000000000 --- a/example/trace/processes/gcmd/main.go +++ /dev/null @@ -1,31 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gcmd" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/os/gproc" -) - -var ( - Main = &gcmd.Command{ - Name: "main", - Brief: "main process", - Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { - g.Log().Debug(ctx, `this is main process`) - return gproc.ShellRun(ctx, `go run sub/sub.go`) - }, - } -) - -func main() { - Main.Run(gctx.GetInitCtx()) -} diff --git a/example/trace/processes/gcmd/sub/sub.go b/example/trace/processes/gcmd/sub/sub.go deleted file mode 100644 index 63009235d6c..00000000000 --- a/example/trace/processes/gcmd/sub/sub.go +++ /dev/null @@ -1,30 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gcmd" - "github.com/gogf/gf/v2/os/gctx" -) - -var ( - Sub = &gcmd.Command{ - Name: "sub", - Brief: "sub process", - Func: func(ctx context.Context, parser *gcmd.Parser) (err error) { - g.Log().Debug(ctx, `this is sub process`) - return nil - }, - } -) - -func main() { - Sub.Run(gctx.GetInitCtx()) -} diff --git a/example/trace/processes/gproc/main.go b/example/trace/processes/gproc/main.go deleted file mode 100644 index f408f3990b3..00000000000 --- a/example/trace/processes/gproc/main.go +++ /dev/null @@ -1,21 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - "github.com/gogf/gf/v2/os/gproc" -) - -func main() { - ctx := gctx.GetInitCtx() - g.Log().Debug(ctx, `this is main process`) - if err := gproc.ShellRun(ctx, `go run sub/sub.go`); err != nil { - panic(err) - } -} diff --git a/example/trace/processes/gproc/sub/sub.go b/example/trace/processes/gproc/sub/sub.go deleted file mode 100644 index b928dda75fd..00000000000 --- a/example/trace/processes/gproc/sub/sub.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" -) - -func main() { - ctx := gctx.GetInitCtx() - g.Log().Debug(ctx, `this is sub process`) -} diff --git a/example/trace/provider/grpc/main.go b/example/trace/provider/grpc/main.go deleted file mode 100644 index 40a9a5aaad9..00000000000 --- a/example/trace/provider/grpc/main.go +++ /dev/null @@ -1,114 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -// Package main provides a simple example for OTLP tracing with gRPC client. -package main - -import ( - "context" - - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/exporters/otlp/otlptrace" - "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc" - "go.opentelemetry.io/otel/sdk/resource" - "go.opentelemetry.io/otel/sdk/trace" - semconv "go.opentelemetry.io/otel/semconv/v1.24.0" - "google.golang.org/grpc/encoding/gzip" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/example/trace/provider/internal" -) - -func main() { - var ( - serverIP, err = internal.GetLocalIP() - ctx = gctx.New() - ) - if err != nil { - g.Log().Fatal(ctx, err) - } - var res *resource.Resource - if res, err = resource.New(ctx, - // WithFromEnv returns a resource option that sets the resource attributes from the environment. - resource.WithFromEnv(), - // WithProcess returns a resource option that sets the process attributes. - resource.WithProcess(), - // WithTelemetrySDK returns a resource option that sets the telemetry SDK attributes. - resource.WithTelemetrySDK(), - // WithHost returns a resource option that sets the host attributes. - resource.WithHost(), - // WithAttributes returns a resource option that sets the resource attributes. - resource.WithAttributes( - // The name of the service displayed on the traceback end。 - semconv.ServiceNameKey.String(internal.GRPCServiceName), - // The IP address of the server. - semconv.HostNameKey.String(serverIP), - // The IP address of the server. - attribute.String(internal.TracerHostnameTagKey, serverIP), - ), - // WithOS returns a resource option that sets the OS attributes. - resource.WithOS(), - // WithProcessPID returns a resource option that sets the process PID attribute. - resource.WithProcessPID(), - // For more parameters, please customize the selection - ); err != nil { - g.Log().Fatal(ctx, err) - } - - var exporter *otlptrace.Exporter - if exporter, err = otlptrace.New(ctx, otlptracegrpc.NewClient( - // WithInsecure returns an otlptracegrpc.Option that disables transport security for the connection. - otlptracegrpc.WithInsecure(), - // WithEndpoint returns an otlptracegrpc.Option that sets the endpoint to which the exporter is going to send the spans. - otlptracegrpc.WithEndpoint(internal.Endpoint), // Replace the otel Agent Addr with the access point obtained in the prerequisite。 - // WithHeaders returns an otlptracegrpc.Option that sets the headers to be sent with gRPC requests. - otlptracegrpc.WithHeaders(map[string]string{"Authentication": internal.TraceToken}), - // WithCompressor returns an otlptracegrpc.Option that sets the compressor to be used for gRPC requests. - otlptracegrpc.WithCompressor(gzip.Name))); err != nil { - g.Log().Fatal(ctx, err) - } - var shutdown func(ctx context.Context) - // WithSampler sets the sampler for the trace provider. - // 1. AlwaysSample: AlwaysSample is a sampler that samples every trace. - // 2. NeverSample: NeverSample is a sampler that samples no traces. - // 3. ParentBased: ParentBased is a sampler that samples a trace based on the parent span. - // 4. TraceIDRatioBased: TraceIDRatioBased is a sampler that samples a trace based on the TraceID. - // WithResource sets the resource for the trace provider. - // WithSpanProcessor sets the span processor for the trace provider. - // 1. NewSimpleSpanProcessor: NewSimpleSpanProcessor returns a new SimpleSpanProcessor. - // 2. NewBatchSpanProcessor: NewBatchSpanProcessor returns a new BatchSpanProcessor. - // WithRawSpanLimits sets the raw span limits for the trace provider. - if shutdown, err = internal.InitTracer( - // WithSampler returns a trace option that sets the sampler for the trace provider. - // trace.WithSampler(trace.AlwaysSample()), - // trace.WithSampler(trace.NeverSample()), - // trace.WithSampler(trace.ParentBased(trace.AlwaysSample())), - // WithSampler returns a trace option that sets the sampler for the trace provider. - // 1. AlwaysSample: AlwaysSample is a sampler that samples every trace. - // 2. NeverSample: NeverSample is a sampler that samples no traces. - // 3. ParentBased: ParentBased is a sampler that samples a trace based on the parent span. - // 4. TraceIDRatioBased: TraceIDRatioBased is a sampler that samples a trace based on the TraceID. - trace.WithSampler(trace.TraceIDRatioBased(0.1)), - // WithResource returns a trace option that sets the resource for the trace provider. - trace.WithResource(res), - // WithSpanProcessor returns a trace option that sets the span processor for the trace provider. - // trace.WithSpanProcessor(trace.NewSimpleSpanProcessor(exporter)), - // trace.WithSpanProcessor(trace.NewBatchSpanProcessor(exporter)), - // 1. NewSimpleSpanProcessor: NewSimpleSpanProcessor returns a new SimpleSpanProcessor. - // 2. NewBatchSpanProcessor: NewBatchSpanProcessor returns a new BatchSpanProcessor. - trace.WithSpanProcessor(trace.NewBatchSpanProcessor(exporter)), - // WithRawSpanLimits returns a trace option that sets the raw span limits for the trace provider. - trace.WithRawSpanLimits(trace.NewSpanLimits()), - ); err != nil { - g.Log().Fatal(ctx, err) - } - - defer shutdown(ctx) - - internal.StartRequests() -} diff --git a/example/trace/provider/http/main.go b/example/trace/provider/http/main.go deleted file mode 100644 index c6f63a6350f..00000000000 --- a/example/trace/provider/http/main.go +++ /dev/null @@ -1,111 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package main - -import ( - "context" - - "go.opentelemetry.io/otel/attribute" - "go.opentelemetry.io/otel/exporters/otlp/otlptrace" - "go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp" - "go.opentelemetry.io/otel/sdk/resource" - "go.opentelemetry.io/otel/sdk/trace" - semconv "go.opentelemetry.io/otel/semconv/v1.24.0" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/os/gctx" - - "github.com/gogf/gf/example/trace/provider/internal" -) - -func main() { - var ( - serverIP, err = internal.GetLocalIP() - ctx = gctx.New() - ) - if err != nil { - g.Log().Fatal(ctx, err) - } - var res *resource.Resource - if res, err = resource.New(ctx, - // WithFromEnv returns a resource option that sets the resource attributes from the environment. - resource.WithFromEnv(), - // WithProcess returns a resource option that sets the process attributes. - resource.WithProcess(), - // WithTelemetrySDK returns a resource option that sets the telemetry SDK attributes. - resource.WithTelemetrySDK(), - // WithHost returns a resource option that sets the host attributes. - resource.WithHost(), - // WithAttributes returns a resource option that sets the resource attributes. - resource.WithAttributes( - // The name of the service displayed on the traceback end。 - semconv.ServiceNameKey.String(internal.HTTPServiceName), - // The IP address of the server. - semconv.HostNameKey.String(serverIP), - // The IP address of the server. - attribute.String(internal.TracerHostnameTagKey, serverIP), - ), - // WithOS returns a resource option that sets the OS attributes. - resource.WithOS(), - // WithProcessPID returns a resource option that sets the process PID attribute. - resource.WithProcessPID(), - // For more parameters, please customize the selection - ); err != nil { - g.Log().Fatal(ctx, err) - } - - var exporter *otlptrace.Exporter - if exporter, err = otlptrace.New(ctx, otlptracehttp.NewClient( - // WithEndpoint returns an otlptracehttp.Option that sets the endpoint to which the exporter is going to send the spans. - otlptracehttp.WithEndpoint(internal.HTTPEndpoint), - // WithHeaders returns an otlptracehttp.Option that sets the headers to be sent with HTTP requests. - otlptracehttp.WithURLPath(internal.HTTPPath), - // WithInsecure returns an otlptracehttp.Option that disables secure connection to the collector. - otlptracehttp.WithInsecure(), - // WithCompression returns an otlptracehttp.Option that sets the compression level for the exporter. - otlptracehttp.WithCompression(1))); err != nil { - g.Log().Fatal(ctx, err) - } - var shutdown func(ctx context.Context) - // WithSampler sets the sampler for the trace provider. - // 1. AlwaysSample: AlwaysSample is a sampler that samples every trace. - // 2. NeverSample: NeverSample is a sampler that samples no traces. - // 3. ParentBased: ParentBased is a sampler that samples a trace based on the parent span. - // 4. TraceIDRatioBased: TraceIDRatioBased is a sampler that samples a trace based on the TraceID. - // WithResource sets the resource for the trace provider. - // WithSpanProcessor sets the span processor for the trace provider. - // 1. NewSimpleSpanProcessor: NewSimpleSpanProcessor returns a new SimpleSpanProcessor. - // 2. NewBatchSpanProcessor: NewBatchSpanProcessor returns a new BatchSpanProcessor. - // WithRawSpanLimits sets the raw span limits for the trace provider. - if shutdown, err = internal.InitTracer( - // WithSampler returns a trace option that sets the sampler for the trace provider. - // trace.WithSampler(trace.AlwaysSample()), - // trace.WithSampler(trace.NeverSample()), - // trace.WithSampler(trace.ParentBased(trace.AlwaysSample())), - // WithSampler returns a trace option that sets the sampler for the trace provider. - // 1. AlwaysSample: AlwaysSample is a sampler that samples every trace. - // 2. NeverSample: NeverSample is a sampler that samples no traces. - // 3. ParentBased: ParentBased is a sampler that samples a trace based on the parent span. - // 4. TraceIDRatioBased: TraceIDRatioBased is a sampler that samples a trace based on the TraceID. - trace.WithSampler(trace.TraceIDRatioBased(0.1)), - // WithResource returns a trace option that sets the resource for the trace provider. - trace.WithResource(res), - // WithSpanProcessor returns a trace option that sets the span processor for the trace provider. - // trace.WithSpanProcessor(trace.NewSimpleSpanProcessor(exporter)), - // trace.WithSpanProcessor(trace.NewBatchSpanProcessor(exporter)), - // 1. NewSimpleSpanProcessor: NewSimpleSpanProcessor returns a new SimpleSpanProcessor. - // 2. NewBatchSpanProcessor: NewBatchSpanProcessor returns a new BatchSpanProcessor. - trace.WithSpanProcessor(trace.NewBatchSpanProcessor(exporter)), - // WithRawSpanLimits returns a trace option that sets the raw span limits for the trace provider. - trace.WithRawSpanLimits(trace.NewSpanLimits()), - ); err != nil { - g.Log().Fatal(ctx, err) - } - defer shutdown(ctx) - - internal.StartRequests() -} diff --git a/example/trace/provider/internal/consts.go b/example/trace/provider/internal/consts.go deleted file mode 100644 index 153c0720cc5..00000000000 --- a/example/trace/provider/internal/consts.go +++ /dev/null @@ -1,17 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package internal - -const ( - GRPCServiceName = "otlp-grpc-client" - Endpoint = "tracing-analysis-dc-bj.aliyuncs.com:8090" - TraceToken = "******_******" - HTTPServiceName = "otlp-http-client" - HTTPEndpoint = "tracing-analysis-dc-hz.aliyuncs.com" - HTTPPath = "adapt_******_******/api/otlp/traces" - TracerHostnameTagKey = "hostname" -) diff --git a/example/trace/provider/internal/provider.go b/example/trace/provider/internal/provider.go deleted file mode 100644 index f456d802807..00000000000 --- a/example/trace/provider/internal/provider.go +++ /dev/null @@ -1,57 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package internal - -import ( - "context" - "time" - - "go.opentelemetry.io/otel" - "go.opentelemetry.io/otel/propagation" - "go.opentelemetry.io/otel/sdk/trace" - - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gipv4" -) - -// InitTracer initializes and registers `otlpgrpc` or `otlphttp` to global TracerProvider. -func InitTracer(opts ...trace.TracerProviderOption) (func(ctx context.Context), error) { - tracerProvider := trace.NewTracerProvider(opts...) - // Set the global propagator to traceContext (not set by default). - otel.SetTextMapPropagator(propagation.NewCompositeTextMapPropagator(propagation.TraceContext{}, propagation.Baggage{})) - otel.SetTracerProvider(tracerProvider) - - return func(ctx context.Context) { - ctx, cancel := context.WithTimeout(ctx, time.Second) - defer cancel() - // Shutdown waits for exported trace spans to be uploaded. - if err := tracerProvider.Shutdown(ctx); err != nil { - g.Log().Errorf(ctx, "Shutdown tracerProvider failed err:%+v", err) - } else { - g.Log().Debug(ctx, "Shutdown tracerProvider success") - } - }, nil -} - -// GetLocalIP returns the IP address of the server. -func GetLocalIP() (string, error) { - var intranetIPArray, err = gipv4.GetIntranetIpArray() - if err != nil { - return "", err - } - - if len(intranetIPArray) == 0 { - if intranetIPArray, err = gipv4.GetIpArray(); err != nil { - return "", err - } - } - var hostIP = "NoHostIpFound" - if len(intranetIPArray) > 0 { - hostIP = intranetIPArray[0] - } - return hostIP, nil -} diff --git a/example/trace/provider/internal/request.go b/example/trace/provider/internal/request.go deleted file mode 100644 index d90f72457e9..00000000000 --- a/example/trace/provider/internal/request.go +++ /dev/null @@ -1,24 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package internal - -import ( - "github.com/gogf/gf/v2/frame/g" - "github.com/gogf/gf/v2/net/gtrace" - "github.com/gogf/gf/v2/os/gctx" -) - -// StartRequests starts requests. -func StartRequests() { - ctx, span := gtrace.NewSpan(gctx.New(), "StartRequests") - defer span.End() - - ctx = gtrace.SetBaggageValue(ctx, "name", "john") - - content := g.Client().GetContent(ctx, "http://127.0.0.1:8199/hello") - g.Log().Print(ctx, content) -} diff --git a/examples b/examples new file mode 160000 index 00000000000..a4a36715aa0 --- /dev/null +++ b/examples @@ -0,0 +1 @@ +Subproject commit a4a36715aa01a720f136536c772028ddeaff213d diff --git a/go.mod b/go.mod index 111d0b72c10..4d1a1940495 100644 --- a/go.mod +++ b/go.mod @@ -15,7 +15,7 @@ require ( go.opentelemetry.io/otel v1.32.0 go.opentelemetry.io/otel/sdk v1.32.0 go.opentelemetry.io/otel/trace v1.32.0 - golang.org/x/net v0.33.0 + golang.org/x/net v0.32.0 golang.org/x/text v0.21.0 gopkg.in/yaml.v3 v3.0.1 ) diff --git a/go.sum b/go.sum index e90708e72f3..67f84761dc8 100644 --- a/go.sum +++ b/go.sum @@ -62,8 +62,8 @@ go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5l go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= -golang.org/x/net v0.33.0 h1:74SYHlV8BIgHIFC/LrYkOGIwL19eTYXQ5wc6TBuO36I= -golang.org/x/net v0.33.0/go.mod h1:HXLR5J+9DxmrqMwG9qjGCxZ+zKXxBru04zlTvWlWuN4= +golang.org/x/net v0.32.0 h1:ZqPmj8Kzc+Y6e0+skZsuACbx+wzMgo5MQsJh9Qd6aYI= +golang.org/x/net v0.32.0/go.mod h1:CwU0IoeOlnQQWJ6ioyFrfRuomB8GKF6KbYXZVyeXNfs= golang.org/x/sys v0.0.0-20220811171246-fbc7d0a398ab/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.6.0/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/sys v0.28.0 h1:Fksou7UEQUWlKvIdsqzJmUmCX3cZuD2+P3XyyzwMhlA= diff --git a/net/gclient/gclient_websocket.go b/net/gclient/gclient_websocket.go index 3bdb38f0219..ffd0b808c46 100644 --- a/net/gclient/gclient_websocket.go +++ b/net/gclient/gclient_websocket.go @@ -15,11 +15,15 @@ import ( // WebSocketClient wraps the underlying websocket client connection // and provides convenient functions. +// +// Deprecated: please use third-party library for websocket client instead. type WebSocketClient struct { *websocket.Dialer } // NewWebSocket creates and returns a new WebSocketClient object. +// +// Deprecated: please use third-party library for websocket client instead. func NewWebSocket() *WebSocketClient { return &WebSocketClient{ &websocket.Dialer{ From f4074cd8159055b17df28a5ff6d7d6c04ef52a18 Mon Sep 17 00:00:00 2001 From: John Guo Date: Mon, 3 Mar 2025 16:43:21 +0800 Subject: [PATCH 091/102] fix(net/gclient): remove default discovery for gclient when Discovery feature enabled (#4174) --- Makefile | 3 +-- contrib/registry/file/file_z_http_test.go | 2 ++ examples | 2 +- net/gclient/gclient.go | 2 +- net/gclient/gclient_discovery.go | 11 +---------- util/gconv/gconv_struct.go | 2 +- .../structcache/structcache_cached_field_info.go | 4 ++-- .../structcache/structcache_cached_struct_info.go | 2 +- 8 files changed, 10 insertions(+), 18 deletions(-) diff --git a/Makefile b/Makefile index 46265203a92..85d4f529958 100644 --- a/Makefile +++ b/Makefile @@ -33,9 +33,8 @@ version: .PHONY: subup subup: @set -e; \ - cd examples; \ echo "Updating submodules..."; \ - git pull origin; \ + cd examples && git pull origin main; \ cd ..; # update and commit submodules diff --git a/contrib/registry/file/file_z_http_test.go b/contrib/registry/file/file_z_http_test.go index a1eac283b44..500837c3351 100644 --- a/contrib/registry/file/file_z_http_test.go +++ b/contrib/registry/file/file_z_http_test.go @@ -45,6 +45,7 @@ func Test_HTTP_Registry(t *testing.T) { gtest.C(t, func(t *gtest.T) { client := g.Client() + client.SetDiscovery(gsvc.GetRegistry()) client.SetPrefix(fmt.Sprintf("http://%s", svcName)) // GET t.Assert(client.GetContent(ctx, "/http-registry"), svcName) @@ -71,6 +72,7 @@ func Test_HTTP_Discovery_Disable(t *testing.T) { gtest.C(t, func(t *gtest.T) { client := g.Client() + client.SetDiscovery(gsvc.GetRegistry()) client.SetPrefix(fmt.Sprintf("http://%s", svcName)) result, err := client.Get(ctx, "/http-registry") defer result.Close() diff --git a/examples b/examples index a4a36715aa0..2544fee34dd 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit a4a36715aa01a720f136536c772028ddeaff213d +Subproject commit 2544fee34dd10e6914687f7335bd9e772215ce07 diff --git a/net/gclient/gclient.go b/net/gclient/gclient.go index f158808433b..10444a9fe5c 100644 --- a/net/gclient/gclient.go +++ b/net/gclient/gclient.go @@ -72,7 +72,7 @@ func New() *Client { header: make(map[string]string), cookies: make(map[string]string), builder: gsel.GetBuilder(), - discovery: gsvc.GetRegistry(), + discovery: nil, } c.header[httpHeaderUserAgent] = defaultClientAgent // It enables OpenTelemetry for client in default. diff --git a/net/gclient/gclient_discovery.go b/net/gclient/gclient_discovery.go index aa1a52f1aac..ff9a1df9d9f 100644 --- a/net/gclient/gclient_discovery.go +++ b/net/gclient/gclient_discovery.go @@ -16,7 +16,6 @@ import ( "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/net/gsel" "github.com/gogf/gf/v2/net/gsvc" - "github.com/gogf/gf/v2/text/gstr" ) type discoveryNode struct { @@ -39,7 +38,7 @@ var clientSelectorMap = gmap.New(true) // internalMiddlewareDiscovery is a client middleware that enables service discovery feature for client. func internalMiddlewareDiscovery(c *Client, r *http.Request) (response *Response, err error) { - if c.discovery == nil && !isServiceName(r.URL.Host) { + if c.discovery == nil { return c.Next(r) } var ( @@ -107,11 +106,3 @@ func updateSelectorNodesByService(ctx context.Context, selector gsel.Selector, s } return selector.Update(ctx, nodes) } - -// isServiceName checks and returns whether given input parameter is service name or not. -// It checks by whether the parameter is address by containing port delimiter character ':'. -// -// It does not contain any port number if using service discovery. -func isServiceName(serviceNameOrAddress string) bool { - return !gstr.Contains(serviceNameOrAddress, gsvc.EndpointHostPortDelimiter) -} diff --git a/util/gconv/gconv_struct.go b/util/gconv/gconv_struct.go index 57fadd7c9d3..cbb6eb0b0cf 100644 --- a/util/gconv/gconv_struct.go +++ b/util/gconv/gconv_struct.go @@ -367,7 +367,7 @@ func bindVarToStructField( customConverterInput reflect.Value ok bool ) - if cachedFieldInfo.IsCustomConvert { + if cachedFieldInfo.HasCustomConvert { if customConverterInput, ok = srcValue.(reflect.Value); !ok { customConverterInput = reflect.ValueOf(srcValue) } diff --git a/util/gconv/internal/structcache/structcache_cached_field_info.go b/util/gconv/internal/structcache/structcache_cached_field_info.go index 1009295e28e..6b07cae15cc 100644 --- a/util/gconv/internal/structcache/structcache_cached_field_info.go +++ b/util/gconv/internal/structcache/structcache_cached_field_info.go @@ -50,8 +50,8 @@ type CachedFieldInfoBase struct { // Purpose: reduce the interface asserting cost in runtime. IsCommonInterface bool - // IsCustomConvert marks there custom converting function for this field type. - IsCustomConvert bool + // HasCustomConvert marks there custom converting function for this field type. + HasCustomConvert bool // StructField is the type info of this field. StructField reflect.StructField diff --git a/util/gconv/internal/structcache/structcache_cached_struct_info.go b/util/gconv/internal/structcache/structcache_cached_struct_info.go index 24510737684..bf6a10aad91 100644 --- a/util/gconv/internal/structcache/structcache_cached_struct_info.go +++ b/util/gconv/internal/structcache/structcache_cached_struct_info.go @@ -99,7 +99,7 @@ func (csi *CachedStructInfo) makeCachedFieldInfo( StructField: field, FieldIndexes: fieldIndexes, ConvertFunc: csi.genFieldConvertFunc(field.Type.String()), - IsCustomConvert: csi.checkTypeHasCustomConvert(field.Type), + HasCustomConvert: csi.checkTypeHasCustomConvert(field.Type), PriorityTagAndFieldName: csi.genPriorityTagAndFieldName(field, priorityTags), RemoveSymbolsFieldName: utils.RemoveSymbols(field.Name), } From dfe088f5cd8c126dee6982a75360e1bb9f522200 Mon Sep 17 00:00:00 2001 From: John Guo Date: Thu, 6 Mar 2025 23:04:26 +0800 Subject: [PATCH 092/102] refactor(util/gconv): add `Converter` feature for more flexable and extensible type converting (#4107) --- .github/PULL_REQUEST_TEMPLATE.MD | 20 +- Makefile | 4 +- cmd/gf/internal/cmd/gendao/gendao.go | 2 +- container/gvar/gvar.go | 152 +--- container/gvar/gvar_basic.go | 105 +++ container/gvar/gvar_copy.go | 30 + container/gvar/gvar_scan.go | 3 +- container/gvar/gvar_set.go | 24 + container/gvar/gvar_time.go | 34 + .../mysql_z_unit_feature_model_struct_test.go | 115 --- .../drivers/mysql/mysql_z_unit_issue_test.go | 299 +++++++- .../drivers/mysql/mysql_z_unit_model_test.go | 3 + .../{issue1380.sql => issues/1380.sql} | 0 .../{issue1401.sql => issues/1401.sql} | 0 .../{issue1412.sql => issues/1412.sql} | 0 .../{issue2105.sql => issues/2105.sql} | 0 .../{issue2119.sql => issues/2119.sql} | 0 .../{issue2439.sql => issues/2439.sql} | 0 .../{issue2643.sql => issues/2643.sql} | 0 .../{issue3086.sql => issues/3086.sql} | 0 .../{issue3218.sql => issues/3218.sql} | 0 .../{issue3626.sql => issues/3626.sql} | 0 .../{issue3754.sql => issues/3754.sql} | 0 .../{issue3915.sql => issues/3915.sql} | 0 .../{issue4034.sql => issues/4034.sql} | 0 .../drivers/mysql/testdata/issues/4086.sql | 10 + contrib/drivers/pgsql/pgsql_convert.go | 2 +- database/gdb/gdb.go | 6 +- database/gdb/gdb_converter.go | 82 +++ database/gdb/gdb_core.go | 3 + database/gdb/gdb_core_structure.go | 16 +- database/gdb/gdb_core_underlying.go | 11 +- database/gdb/gdb_type_record.go | 5 +- database/gdb/gdb_type_result.go | 9 +- database/gdb/gdb_z_mysql_internal_test.go | 9 + examples | 2 +- net/ghttp/ghttp_z_unit_feature_config_test.go | 6 +- ...ghttp_z_unit_feature_router_strict_test.go | 1 - util/gconv/gconv.go | 163 ++++- util/gconv/gconv_basic.go | 303 +------- util/gconv/gconv_convert.go | 351 +--------- util/gconv/gconv_converter.go | 187 ----- util/gconv/gconv_float.go | 133 +--- util/gconv/gconv_int.go | 154 +--- util/gconv/gconv_map.go | 566 +-------------- util/gconv/gconv_maps.go | 68 +- util/gconv/gconv_maptomap.go | 119 +--- util/gconv/gconv_maptomaps.go | 115 +-- util/gconv/gconv_scan.go | 327 +-------- util/gconv/gconv_scan_list.go | 10 +- util/gconv/gconv_slice_any.go | 119 +--- util/gconv/gconv_slice_float.go | 256 +------ util/gconv/gconv_slice_int.go | 407 +---------- util/gconv/gconv_slice_str.go | 148 +--- util/gconv/gconv_slice_uint.go | 415 +---------- util/gconv/gconv_struct.go | 617 +--------------- util/gconv/gconv_structs.go | 121 +--- util/gconv/gconv_time.go | 72 +- util/gconv/gconv_uint.go | 158 +---- util/gconv/gconv_z_bench_struct_test.go | 2 +- util/gconv/gconv_z_unit_converter_test.go | 87 +++ util/gconv/internal/converter/converter.go | 180 +++++ .../internal/converter/converter_bool.go | 75 ++ .../internal/converter/converter_builtin.go | 89 +++ .../internal/converter/converter_bytes.go | 68 ++ .../internal/converter/converter_convert.go | 563 +++++++++++++++ .../internal/converter/converter_float.go | 147 ++++ .../gconv/internal/converter/converter_int.go | 157 +++++ .../gconv/internal/converter/converter_map.go | 646 +++++++++++++++++ .../internal/converter/converter_maptomap.go | 140 ++++ .../internal/converter/converter_maptomaps.go | 122 ++++ .../internal/converter/converter_rune.go | 31 + .../internal/converter/converter_scan.go | 395 +++++++++++ .../internal/converter/converter_slice_any.go | 143 ++++ .../converter/converter_slice_float.go | 417 +++++++++++ .../internal/converter/converter_slice_int.go | 536 ++++++++++++++ .../internal/converter/converter_slice_map.go | 59 ++ .../internal/converter/converter_slice_str.go | 220 ++++++ .../converter/converter_slice_uint.go | 527 ++++++++++++++ .../internal/converter/converter_string.go | 135 ++++ .../internal/converter/converter_struct.go | 662 ++++++++++++++++++ .../internal/converter/converter_structs.go | 120 ++++ .../internal/converter/converter_time.go | 111 +++ .../internal/converter/converter_uint.go | 161 +++++ .../internal/localinterface/localinterface.go | 14 +- .../gconv/internal/structcache/structcache.go | 76 +- .../structcache/structcache_cached.go | 53 +- .../structcache_cached_field_info.go | 4 +- .../structcache_cached_struct_info.go | 118 ++-- 89 files changed, 6870 insertions(+), 4950 deletions(-) create mode 100644 container/gvar/gvar_basic.go create mode 100644 container/gvar/gvar_copy.go create mode 100644 container/gvar/gvar_set.go create mode 100644 container/gvar/gvar_time.go rename contrib/drivers/mysql/testdata/{issue1380.sql => issues/1380.sql} (100%) rename contrib/drivers/mysql/testdata/{issue1401.sql => issues/1401.sql} (100%) rename contrib/drivers/mysql/testdata/{issue1412.sql => issues/1412.sql} (100%) rename contrib/drivers/mysql/testdata/{issue2105.sql => issues/2105.sql} (100%) rename contrib/drivers/mysql/testdata/{issue2119.sql => issues/2119.sql} (100%) rename contrib/drivers/mysql/testdata/{issue2439.sql => issues/2439.sql} (100%) rename contrib/drivers/mysql/testdata/{issue2643.sql => issues/2643.sql} (100%) rename contrib/drivers/mysql/testdata/{issue3086.sql => issues/3086.sql} (100%) rename contrib/drivers/mysql/testdata/{issue3218.sql => issues/3218.sql} (100%) rename contrib/drivers/mysql/testdata/{issue3626.sql => issues/3626.sql} (100%) rename contrib/drivers/mysql/testdata/{issue3754.sql => issues/3754.sql} (100%) rename contrib/drivers/mysql/testdata/{issue3915.sql => issues/3915.sql} (100%) rename contrib/drivers/mysql/testdata/{issue4034.sql => issues/4034.sql} (100%) create mode 100644 contrib/drivers/mysql/testdata/issues/4086.sql create mode 100644 database/gdb/gdb_converter.go delete mode 100644 util/gconv/gconv_converter.go create mode 100644 util/gconv/internal/converter/converter.go create mode 100644 util/gconv/internal/converter/converter_bool.go create mode 100644 util/gconv/internal/converter/converter_builtin.go create mode 100644 util/gconv/internal/converter/converter_bytes.go create mode 100644 util/gconv/internal/converter/converter_convert.go create mode 100644 util/gconv/internal/converter/converter_float.go create mode 100644 util/gconv/internal/converter/converter_int.go create mode 100644 util/gconv/internal/converter/converter_map.go create mode 100644 util/gconv/internal/converter/converter_maptomap.go create mode 100644 util/gconv/internal/converter/converter_maptomaps.go create mode 100644 util/gconv/internal/converter/converter_rune.go create mode 100644 util/gconv/internal/converter/converter_scan.go create mode 100644 util/gconv/internal/converter/converter_slice_any.go create mode 100644 util/gconv/internal/converter/converter_slice_float.go create mode 100644 util/gconv/internal/converter/converter_slice_int.go create mode 100644 util/gconv/internal/converter/converter_slice_map.go create mode 100644 util/gconv/internal/converter/converter_slice_str.go create mode 100644 util/gconv/internal/converter/converter_slice_uint.go create mode 100644 util/gconv/internal/converter/converter_string.go create mode 100644 util/gconv/internal/converter/converter_struct.go create mode 100644 util/gconv/internal/converter/converter_structs.go create mode 100644 util/gconv/internal/converter/converter_time.go create mode 100644 util/gconv/internal/converter/converter_uint.go diff --git a/.github/PULL_REQUEST_TEMPLATE.MD b/.github/PULL_REQUEST_TEMPLATE.MD index 4f959f68692..5a79a607ec7 100644 --- a/.github/PULL_REQUEST_TEMPLATE.MD +++ b/.github/PULL_REQUEST_TEMPLATE.MD @@ -1,16 +1,16 @@ **Please ensure you adhere to every item in this list.** + The PR title is formatted as follows: `[optional scope]: ` For example, `fix(os/gtime): fix time zone issue` + `` is mandatory and can be one of `fix`, `feat`, `build`, `ci`, `docs`, `style`, `refactor`, `perf`, `test`, `chore` - + fix: Used when a bug has been fixed. - + feat: Used when a new feature has been added. - + build: Used for modifications to the project build system, such as changes to dependencies, external interfaces, or upgrading Node version. - + ci: Used for modifications to continuous integration processes, such as changes to Travis, Jenkins workflow configurations. - + docs: Used for modifications to documentation, such as changes to README files, API documentation, etc. - + style: Used for changes to code style, such as adjustments to indentation, spaces, blank lines, etc. - + refactor: Used for code refactoring, such as changes to code structure, variable names, function names, without altering functionality. - + perf: Used for performance optimization, such as improving code performance, reducing memory usage, etc. - + test: Used for modifications to test cases, such as adding, deleting, or modifying test cases for code. - + chore: Used for modifications to non-business-related code, such as changes to build processes or tool configurations. + + `fix`: Used when a bug has been fixed. + + `feat`: Used when a new feature has been added. + + `build`: Used for modifications to the project build system, such as changes to dependencies, external interfaces, or upgrading Node version. + + `ci`: Used for modifications to continuous integration processes, such as changes to Travis, Jenkins workflow configurations. + + `docs`: Used for modifications to documentation, such as changes to README files, API documentation, etc. + + `style`: Used for changes to code style, such as adjustments to indentation, spaces, blank lines, etc. + + `refactor`: Used for code refactoring, such as changes to code structure, variable names, function names, without altering functionality. + + `perf`: Used for performance optimization, such as improving code performance, reducing memory usage, etc. + + `test`: Used for modifications to test cases, such as adding, deleting, or modifying test cases for code. + + `chore`: Used for modifications to non-business-related code, such as changes to build processes or tool configurations. + After ``, specify the affected package name or scope in parentheses, for example, `(os/gtime)`. + The part after the colon uses the verb tense + phrase that completes the blank in + Lowercase verb after the colon diff --git a/Makefile b/Makefile index 85d4f529958..03f69483951 100644 --- a/Makefile +++ b/Makefile @@ -34,8 +34,8 @@ version: subup: @set -e; \ echo "Updating submodules..."; \ - cd examples && git pull origin main; \ - cd ..; + git submodule init;\ + git submodule update; # update and commit submodules .PHONY: subsync diff --git a/cmd/gf/internal/cmd/gendao/gendao.go b/cmd/gf/internal/cmd/gendao/gendao.go index ff190a401cf..5c38c5c69a8 100644 --- a/cmd/gf/internal/cmd/gendao/gendao.go +++ b/cmd/gf/internal/cmd/gendao/gendao.go @@ -36,7 +36,7 @@ type ( Link string `name:"link" short:"l" brief:"{CGenDaoBriefLink}"` Tables string `name:"tables" short:"t" brief:"{CGenDaoBriefTables}"` TablesEx string `name:"tablesEx" short:"x" brief:"{CGenDaoBriefTablesEx}"` - ShardingPattern []string `name:"ShardingPattern" short:"sp" brief:"{CGenDaoBriefShardingPattern}"` + ShardingPattern []string `name:"shardingPattern" short:"sp" brief:"{CGenDaoBriefShardingPattern}"` Group string `name:"group" short:"g" brief:"{CGenDaoBriefGroup}" d:"default"` Prefix string `name:"prefix" short:"f" brief:"{CGenDaoBriefPrefix}"` RemovePrefix string `name:"removePrefix" short:"r" brief:"{CGenDaoBriefRemovePrefix}"` diff --git a/container/gvar/gvar.go b/container/gvar/gvar.go index 3f7781421c6..07cd9af69b6 100644 --- a/container/gvar/gvar.go +++ b/container/gvar/gvar.go @@ -8,14 +8,8 @@ package gvar import ( - "time" - "github.com/gogf/gf/v2/container/gtype" - "github.com/gogf/gf/v2/internal/deepcopy" "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/util/gconv" - "github.com/gogf/gf/v2/util/gutil" ) // Var is an universal variable type implementer. @@ -39,144 +33,8 @@ func New(value interface{}, safe ...bool) *Var { } } -// Copy does a deep copy of current Var and returns a pointer to this Var. -func (v *Var) Copy() *Var { - return New(gutil.Copy(v.Val()), v.safe) -} - -// Clone does a shallow copy of current Var and returns a pointer to this Var. -func (v *Var) Clone() *Var { - return New(v.Val(), v.safe) -} - -// Set sets `value` to `v`, and returns the old value. -func (v *Var) Set(value interface{}) (old interface{}) { - if v.safe { - if t, ok := v.value.(*gtype.Interface); ok { - old = t.Set(value) - return - } - } - old = v.value - v.value = value - return -} - -// Val returns the current value of `v`. -func (v *Var) Val() interface{} { - if v == nil { - return nil - } - if v.safe { - if t, ok := v.value.(*gtype.Interface); ok { - return t.Val() - } - } - return v.value -} - -// Interface is alias of Val. -func (v *Var) Interface() interface{} { - return v.Val() -} - -// Bytes converts and returns `v` as []byte. -func (v *Var) Bytes() []byte { - return gconv.Bytes(v.Val()) -} - -// String converts and returns `v` as string. -func (v *Var) String() string { - return gconv.String(v.Val()) -} - -// Bool converts and returns `v` as bool. -func (v *Var) Bool() bool { - return gconv.Bool(v.Val()) -} - -// Int converts and returns `v` as int. -func (v *Var) Int() int { - return gconv.Int(v.Val()) -} - -// Int8 converts and returns `v` as int8. -func (v *Var) Int8() int8 { - return gconv.Int8(v.Val()) -} - -// Int16 converts and returns `v` as int16. -func (v *Var) Int16() int16 { - return gconv.Int16(v.Val()) -} - -// Int32 converts and returns `v` as int32. -func (v *Var) Int32() int32 { - return gconv.Int32(v.Val()) -} - -// Int64 converts and returns `v` as int64. -func (v *Var) Int64() int64 { - return gconv.Int64(v.Val()) -} - -// Uint converts and returns `v` as uint. -func (v *Var) Uint() uint { - return gconv.Uint(v.Val()) -} - -// Uint8 converts and returns `v` as uint8. -func (v *Var) Uint8() uint8 { - return gconv.Uint8(v.Val()) -} - -// Uint16 converts and returns `v` as uint16. -func (v *Var) Uint16() uint16 { - return gconv.Uint16(v.Val()) -} - -// Uint32 converts and returns `v` as uint32. -func (v *Var) Uint32() uint32 { - return gconv.Uint32(v.Val()) -} - -// Uint64 converts and returns `v` as uint64. -func (v *Var) Uint64() uint64 { - return gconv.Uint64(v.Val()) -} - -// Float32 converts and returns `v` as float32. -func (v *Var) Float32() float32 { - return gconv.Float32(v.Val()) -} - -// Float64 converts and returns `v` as float64. -func (v *Var) Float64() float64 { - return gconv.Float64(v.Val()) -} - -// Time converts and returns `v` as time.Time. -// The parameter `format` specifies the format of the time string using gtime, -// eg: Y-m-d H:i:s. -func (v *Var) Time(format ...string) time.Time { - return gconv.Time(v.Val(), format...) -} - -// Duration converts and returns `v` as time.Duration. -// If value of `v` is string, then it uses time.ParseDuration for conversion. -func (v *Var) Duration() time.Duration { - return gconv.Duration(v.Val()) -} - -// GTime converts and returns `v` as *gtime.Time. -// The parameter `format` specifies the format of the time string using gtime, -// eg: Y-m-d H:i:s. -func (v *Var) GTime(format ...string) *gtime.Time { - return gconv.GTime(v.Val(), format...) -} - // MarshalJSON implements the interface MarshalJSON for json.Marshal. -func (v Var) MarshalJSON() ([]byte, error) { +func (v *Var) MarshalJSON() ([]byte, error) { return json.Marshal(v.Val()) } @@ -195,11 +53,3 @@ func (v *Var) UnmarshalValue(value interface{}) error { v.Set(value) return nil } - -// DeepCopy implements interface for deep copy of current type. -func (v *Var) DeepCopy() interface{} { - if v == nil { - return nil - } - return New(deepcopy.Copy(v.Val()), v.safe) -} diff --git a/container/gvar/gvar_basic.go b/container/gvar/gvar_basic.go new file mode 100644 index 00000000000..b57b235578d --- /dev/null +++ b/container/gvar/gvar_basic.go @@ -0,0 +1,105 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package gvar + +import ( + "github.com/gogf/gf/v2/container/gtype" + "github.com/gogf/gf/v2/util/gconv" +) + +// Val returns the current value of `v`. +func (v *Var) Val() any { + if v == nil { + return nil + } + if v.safe { + if t, ok := v.value.(*gtype.Interface); ok { + return t.Val() + } + } + return v.value +} + +// Interface is alias of Val. +func (v *Var) Interface() any { + return v.Val() +} + +// Bytes converts and returns `v` as []byte. +func (v *Var) Bytes() []byte { + return gconv.Bytes(v.Val()) +} + +// String converts and returns `v` as string. +func (v *Var) String() string { + return gconv.String(v.Val()) +} + +// Bool converts and returns `v` as bool. +func (v *Var) Bool() bool { + return gconv.Bool(v.Val()) +} + +// Int converts and returns `v` as int. +func (v *Var) Int() int { + return gconv.Int(v.Val()) +} + +// Int8 converts and returns `v` as int8. +func (v *Var) Int8() int8 { + return gconv.Int8(v.Val()) +} + +// Int16 converts and returns `v` as int16. +func (v *Var) Int16() int16 { + return gconv.Int16(v.Val()) +} + +// Int32 converts and returns `v` as int32. +func (v *Var) Int32() int32 { + return gconv.Int32(v.Val()) +} + +// Int64 converts and returns `v` as int64. +func (v *Var) Int64() int64 { + return gconv.Int64(v.Val()) +} + +// Uint converts and returns `v` as uint. +func (v *Var) Uint() uint { + return gconv.Uint(v.Val()) +} + +// Uint8 converts and returns `v` as uint8. +func (v *Var) Uint8() uint8 { + return gconv.Uint8(v.Val()) +} + +// Uint16 converts and returns `v` as uint16. +func (v *Var) Uint16() uint16 { + return gconv.Uint16(v.Val()) +} + +// Uint32 converts and returns `v` as uint32. +func (v *Var) Uint32() uint32 { + return gconv.Uint32(v.Val()) +} + +// Uint64 converts and returns `v` as uint64. +func (v *Var) Uint64() uint64 { + return gconv.Uint64(v.Val()) +} + +// Float32 converts and returns `v` as float32. +func (v *Var) Float32() float32 { + return gconv.Float32(v.Val()) +} + +// Float64 converts and returns `v` as float64. +func (v *Var) Float64() float64 { + return gconv.Float64(v.Val()) +} diff --git a/container/gvar/gvar_copy.go b/container/gvar/gvar_copy.go new file mode 100644 index 00000000000..a85d3748288 --- /dev/null +++ b/container/gvar/gvar_copy.go @@ -0,0 +1,30 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package gvar + +import ( + "github.com/gogf/gf/v2/internal/deepcopy" + "github.com/gogf/gf/v2/util/gutil" +) + +// Copy does a deep copy of current Var and returns a pointer to this Var. +func (v *Var) Copy() *Var { + return New(gutil.Copy(v.Val()), v.safe) +} + +// Clone does a shallow copy of current Var and returns a pointer to this Var. +func (v *Var) Clone() *Var { + return New(v.Val(), v.safe) +} + +// DeepCopy implements interface for deep copy of current type. +func (v *Var) DeepCopy() interface{} { + if v == nil { + return nil + } + return New(deepcopy.Copy(v.Val()), v.safe) +} diff --git a/container/gvar/gvar_scan.go b/container/gvar/gvar_scan.go index 469005b5034..5c38bfbfe6d 100644 --- a/container/gvar/gvar_scan.go +++ b/container/gvar/gvar_scan.go @@ -10,8 +10,7 @@ import ( "github.com/gogf/gf/v2/util/gconv" ) -// Scan automatically checks the type of `pointer` and converts `params` to `pointer`. It supports `pointer` -// with type of `*map/*[]map/*[]*map/*struct/**struct/*[]struct/*[]*struct` for converting. +// Scan automatically checks the type of `pointer` and converts value of Var to `pointer`. // // See gconv.Scan. func (v *Var) Scan(pointer interface{}, mapping ...map[string]string) error { diff --git a/container/gvar/gvar_set.go b/container/gvar/gvar_set.go new file mode 100644 index 00000000000..a00b2a627d4 --- /dev/null +++ b/container/gvar/gvar_set.go @@ -0,0 +1,24 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package gvar + +import ( + "github.com/gogf/gf/v2/container/gtype" +) + +// Set sets `value` to `v`, and returns the old value. +func (v *Var) Set(value interface{}) (old interface{}) { + if v.safe { + if t, ok := v.value.(*gtype.Interface); ok { + old = t.Set(value) + return + } + } + old = v.value + v.value = value + return +} diff --git a/container/gvar/gvar_time.go b/container/gvar/gvar_time.go new file mode 100644 index 00000000000..2f47ad0815a --- /dev/null +++ b/container/gvar/gvar_time.go @@ -0,0 +1,34 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package gvar + +import ( + "time" + + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/util/gconv" +) + +// Time converts and returns `v` as time.Time. +// The parameter `format` specifies the format of the time string using gtime, +// eg: Y-m-d H:i:s. +func (v *Var) Time(format ...string) time.Time { + return gconv.Time(v.Val(), format...) +} + +// Duration converts and returns `v` as time.Duration. +// If value of `v` is string, then it uses time.ParseDuration for conversion. +func (v *Var) Duration() time.Duration { + return gconv.Duration(v.Val()) +} + +// GTime converts and returns `v` as *gtime.Time. +// The parameter `format` specifies the format of the time string using gtime, +// eg: Y-m-d H:i:s. +func (v *Var) GTime(format ...string) *gtime.Time { + return gconv.GTime(v.Val(), format...) +} diff --git a/contrib/drivers/mysql/mysql_z_unit_feature_model_struct_test.go b/contrib/drivers/mysql/mysql_z_unit_feature_model_struct_test.go index 7d9902c799b..1463c4080db 100644 --- a/contrib/drivers/mysql/mysql_z_unit_feature_model_struct_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_feature_model_struct_test.go @@ -17,7 +17,6 @@ import ( "github.com/gogf/gf/v2/frame/g" "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/test/gtest" - "github.com/gogf/gf/v2/text/gstr" "github.com/gogf/gf/v2/util/gconv" ) @@ -481,117 +480,3 @@ func Test_Scan_AutoFilteringByStructAttributes(t *testing.T) { t.Assert(users[0].Id, 1) }) } - -func Test_Scan_JsonAttributes(t *testing.T) { - type GiftImage struct { - Uid string `json:"uid"` - Url string `json:"url"` - Status string `json:"status"` - Name string `json:"name"` - } - - type GiftComment struct { - Name string `json:"name"` - Field string `json:"field"` - Required bool `json:"required"` - } - - type Prop struct { - Name string `json:"name"` - Values []string `json:"values"` - } - - type Sku struct { - GiftId int64 `json:"gift_id"` - Name string `json:"name"` - ScorePrice int `json:"score_price"` - MarketPrice int `json:"market_price"` - CostPrice int `json:"cost_price"` - Stock int `json:"stock"` - } - - type Covers struct { - List []GiftImage `json:"list"` - } - - type GiftEntity struct { - Id int64 `json:"id"` - StoreId int64 `json:"store_id"` - GiftType int `json:"gift_type"` - GiftName string `json:"gift_name"` - Description string `json:"description"` - Covers Covers `json:"covers"` - Cover string `json:"cover"` - GiftCategoryId []int64 `json:"gift_category_id"` - HasProps bool `json:"has_props"` - OutSn string `json:"out_sn"` - IsLimitSell bool `json:"is_limit_sell"` - LimitSellType int `json:"limit_sell_type"` - LimitSellCycle string `json:"limit_sell_cycle"` - LimitSellCycleCount int `json:"limit_sell_cycle_count"` - LimitSellCustom bool `json:"limit_sell_custom"` // 只允许特定会员兑换 - LimitCustomerTags []int64 `json:"limit_customer_tags"` // 允许兑换的成员 - ScorePrice int `json:"score_price"` - MarketPrice float64 `json:"market_price"` - CostPrice int `json:"cost_price"` - Stock int `json:"stock"` - Props []Prop `json:"props"` - Skus []Sku `json:"skus"` - ExpressType []string `json:"express_type"` - Comments []GiftComment `json:"comments"` - Content string `json:"content"` - AtLeastRechargeCount int `json:"at_least_recharge_count"` - Status int `json:"status"` - } - - type User struct { - Id int - Passport string - } - - table := "jfy_gift" - array := gstr.SplitAndTrim(gtest.DataContent(`issue1380.sql`), ";") - for _, v := range array { - if _, err := db.Exec(ctx, v); err != nil { - gtest.Error(err) - } - } - defer dropTable(table) - - gtest.C(t, func(t *gtest.T) { - var ( - entity = new(GiftEntity) - err = db.Model(table).Where("id", 17).Scan(entity) - ) - t.AssertNil(err) - t.Assert(len(entity.Skus), 2) - - t.Assert(entity.Skus[0].Name, "red") - t.Assert(entity.Skus[0].Stock, 10) - t.Assert(entity.Skus[0].GiftId, 1) - t.Assert(entity.Skus[0].CostPrice, 80) - t.Assert(entity.Skus[0].ScorePrice, 188) - t.Assert(entity.Skus[0].MarketPrice, 388) - - t.Assert(entity.Skus[1].Name, "blue") - t.Assert(entity.Skus[1].Stock, 100) - t.Assert(entity.Skus[1].GiftId, 2) - t.Assert(entity.Skus[1].CostPrice, 81) - t.Assert(entity.Skus[1].ScorePrice, 200) - t.Assert(entity.Skus[1].MarketPrice, 288) - - t.Assert(entity.Id, 17) - t.Assert(entity.StoreId, 100004) - t.Assert(entity.GiftType, 1) - t.Assert(entity.GiftName, "GIFT") - t.Assert(entity.Description, "支持个性定制的父亲节老师长辈的专属礼物") - t.Assert(len(entity.Covers.List), 3) - t.Assert(entity.OutSn, "259402") - t.Assert(entity.LimitCustomerTags, "[]") - t.Assert(entity.ScorePrice, 10) - t.Assert(len(entity.Props), 1) - t.Assert(len(entity.Comments), 2) - t.Assert(entity.Status, 99) - t.Assert(entity.Content, `

礼品详情

`) - }) -} diff --git a/contrib/drivers/mysql/mysql_z_unit_issue_test.go b/contrib/drivers/mysql/mysql_z_unit_issue_test.go index af4e43b29e1..7f7f0a85401 100644 --- a/contrib/drivers/mysql/mysql_z_unit_issue_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_issue_test.go @@ -8,6 +8,7 @@ package mysql_test import ( "context" + "encoding/json" "fmt" "sync" "testing" @@ -24,6 +25,121 @@ import ( "github.com/gogf/gf/v2/util/guid" ) +// https://github.com/gogf/gf/issues/1380 +func Test_Issue1380(t *testing.T) { + type GiftImage struct { + Uid string `json:"uid"` + Url string `json:"url"` + Status string `json:"status"` + Name string `json:"name"` + } + + type GiftComment struct { + Name string `json:"name"` + Field string `json:"field"` + Required bool `json:"required"` + } + + type Prop struct { + Name string `json:"name"` + Values []string `json:"values"` + } + + type Sku struct { + GiftId int64 `json:"gift_id"` + Name string `json:"name"` + ScorePrice int `json:"score_price"` + MarketPrice int `json:"market_price"` + CostPrice int `json:"cost_price"` + Stock int `json:"stock"` + } + + type Covers struct { + List []GiftImage `json:"list"` + } + + type GiftEntity struct { + Id int64 `json:"id"` + StoreId int64 `json:"store_id"` + GiftType int `json:"gift_type"` + GiftName string `json:"gift_name"` + Description string `json:"description"` + Covers Covers `json:"covers"` + Cover string `json:"cover"` + GiftCategoryId []int64 `json:"gift_category_id"` + HasProps bool `json:"has_props"` + OutSn string `json:"out_sn"` + IsLimitSell bool `json:"is_limit_sell"` + LimitSellType int `json:"limit_sell_type"` + LimitSellCycle string `json:"limit_sell_cycle"` + LimitSellCycleCount int `json:"limit_sell_cycle_count"` + LimitSellCustom bool `json:"limit_sell_custom"` // 只允许特定会员兑换 + LimitCustomerTags []int64 `json:"limit_customer_tags"` // 允许兑换的成员 + ScorePrice int `json:"score_price"` + MarketPrice float64 `json:"market_price"` + CostPrice int `json:"cost_price"` + Stock int `json:"stock"` + Props []Prop `json:"props"` + Skus []Sku `json:"skus"` + ExpressType []string `json:"express_type"` + Comments []GiftComment `json:"comments"` + Content string `json:"content"` + AtLeastRechargeCount int `json:"at_least_recharge_count"` + Status int `json:"status"` + } + + type User struct { + Id int + Passport string + } + + table := "jfy_gift" + array := gstr.SplitAndTrim(gtest.DataContent(`issues`, `1380.sql`), ";") + for _, v := range array { + if _, err := db.Exec(ctx, v); err != nil { + gtest.Error(err) + } + } + defer dropTable(table) + + gtest.C(t, func(t *gtest.T) { + var ( + entity = new(GiftEntity) + err = db.Model(table).Where("id", 17).Scan(entity) + ) + t.AssertNil(err) + t.Assert(len(entity.Skus), 2) + + t.Assert(entity.Skus[0].Name, "red") + t.Assert(entity.Skus[0].Stock, 10) + t.Assert(entity.Skus[0].GiftId, 1) + t.Assert(entity.Skus[0].CostPrice, 80) + t.Assert(entity.Skus[0].ScorePrice, 188) + t.Assert(entity.Skus[0].MarketPrice, 388) + + t.Assert(entity.Skus[1].Name, "blue") + t.Assert(entity.Skus[1].Stock, 100) + t.Assert(entity.Skus[1].GiftId, 2) + t.Assert(entity.Skus[1].CostPrice, 81) + t.Assert(entity.Skus[1].ScorePrice, 200) + t.Assert(entity.Skus[1].MarketPrice, 288) + + t.Assert(entity.Id, 17) + t.Assert(entity.StoreId, 100004) + t.Assert(entity.GiftType, 1) + t.Assert(entity.GiftName, "GIFT") + t.Assert(entity.Description, "支持个性定制的父亲节老师长辈的专属礼物") + t.Assert(len(entity.Covers.List), 3) + t.Assert(entity.OutSn, "259402") + t.Assert(entity.LimitCustomerTags, "[]") + t.Assert(entity.ScorePrice, 10) + t.Assert(len(entity.Props), 1) + t.Assert(len(entity.Comments), 2) + t.Assert(entity.Status, 99) + t.Assert(entity.Content, `

礼品详情

`) + }) +} + // https://github.com/gogf/gf/issues/1934 func Test_Issue1934(t *testing.T) { table := createInitTable() @@ -170,7 +286,7 @@ func Test_Issue1401(t *testing.T) { table1 = "parcels" table2 = "parcel_items" ) - array := gstr.SplitAndTrim(gtest.DataContent(`issue1401.sql`), ";") + array := gstr.SplitAndTrim(gtest.DataContent(`issues`, `1401.sql`), ";") for _, v := range array { if _, err := db.Exec(ctx, v); err != nil { gtest.Error(err) @@ -212,7 +328,7 @@ func Test_Issue1412(t *testing.T) { table1 = "parcels" table2 = "items" ) - array := gstr.SplitAndTrim(gtest.DataContent(`issue1412.sql`), ";") + array := gstr.SplitAndTrim(gtest.DataContent(`issues`, `1412.sql`), ";") for _, v := range array { if _, err := db.Exec(ctx, v); err != nil { gtest.Error(err) @@ -474,7 +590,7 @@ func Test_Issue2012(t *testing.T) { // https://github.com/gogf/gf/issues/2105 func Test_Issue2105(t *testing.T) { table := "issue2105" - array := gstr.SplitAndTrim(gtest.DataContent(`issue2105.sql`), ";") + array := gstr.SplitAndTrim(gtest.DataContent(`issues`, `2105.sql`), ";") for _, v := range array { if _, err := db.Exec(ctx, v); err != nil { gtest.Error(err) @@ -772,7 +888,7 @@ func Test_Issue2561(t *testing.T) { // https://github.com/gogf/gf/issues/2439 func Test_Issue2439(t *testing.T) { gtest.C(t, func(t *gtest.T) { - array := gstr.SplitAndTrim(gtest.DataContent(`issue2439.sql`), ";") + array := gstr.SplitAndTrim(gtest.DataContent(`issues`, `2439.sql`), ";") for _, v := range array { if _, err := db.Exec(ctx, v); err != nil { gtest.Error(err) @@ -868,7 +984,7 @@ func Test_Issue2907(t *testing.T) { // https://github.com/gogf/gf/issues/3086 func Test_Issue3086(t *testing.T) { table := "issue3086_user" - array := gstr.SplitAndTrim(gtest.DataContent(`issue3086.sql`), ";") + array := gstr.SplitAndTrim(gtest.DataContent(`issues`, `3086.sql`), ";") for _, v := range array { if _, err := db.Exec(ctx, v); err != nil { gtest.Error(err) @@ -1013,7 +1129,7 @@ func Test_Issue3204(t *testing.T) { // https://github.com/gogf/gf/issues/3218 func Test_Issue3218(t *testing.T) { table := "issue3218_sys_config" - array := gstr.SplitAndTrim(gtest.DataContent(`issue3218.sql`), ";") + array := gstr.SplitAndTrim(gtest.DataContent(`issues`, `3218.sql`), ";") for _, v := range array { if _, err := db.Exec(ctx, v); err != nil { gtest.Error(err) @@ -1136,7 +1252,7 @@ func Test_Issue2552_ClearTableFields(t *testing.T) { // https://github.com/gogf/gf/issues/2643 func Test_Issue2643(t *testing.T) { table := "issue2643" - array := gstr.SplitAndTrim(gtest.DataContent(`issue2643.sql`), ";") + array := gstr.SplitAndTrim(gtest.DataContent(`issues`, `2643.sql`), ";") for _, v := range array { if _, err := db.Exec(ctx, v); err != nil { gtest.Error(err) @@ -1221,7 +1337,7 @@ func Test_Issue3649(t *testing.T) { // https://github.com/gogf/gf/issues/3754 func Test_Issue3754(t *testing.T) { table := "issue3754" - array := gstr.SplitAndTrim(gtest.DataContent(`issue3754.sql`), ";") + array := gstr.SplitAndTrim(gtest.DataContent(`issues`, `3754.sql`), ";") for _, v := range array { if _, err := db.Exec(ctx, v); err != nil { gtest.Error(err) @@ -1283,7 +1399,7 @@ func Test_Issue3754(t *testing.T) { // https://github.com/gogf/gf/issues/3626 func Test_Issue3626(t *testing.T) { table := "issue3626" - array := gstr.SplitAndTrim(gtest.DataContent(`issue3626.sql`), ";") + array := gstr.SplitAndTrim(gtest.DataContent(`issues`, `3626.sql`), ";") defer dropTable(table) for _, v := range array { if _, err := db.Exec(ctx, v); err != nil { @@ -1413,7 +1529,7 @@ func Test_Issue3968(t *testing.T) { // https://github.com/gogf/gf/issues/3915 func Test_Issue3915(t *testing.T) { table := "issue3915" - array := gstr.SplitAndTrim(gtest.DataContent(`issue3915.sql`), ";") + array := gstr.SplitAndTrim(gtest.DataContent(`issues`, `3915.sql`), ";") for _, v := range array { if _, err := db.Exec(ctx, v); err != nil { gtest.Error(err) @@ -1500,7 +1616,7 @@ func Test_Issue2119(t *testing.T) { defer dropTable(tables[0]) defer dropTable(tables[1]) _ = tables - array := gstr.SplitAndTrim(gtest.DataContent(`issue2119.sql`), ";") + array := gstr.SplitAndTrim(gtest.DataContent(`issues`, `2119.sql`), ";") for _, v := range array { _, err := db.Exec(ctx, v) t.AssertNil(err) @@ -1561,7 +1677,7 @@ func Test_Issue2119(t *testing.T) { func Test_Issue4034(t *testing.T) { gtest.C(t, func(t *gtest.T) { table := "issue4034" - array := gstr.SplitAndTrim(gtest.DataContent(`issue4034.sql`), ";") + array := gstr.SplitAndTrim(gtest.DataContent(`issues`, `4034.sql`), ";") for _, v := range array { _, err := db.Exec(ctx, v) t.AssertNil(err) @@ -1590,3 +1706,162 @@ func issue4034SaveAppDevice(ctx context.Context, table string, tx gdb.TX) error }).Save() return err } + +// https://github.com/gogf/gf/issues/4086 +func Test_Issue4086(t *testing.T) { + table := "issue4086" + defer dropTable(table) + array := gstr.SplitAndTrim(gtest.DataContent(`issues`, `4086.sql`), ";") + for _, v := range array { + _, err := db.Exec(ctx, v) + gtest.AssertNil(err) + } + + gtest.C(t, func(t *gtest.T) { + type ProxyParam struct { + ProxyId int64 `json:"proxyId" orm:"proxy_id"` + RecommendIds []int64 `json:"recommendIds" orm:"recommend_ids"` + Photos []int64 `json:"photos" orm:"photos"` + } + + var proxyParamList []*ProxyParam + err := db.Model(table).Ctx(ctx).Scan(&proxyParamList) + t.AssertNil(err) + t.Assert(len(proxyParamList), 2) + t.Assert(proxyParamList, []*ProxyParam{ + { + ProxyId: 1, + RecommendIds: []int64{584, 585}, + Photos: nil, + }, + { + ProxyId: 2, + RecommendIds: []int64{}, + Photos: nil, + }, + }) + }) + + gtest.C(t, func(t *gtest.T) { + type ProxyParam struct { + ProxyId int64 `json:"proxyId" orm:"proxy_id"` + RecommendIds []int64 `json:"recommendIds" orm:"recommend_ids"` + Photos []float32 `json:"photos" orm:"photos"` + } + + var proxyParamList []*ProxyParam + err := db.Model(table).Ctx(ctx).Scan(&proxyParamList) + t.AssertNil(err) + t.Assert(len(proxyParamList), 2) + t.Assert(proxyParamList, []*ProxyParam{ + { + ProxyId: 1, + RecommendIds: []int64{584, 585}, + Photos: nil, + }, + { + ProxyId: 2, + RecommendIds: []int64{}, + Photos: nil, + }, + }) + }) + + gtest.C(t, func(t *gtest.T) { + type ProxyParam struct { + ProxyId int64 `json:"proxyId" orm:"proxy_id"` + RecommendIds []int64 `json:"recommendIds" orm:"recommend_ids"` + Photos []string `json:"photos" orm:"photos"` + } + + var proxyParamList []*ProxyParam + err := db.Model(table).Ctx(ctx).Scan(&proxyParamList) + t.AssertNil(err) + t.Assert(len(proxyParamList), 2) + t.Assert(proxyParamList, []*ProxyParam{ + { + ProxyId: 1, + RecommendIds: []int64{584, 585}, + Photos: nil, + }, + { + ProxyId: 2, + RecommendIds: []int64{}, + Photos: nil, + }, + }) + }) + + gtest.C(t, func(t *gtest.T) { + type ProxyParam struct { + ProxyId int64 `json:"proxyId" orm:"proxy_id"` + RecommendIds []int64 `json:"recommendIds" orm:"recommend_ids"` + Photos []any `json:"photos" orm:"photos"` + } + + var proxyParamList []*ProxyParam + err := db.Model(table).Ctx(ctx).Scan(&proxyParamList) + t.AssertNil(err) + t.Assert(len(proxyParamList), 2) + t.Assert(proxyParamList, []*ProxyParam{ + { + ProxyId: 1, + RecommendIds: []int64{584, 585}, + Photos: nil, + }, + { + ProxyId: 2, + RecommendIds: []int64{}, + Photos: nil, + }, + }) + }) + gtest.C(t, func(t *gtest.T) { + type ProxyParam struct { + ProxyId int64 `json:"proxyId" orm:"proxy_id"` + RecommendIds []int64 `json:"recommendIds" orm:"recommend_ids"` + Photos string `json:"photos" orm:"photos"` + } + + var proxyParamList []*ProxyParam + err := db.Model(table).Ctx(ctx).Scan(&proxyParamList) + t.AssertNil(err) + t.Assert(len(proxyParamList), 2) + t.Assert(proxyParamList, []*ProxyParam{ + { + ProxyId: 1, + RecommendIds: []int64{584, 585}, + Photos: "null", + }, + { + ProxyId: 2, + RecommendIds: []int64{}, + Photos: "", + }, + }) + }) + gtest.C(t, func(t *gtest.T) { + type ProxyParam struct { + ProxyId int64 `json:"proxyId" orm:"proxy_id"` + RecommendIds string `json:"recommendIds" orm:"recommend_ids"` + Photos json.RawMessage `json:"photos" orm:"photos"` + } + + var proxyParamList []*ProxyParam + err := db.Model(table).Ctx(ctx).Scan(&proxyParamList) + t.AssertNil(err) + t.Assert(len(proxyParamList), 2) + t.Assert(proxyParamList, []*ProxyParam{ + { + ProxyId: 1, + RecommendIds: "[584, 585]", + Photos: json.RawMessage("null"), + }, + { + ProxyId: 2, + RecommendIds: "[]", + Photos: json.RawMessage("null"), + }, + }) + }) +} diff --git a/contrib/drivers/mysql/mysql_z_unit_model_test.go b/contrib/drivers/mysql/mysql_z_unit_model_test.go index d28f461c241..e4190e66312 100644 --- a/contrib/drivers/mysql/mysql_z_unit_model_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_model_test.go @@ -682,6 +682,7 @@ func Test_Model_Array(t *testing.T) { t.Assert(all.Array("id"), g.Slice{1, 2, 3}) t.Assert(all.Array("nickname"), g.Slice{"name_1", "name_2", "name_3"}) }) + gtest.C(t, func(t *gtest.T) { array, err := db.Model(table).Fields("nickname").Where("id", g.Slice{1, 2, 3}).Array() t.AssertNil(err) @@ -757,6 +758,7 @@ func Test_Model_Value_WithCache(t *testing.T) { t.AssertNil(err) t.Assert(value.Int(), 0) }) + gtest.C(t, func(t *gtest.T) { result, err := db.Model(table).Data(g.MapStrAny{ "id": 1, @@ -1437,6 +1439,7 @@ func Test_Model_Option_Map(t *testing.T) { t.AssertNE(one["nickname"].String(), "1") t.Assert(one["passport"].String(), "1") }) + gtest.C(t, func(t *gtest.T) { table := createTable() defer dropTable(table) diff --git a/contrib/drivers/mysql/testdata/issue1380.sql b/contrib/drivers/mysql/testdata/issues/1380.sql similarity index 100% rename from contrib/drivers/mysql/testdata/issue1380.sql rename to contrib/drivers/mysql/testdata/issues/1380.sql diff --git a/contrib/drivers/mysql/testdata/issue1401.sql b/contrib/drivers/mysql/testdata/issues/1401.sql similarity index 100% rename from contrib/drivers/mysql/testdata/issue1401.sql rename to contrib/drivers/mysql/testdata/issues/1401.sql diff --git a/contrib/drivers/mysql/testdata/issue1412.sql b/contrib/drivers/mysql/testdata/issues/1412.sql similarity index 100% rename from contrib/drivers/mysql/testdata/issue1412.sql rename to contrib/drivers/mysql/testdata/issues/1412.sql diff --git a/contrib/drivers/mysql/testdata/issue2105.sql b/contrib/drivers/mysql/testdata/issues/2105.sql similarity index 100% rename from contrib/drivers/mysql/testdata/issue2105.sql rename to contrib/drivers/mysql/testdata/issues/2105.sql diff --git a/contrib/drivers/mysql/testdata/issue2119.sql b/contrib/drivers/mysql/testdata/issues/2119.sql similarity index 100% rename from contrib/drivers/mysql/testdata/issue2119.sql rename to contrib/drivers/mysql/testdata/issues/2119.sql diff --git a/contrib/drivers/mysql/testdata/issue2439.sql b/contrib/drivers/mysql/testdata/issues/2439.sql similarity index 100% rename from contrib/drivers/mysql/testdata/issue2439.sql rename to contrib/drivers/mysql/testdata/issues/2439.sql diff --git a/contrib/drivers/mysql/testdata/issue2643.sql b/contrib/drivers/mysql/testdata/issues/2643.sql similarity index 100% rename from contrib/drivers/mysql/testdata/issue2643.sql rename to contrib/drivers/mysql/testdata/issues/2643.sql diff --git a/contrib/drivers/mysql/testdata/issue3086.sql b/contrib/drivers/mysql/testdata/issues/3086.sql similarity index 100% rename from contrib/drivers/mysql/testdata/issue3086.sql rename to contrib/drivers/mysql/testdata/issues/3086.sql diff --git a/contrib/drivers/mysql/testdata/issue3218.sql b/contrib/drivers/mysql/testdata/issues/3218.sql similarity index 100% rename from contrib/drivers/mysql/testdata/issue3218.sql rename to contrib/drivers/mysql/testdata/issues/3218.sql diff --git a/contrib/drivers/mysql/testdata/issue3626.sql b/contrib/drivers/mysql/testdata/issues/3626.sql similarity index 100% rename from contrib/drivers/mysql/testdata/issue3626.sql rename to contrib/drivers/mysql/testdata/issues/3626.sql diff --git a/contrib/drivers/mysql/testdata/issue3754.sql b/contrib/drivers/mysql/testdata/issues/3754.sql similarity index 100% rename from contrib/drivers/mysql/testdata/issue3754.sql rename to contrib/drivers/mysql/testdata/issues/3754.sql diff --git a/contrib/drivers/mysql/testdata/issue3915.sql b/contrib/drivers/mysql/testdata/issues/3915.sql similarity index 100% rename from contrib/drivers/mysql/testdata/issue3915.sql rename to contrib/drivers/mysql/testdata/issues/3915.sql diff --git a/contrib/drivers/mysql/testdata/issue4034.sql b/contrib/drivers/mysql/testdata/issues/4034.sql similarity index 100% rename from contrib/drivers/mysql/testdata/issue4034.sql rename to contrib/drivers/mysql/testdata/issues/4034.sql diff --git a/contrib/drivers/mysql/testdata/issues/4086.sql b/contrib/drivers/mysql/testdata/issues/4086.sql new file mode 100644 index 00000000000..5e7ba66e1c5 --- /dev/null +++ b/contrib/drivers/mysql/testdata/issues/4086.sql @@ -0,0 +1,10 @@ +DROP TABLE IF EXISTS `issue4086`; +CREATE TABLE `issue4086` ( + `proxy_id` bigint NOT NULL, + `recommend_ids` json DEFAULT NULL, + `photos` json DEFAULT NULL, + PRIMARY KEY (`proxy_id`) +) ENGINE=InnoDB; + +INSERT INTO `issue4086` (`proxy_id`, `recommend_ids`, `photos`) VALUES (1, '[584, 585]', 'null'); +INSERT INTO `issue4086` (`proxy_id`, `recommend_ids`, `photos`) VALUES (2, '[]', NULL); \ No newline at end of file diff --git a/contrib/drivers/pgsql/pgsql_convert.go b/contrib/drivers/pgsql/pgsql_convert.go index d2652d307c8..c83a1e02918 100644 --- a/contrib/drivers/pgsql/pgsql_convert.go +++ b/contrib/drivers/pgsql/pgsql_convert.go @@ -124,7 +124,7 @@ func (d *Driver) ConvertValueForLocal(ctx context.Context, fieldType string, fie // String slice. case "_varchar", "_text": - var result pq.StringArray + var result = make(pq.StringArray, 0) if err := result.Scan(fieldValue); err != nil { return nil, err } diff --git a/database/gdb/gdb.go b/database/gdb/gdb.go index 558ca92c957..a1ea177dd24 100644 --- a/database/gdb/gdb.go +++ b/database/gdb/gdb.go @@ -516,8 +516,9 @@ type Core struct { links *gmap.Map // links caches all created links by node. logger glog.ILogger // Logger for logging functionality. config *ConfigNode // Current config node. + localTypeMap *gmap.StrAnyMap // Local type map for database field type conversion. dynamicConfig dynamicConfig // Dynamic configurations, which can be changed in runtime. - innerMemCache *gcache.Cache + innerMemCache *gcache.Cache // Internal memory cache for storing temporary data. } type dynamicConfig struct { @@ -768,6 +769,8 @@ const ( SqlTypeStmtQueryRowContext SqlType = "DB.Statement.QueryRowContext" ) +// LocalType is a type that defines the local storage type of a field value. +// It is used to specify how the field value should be processed locally. type LocalType string const ( @@ -925,6 +928,7 @@ func newDBByConfigNode(node *ConfigNode, group string) (db DB, err error) { links: gmap.New(true), logger: glog.New(), config: node, + localTypeMap: gmap.NewStrAnyMap(true), innerMemCache: gcache.New(), dynamicConfig: dynamicConfig{ MaxIdleConnCount: node.MaxIdleConnCount, diff --git a/database/gdb/gdb_converter.go b/database/gdb/gdb_converter.go new file mode 100644 index 00000000000..486ca61d5de --- /dev/null +++ b/database/gdb/gdb_converter.go @@ -0,0 +1,82 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package gdb + +import ( + "reflect" + + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/util/gconv" +) + +// iVal is used for type assert api for Val(). +type iVal interface { + Val() any +} + +var ( + // converter is the internal type converter for gdb. + converter = gconv.NewConverter() +) + +func init() { + converter.RegisterAnyConverterFunc( + sliceTypeConverterFunc, + reflect.TypeOf([]string{}), + reflect.TypeOf([]float32{}), + reflect.TypeOf([]float64{}), + reflect.TypeOf([]int{}), + reflect.TypeOf([]int32{}), + reflect.TypeOf([]int64{}), + reflect.TypeOf([]uint{}), + reflect.TypeOf([]uint32{}), + reflect.TypeOf([]uint64{}), + ) +} + +// GetConverter returns the internal type converter for gdb. +func GetConverter() gconv.Converter { + return converter +} + +func sliceTypeConverterFunc(from any, to reflect.Value) (err error) { + v, ok := from.(iVal) + if !ok { + return nil + } + fromVal := v.Val() + switch x := fromVal.(type) { + case []byte: + dst := to.Addr().Interface() + err = json.Unmarshal(x, dst) + case string: + dst := to.Addr().Interface() + err = json.Unmarshal([]byte(x), dst) + default: + fromType := reflect.TypeOf(fromVal) + switch fromType.Kind() { + case reflect.Slice: + convertOption := gconv.ConvertOption{ + SliceOption: gconv.SliceOption{ContinueOnError: true}, + MapOption: gconv.MapOption{ContinueOnError: true}, + StructOption: gconv.StructOption{ContinueOnError: true}, + } + dv, err := converter.ConvertWithTypeName(fromVal, to.Type().String(), convertOption) + if err != nil { + return err + } + to.Set(reflect.ValueOf(dv)) + default: + err = gerror.Newf( + `unsupported type converting from type "%T" to type "%T"`, + fromVal, to, + ) + } + } + return err +} diff --git a/database/gdb/gdb_core.go b/database/gdb/gdb_core.go index f4faa0bf4f9..3665841a364 100644 --- a/database/gdb/gdb_core.go +++ b/database/gdb/gdb_core.go @@ -223,6 +223,8 @@ func (c *Core) GetScan(ctx context.Context, pointer interface{}, sql string, arg case reflect.Struct: return c.db.GetCore().doGetStruct(ctx, pointer, sql, args...) + + default: } return gerror.NewCodef( gcode.CodeInvalidParameter, @@ -735,6 +737,7 @@ func (c *Core) HasTable(name string) (bool, error) { return false, nil } +// GetInnerMemCache retrieves and returns the inner memory cache object. func (c *Core) GetInnerMemCache() *gcache.Cache { return c.innerMemCache } diff --git a/database/gdb/gdb_core_structure.go b/database/gdb/gdb_core_structure.go index bbb9df7574c..a954e03f97e 100644 --- a/database/gdb/gdb_core_structure.go +++ b/database/gdb/gdb_core_structure.go @@ -223,7 +223,9 @@ Default: } // CheckLocalTypeForField checks and returns corresponding type for given db type. -func (c *Core) CheckLocalTypeForField(ctx context.Context, fieldType string, fieldValue interface{}) (LocalType, error) { +// The `fieldType` is retrieved from ColumnTypes of db driver, example: +// UNSIGNED INT +func (c *Core) CheckLocalTypeForField(ctx context.Context, fieldType string, _ interface{}) (LocalType, error) { var ( typeName string typePattern string @@ -233,7 +235,12 @@ func (c *Core) CheckLocalTypeForField(ctx context.Context, fieldType string, fie typeName = gstr.Trim(match[1]) typePattern = gstr.Trim(match[2]) } else { - typeName = gstr.Split(fieldType, " ")[0] + var array = gstr.SplitAndTrim(fieldType, " ") + if len(array) > 1 && gstr.Equal(array[0], "unsigned") { + typeName = array[1] + } else if len(array) > 0 { + typeName = array[0] + } } typeName = strings.ToLower(typeName) @@ -291,11 +298,6 @@ func (c *Core) CheckLocalTypeForField(ctx context.Context, fieldType string, fie if typePattern == "1" { return LocalTypeBool, nil } - s := gconv.String(fieldValue) - // mssql is true|false string. - if strings.EqualFold(s, "true") || strings.EqualFold(s, "false") { - return LocalTypeBool, nil - } if gstr.ContainsI(fieldType, "unsigned") { return LocalTypeUint64Bytes, nil } diff --git a/database/gdb/gdb_core_underlying.go b/database/gdb/gdb_core_underlying.go index 6e06ff0a50f..d7d8d1c510c 100644 --- a/database/gdb/gdb_core_underlying.go +++ b/database/gdb/gdb_core_underlying.go @@ -478,8 +478,11 @@ func (c *Core) RowsToResult(ctx context.Context, rows *sql.Rows) (Result, error) // which will cause struct converting issue. record[columnTypes[i].Name()] = nil } else { - var convertedValue interface{} - if convertedValue, err = c.columnValueToLocalValue(ctx, value, columnTypes[i]); err != nil { + var ( + convertedValue interface{} + columnType = columnTypes[i] + ) + if convertedValue, err = c.columnValueToLocalValue(ctx, value, columnType); err != nil { return nil, err } record[columnTypes[i].Name()] = gvar.New(convertedValue) @@ -498,7 +501,9 @@ func (c *Core) OrderRandomFunction() string { return "RAND()" } -func (c *Core) columnValueToLocalValue(ctx context.Context, value interface{}, columnType *sql.ColumnType) (interface{}, error) { +func (c *Core) columnValueToLocalValue( + ctx context.Context, value interface{}, columnType *sql.ColumnType, +) (interface{}, error) { var scanType = columnType.ScanType() if scanType != nil { // Common basic builtin types. diff --git a/database/gdb/gdb_type_record.go b/database/gdb/gdb_type_record.go index 2b14c537573..93470551026 100644 --- a/database/gdb/gdb_type_record.go +++ b/database/gdb/gdb_type_record.go @@ -53,7 +53,10 @@ func (r Record) Struct(pointer interface{}) error { } return nil } - return gconv.StructTag(r, pointer, OrmTagForStruct) + return converter.Struct(r, pointer, gconv.StructOption{ + PriorityTag: OrmTagForStruct, + ContinueOnError: true, + }) } // IsEmpty checks and returns whether `r` is empty. diff --git a/database/gdb/gdb_type_result.go b/database/gdb/gdb_type_result.go index 03e7051d3a9..8c02d828c8c 100644 --- a/database/gdb/gdb_type_result.go +++ b/database/gdb/gdb_type_result.go @@ -200,5 +200,12 @@ func (r Result) Structs(pointer interface{}) (err error) { } return nil } - return gconv.StructsTag(r, pointer, OrmTagForStruct) + var ( + sliceOption = gconv.SliceOption{ContinueOnError: true} + mapOption = gconv.StructOption{ + PriorityTag: OrmTagForStruct, + ContinueOnError: true, + } + ) + return converter.Structs(r, pointer, sliceOption, mapOption) } diff --git a/database/gdb/gdb_z_mysql_internal_test.go b/database/gdb/gdb_z_mysql_internal_test.go index 8539c2c9481..5b5872eb84b 100644 --- a/database/gdb/gdb_z_mysql_internal_test.go +++ b/database/gdb/gdb_z_mysql_internal_test.go @@ -14,6 +14,15 @@ import ( "github.com/gogf/gf/v2/text/gregex" ) +func Test_GetConverter(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + c := GetConverter() + s, err := c.String(1) + t.AssertNil(err) + t.AssertEQ(s, "1") + }) +} + func Test_HookSelect_Regex(t *testing.T) { gtest.C(t, func(t *gtest.T) { var ( diff --git a/examples b/examples index 2544fee34dd..c454db2549a 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit 2544fee34dd10e6914687f7335bd9e772215ce07 +Subproject commit c454db2549ac7ecce844b687c1e610461818830d diff --git a/net/ghttp/ghttp_z_unit_feature_config_test.go b/net/ghttp/ghttp_z_unit_feature_config_test.go index c84cf24255e..306d61e97e4 100644 --- a/net/ghttp/ghttp_z_unit_feature_config_test.go +++ b/net/ghttp/ghttp_z_unit_feature_config_test.go @@ -30,15 +30,15 @@ func Test_ConfigFromMap(t *testing.T) { "readTimeout": "60s", "indexFiles": g.Slice{"index.php", "main.php"}, "errorLogEnabled": true, - "cookieMaxAge": "1y", + "cookieMaxAge": "1d", "cookieSameSite": "lax", "cookieSecure": true, "cookieHttpOnly": true, } config, err := ghttp.ConfigFromMap(m) t.AssertNil(err) - d1, _ := time.ParseDuration(gconv.String(m["readTimeout"])) - d2, _ := time.ParseDuration(gconv.String(m["cookieMaxAge"])) + d1, _ := gtime.ParseDuration(gconv.String(m["readTimeout"])) + d2, _ := gtime.ParseDuration(gconv.String(m["cookieMaxAge"])) t.Assert(config.Address, m["address"]) t.Assert(config.ReadTimeout, d1) t.Assert(config.CookieMaxAge, d2) diff --git a/net/ghttp/ghttp_z_unit_feature_router_strict_test.go b/net/ghttp/ghttp_z_unit_feature_router_strict_test.go index ef4fa12112b..c193c35a4b8 100644 --- a/net/ghttp/ghttp_z_unit_feature_router_strict_test.go +++ b/net/ghttp/ghttp_z_unit_feature_router_strict_test.go @@ -505,7 +505,6 @@ func (t *testNullStringIssue3465) Test(ctx context.Context, req *testNullStringI // https://github.com/gogf/gf/issues/3465 func Test_NullString_Issue3465(t *testing.T) { - s := g.Server(guid.S()) s.Use(ghttp.MiddlewareHandlerResponse) s.Group("/", func(group *ghttp.RouterGroup) { diff --git a/util/gconv/gconv.go b/util/gconv/gconv.go index d3bc027ef05..38302b1e3cf 100644 --- a/util/gconv/gconv.go +++ b/util/gconv/gconv.go @@ -10,36 +10,155 @@ package gconv import ( + "reflect" + "time" + + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/util/gconv/internal/converter" "github.com/gogf/gf/v2/util/gconv/internal/localinterface" "github.com/gogf/gf/v2/util/gconv/internal/structcache" ) -var ( - // Empty strings. - emptyStringMap = map[string]struct{}{ - "": {}, - "0": {}, - "no": {}, - "off": {}, - "false": {}, - } +// Converter is the manager for type converting. +type Converter interface { + ConverterForConvert + ConverterForRegister + ConverterForInt + ConverterForUint + ConverterForTime + ConverterForFloat + ConverterForMap + ConverterForSlice + ConverterForStruct + ConverterForBasic +} + +// ConverterForBasic is the basic converting interface. +type ConverterForBasic interface { + Scan(srcValue, dstPointer any, option ScanOption) (err error) + String(any any) (string, error) + Bool(any any) (bool, error) + Rune(any any) (rune, error) +} + +// ConverterForTime is the converting interface for time. +type ConverterForTime interface { + Time(v any, format ...string) (time.Time, error) + Duration(v any) (time.Duration, error) + GTime(v any, format ...string) (*gtime.Time, error) +} + +// ConverterForInt is the converting interface for integer. +type ConverterForInt interface { + Int(v any) (int, error) + Int8(v any) (int8, error) + Int16(v any) (int16, error) + Int32(v any) (int32, error) + Int64(v any) (int64, error) +} + +// ConverterForUint is the converting interface for unsigned integer. +type ConverterForUint interface { + Uint(v any) (uint, error) + Uint8(v any) (uint8, error) + Uint16(v any) (uint16, error) + Uint32(v any) (uint32, error) + Uint64(v any) (uint64, error) +} + +// ConverterForFloat is the converting interface for float. +type ConverterForFloat interface { + Float32(v any) (float32, error) + Float64(v any) (float64, error) +} + +// ConverterForMap is the converting interface for map. +type ConverterForMap interface { + Map(v any, option MapOption) (map[string]any, error) + MapStrStr(v any, option MapOption) (map[string]string, error) +} + +// ConverterForSlice is the converting interface for slice. +type ConverterForSlice interface { + Bytes(v any) ([]byte, error) + Runes(v any) ([]rune, error) + SliceAny(v any, option SliceOption) ([]any, error) + SliceFloat32(v any, option SliceOption) ([]float32, error) + SliceFloat64(v any, option SliceOption) ([]float64, error) + SliceInt(v any, option SliceOption) ([]int, error) + SliceInt32(v any, option SliceOption) ([]int32, error) + SliceInt64(v any, option SliceOption) ([]int64, error) + SliceUint(v any, option SliceOption) ([]uint, error) + SliceUint32(v any, option SliceOption) ([]uint32, error) + SliceUint64(v any, option SliceOption) ([]uint64, error) + SliceStr(v any, option SliceOption) ([]string, error) + SliceMap(v any, sliceOption SliceOption, mapOption MapOption) ([]map[string]any, error) +} + +// ConverterForStruct is the converting interface for struct. +type ConverterForStruct interface { + Struct(params, pointer any, option StructOption) (err error) + Structs(params, pointer any, sliceOption SliceOption, structOption StructOption) (err error) +} + +// ConverterForConvert is the converting interface for custom converting. +type ConverterForConvert interface { + ConvertWithRefer(fromValue, referValue any, option ConvertOption) (any, error) + ConvertWithTypeName(fromValue any, toTypeName string, option ConvertOption) (any, error) +} + +// ConverterForRegister is the converting interface for custom converter registration. +type ConverterForRegister interface { + RegisterTypeConverterFunc(f any) error + RegisterAnyConverterFunc(f AnyConvertFunc, types ...reflect.Type) +} + +type ( + // AnyConvertFunc is the function type for converting any to specified type. + AnyConvertFunc = structcache.AnyConvertFunc + + // MapOption specifies the option for map converting. + MapOption = converter.MapOption + + // SliceOption is the option for Slice type converting. + SliceOption = converter.SliceOption + + // ScanOption is the option for the Scan function. + ScanOption = converter.ScanOption + + // StructOption is the option for Struct converting. + StructOption = converter.StructOption + + // ConvertOption is the option for converting. + ConvertOption = converter.ConvertOption ) // IUnmarshalValue is the interface for custom defined types customizing value assignment. // Note that only pointer can implement interface IUnmarshalValue. type IUnmarshalValue = localinterface.IUnmarshalValue -func init() { - // register common converters for internal usage. - structcache.RegisterCommonConverter(structcache.CommonConverter{ - Int64: Int64, - Uint64: Uint64, - String: String, - Float32: Float32, - Float64: Float64, - Time: Time, - GTime: GTime, - Bytes: Bytes, - Bool: Bool, - }) +var ( + // defaultConverter is the default management object converting. + defaultConverter = converter.NewConverter() +) + +// RegisterAnyConverterFunc registers custom type converting function for specified type. +func RegisterAnyConverterFunc(f AnyConvertFunc, types ...reflect.Type) { + defaultConverter.RegisterAnyConverterFunc(f, types...) +} + +// NewConverter creates and returns management object for type converting. +func NewConverter() Converter { + return converter.NewConverter() +} + +// RegisterConverter registers custom converter. +// Deprecated: use RegisterTypeConverterFunc instead for clear +func RegisterConverter(fn any) (err error) { + return RegisterTypeConverterFunc(fn) +} + +// RegisterTypeConverterFunc registers custom converter. +func RegisterTypeConverterFunc(fn any) (err error) { + return defaultConverter.RegisterTypeConverterFunc(fn) } diff --git a/util/gconv/gconv_basic.go b/util/gconv/gconv_basic.go index 56a10e07577..d4ab35eaf2f 100644 --- a/util/gconv/gconv_basic.go +++ b/util/gconv/gconv_basic.go @@ -6,331 +6,40 @@ package gconv -import ( - "fmt" - "math" - "reflect" - "strconv" - "strings" - "time" - - "github.com/gogf/gf/v2/encoding/gbinary" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/internal/reflection" - "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/util/gconv/internal/localinterface" -) - // Byte converts `any` to byte. func Byte(any any) byte { - v, _ := doByte(any) + v, _ := defaultConverter.Uint8(any) return v } -func doByte(any any) (byte, error) { - if v, ok := any.(byte); ok { - return v, nil - } - return doUint8(any) -} - // Bytes converts `any` to []byte. func Bytes(any any) []byte { - v, _ := doBytes(any) + v, _ := defaultConverter.Bytes(any) return v } -func doBytes(any any) ([]byte, error) { - if any == nil { - return nil, nil - } - switch value := any.(type) { - case string: - return []byte(value), nil - - case []byte: - return value, nil - - default: - if f, ok := value.(localinterface.IBytes); ok { - return f.Bytes(), nil - } - originValueAndKind := reflection.OriginValueAndKind(any) - switch originValueAndKind.OriginKind { - case reflect.Map: - bytes, err := json.Marshal(any) - if err != nil { - return nil, err - } - return bytes, nil - - case reflect.Array, reflect.Slice: - var ( - ok = true - bytes = make([]byte, originValueAndKind.OriginValue.Len()) - ) - for i := range bytes { - int32Value, err := doInt32(originValueAndKind.OriginValue.Index(i).Interface()) - if err != nil { - return nil, err - } - if int32Value < 0 || int32Value > math.MaxUint8 { - ok = false - break - } - bytes[i] = byte(int32Value) - } - if ok { - return bytes, nil - } - default: - } - return gbinary.Encode(any), nil - } -} - // Rune converts `any` to rune. func Rune(any any) rune { - v, _ := doRune(any) + v, _ := defaultConverter.Rune(any) return v } -func doRune(any any) (rune, error) { - if v, ok := any.(rune); ok { - return v, nil - } - v, err := doInt32(any) - if err != nil { - return 0, err - } - return v, nil -} - // Runes converts `any` to []rune. func Runes(any any) []rune { - v, _ := doRunes(any) + v, _ := defaultConverter.Runes(any) return v } -func doRunes(any any) ([]rune, error) { - if v, ok := any.([]rune); ok { - return v, nil - } - s, err := doString(any) - if err != nil { - return nil, err - } - return []rune(s), nil -} - // String converts `any` to string. // It's most commonly used converting function. func String(any any) string { - v, _ := doString(any) + v, _ := defaultConverter.String(any) return v } -func doString(any any) (string, error) { - if any == nil { - return "", nil - } - switch value := any.(type) { - case int: - return strconv.Itoa(value), nil - case int8: - return strconv.Itoa(int(value)), nil - case int16: - return strconv.Itoa(int(value)), nil - case int32: - return strconv.Itoa(int(value)), nil - case int64: - return strconv.FormatInt(value, 10), nil - case uint: - return strconv.FormatUint(uint64(value), 10), nil - case uint8: - return strconv.FormatUint(uint64(value), 10), nil - case uint16: - return strconv.FormatUint(uint64(value), 10), nil - case uint32: - return strconv.FormatUint(uint64(value), 10), nil - case uint64: - return strconv.FormatUint(value, 10), nil - case float32: - return strconv.FormatFloat(float64(value), 'f', -1, 32), nil - case float64: - return strconv.FormatFloat(value, 'f', -1, 64), nil - case bool: - return strconv.FormatBool(value), nil - case string: - return value, nil - case []byte: - return string(value), nil - case complex64, complex128: - return fmt.Sprintf("%v", value), nil - case time.Time: - if value.IsZero() { - return "", nil - } - return value.String(), nil - case *time.Time: - if value == nil { - return "", nil - } - return value.String(), nil - case gtime.Time: - if value.IsZero() { - return "", nil - } - return value.String(), nil - case *gtime.Time: - if value == nil { - return "", nil - } - return value.String(), nil - default: - if f, ok := value.(localinterface.IString); ok { - // If the variable implements the String() interface, - // then use that interface to perform the conversion - return f.String(), nil - } - if f, ok := value.(localinterface.IError); ok { - // If the variable implements the Error() interface, - // then use that interface to perform the conversion - return f.Error(), nil - } - // Reflect checks. - var ( - rv = reflect.ValueOf(value) - kind = rv.Kind() - ) - switch kind { - case - reflect.Chan, - reflect.Map, - reflect.Slice, - reflect.Func, - reflect.Interface, - reflect.UnsafePointer: - if rv.IsNil() { - return "", nil - } - case reflect.String: - return rv.String(), nil - case reflect.Ptr: - if rv.IsNil() { - return "", nil - } - return doString(rv.Elem().Interface()) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return strconv.FormatInt(rv.Int(), 10), nil - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return strconv.FormatUint(rv.Uint(), 10), nil - case reflect.Uintptr: - return strconv.FormatUint(rv.Uint(), 10), nil - case reflect.Float32, reflect.Float64: - return strconv.FormatFloat(rv.Float(), 'f', -1, 64), nil - case reflect.Bool: - return strconv.FormatBool(rv.Bool()), nil - default: - } - // Finally, we use json.Marshal to convert. - jsonContent, err := json.Marshal(value) - if err != nil { - return fmt.Sprint(value), gerror.WrapCodef( - gcode.CodeInvalidParameter, err, "error marshaling value to JSON for: %v", value, - ) - } - return string(jsonContent), nil - } -} - // Bool converts `any` to bool. // It returns false if `any` is: false, "", 0, "false", "off", "no", empty slice/map. func Bool(any any) bool { - v, _ := doBool(any) + v, _ := defaultConverter.Bool(any) return v } - -func doBool(any any) (bool, error) { - if any == nil { - return false, nil - } - switch value := any.(type) { - case bool: - return value, nil - case []byte: - if _, ok := emptyStringMap[strings.ToLower(string(value))]; ok { - return false, nil - } - return true, nil - case string: - if _, ok := emptyStringMap[strings.ToLower(value)]; ok { - return false, nil - } - return true, nil - default: - if f, ok := value.(localinterface.IBool); ok { - return f.Bool(), nil - } - rv := reflect.ValueOf(any) - switch rv.Kind() { - case reflect.Ptr: - if rv.IsNil() { - return false, nil - } - if rv.Type().Elem().Kind() == reflect.Bool { - return rv.Elem().Bool(), nil - } - return doBool(rv.Elem().Interface()) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return rv.Int() != 0, nil - case reflect.Uintptr, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return rv.Uint() != 0, nil - case reflect.Float32, reflect.Float64: - return rv.Float() != 0, nil - case reflect.Bool: - return rv.Bool(), nil - // TODO:(Map,Array,Slice,Struct) It might panic here for these types. - case reflect.Map, reflect.Array: - fallthrough - case reflect.Slice: - return rv.Len() != 0, nil - case reflect.Struct: - return true, nil - default: - s, err := doString(any) - if err != nil { - return false, err - } - if _, ok := emptyStringMap[strings.ToLower(s)]; ok { - return false, nil - } - return true, nil - } - } -} - -// checkJsonAndUnmarshalUseNumber checks if given `any` is JSON formatted string value and does converting using `json.UnmarshalUseNumber`. -func checkJsonAndUnmarshalUseNumber(any any, target any) bool { - switch r := any.(type) { - case []byte: - if json.Valid(r) { - if err := json.UnmarshalUseNumber(r, &target); err != nil { - return false - } - return true - } - - case string: - anyAsBytes := []byte(r) - if json.Valid(anyAsBytes) { - if err := json.UnmarshalUseNumber(anyAsBytes, &target); err != nil { - return false - } - return true - } - } - return false -} diff --git a/util/gconv/gconv_convert.go b/util/gconv/gconv_convert.go index 49bb32b1fd3..eb47a6d4b93 100644 --- a/util/gconv/gconv_convert.go +++ b/util/gconv/gconv_convert.go @@ -6,353 +6,30 @@ package gconv -import ( - "context" - "reflect" - "time" - - "github.com/gogf/gf/v2/internal/intlog" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/os/gtime" -) - // Convert converts the variable `fromValue` to the type `toTypeName`, the type `toTypeName` is specified by string. // // The optional parameter `extraParams` is used for additional necessary parameter for this conversion. // It supports common basic types conversion as its conversion based on type name string. -func Convert(fromValue interface{}, toTypeName string, extraParams ...interface{}) interface{} { - return doConvert(doConvertInput{ - FromValue: fromValue, - ToTypeName: toTypeName, - ReferValue: nil, - Extra: extraParams, +func Convert(fromValue any, toTypeName string, extraParams ...any) any { + result, _ := defaultConverter.ConvertWithTypeName(fromValue, toTypeName, ConvertOption{ + ExtraParams: extraParams, + SliceOption: SliceOption{ContinueOnError: true}, + MapOption: MapOption{ContinueOnError: true}, + StructOption: StructOption{ContinueOnError: true}, }) + return result } // ConvertWithRefer converts the variable `fromValue` to the type referred by value `referValue`. // // The optional parameter `extraParams` is used for additional necessary parameter for this conversion. // It supports common basic types conversion as its conversion based on type name string. -func ConvertWithRefer(fromValue interface{}, referValue interface{}, extraParams ...interface{}) interface{} { - var referValueRf reflect.Value - if v, ok := referValue.(reflect.Value); ok { - referValueRf = v - } else { - referValueRf = reflect.ValueOf(referValue) - } - return doConvert(doConvertInput{ - FromValue: fromValue, - ToTypeName: referValueRf.Type().String(), - ReferValue: referValue, - Extra: extraParams, +func ConvertWithRefer(fromValue any, referValue any, extraParams ...any) any { + result, _ := defaultConverter.ConvertWithRefer(fromValue, referValue, ConvertOption{ + ExtraParams: extraParams, + SliceOption: SliceOption{ContinueOnError: true}, + MapOption: MapOption{ContinueOnError: true}, + StructOption: StructOption{ContinueOnError: true}, }) -} - -type doConvertInput struct { - FromValue interface{} // Value that is converted from. - ToTypeName string // Target value type name in string. - ReferValue interface{} // Referred value, a value in type `ToTypeName`. Note that its type might be reflect.Value. - Extra []interface{} // Extra values for implementing the converting. - // Marks that the value is already converted and set to `ReferValue`. Caller can ignore the returned result. - // It is an attribute for internal usage purpose. - alreadySetToReferValue bool -} - -// doConvert does commonly use types converting. -func doConvert(in doConvertInput) (convertedValue interface{}) { - switch in.ToTypeName { - case "int": - return Int(in.FromValue) - case "*int": - if _, ok := in.FromValue.(*int); ok { - return in.FromValue - } - v := Int(in.FromValue) - return &v - - case "int8": - return Int8(in.FromValue) - case "*int8": - if _, ok := in.FromValue.(*int8); ok { - return in.FromValue - } - v := Int8(in.FromValue) - return &v - - case "int16": - return Int16(in.FromValue) - case "*int16": - if _, ok := in.FromValue.(*int16); ok { - return in.FromValue - } - v := Int16(in.FromValue) - return &v - - case "int32": - return Int32(in.FromValue) - case "*int32": - if _, ok := in.FromValue.(*int32); ok { - return in.FromValue - } - v := Int32(in.FromValue) - return &v - - case "int64": - return Int64(in.FromValue) - case "*int64": - if _, ok := in.FromValue.(*int64); ok { - return in.FromValue - } - v := Int64(in.FromValue) - return &v - - case "uint": - return Uint(in.FromValue) - case "*uint": - if _, ok := in.FromValue.(*uint); ok { - return in.FromValue - } - v := Uint(in.FromValue) - return &v - - case "uint8": - return Uint8(in.FromValue) - case "*uint8": - if _, ok := in.FromValue.(*uint8); ok { - return in.FromValue - } - v := Uint8(in.FromValue) - return &v - - case "uint16": - return Uint16(in.FromValue) - case "*uint16": - if _, ok := in.FromValue.(*uint16); ok { - return in.FromValue - } - v := Uint16(in.FromValue) - return &v - - case "uint32": - return Uint32(in.FromValue) - case "*uint32": - if _, ok := in.FromValue.(*uint32); ok { - return in.FromValue - } - v := Uint32(in.FromValue) - return &v - - case "uint64": - return Uint64(in.FromValue) - case "*uint64": - if _, ok := in.FromValue.(*uint64); ok { - return in.FromValue - } - v := Uint64(in.FromValue) - return &v - - case "float32": - return Float32(in.FromValue) - case "*float32": - if _, ok := in.FromValue.(*float32); ok { - return in.FromValue - } - v := Float32(in.FromValue) - return &v - - case "float64": - return Float64(in.FromValue) - case "*float64": - if _, ok := in.FromValue.(*float64); ok { - return in.FromValue - } - v := Float64(in.FromValue) - return &v - - case "bool": - return Bool(in.FromValue) - case "*bool": - if _, ok := in.FromValue.(*bool); ok { - return in.FromValue - } - v := Bool(in.FromValue) - return &v - - case "string": - return String(in.FromValue) - case "*string": - if _, ok := in.FromValue.(*string); ok { - return in.FromValue - } - v := String(in.FromValue) - return &v - - case "[]byte": - return Bytes(in.FromValue) - case "[]int": - return Ints(in.FromValue) - case "[]int32": - return Int32s(in.FromValue) - case "[]int64": - return Int64s(in.FromValue) - case "[]uint": - return Uints(in.FromValue) - case "[]uint8": - return Bytes(in.FromValue) - case "[]uint32": - return Uint32s(in.FromValue) - case "[]uint64": - return Uint64s(in.FromValue) - case "[]float32": - return Float32s(in.FromValue) - case "[]float64": - return Float64s(in.FromValue) - case "[]string": - return Strings(in.FromValue) - - case "Time", "time.Time": - if len(in.Extra) > 0 { - return Time(in.FromValue, String(in.Extra[0])) - } - return Time(in.FromValue) - case "*time.Time": - var v time.Time - if len(in.Extra) > 0 { - v = Time(in.FromValue, String(in.Extra[0])) - } else { - if _, ok := in.FromValue.(*time.Time); ok { - return in.FromValue - } - v = Time(in.FromValue) - } - return &v - - case "GTime", "gtime.Time": - if len(in.Extra) > 0 { - if v := GTime(in.FromValue, String(in.Extra[0])); v != nil { - return *v - } else { - return *gtime.New() - } - } - if v := GTime(in.FromValue); v != nil { - return *v - } else { - return *gtime.New() - } - case "*gtime.Time": - if len(in.Extra) > 0 { - if v := GTime(in.FromValue, String(in.Extra[0])); v != nil { - return v - } else { - return gtime.New() - } - } - if v := GTime(in.FromValue); v != nil { - return v - } else { - return gtime.New() - } - - case "Duration", "time.Duration": - return Duration(in.FromValue) - case "*time.Duration": - if _, ok := in.FromValue.(*time.Duration); ok { - return in.FromValue - } - v := Duration(in.FromValue) - return &v - - case "map[string]string": - return MapStrStr(in.FromValue) - - case "map[string]interface {}": - return Map(in.FromValue) - - case "[]map[string]interface {}": - return Maps(in.FromValue) - - case "RawMessage", "json.RawMessage": - // issue 3449 - bytes, err := json.Marshal(in.FromValue) - if err != nil { - intlog.Errorf(context.TODO(), `%+v`, err) - } - return bytes - - default: - if in.ReferValue != nil { - var referReflectValue reflect.Value - if v, ok := in.ReferValue.(reflect.Value); ok { - referReflectValue = v - } else { - referReflectValue = reflect.ValueOf(in.ReferValue) - } - var fromReflectValue reflect.Value - if v, ok := in.FromValue.(reflect.Value); ok { - fromReflectValue = v - } else { - fromReflectValue = reflect.ValueOf(in.FromValue) - } - - // custom converter. - if dstReflectValue, ok, _ := callCustomConverterWithRefer(fromReflectValue, referReflectValue); ok { - return dstReflectValue.Interface() - } - - defer func() { - if recover() != nil { - in.alreadySetToReferValue = false - if err := bindVarToReflectValue(referReflectValue, in.FromValue, nil); err == nil { - in.alreadySetToReferValue = true - convertedValue = referReflectValue.Interface() - } - } - }() - switch referReflectValue.Kind() { - case reflect.Ptr: - // Type converting for custom type pointers. - // Eg: - // type PayMode int - // type Req struct{ - // Mode *PayMode - // } - // - // Struct(`{"Mode": 1000}`, &req) - originType := referReflectValue.Type().Elem() - switch originType.Kind() { - case reflect.Struct: - // Not support some kinds. - default: - in.ToTypeName = originType.Kind().String() - in.ReferValue = nil - refElementValue := reflect.ValueOf(doConvert(in)) - originTypeValue := reflect.New(refElementValue.Type()).Elem() - originTypeValue.Set(refElementValue) - in.alreadySetToReferValue = true - return originTypeValue.Addr().Convert(referReflectValue.Type()).Interface() - } - - case reflect.Map: - var targetValue = reflect.New(referReflectValue.Type()).Elem() - if err := doMapToMap(in.FromValue, targetValue); err == nil { - in.alreadySetToReferValue = true - } - return targetValue.Interface() - } - in.ToTypeName = referReflectValue.Kind().String() - in.ReferValue = nil - in.alreadySetToReferValue = true - convertedValue = reflect.ValueOf(doConvert(in)).Convert(referReflectValue.Type()).Interface() - return convertedValue - } - return in.FromValue - } -} - -func doConvertWithReflectValueSet(reflectValue reflect.Value, in doConvertInput) { - convertedValue := doConvert(in) - if !in.alreadySetToReferValue { - reflectValue.Set(reflect.ValueOf(convertedValue)) - } + return result } diff --git a/util/gconv/gconv_converter.go b/util/gconv/gconv_converter.go deleted file mode 100644 index eb0e226d1c0..00000000000 --- a/util/gconv/gconv_converter.go +++ /dev/null @@ -1,187 +0,0 @@ -// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. -// -// This Source Code Form is subject to the terms of the MIT License. -// If a copy of the MIT was not distributed with this file, -// You can obtain one at https://github.com/gogf/gf. - -package gconv - -import ( - "reflect" - - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/util/gconv/internal/structcache" -) - -type ( - converterInType = reflect.Type - converterOutType = reflect.Type - converterFunc = reflect.Value -) - -// customConverters for internal converter storing. -var customConverters = make(map[converterInType]map[converterOutType]converterFunc) - -// RegisterConverter to register custom converter. -// It must be registered before you use this custom converting feature. -// It is suggested to do it in boot procedure of the process. -// -// Note: -// 1. The parameter `fn` must be defined as pattern `func(T1) (T2, error)`. -// It will convert type `T1` to type `T2`. -// 2. The `T1` should not be type of pointer, but the `T2` should be type of pointer. -func RegisterConverter(fn interface{}) (err error) { - var ( - fnReflectType = reflect.TypeOf(fn) - errType = reflect.TypeOf((*error)(nil)).Elem() - ) - if fnReflectType.Kind() != reflect.Func || - fnReflectType.NumIn() != 1 || fnReflectType.NumOut() != 2 || - !fnReflectType.Out(1).Implements(errType) { - err = gerror.NewCodef( - gcode.CodeInvalidParameter, - "parameter must be type of converter function and defined as pattern `func(T1) (T2, error)`, but defined as `%s`", - fnReflectType.String(), - ) - return - } - - // The Key and Value of the converter map should not be pointer. - var ( - inType = fnReflectType.In(0) - outType = fnReflectType.Out(0) - ) - if inType.Kind() == reflect.Pointer { - err = gerror.NewCodef( - gcode.CodeInvalidParameter, - "invalid converter function `%s`: invalid input parameter type `%s`, should not be type of pointer", - fnReflectType.String(), inType.String(), - ) - return - } - if outType.Kind() != reflect.Pointer { - err = gerror.NewCodef( - gcode.CodeInvalidParameter, - "invalid converter function `%s`: invalid output parameter type `%s` should be type of pointer", - fnReflectType.String(), outType.String(), - ) - return - } - - registeredOutTypeMap, ok := customConverters[inType] - if !ok { - registeredOutTypeMap = make(map[converterOutType]converterFunc) - customConverters[inType] = registeredOutTypeMap - } - if _, ok = registeredOutTypeMap[outType]; ok { - err = gerror.NewCodef( - gcode.CodeInvalidOperation, - "the converter parameter type `%s` to type `%s` has already been registered", - inType.String(), outType.String(), - ) - return - } - registeredOutTypeMap[outType] = reflect.ValueOf(fn) - structcache.RegisterCustomConvertType(outType) - return -} - -func getRegisteredConverterFuncAndSrcType( - srcReflectValue, dstReflectValueForRefer reflect.Value, -) (f converterFunc, srcType reflect.Type, ok bool) { - if len(customConverters) == 0 { - return reflect.Value{}, nil, false - } - srcType = srcReflectValue.Type() - for srcType.Kind() == reflect.Pointer { - srcType = srcType.Elem() - } - var registeredOutTypeMap map[converterOutType]converterFunc - // firstly, it searches the map by input parameter type. - registeredOutTypeMap, ok = customConverters[srcType] - if !ok { - return reflect.Value{}, nil, false - } - var dstType = dstReflectValueForRefer.Type() - if dstType.Kind() == reflect.Pointer { - // Might be **struct, which is support as designed. - if dstType.Elem().Kind() == reflect.Pointer { - dstType = dstType.Elem() - } - } else if dstReflectValueForRefer.IsValid() && dstReflectValueForRefer.CanAddr() { - dstType = dstReflectValueForRefer.Addr().Type() - } else { - dstType = reflect.PointerTo(dstType) - } - // secondly, it searches the input parameter type map - // and finds the result converter function by the output parameter type. - f, ok = registeredOutTypeMap[dstType] - if !ok { - return reflect.Value{}, nil, false - } - return -} - -func callCustomConverterWithRefer( - srcReflectValue, referReflectValue reflect.Value, -) (dstReflectValue reflect.Value, converted bool, err error) { - registeredConverterFunc, srcType, ok := getRegisteredConverterFuncAndSrcType(srcReflectValue, referReflectValue) - if !ok { - return reflect.Value{}, false, nil - } - dstReflectValue = reflect.New(referReflectValue.Type()).Elem() - converted, err = doCallCustomConverter(srcReflectValue, dstReflectValue, registeredConverterFunc, srcType) - return -} - -// callCustomConverter call the custom converter. It will try some possible type. -func callCustomConverter(srcReflectValue, dstReflectValue reflect.Value) (converted bool, err error) { - registeredConverterFunc, srcType, ok := getRegisteredConverterFuncAndSrcType(srcReflectValue, dstReflectValue) - if !ok { - return false, nil - } - return doCallCustomConverter(srcReflectValue, dstReflectValue, registeredConverterFunc, srcType) -} - -func doCallCustomConverter( - srcReflectValue reflect.Value, - dstReflectValue reflect.Value, - registeredConverterFunc converterFunc, - srcType reflect.Type, -) (converted bool, err error) { - // Converter function calling. - for srcReflectValue.Type() != srcType { - srcReflectValue = srcReflectValue.Elem() - } - result := registeredConverterFunc.Call([]reflect.Value{srcReflectValue}) - if !result[1].IsNil() { - return false, result[1].Interface().(error) - } - // The `result[0]` is a pointer. - if result[0].IsNil() { - return false, nil - } - var resultValue = result[0] - for { - if resultValue.Type() == dstReflectValue.Type() && dstReflectValue.CanSet() { - dstReflectValue.Set(resultValue) - converted = true - } else if dstReflectValue.Kind() == reflect.Pointer { - if resultValue.Type() == dstReflectValue.Elem().Type() && dstReflectValue.Elem().CanSet() { - dstReflectValue.Elem().Set(resultValue) - converted = true - } - } - if converted { - break - } - if resultValue.Kind() == reflect.Pointer { - resultValue = resultValue.Elem() - } else { - break - } - } - - return converted, nil -} diff --git a/util/gconv/gconv_float.go b/util/gconv/gconv_float.go index 2f7204a5cf9..62d6d4861d5 100644 --- a/util/gconv/gconv_float.go +++ b/util/gconv/gconv_float.go @@ -6,143 +6,14 @@ package gconv -import ( - "reflect" - "strconv" - - "github.com/gogf/gf/v2/encoding/gbinary" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/util/gconv/internal/localinterface" -) - // Float32 converts `any` to float32. func Float32(any any) float32 { - v, _ := doFloat32(any) + v, _ := defaultConverter.Float32(any) return v } -func doFloat32(any any) (float32, error) { - if any == nil { - return 0, nil - } - switch value := any.(type) { - case float32: - return value, nil - case float64: - return float32(value), nil - case []byte: - // TODO: It might panic here for these types. - return gbinary.DecodeToFloat32(value), nil - default: - rv := reflect.ValueOf(any) - switch rv.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return float32(rv.Int()), nil - case reflect.Uintptr, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return float32(rv.Uint()), nil - case reflect.Float32, reflect.Float64: - return float32(rv.Float()), nil - case reflect.Bool: - if rv.Bool() { - return 1, nil - } - return 0, nil - case reflect.String: - f, err := strconv.ParseFloat(rv.String(), 32) - if err != nil { - return 0, gerror.WrapCodef( - gcode.CodeInvalidParameter, err, "converting string to float32 failed for: %v", any, - ) - } - return float32(f), nil - case reflect.Ptr: - if rv.IsNil() { - return 0, nil - } - if f, ok := value.(localinterface.IFloat32); ok { - return f.Float32(), nil - } - return doFloat32(rv.Elem().Interface()) - default: - if f, ok := value.(localinterface.IFloat32); ok { - return f.Float32(), nil - } - v, err := strconv.ParseFloat(String(any), 32) - if err != nil { - return 0, gerror.WrapCodef( - gcode.CodeInvalidParameter, err, "converting string to float32 failed for: %v", any, - ) - } - return float32(v), nil - } - } -} - // Float64 converts `any` to float64. func Float64(any any) float64 { - v, _ := doFloat64(any) + v, _ := defaultConverter.Float64(any) return v } - -func doFloat64(any any) (float64, error) { - if any == nil { - return 0, nil - } - switch value := any.(type) { - case float32: - return float64(value), nil - case float64: - return value, nil - case []byte: - // TODO: It might panic here for these types. - return gbinary.DecodeToFloat64(value), nil - default: - rv := reflect.ValueOf(any) - switch rv.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return float64(rv.Int()), nil - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return float64(rv.Uint()), nil - case reflect.Uintptr: - return float64(rv.Uint()), nil - case reflect.Float32, reflect.Float64: - // Please Note: - // When the type is float32 or a custom type defined based on float32, - // switching to float64 may result in a few extra decimal places. - return rv.Float(), nil - case reflect.Bool: - if rv.Bool() { - return 1, nil - } - return 0, nil - case reflect.String: - f, err := strconv.ParseFloat(rv.String(), 64) - if err != nil { - return 0, gerror.WrapCodef( - gcode.CodeInvalidParameter, err, "converting string to float64 failed for: %v", any, - ) - } - return f, nil - case reflect.Ptr: - if rv.IsNil() { - return 0, nil - } - if f, ok := value.(localinterface.IFloat64); ok { - return f.Float64(), nil - } - return doFloat64(rv.Elem().Interface()) - default: - if f, ok := value.(localinterface.IFloat64); ok { - return f.Float64(), nil - } - v, err := strconv.ParseFloat(String(any), 64) - if err != nil { - return 0, gerror.WrapCodef( - gcode.CodeInvalidParameter, err, "converting string to float64 failed for: %v", any, - ) - } - return v, nil - } - } -} diff --git a/util/gconv/gconv_int.go b/util/gconv/gconv_int.go index 7e1e6a129dd..78c534d6fa2 100644 --- a/util/gconv/gconv_int.go +++ b/util/gconv/gconv_int.go @@ -6,176 +6,32 @@ package gconv -import ( - "math" - "reflect" - "strconv" - - "github.com/gogf/gf/v2/encoding/gbinary" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/util/gconv/internal/localinterface" -) - // Int converts `any` to int. func Int(any any) int { - v, _ := doInt(any) + v, _ := defaultConverter.Int(any) return v } -func doInt(any any) (int, error) { - if v, ok := any.(int); ok { - return v, nil - } - v, err := doInt64(any) - if err != nil { - return 0, err - } - return int(v), nil -} - // Int8 converts `any` to int8. func Int8(any any) int8 { - v, _ := doInt8(any) + v, _ := defaultConverter.Int8(any) return v } -func doInt8(any any) (int8, error) { - if v, ok := any.(int8); ok { - return v, nil - } - v, err := doInt64(any) - if err != nil { - return 0, err - } - return int8(v), nil -} - // Int16 converts `any` to int16. func Int16(any any) int16 { - v, _ := doInt16(any) + v, _ := defaultConverter.Int16(any) return v } -func doInt16(any any) (int16, error) { - if v, ok := any.(int16); ok { - return v, nil - } - v, err := doInt64(any) - if err != nil { - return 0, err - } - return int16(v), nil -} - // Int32 converts `any` to int32. func Int32(any any) int32 { - v, _ := doInt32(any) + v, _ := defaultConverter.Int32(any) return v } -func doInt32(any any) (int32, error) { - if v, ok := any.(int32); ok { - return v, nil - } - v, err := doInt64(any) - if err != nil { - return 0, err - } - return int32(v), nil -} - // Int64 converts `any` to int64. func Int64(any any) int64 { - v, _ := doInt64(any) + v, _ := defaultConverter.Int64(any) return v } - -func doInt64(any any) (int64, error) { - if any == nil { - return 0, nil - } - if v, ok := any.(int64); ok { - return v, nil - } - rv := reflect.ValueOf(any) - switch rv.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - return rv.Int(), nil - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return int64(rv.Uint()), nil - case reflect.Uintptr: - return int64(rv.Uint()), nil - case reflect.Float32, reflect.Float64: - return int64(rv.Float()), nil - case reflect.Bool: - if rv.Bool() { - return 1, nil - } - return 0, nil - case reflect.Ptr: - if rv.IsNil() { - return 0, nil - } - if f, ok := any.(localinterface.IInt64); ok { - return f.Int64(), nil - } - return doInt64(rv.Elem().Interface()) - case reflect.Slice: - // TODO: It might panic here for these types. - if rv.Type().Elem().Kind() == reflect.Uint8 { - return gbinary.DecodeToInt64(rv.Bytes()), nil - } - case reflect.String: - var ( - s = rv.String() - isMinus = false - ) - if len(s) > 0 { - if s[0] == '-' { - isMinus = true - s = s[1:] - } else if s[0] == '+' { - s = s[1:] - } - } - // Hexadecimal. - if len(s) > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X') { - if v, e := strconv.ParseInt(s[2:], 16, 64); e == nil { - if isMinus { - return -v, nil - } - return v, nil - } - } - // Decimal. - if v, e := strconv.ParseInt(s, 10, 64); e == nil { - if isMinus { - return -v, nil - } - return v, nil - } - // Float64. - valueInt64, err := doFloat64(s) - if err != nil { - return 0, err - } - if math.IsNaN(valueInt64) { - return 0, nil - } else { - if isMinus { - return -int64(valueInt64), nil - } - return int64(valueInt64), nil - } - default: - if f, ok := any.(localinterface.IInt64); ok { - return f.Int64(), nil - } - } - return 0, gerror.NewCodef( - gcode.CodeInvalidParameter, - `unsupport value type for converting to int64: %v`, - reflect.TypeOf(any), - ) -} diff --git a/util/gconv/gconv_map.go b/util/gconv/gconv_map.go index 46809da6f13..04733e8b3e8 100644 --- a/util/gconv/gconv_map.go +++ b/util/gconv/gconv_map.go @@ -6,566 +6,42 @@ package gconv -import ( - "reflect" - "strings" - - "github.com/gogf/gf/v2/internal/empty" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/internal/utils" - "github.com/gogf/gf/v2/util/gconv/internal/localinterface" - "github.com/gogf/gf/v2/util/gtag" -) - -type recursiveType string - -const ( - recursiveTypeAuto recursiveType = "auto" - recursiveTypeTrue recursiveType = "true" -) - -// MapOption specifies the option for map converting. -type MapOption struct { - // Deep marks doing Map function recursively, which means if the attribute of given converting value - // is also a struct/*struct, it automatically calls Map function on this attribute converting it to - // a map[string]interface{} type variable. - Deep bool - - // OmitEmpty ignores the attributes that has json `omitempty` tag. - OmitEmpty bool - - // Tags specifies the converted map key name by struct tag name. - Tags []string -} - -// Map converts any variable `value` to map[string]interface{}. If the parameter `value` is not a +// Map converts any variable `value` to map[string]any. If the parameter `value` is not a // map/struct/*struct type, then the conversion will fail and returns nil. // // If `value` is a struct/*struct object, the second parameter `priorityTagAndFieldName` specifies the most priority // priorityTagAndFieldName that will be detected, otherwise it detects the priorityTagAndFieldName in order of: // gconv, json, field name. -func Map(value interface{}, option ...MapOption) map[string]interface{} { - return doMapConvert(value, recursiveTypeAuto, false, option...) +func Map(value any, option ...MapOption) map[string]any { + result, _ := defaultConverter.Map(value, getUsedMapOption(option...)) + return result } // MapDeep does Map function recursively, which means if the attribute of `value` // is also a struct/*struct, calls Map function on this attribute converting it to -// a map[string]interface{} type variable. +// a map[string]any type variable. // Deprecated: used Map instead. -func MapDeep(value interface{}, tags ...string) map[string]interface{} { - return doMapConvert(value, recursiveTypeTrue, false, MapOption{ - Deep: true, - Tags: tags, +func MapDeep(value any, tags ...string) map[string]any { + result, _ := defaultConverter.Map(value, MapOption{ + Deep: true, + OmitEmpty: false, + Tags: tags, + ContinueOnError: true, }) -} - -// doMapConvert implements the map converting. -// It automatically checks and converts json string to map if `value` is string/[]byte. -// -// TODO completely implement the recursive converting for all types, especially the map. -func doMapConvert(value interface{}, recursive recursiveType, mustMapReturn bool, option ...MapOption) map[string]interface{} { - if value == nil { - return nil - } - // It redirects to its underlying value if it has implemented interface iVal. - if v, ok := value.(localinterface.IVal); ok { - value = v.Val() - } - var ( - usedOption = getUsedMapOption(option...) - newTags = gtag.StructTagPriority - ) - if usedOption.Deep { - recursive = recursiveTypeTrue - } - switch len(usedOption.Tags) { - case 0: - // No need handling. - case 1: - newTags = append(strings.Split(usedOption.Tags[0], ","), gtag.StructTagPriority...) - default: - newTags = append(usedOption.Tags, gtag.StructTagPriority...) - } - // Assert the common combination of types, and finally it uses reflection. - dataMap := make(map[string]interface{}) - switch r := value.(type) { - case string: - // If it is a JSON string, automatically unmarshal it! - if len(r) > 0 && r[0] == '{' && r[len(r)-1] == '}' { - if err := json.UnmarshalUseNumber([]byte(r), &dataMap); err != nil { - return nil - } - } else { - return nil - } - case []byte: - // If it is a JSON string, automatically unmarshal it! - if len(r) > 0 && r[0] == '{' && r[len(r)-1] == '}' { - if err := json.UnmarshalUseNumber(r, &dataMap); err != nil { - return nil - } - } else { - return nil - } - case map[interface{}]interface{}: - recursiveOption := usedOption - recursiveOption.Tags = newTags - for k, v := range r { - dataMap[String(k)] = doMapConvertForMapOrStructValue( - doMapConvertForMapOrStructValueInput{ - IsRoot: false, - Value: v, - RecursiveType: recursive, - RecursiveOption: recursive == recursiveTypeTrue, - Option: recursiveOption, - }, - ) - } - case map[interface{}]string: - for k, v := range r { - dataMap[String(k)] = v - } - case map[interface{}]int: - for k, v := range r { - dataMap[String(k)] = v - } - case map[interface{}]uint: - for k, v := range r { - dataMap[String(k)] = v - } - case map[interface{}]float32: - for k, v := range r { - dataMap[String(k)] = v - } - case map[interface{}]float64: - for k, v := range r { - dataMap[String(k)] = v - } - case map[string]bool: - for k, v := range r { - dataMap[k] = v - } - case map[string]int: - for k, v := range r { - dataMap[k] = v - } - case map[string]uint: - for k, v := range r { - dataMap[k] = v - } - case map[string]float32: - for k, v := range r { - dataMap[k] = v - } - case map[string]float64: - for k, v := range r { - dataMap[k] = v - } - case map[string]string: - for k, v := range r { - dataMap[k] = v - } - case map[string]interface{}: - if recursive == recursiveTypeTrue { - recursiveOption := usedOption - recursiveOption.Tags = newTags - // A copy of current map. - for k, v := range r { - dataMap[k] = doMapConvertForMapOrStructValue( - doMapConvertForMapOrStructValueInput{ - IsRoot: false, - Value: v, - RecursiveType: recursive, - RecursiveOption: recursive == recursiveTypeTrue, - Option: recursiveOption, - }, - ) - } - } else { - // It returns the map directly without any changing. - return r - } - case map[int]interface{}: - recursiveOption := usedOption - recursiveOption.Tags = newTags - for k, v := range r { - dataMap[String(k)] = doMapConvertForMapOrStructValue( - doMapConvertForMapOrStructValueInput{ - IsRoot: false, - Value: v, - RecursiveType: recursive, - RecursiveOption: recursive == recursiveTypeTrue, - Option: recursiveOption, - }, - ) - } - case map[int]string: - for k, v := range r { - dataMap[String(k)] = v - } - case map[uint]string: - for k, v := range r { - dataMap[String(k)] = v - } - - default: - // Not a common type, it then uses reflection for conversion. - var reflectValue reflect.Value - if v, ok := value.(reflect.Value); ok { - reflectValue = v - } else { - reflectValue = reflect.ValueOf(value) - } - reflectKind := reflectValue.Kind() - // If it is a pointer, we should find its real data type. - for reflectKind == reflect.Ptr { - reflectValue = reflectValue.Elem() - reflectKind = reflectValue.Kind() - } - switch reflectKind { - // If `value` is type of array, it converts the value of even number index as its key and - // the value of odd number index as its corresponding value, for example: - // []string{"k1","v1","k2","v2"} => map[string]interface{}{"k1":"v1", "k2":"v2"} - // []string{"k1","v1","k2"} => map[string]interface{}{"k1":"v1", "k2":nil} - case reflect.Slice, reflect.Array: - length := reflectValue.Len() - for i := 0; i < length; i += 2 { - if i+1 < length { - dataMap[String(reflectValue.Index(i).Interface())] = reflectValue.Index(i + 1).Interface() - } else { - dataMap[String(reflectValue.Index(i).Interface())] = nil - } - } - case reflect.Map, reflect.Struct, reflect.Interface: - recursiveOption := usedOption - recursiveOption.Tags = newTags - convertedValue := doMapConvertForMapOrStructValue( - doMapConvertForMapOrStructValueInput{ - IsRoot: true, - Value: value, - RecursiveType: recursive, - RecursiveOption: recursive == recursiveTypeTrue, - Option: recursiveOption, - MustMapReturn: mustMapReturn, - }, - ) - if m, ok := convertedValue.(map[string]interface{}); ok { - return m - } - return nil - default: - return nil - } - } - return dataMap -} - -func getUsedMapOption(option ...MapOption) MapOption { - var usedOption MapOption - if len(option) > 0 { - usedOption = option[0] - } - return usedOption -} - -type doMapConvertForMapOrStructValueInput struct { - IsRoot bool // It returns directly if it is not root and with no recursive converting. - Value interface{} // Current operation value. - RecursiveType recursiveType // The type from top function entry. - RecursiveOption bool // Whether convert recursively for `current` operation. - Option MapOption // Map converting option. - MustMapReturn bool // Must return map instead of Value when empty. -} - -func doMapConvertForMapOrStructValue(in doMapConvertForMapOrStructValueInput) interface{} { - if !in.IsRoot && !in.RecursiveOption { - return in.Value - } - - var reflectValue reflect.Value - if v, ok := in.Value.(reflect.Value); ok { - reflectValue = v - in.Value = v.Interface() - } else { - reflectValue = reflect.ValueOf(in.Value) - } - reflectKind := reflectValue.Kind() - // If it is a pointer, we should find its real data type. - for reflectKind == reflect.Ptr { - reflectValue = reflectValue.Elem() - reflectKind = reflectValue.Kind() - } - switch reflectKind { - case reflect.Map: - var ( - mapIter = reflectValue.MapRange() - dataMap = make(map[string]interface{}) - ) - for mapIter.Next() { - var ( - mapKeyValue = mapIter.Value() - mapValue interface{} - ) - switch { - case mapKeyValue.IsZero(): - if utils.CanCallIsNil(mapKeyValue) && mapKeyValue.IsNil() { - // quick check for nil value. - mapValue = nil - } else { - // in case of: - // exception recovered: reflect: call of reflect.Value.Interface on zero Value - mapValue = reflect.New(mapKeyValue.Type()).Elem().Interface() - } - default: - mapValue = mapKeyValue.Interface() - } - dataMap[String(mapIter.Key().Interface())] = doMapConvertForMapOrStructValue( - doMapConvertForMapOrStructValueInput{ - IsRoot: false, - Value: mapValue, - RecursiveType: in.RecursiveType, - RecursiveOption: in.RecursiveType == recursiveTypeTrue, - Option: in.Option, - }, - ) - } - return dataMap - - case reflect.Struct: - var dataMap = make(map[string]interface{}) - // Map converting interface check. - if v, ok := in.Value.(localinterface.IMapStrAny); ok { - // Value copy, in case of concurrent safety. - for mapK, mapV := range v.MapStrAny() { - if in.RecursiveOption { - dataMap[mapK] = doMapConvertForMapOrStructValue( - doMapConvertForMapOrStructValueInput{ - IsRoot: false, - Value: mapV, - RecursiveType: in.RecursiveType, - RecursiveOption: in.RecursiveType == recursiveTypeTrue, - Option: in.Option, - }, - ) - } else { - dataMap[mapK] = mapV - } - } - if len(dataMap) > 0 { - return dataMap - } - } - // Using reflect for converting. - var ( - rtField reflect.StructField - rvField reflect.Value - reflectType = reflectValue.Type() // attribute value type. - mapKey = "" // mapKey may be the tag name or the struct attribute name. - ) - for i := 0; i < reflectValue.NumField(); i++ { - rtField = reflectType.Field(i) - rvField = reflectValue.Field(i) - // Only convert the public attributes. - fieldName := rtField.Name - if !utils.IsLetterUpper(fieldName[0]) { - continue - } - mapKey = "" - fieldTag := rtField.Tag - for _, tag := range in.Option.Tags { - if mapKey = fieldTag.Get(tag); mapKey != "" { - break - } - } - if mapKey == "" { - mapKey = fieldName - } else { - // Support json tag feature: -, omitempty - mapKey = strings.TrimSpace(mapKey) - if mapKey == "-" { - continue - } - array := strings.Split(mapKey, ",") - if len(array) > 1 { - switch strings.TrimSpace(array[1]) { - case "omitempty": - if in.Option.OmitEmpty && empty.IsEmpty(rvField.Interface()) { - continue - } else { - mapKey = strings.TrimSpace(array[0]) - } - default: - mapKey = strings.TrimSpace(array[0]) - } - } - if mapKey == "" { - mapKey = fieldName - } - } - if in.RecursiveOption || rtField.Anonymous { - // Do map converting recursively. - var ( - rvAttrField = rvField - rvAttrKind = rvField.Kind() - ) - if rvAttrKind == reflect.Ptr { - rvAttrField = rvField.Elem() - rvAttrKind = rvAttrField.Kind() - } - switch rvAttrKind { - case reflect.Struct: - // Embedded struct and has no fields, just ignores it. - // Eg: gmeta.Meta - if rvAttrField.Type().NumField() == 0 { - continue - } - var ( - hasNoTag = mapKey == fieldName - // DO NOT use rvAttrField.Interface() here, - // as it might be changed from pointer to struct. - rvInterface = rvField.Interface() - ) - switch { - case hasNoTag && rtField.Anonymous: - // It means this attribute field has no tag. - // Overwrite the attribute with sub-struct attribute fields. - anonymousValue := doMapConvertForMapOrStructValue(doMapConvertForMapOrStructValueInput{ - IsRoot: false, - Value: rvInterface, - RecursiveType: in.RecursiveType, - RecursiveOption: true, - Option: in.Option, - }) - if m, ok := anonymousValue.(map[string]interface{}); ok { - for k, v := range m { - dataMap[k] = v - } - } else { - dataMap[mapKey] = rvInterface - } - - // It means this attribute field has desired tag. - case !hasNoTag && rtField.Anonymous: - dataMap[mapKey] = doMapConvertForMapOrStructValue(doMapConvertForMapOrStructValueInput{ - IsRoot: false, - Value: rvInterface, - RecursiveType: in.RecursiveType, - RecursiveOption: true, - Option: in.Option, - }) - - default: - dataMap[mapKey] = doMapConvertForMapOrStructValue(doMapConvertForMapOrStructValueInput{ - IsRoot: false, - Value: rvInterface, - RecursiveType: in.RecursiveType, - RecursiveOption: in.RecursiveType == recursiveTypeTrue, - Option: in.Option, - }) - } - - // The struct attribute is type of slice. - case reflect.Array, reflect.Slice: - length := rvAttrField.Len() - if length == 0 { - dataMap[mapKey] = rvAttrField.Interface() - break - } - array := make([]interface{}, length) - for arrayIndex := 0; arrayIndex < length; arrayIndex++ { - array[arrayIndex] = doMapConvertForMapOrStructValue( - doMapConvertForMapOrStructValueInput{ - IsRoot: false, - Value: rvAttrField.Index(arrayIndex).Interface(), - RecursiveType: in.RecursiveType, - RecursiveOption: in.RecursiveType == recursiveTypeTrue, - Option: in.Option, - }, - ) - } - dataMap[mapKey] = array - case reflect.Map: - var ( - mapIter = rvAttrField.MapRange() - nestedMap = make(map[string]interface{}) - ) - for mapIter.Next() { - nestedMap[String(mapIter.Key().Interface())] = doMapConvertForMapOrStructValue( - doMapConvertForMapOrStructValueInput{ - IsRoot: false, - Value: mapIter.Value().Interface(), - RecursiveType: in.RecursiveType, - RecursiveOption: in.RecursiveType == recursiveTypeTrue, - Option: in.Option, - }, - ) - } - dataMap[mapKey] = nestedMap - default: - if rvField.IsValid() { - dataMap[mapKey] = reflectValue.Field(i).Interface() - } else { - dataMap[mapKey] = nil - } - } - } else { - // No recursive map value converting - if rvField.IsValid() { - dataMap[mapKey] = reflectValue.Field(i).Interface() - } else { - dataMap[mapKey] = nil - } - } - } - if !in.MustMapReturn && len(dataMap) == 0 { - return in.Value - } - return dataMap - - // The given value is type of slice. - case reflect.Array, reflect.Slice: - length := reflectValue.Len() - if length == 0 { - break - } - array := make([]interface{}, reflectValue.Len()) - for i := 0; i < length; i++ { - array[i] = doMapConvertForMapOrStructValue(doMapConvertForMapOrStructValueInput{ - IsRoot: false, - Value: reflectValue.Index(i).Interface(), - RecursiveType: in.RecursiveType, - RecursiveOption: in.RecursiveType == recursiveTypeTrue, - Option: in.Option, - }) - } - return array - - default: - } - return in.Value + return result } // MapStrStr converts `value` to map[string]string. // Note that there might be data copy for this map type converting. -func MapStrStr(value interface{}, option ...MapOption) map[string]string { - if r, ok := value.(map[string]string); ok { - return r - } - m := Map(value, option...) - if len(m) > 0 { - vMap := make(map[string]string, len(m)) - for k, v := range m { - vMap[k] = String(v) - } - return vMap - } - return nil +func MapStrStr(value any, option ...MapOption) map[string]string { + result, _ := defaultConverter.MapStrStr(value, getUsedMapOption(option...)) + return result } // MapStrStrDeep converts `value` to map[string]string recursively. // Note that there might be data copy for this map type converting. // Deprecated: used MapStrStr instead. -func MapStrStrDeep(value interface{}, tags ...string) map[string]string { +func MapStrStrDeep(value any, tags ...string) map[string]string { if r, ok := value.(map[string]string); ok { return r } @@ -579,3 +55,13 @@ func MapStrStrDeep(value interface{}, tags ...string) map[string]string { } return nil } + +func getUsedMapOption(option ...MapOption) MapOption { + var usedOption = MapOption{ + ContinueOnError: true, + } + if len(option) > 0 { + usedOption = option[0] + } + return usedOption +} diff --git a/util/gconv/gconv_maps.go b/util/gconv/gconv_maps.go index a68bb4e1046..b2d57499458 100644 --- a/util/gconv/gconv_maps.go +++ b/util/gconv/gconv_maps.go @@ -9,72 +9,42 @@ package gconv import "github.com/gogf/gf/v2/internal/json" // SliceMap is alias of Maps. -func SliceMap(any interface{}, option ...MapOption) []map[string]interface{} { +func SliceMap(any any, option ...MapOption) []map[string]any { return Maps(any, option...) } // SliceMapDeep is alias of MapsDeep. // Deprecated: used SliceMap instead. -func SliceMapDeep(any interface{}) []map[string]interface{} { +func SliceMapDeep(any any) []map[string]any { return MapsDeep(any) } -// Maps converts `value` to []map[string]interface{}. +// Maps converts `value` to []map[string]any. // Note that it automatically checks and converts json string to []map if `value` is string/[]byte. -func Maps(value interface{}, option ...MapOption) []map[string]interface{} { - if value == nil { - return nil +func Maps(value any, option ...MapOption) []map[string]any { + mapOption := MapOption{ + ContinueOnError: true, } - switch r := value.(type) { - case string: - list := make([]map[string]interface{}, 0) - if len(r) > 0 && r[0] == '[' && r[len(r)-1] == ']' { - if err := json.UnmarshalUseNumber([]byte(r), &list); err != nil { - return nil - } - return list - } else { - return nil - } - - case []byte: - list := make([]map[string]interface{}, 0) - if len(r) > 0 && r[0] == '[' && r[len(r)-1] == ']' { - if err := json.UnmarshalUseNumber(r, &list); err != nil { - return nil - } - return list - } else { - return nil - } - - case []map[string]interface{}: - return r - - default: - array := Interfaces(value) - if len(array) == 0 { - return nil - } - list := make([]map[string]interface{}, len(array)) - for k, v := range array { - list[k] = Map(v, option...) - } - return list + if len(option) > 0 { + mapOption = option[0] } + result, _ := defaultConverter.SliceMap(value, SliceOption{ + ContinueOnError: true, + }, mapOption) + return result } -// MapsDeep converts `value` to []map[string]interface{} recursively. +// MapsDeep converts `value` to []map[string]any recursively. // // TODO completely implement the recursive converting for all types. // Deprecated: used Maps instead. -func MapsDeep(value interface{}, tags ...string) []map[string]interface{} { +func MapsDeep(value any, tags ...string) []map[string]any { if value == nil { return nil } switch r := value.(type) { case string: - list := make([]map[string]interface{}, 0) + list := make([]map[string]any, 0) if len(r) > 0 && r[0] == '[' && r[len(r)-1] == ']' { if err := json.UnmarshalUseNumber([]byte(r), &list); err != nil { return nil @@ -85,7 +55,7 @@ func MapsDeep(value interface{}, tags ...string) []map[string]interface{} { } case []byte: - list := make([]map[string]interface{}, 0) + list := make([]map[string]any, 0) if len(r) > 0 && r[0] == '[' && r[len(r)-1] == ']' { if err := json.UnmarshalUseNumber(r, &list); err != nil { return nil @@ -95,8 +65,8 @@ func MapsDeep(value interface{}, tags ...string) []map[string]interface{} { return nil } - case []map[string]interface{}: - list := make([]map[string]interface{}, len(r)) + case []map[string]any: + list := make([]map[string]any, len(r)) for k, v := range r { list[k] = MapDeep(v, tags...) } @@ -107,7 +77,7 @@ func MapsDeep(value interface{}, tags ...string) []map[string]interface{} { if len(array) == 0 { return nil } - list := make([]map[string]interface{}, len(array)) + list := make([]map[string]any, len(array)) for k, v := range array { list[k] = MapDeep(v, tags...) } diff --git a/util/gconv/gconv_maptomap.go b/util/gconv/gconv_maptomap.go index ffd352e582f..5986c332209 100644 --- a/util/gconv/gconv_maptomap.go +++ b/util/gconv/gconv_maptomap.go @@ -6,126 +6,9 @@ package gconv -import ( - "reflect" - - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" -) - // MapToMap converts any map type variable `params` to another map type variable `pointer` // using reflect. // See doMapToMap. -func MapToMap(params interface{}, pointer interface{}, mapping ...map[string]string) error { +func MapToMap(params any, pointer any, mapping ...map[string]string) error { return Scan(params, pointer, mapping...) } - -// doMapToMap converts any map type variable `params` to another map type variable `pointer`. -// -// The parameter `params` can be any type of map, like: -// map[string]string, map[string]struct, map[string]*struct, reflect.Value, etc. -// -// The parameter `pointer` should be type of *map, like: -// map[int]string, map[string]struct, map[string]*struct, reflect.Value, etc. -// -// The optional parameter `mapping` is used for struct attribute to map key mapping, which makes -// sense only if the items of original map `params` is type struct. -func doMapToMap(params interface{}, pointer interface{}, mapping ...map[string]string) (err error) { - var ( - paramsRv reflect.Value - paramsKind reflect.Kind - keyToAttributeNameMapping map[string]string - ) - if len(mapping) > 0 { - keyToAttributeNameMapping = mapping[0] - } - if v, ok := params.(reflect.Value); ok { - paramsRv = v - } else { - paramsRv = reflect.ValueOf(params) - } - paramsKind = paramsRv.Kind() - if paramsKind == reflect.Ptr { - paramsRv = paramsRv.Elem() - paramsKind = paramsRv.Kind() - } - if paramsKind != reflect.Map { - return doMapToMap(Map(params), pointer, mapping...) - } - // Empty params map, no need continue. - if paramsRv.Len() == 0 { - return nil - } - var pointerRv reflect.Value - if v, ok := pointer.(reflect.Value); ok { - pointerRv = v - } else { - pointerRv = reflect.ValueOf(pointer) - } - pointerKind := pointerRv.Kind() - for pointerKind == reflect.Ptr { - pointerRv = pointerRv.Elem() - pointerKind = pointerRv.Kind() - } - if pointerKind != reflect.Map { - return gerror.NewCodef( - gcode.CodeInvalidParameter, - `destination pointer should be type of *map, but got: %s`, - pointerKind, - ) - } - defer func() { - // Catch the panic, especially the reflection operation panics. - if exception := recover(); exception != nil { - if v, ok := exception.(error); ok && gerror.HasStack(v) { - err = v - } else { - err = gerror.NewCodeSkipf(gcode.CodeInternalPanic, 1, "%+v", exception) - } - } - }() - var ( - paramsKeys = paramsRv.MapKeys() - pointerKeyType = pointerRv.Type().Key() - pointerValueType = pointerRv.Type().Elem() - pointerValueKind = pointerValueType.Kind() - dataMap = reflect.MakeMapWithSize(pointerRv.Type(), len(paramsKeys)) - ) - // Retrieve the true element type of target map. - if pointerValueKind == reflect.Ptr { - pointerValueKind = pointerValueType.Elem().Kind() - } - for _, key := range paramsKeys { - mapValue := reflect.New(pointerValueType).Elem() - switch pointerValueKind { - case reflect.Map, reflect.Struct: - if err = doStruct( - paramsRv.MapIndex(key).Interface(), mapValue, keyToAttributeNameMapping, "", - ); err != nil { - return err - } - default: - mapValue.Set( - reflect.ValueOf( - doConvert(doConvertInput{ - FromValue: paramsRv.MapIndex(key).Interface(), - ToTypeName: pointerValueType.String(), - ReferValue: mapValue, - Extra: nil, - }), - ), - ) - } - var mapKey = reflect.ValueOf( - doConvert(doConvertInput{ - FromValue: key.Interface(), - ToTypeName: pointerKeyType.Name(), - ReferValue: reflect.New(pointerKeyType).Elem().Interface(), - Extra: nil, - }), - ) - dataMap.SetMapIndex(mapKey, mapValue) - } - pointerRv.Set(dataMap) - return nil -} diff --git a/util/gconv/gconv_maptomaps.go b/util/gconv/gconv_maptomaps.go index 330ed40d045..aaf9ae2743d 100644 --- a/util/gconv/gconv_maptomaps.go +++ b/util/gconv/gconv_maptomaps.go @@ -6,121 +6,8 @@ package gconv -import ( - "reflect" - - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" -) - // MapToMaps converts any slice type variable `params` to another map slice type variable `pointer`. // See doMapToMaps. -func MapToMaps(params interface{}, pointer interface{}, mapping ...map[string]string) error { +func MapToMaps(params any, pointer any, mapping ...map[string]string) error { return Scan(params, pointer, mapping...) } - -// doMapToMaps converts any map type variable `params` to another map slice variable `pointer`. -// -// The parameter `params` can be type of []map, []*map, []struct, []*struct. -// -// The parameter `pointer` should be type of []map, []*map. -// -// The optional parameter `mapping` is used for struct attribute to map key mapping, which makes -// sense only if the item of `params` is type struct. -func doMapToMaps(params interface{}, pointer interface{}, paramKeyToAttrMap ...map[string]string) (err error) { - // Params and its element type check. - var ( - paramsRv reflect.Value - paramsKind reflect.Kind - ) - if v, ok := params.(reflect.Value); ok { - paramsRv = v - } else { - paramsRv = reflect.ValueOf(params) - } - paramsKind = paramsRv.Kind() - if paramsKind == reflect.Ptr { - paramsRv = paramsRv.Elem() - paramsKind = paramsRv.Kind() - } - if paramsKind != reflect.Array && paramsKind != reflect.Slice { - return gerror.NewCode( - gcode.CodeInvalidParameter, - "params should be type of slice, example: []map/[]*map/[]struct/[]*struct", - ) - } - var ( - paramsElem = paramsRv.Type().Elem() - paramsElemKind = paramsElem.Kind() - ) - if paramsElemKind == reflect.Ptr { - paramsElem = paramsElem.Elem() - paramsElemKind = paramsElem.Kind() - } - if paramsElemKind != reflect.Map && - paramsElemKind != reflect.Struct && - paramsElemKind != reflect.Interface { - return gerror.NewCodef( - gcode.CodeInvalidParameter, - "params element should be type of map/*map/struct/*struct, but got: %s", - paramsElemKind, - ) - } - // Empty slice, no need continue. - if paramsRv.Len() == 0 { - return nil - } - // Pointer and its element type check. - var ( - pointerRv = reflect.ValueOf(pointer) - pointerKind = pointerRv.Kind() - ) - for pointerKind == reflect.Ptr { - pointerRv = pointerRv.Elem() - pointerKind = pointerRv.Kind() - } - if pointerKind != reflect.Array && pointerKind != reflect.Slice { - return gerror.NewCode(gcode.CodeInvalidParameter, "pointer should be type of *[]map/*[]*map") - } - var ( - pointerElemType = pointerRv.Type().Elem() - pointerElemKind = pointerElemType.Kind() - ) - if pointerElemKind == reflect.Ptr { - pointerElemKind = pointerElemType.Elem().Kind() - } - if pointerElemKind != reflect.Map { - return gerror.NewCode(gcode.CodeInvalidParameter, "pointer element should be type of map/*map") - } - defer func() { - // Catch the panic, especially the reflection operation panics. - if exception := recover(); exception != nil { - if v, ok := exception.(error); ok && gerror.HasStack(v) { - err = v - } else { - err = gerror.NewCodeSkipf(gcode.CodeInternalPanic, 1, "%+v", exception) - } - } - }() - var ( - pointerSlice = reflect.MakeSlice(pointerRv.Type(), paramsRv.Len(), paramsRv.Len()) - ) - for i := 0; i < paramsRv.Len(); i++ { - var item reflect.Value - if pointerElemType.Kind() == reflect.Ptr { - item = reflect.New(pointerElemType.Elem()) - if err = MapToMap(paramsRv.Index(i).Interface(), item, paramKeyToAttrMap...); err != nil { - return err - } - pointerSlice.Index(i).Set(item) - } else { - item = reflect.New(pointerElemType) - if err = MapToMap(paramsRv.Index(i).Interface(), item, paramKeyToAttrMap...); err != nil { - return err - } - pointerSlice.Index(i).Set(item.Elem()) - } - } - pointerRv.Set(pointerSlice) - return -} diff --git a/util/gconv/gconv_scan.go b/util/gconv/gconv_scan.go index 376a2b1aae2..8d872420863 100644 --- a/util/gconv/gconv_scan.go +++ b/util/gconv/gconv_scan.go @@ -6,15 +6,6 @@ package gconv -import ( - "reflect" - - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/util/gconv/internal/localinterface" -) - // Scan automatically checks the type of `pointer` and converts `params` to `pointer`. // It supports various types of parameter conversions, including: // 1. Basic types (int, string, float, etc.) @@ -26,321 +17,11 @@ import ( // The `paramKeyToAttrMap` parameter is used for mapping between attribute names and parameter keys. // TODO: change `paramKeyToAttrMap` to `ScanOption` to be more scalable; add `DeepCopy` option for `ScanOption`. func Scan(srcValue any, dstPointer any, paramKeyToAttrMap ...map[string]string) (err error) { - // Check if srcValue is nil, in which case no conversion is needed - if srcValue == nil { - return nil - } - // Check if dstPointer is nil, which is an invalid parameter - if dstPointer == nil { - return gerror.NewCode( - gcode.CodeInvalidParameter, - `destination pointer should not be nil`, - ) - } - - // Get the reflection type and value of dstPointer - var ( - dstPointerReflectType reflect.Type - dstPointerReflectValue reflect.Value - ) - if v, ok := dstPointer.(reflect.Value); ok { - dstPointerReflectValue = v - dstPointerReflectType = v.Type() - } else { - dstPointerReflectValue = reflect.ValueOf(dstPointer) - // Do not use dstPointerReflectValue.Type() as dstPointerReflectValue might be zero - dstPointerReflectType = reflect.TypeOf(dstPointer) - } - - // Validate the kind of dstPointer - var dstPointerReflectKind = dstPointerReflectType.Kind() - if dstPointerReflectKind != reflect.Ptr { - // If dstPointer is not a pointer, try to get its address - if dstPointerReflectValue.CanAddr() { - dstPointerReflectValue = dstPointerReflectValue.Addr() - dstPointerReflectType = dstPointerReflectValue.Type() - dstPointerReflectKind = dstPointerReflectType.Kind() - } else { - // If dstPointer is not a pointer and cannot be addressed, return an error - return gerror.NewCodef( - gcode.CodeInvalidParameter, - `destination pointer should be type of pointer, but got type: %v`, - dstPointerReflectType, - ) - } - } - - // Get the reflection value of srcValue - var srcValueReflectValue reflect.Value - if v, ok := srcValue.(reflect.Value); ok { - srcValueReflectValue = v - } else { - srcValueReflectValue = reflect.ValueOf(srcValue) - } - - // Get the element type and kind of dstPointer - var ( - dstPointerReflectValueElem = dstPointerReflectValue.Elem() - dstPointerReflectValueElemKind = dstPointerReflectValueElem.Kind() - ) - // Handle multiple level pointers - if dstPointerReflectValueElemKind == reflect.Ptr { - if dstPointerReflectValueElem.IsNil() { - // Create a new value for the pointer dereference - nextLevelPtr := reflect.New(dstPointerReflectValueElem.Type().Elem()) - // Recursively scan into the dereferenced pointer - if err = Scan(srcValueReflectValue, nextLevelPtr, paramKeyToAttrMap...); err == nil { - dstPointerReflectValueElem.Set(nextLevelPtr) - } - return - } - return Scan(srcValueReflectValue, dstPointerReflectValueElem, paramKeyToAttrMap...) - } - - // Check if srcValue and dstPointer are the same type, in which case direct assignment can be performed - if ok := doConvertWithTypeCheck(srcValueReflectValue, dstPointerReflectValueElem); ok { - return nil - } - - // Handle different destination types - switch dstPointerReflectValueElemKind { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - // Convert to int type - dstPointerReflectValueElem.SetInt(Int64(srcValue)) - return nil - - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - // Convert to uint type - dstPointerReflectValueElem.SetUint(Uint64(srcValue)) - return nil - - case reflect.Float32, reflect.Float64: - // Convert to float type - dstPointerReflectValueElem.SetFloat(Float64(srcValue)) - return nil - - case reflect.String: - // Convert to string type - dstPointerReflectValueElem.SetString(String(srcValue)) - return nil - - case reflect.Bool: - // Convert to bool type - dstPointerReflectValueElem.SetBool(Bool(srcValue)) - return nil - - case reflect.Slice: - // Handle slice type conversion - var ( - dstElemType = dstPointerReflectValueElem.Type().Elem() - dstElemKind = dstElemType.Kind() - ) - // The slice element might be a pointer type - if dstElemKind == reflect.Ptr { - dstElemType = dstElemType.Elem() - dstElemKind = dstElemType.Kind() - } - // Special handling for struct or map slice elements - if dstElemKind == reflect.Struct || dstElemKind == reflect.Map { - return doScanForComplicatedTypes(srcValue, dstPointer, dstPointerReflectType, paramKeyToAttrMap...) - } - // Handle basic type slice conversions - var srcValueReflectValueKind = srcValueReflectValue.Kind() - if srcValueReflectValueKind == reflect.Slice || srcValueReflectValueKind == reflect.Array { - var ( - srcLen = srcValueReflectValue.Len() - newSlice = reflect.MakeSlice(dstPointerReflectValueElem.Type(), srcLen, srcLen) - ) - for i := 0; i < srcLen; i++ { - srcElem := srcValueReflectValue.Index(i).Interface() - switch dstElemType.Kind() { - case reflect.String: - newSlice.Index(i).SetString(String(srcElem)) - case reflect.Int: - newSlice.Index(i).SetInt(Int64(srcElem)) - case reflect.Int64: - newSlice.Index(i).SetInt(Int64(srcElem)) - case reflect.Float64: - newSlice.Index(i).SetFloat(Float64(srcElem)) - case reflect.Bool: - newSlice.Index(i).SetBool(Bool(srcElem)) - default: - return Scan( - srcElem, newSlice.Index(i).Addr().Interface(), paramKeyToAttrMap..., - ) - } - } - dstPointerReflectValueElem.Set(newSlice) - return nil - } - return doScanForComplicatedTypes(srcValue, dstPointer, dstPointerReflectType, paramKeyToAttrMap...) - - default: - // Handle complex types (structs, maps, etc.) - return doScanForComplicatedTypes(srcValue, dstPointer, dstPointerReflectType, paramKeyToAttrMap...) - } -} - -// doScanForComplicatedTypes handles the scanning of complex data types. -// It supports converting between maps, structs, and slices of these types. -// The function first attempts JSON conversion, then falls back to specific type handling. -// -// It supports `pointer` in type of `*map/*[]map/*[]*map/*struct/**struct/*[]struct/*[]*struct` for converting. -// -// Parameters: -// - srcValue: The source value to convert from -// - dstPointer: The destination pointer to convert to -// - dstPointerReflectType: The reflection type of the destination pointer -// - paramKeyToAttrMap: Optional mapping between parameter keys and struct attribute names -func doScanForComplicatedTypes( - srcValue, dstPointer any, - dstPointerReflectType reflect.Type, - paramKeyToAttrMap ...map[string]string, -) error { - // Try JSON conversion first - ok, err := doConvertWithJsonCheck(srcValue, dstPointer) - if err != nil { - return err + option := ScanOption{ + ContinueOnError: true, } - if ok { - return nil - } - - // Handle specific type conversions - var ( - dstPointerReflectTypeElem = dstPointerReflectType.Elem() - dstPointerReflectTypeElemKind = dstPointerReflectTypeElem.Kind() - keyToAttributeNameMapping map[string]string - ) if len(paramKeyToAttrMap) > 0 { - keyToAttributeNameMapping = paramKeyToAttrMap[0] - } - - // Handle different destination types - switch dstPointerReflectTypeElemKind { - case reflect.Map: - // Convert map to map - return doMapToMap(srcValue, dstPointer, paramKeyToAttrMap...) - - case reflect.Array, reflect.Slice: - var ( - sliceElem = dstPointerReflectTypeElem.Elem() - sliceElemKind = sliceElem.Kind() - ) - // Handle pointer elements - for sliceElemKind == reflect.Ptr { - sliceElem = sliceElem.Elem() - sliceElemKind = sliceElem.Kind() - } - if sliceElemKind == reflect.Map { - // Convert to slice of maps - return doMapToMaps(srcValue, dstPointer, paramKeyToAttrMap...) - } - // Convert to slice of structs - return doStructs(srcValue, dstPointer, keyToAttributeNameMapping, "") - - default: - // Convert to single struct - return doStruct(srcValue, dstPointer, keyToAttributeNameMapping, "") - } -} - -// doConvertWithTypeCheck supports `pointer` in type of `*map/*[]map/*[]*map/*struct/**struct/*[]struct/*[]*struct` -// for converting. -func doConvertWithTypeCheck(srcValueReflectValue, dstPointerReflectValueElem reflect.Value) (ok bool) { - if !dstPointerReflectValueElem.IsValid() || !srcValueReflectValue.IsValid() { - return false - } - switch { - // Examples: - // UploadFile => UploadFile - // []UploadFile => []UploadFile - // *UploadFile => *UploadFile - // *[]UploadFile => *[]UploadFile - // map[int][int] => map[int][int] - // []map[int][int] => []map[int][int] - // *[]map[int][int] => *[]map[int][int] - case dstPointerReflectValueElem.Type() == srcValueReflectValue.Type(): - dstPointerReflectValueElem.Set(srcValueReflectValue) - return true - - // Examples: - // UploadFile => *UploadFile - // []UploadFile => *[]UploadFile - // map[int][int] => *map[int][int] - // []map[int][int] => *[]map[int][int] - case dstPointerReflectValueElem.Kind() == reflect.Ptr && - dstPointerReflectValueElem.Elem().IsValid() && - dstPointerReflectValueElem.Elem().Type() == srcValueReflectValue.Type(): - dstPointerReflectValueElem.Elem().Set(srcValueReflectValue) - return true - - // Examples: - // *UploadFile => UploadFile - // *[]UploadFile => []UploadFile - // *map[int][int] => map[int][int] - // *[]map[int][int] => []map[int][int] - case srcValueReflectValue.Kind() == reflect.Ptr && - srcValueReflectValue.Elem().IsValid() && - dstPointerReflectValueElem.Type() == srcValueReflectValue.Elem().Type(): - dstPointerReflectValueElem.Set(srcValueReflectValue.Elem()) - return true - - default: - return false - } -} - -// doConvertWithJsonCheck attempts to convert the source value to the destination -// using JSON marshaling and unmarshaling. This is particularly useful for complex -// types that can be represented as JSON. -// -// Parameters: -// - srcValue: The source value to convert from -// - dstPointer: The destination pointer to convert to -// -// Returns: -// - bool: true if JSON conversion was successful -// - error: any error that occurred during conversion -func doConvertWithJsonCheck(srcValue any, dstPointer any) (ok bool, err error) { - switch valueResult := srcValue.(type) { - case []byte: - if json.Valid(valueResult) { - if dstPointerReflectType, ok := dstPointer.(reflect.Value); ok { - if dstPointerReflectType.Kind() == reflect.Ptr { - if dstPointerReflectType.IsNil() { - return false, nil - } - return true, json.UnmarshalUseNumber(valueResult, dstPointerReflectType.Interface()) - } else if dstPointerReflectType.CanAddr() { - return true, json.UnmarshalUseNumber(valueResult, dstPointerReflectType.Addr().Interface()) - } - } else { - return true, json.UnmarshalUseNumber(valueResult, dstPointer) - } - } - - case string: - if valueBytes := []byte(valueResult); json.Valid(valueBytes) { - if dstPointerReflectType, ok := dstPointer.(reflect.Value); ok { - if dstPointerReflectType.Kind() == reflect.Ptr { - if dstPointerReflectType.IsNil() { - return false, nil - } - return true, json.UnmarshalUseNumber(valueBytes, dstPointerReflectType.Interface()) - } else if dstPointerReflectType.CanAddr() { - return true, json.UnmarshalUseNumber(valueBytes, dstPointerReflectType.Addr().Interface()) - } - } else { - return true, json.UnmarshalUseNumber(valueBytes, dstPointer) - } - } - - default: - // The `params` might be struct that implements interface function Interface, eg: gvar.Var. - if v, ok := srcValue.(localinterface.IInterface); ok { - return doConvertWithJsonCheck(v.Interface(), dstPointer) - } + option.ParamKeyToAttrMap = paramKeyToAttrMap[0] } - return false, nil + return defaultConverter.Scan(srcValue, dstPointer, option) } diff --git a/util/gconv/gconv_scan_list.go b/util/gconv/gconv_scan_list.go index 8fae2265ce1..78cc98335b5 100644 --- a/util/gconv/gconv_scan_list.go +++ b/util/gconv/gconv_scan_list.go @@ -93,7 +93,9 @@ import ( // given `relation` parameter. // // See the example or unit testing cases for clear understanding for this function. -func ScanList(structSlice interface{}, structSlicePointer interface{}, bindToAttrName string, relationAttrNameAndFields ...string) (err error) { +func ScanList( + structSlice any, structSlicePointer any, bindToAttrName string, relationAttrNameAndFields ...string, +) (err error) { var ( relationAttrName string relationFields string @@ -111,7 +113,7 @@ func ScanList(structSlice interface{}, structSlicePointer interface{}, bindToAtt // doScanList converts `structSlice` to struct slice which contains other complex struct attributes recursively. // Note that the parameter `structSlicePointer` should be type of *[]struct/*[]*struct. func doScanList( - structSlice interface{}, structSlicePointer interface{}, bindToAttrName, relationAttrName, relationFields string, + structSlice any, structSlicePointer any, bindToAttrName, relationAttrName, relationFields string, ) (err error) { var ( maps = Maps(structSlice) @@ -169,7 +171,7 @@ func doScanList( // Relation variables. var ( - relationDataMap map[string]interface{} + relationDataMap map[string]any relationFromFieldName string // Eg: relationKV: id:uid -> id relationBindToFieldName string // Eg: relationKV: id:uid -> uid ) @@ -315,7 +317,7 @@ func doScanList( relationFromAttrField = relationFromAttrValue.FieldByName(relationBindToFieldName) if relationFromAttrField.IsValid() { // results := make(Result, 0) - results := make([]interface{}, 0) + results := make([]any, 0) for _, v := range SliceAny(relationDataMap[String(relationFromAttrField.Interface())]) { item := v results = append(results, item) diff --git a/util/gconv/gconv_slice_any.go b/util/gconv/gconv_slice_any.go index 00ecee0c224..8506f25428d 100644 --- a/util/gconv/gconv_slice_any.go +++ b/util/gconv/gconv_slice_any.go @@ -6,14 +6,6 @@ package gconv -import ( - "reflect" - - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/internal/reflection" - "github.com/gogf/gf/v2/util/gconv/internal/localinterface" -) - // SliceAny is alias of Interfaces. func SliceAny(any interface{}) []interface{} { return Interfaces(any) @@ -21,111 +13,8 @@ func SliceAny(any interface{}) []interface{} { // Interfaces converts `any` to []interface{}. func Interfaces(any interface{}) []interface{} { - if any == nil { - return nil - } - var array []interface{} - switch value := any.(type) { - case []interface{}: - array = value - case []string: - array = make([]interface{}, len(value)) - for k, v := range value { - array[k] = v - } - case []int: - array = make([]interface{}, len(value)) - for k, v := range value { - array[k] = v - } - case []int8: - array = make([]interface{}, len(value)) - for k, v := range value { - array[k] = v - } - case []int16: - array = make([]interface{}, len(value)) - for k, v := range value { - array[k] = v - } - case []int32: - array = make([]interface{}, len(value)) - for k, v := range value { - array[k] = v - } - case []int64: - array = make([]interface{}, len(value)) - for k, v := range value { - array[k] = v - } - case []uint: - array = make([]interface{}, len(value)) - for k, v := range value { - array[k] = v - } - case []uint8: - if json.Valid(value) { - _ = json.UnmarshalUseNumber(value, &array) - } else { - array = make([]interface{}, len(value)) - for k, v := range value { - array[k] = v - } - } - case []uint16: - array = make([]interface{}, len(value)) - for k, v := range value { - array[k] = v - } - case []uint32: - for _, v := range value { - array = append(array, v) - } - case []uint64: - array = make([]interface{}, len(value)) - for k, v := range value { - array[k] = v - } - case []bool: - array = make([]interface{}, len(value)) - for k, v := range value { - array[k] = v - } - case []float32: - array = make([]interface{}, len(value)) - for k, v := range value { - array[k] = v - } - case []float64: - array = make([]interface{}, len(value)) - for k, v := range value { - array[k] = v - } - } - if array != nil { - return array - } - if v, ok := any.(localinterface.IInterfaces); ok { - return v.Interfaces() - } - // JSON format string value converting. - if checkJsonAndUnmarshalUseNumber(any, &array) { - return array - } - // Not a common type, it then uses reflection for conversion. - originValueAndKind := reflection.OriginValueAndKind(any) - switch originValueAndKind.OriginKind { - case reflect.Slice, reflect.Array: - var ( - length = originValueAndKind.OriginValue.Len() - slice = make([]interface{}, length) - ) - for i := 0; i < length; i++ { - slice[i] = originValueAndKind.OriginValue.Index(i).Interface() - } - return slice - - default: - return []interface{}{any} - } + result, _ := defaultConverter.SliceAny(any, SliceOption{ + ContinueOnError: true, + }) + return result } diff --git a/util/gconv/gconv_slice_float.go b/util/gconv/gconv_slice_float.go index bca5af6b04b..32757782f79 100644 --- a/util/gconv/gconv_slice_float.go +++ b/util/gconv/gconv_slice_float.go @@ -6,14 +6,6 @@ package gconv -import ( - "reflect" - - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/internal/reflection" - "github.com/gogf/gf/v2/util/gconv/internal/localinterface" -) - // SliceFloat is alias of Floats. func SliceFloat(any interface{}) []float64 { return Floats(any) @@ -36,248 +28,16 @@ func Floats(any interface{}) []float64 { // Float32s converts `any` to []float32. func Float32s(any interface{}) []float32 { - if any == nil { - return nil - } - var ( - array []float32 = nil - ) - switch value := any.(type) { - case string: - if value == "" { - return []float32{} - } - return []float32{Float32(value)} - case []string: - array = make([]float32, len(value)) - for k, v := range value { - array[k] = Float32(v) - } - case []int: - array = make([]float32, len(value)) - for k, v := range value { - array[k] = Float32(v) - } - case []int8: - array = make([]float32, len(value)) - for k, v := range value { - array[k] = Float32(v) - } - case []int16: - array = make([]float32, len(value)) - for k, v := range value { - array[k] = Float32(v) - } - case []int32: - array = make([]float32, len(value)) - for k, v := range value { - array[k] = Float32(v) - } - case []int64: - array = make([]float32, len(value)) - for k, v := range value { - array[k] = Float32(v) - } - case []uint: - for _, v := range value { - array = append(array, Float32(v)) - } - case []uint8: - if json.Valid(value) { - _ = json.UnmarshalUseNumber(value, &array) - } else { - array = make([]float32, len(value)) - for k, v := range value { - array[k] = Float32(v) - } - } - case []uint16: - array = make([]float32, len(value)) - for k, v := range value { - array[k] = Float32(v) - } - case []uint32: - array = make([]float32, len(value)) - for k, v := range value { - array[k] = Float32(v) - } - case []uint64: - array = make([]float32, len(value)) - for k, v := range value { - array[k] = Float32(v) - } - case []bool: - array = make([]float32, len(value)) - for k, v := range value { - array[k] = Float32(v) - } - case []float32: - array = value - case []float64: - array = make([]float32, len(value)) - for k, v := range value { - array[k] = Float32(v) - } - case []interface{}: - array = make([]float32, len(value)) - for k, v := range value { - array[k] = Float32(v) - } - } - if array != nil { - return array - } - if v, ok := any.(localinterface.IFloats); ok { - return Float32s(v.Floats()) - } - if v, ok := any.(localinterface.IInterfaces); ok { - return Float32s(v.Interfaces()) - } - // JSON format string value converting. - if checkJsonAndUnmarshalUseNumber(any, &array) { - return array - } - // Not a common type, it then uses reflection for conversion. - originValueAndKind := reflection.OriginValueAndKind(any) - switch originValueAndKind.OriginKind { - case reflect.Slice, reflect.Array: - var ( - length = originValueAndKind.OriginValue.Len() - slice = make([]float32, length) - ) - for i := 0; i < length; i++ { - slice[i] = Float32(originValueAndKind.OriginValue.Index(i).Interface()) - } - return slice - - default: - if originValueAndKind.OriginValue.IsZero() { - return []float32{} - } - return []float32{Float32(any)} - } + result, _ := defaultConverter.SliceFloat32(any, SliceOption{ + ContinueOnError: true, + }) + return result } // Float64s converts `any` to []float64. func Float64s(any interface{}) []float64 { - if any == nil { - return nil - } - var ( - array []float64 = nil - ) - switch value := any.(type) { - case string: - if value == "" { - return []float64{} - } - return []float64{Float64(value)} - case []string: - array = make([]float64, len(value)) - for k, v := range value { - array[k] = Float64(v) - } - case []int: - array = make([]float64, len(value)) - for k, v := range value { - array[k] = Float64(v) - } - case []int8: - array = make([]float64, len(value)) - for k, v := range value { - array[k] = Float64(v) - } - case []int16: - array = make([]float64, len(value)) - for k, v := range value { - array[k] = Float64(v) - } - case []int32: - array = make([]float64, len(value)) - for k, v := range value { - array[k] = Float64(v) - } - case []int64: - array = make([]float64, len(value)) - for k, v := range value { - array[k] = Float64(v) - } - case []uint: - for _, v := range value { - array = append(array, Float64(v)) - } - case []uint8: - if json.Valid(value) { - _ = json.UnmarshalUseNumber(value, &array) - } else { - array = make([]float64, len(value)) - for k, v := range value { - array[k] = Float64(v) - } - } - case []uint16: - array = make([]float64, len(value)) - for k, v := range value { - array[k] = Float64(v) - } - case []uint32: - array = make([]float64, len(value)) - for k, v := range value { - array[k] = Float64(v) - } - case []uint64: - array = make([]float64, len(value)) - for k, v := range value { - array[k] = Float64(v) - } - case []bool: - array = make([]float64, len(value)) - for k, v := range value { - array[k] = Float64(v) - } - case []float32: - array = make([]float64, len(value)) - for k, v := range value { - array[k] = Float64(v) - } - case []float64: - array = value - case []interface{}: - array = make([]float64, len(value)) - for k, v := range value { - array[k] = Float64(v) - } - } - if array != nil { - return array - } - if v, ok := any.(localinterface.IFloats); ok { - return v.Floats() - } - if v, ok := any.(localinterface.IInterfaces); ok { - return Floats(v.Interfaces()) - } - // JSON format string value converting. - if checkJsonAndUnmarshalUseNumber(any, &array) { - return array - } - // Not a common type, it then uses reflection for conversion. - originValueAndKind := reflection.OriginValueAndKind(any) - switch originValueAndKind.OriginKind { - case reflect.Slice, reflect.Array: - var ( - length = originValueAndKind.OriginValue.Len() - slice = make([]float64, length) - ) - for i := 0; i < length; i++ { - slice[i] = Float64(originValueAndKind.OriginValue.Index(i).Interface()) - } - return slice - - default: - if originValueAndKind.OriginValue.IsZero() { - return []float64{} - } - return []float64{Float64(any)} - } + result, _ := defaultConverter.SliceFloat64(any, SliceOption{ + ContinueOnError: true, + }) + return result } diff --git a/util/gconv/gconv_slice_int.go b/util/gconv/gconv_slice_int.go index 929acfa147e..dedc634d115 100644 --- a/util/gconv/gconv_slice_int.go +++ b/util/gconv/gconv_slice_int.go @@ -6,412 +6,41 @@ package gconv -import ( - "reflect" - - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/internal/reflection" - "github.com/gogf/gf/v2/util/gconv/internal/localinterface" -) - // SliceInt is alias of Ints. -func SliceInt(any interface{}) []int { +func SliceInt(any any) []int { return Ints(any) } // SliceInt32 is alias of Int32s. -func SliceInt32(any interface{}) []int32 { +func SliceInt32(any any) []int32 { return Int32s(any) } // SliceInt64 is alias of Int64s. -func SliceInt64(any interface{}) []int64 { +func SliceInt64(any any) []int64 { return Int64s(any) } // Ints converts `any` to []int. -func Ints(any interface{}) []int { - if any == nil { - return nil - } - var ( - array []int = nil - ) - switch value := any.(type) { - case []string: - array = make([]int, len(value)) - for k, v := range value { - array[k] = Int(v) - } - case []int: - array = value - case []int8: - array = make([]int, len(value)) - for k, v := range value { - array[k] = int(v) - } - case []int16: - array = make([]int, len(value)) - for k, v := range value { - array[k] = int(v) - } - case []int32: - array = make([]int, len(value)) - for k, v := range value { - array[k] = int(v) - } - case []int64: - array = make([]int, len(value)) - for k, v := range value { - array[k] = int(v) - } - case []uint: - array = make([]int, len(value)) - for k, v := range value { - array[k] = int(v) - } - case []uint8: - if json.Valid(value) { - _ = json.UnmarshalUseNumber(value, &array) - } else { - array = make([]int, len(value)) - for k, v := range value { - array[k] = int(v) - } - } - case []uint16: - array = make([]int, len(value)) - for k, v := range value { - array[k] = int(v) - } - case []uint32: - array = make([]int, len(value)) - for k, v := range value { - array[k] = int(v) - } - case []uint64: - array = make([]int, len(value)) - for k, v := range value { - array[k] = int(v) - } - case []bool: - array = make([]int, len(value)) - for k, v := range value { - if v { - array[k] = 1 - } else { - array[k] = 0 - } - } - case []float32: - array = make([]int, len(value)) - for k, v := range value { - array[k] = Int(v) - } - case []float64: - array = make([]int, len(value)) - for k, v := range value { - array[k] = Int(v) - } - case []interface{}: - array = make([]int, len(value)) - for k, v := range value { - array[k] = Int(v) - } - case [][]byte: - array = make([]int, len(value)) - for k, v := range value { - array[k] = Int(v) - } - } - if array != nil { - return array - } - if v, ok := any.(localinterface.IInts); ok { - return v.Ints() - } - if v, ok := any.(localinterface.IInterfaces); ok { - return Ints(v.Interfaces()) - } - // JSON format string value converting. - if checkJsonAndUnmarshalUseNumber(any, &array) { - return array - } - // Not a common type, it then uses reflection for conversion. - originValueAndKind := reflection.OriginValueAndKind(any) - switch originValueAndKind.OriginKind { - case reflect.Slice, reflect.Array: - var ( - length = originValueAndKind.OriginValue.Len() - slice = make([]int, length) - ) - for i := 0; i < length; i++ { - slice[i] = Int(originValueAndKind.OriginValue.Index(i).Interface()) - } - return slice - - default: - if originValueAndKind.OriginValue.IsZero() { - return []int{} - } - return []int{Int(any)} - } +func Ints(any any) []int { + result, _ := defaultConverter.SliceInt(any, SliceOption{ + ContinueOnError: true, + }) + return result } // Int32s converts `any` to []int32. -func Int32s(any interface{}) []int32 { - if any == nil { - return nil - } - var ( - array []int32 = nil - ) - switch value := any.(type) { - case []string: - array = make([]int32, len(value)) - for k, v := range value { - array[k] = Int32(v) - } - case []int: - array = make([]int32, len(value)) - for k, v := range value { - array[k] = int32(v) - } - case []int8: - array = make([]int32, len(value)) - for k, v := range value { - array[k] = int32(v) - } - case []int16: - array = make([]int32, len(value)) - for k, v := range value { - array[k] = int32(v) - } - case []int32: - array = value - case []int64: - array = make([]int32, len(value)) - for k, v := range value { - array[k] = int32(v) - } - case []uint: - array = make([]int32, len(value)) - for k, v := range value { - array[k] = int32(v) - } - case []uint8: - if json.Valid(value) { - _ = json.UnmarshalUseNumber(value, &array) - } else { - array = make([]int32, len(value)) - for k, v := range value { - array[k] = int32(v) - } - } - case []uint16: - array = make([]int32, len(value)) - for k, v := range value { - array[k] = int32(v) - } - case []uint32: - array = make([]int32, len(value)) - for k, v := range value { - array[k] = int32(v) - } - case []uint64: - array = make([]int32, len(value)) - for k, v := range value { - array[k] = int32(v) - } - case []bool: - array = make([]int32, len(value)) - for k, v := range value { - if v { - array[k] = 1 - } else { - array[k] = 0 - } - } - case []float32: - array = make([]int32, len(value)) - for k, v := range value { - array[k] = Int32(v) - } - case []float64: - array = make([]int32, len(value)) - for k, v := range value { - array[k] = Int32(v) - } - case []interface{}: - array = make([]int32, len(value)) - for k, v := range value { - array[k] = Int32(v) - } - case [][]byte: - array = make([]int32, len(value)) - for k, v := range value { - array[k] = Int32(v) - } - } - if array != nil { - return array - } - if v, ok := any.(localinterface.IInts); ok { - return Int32s(v.Ints()) - } - if v, ok := any.(localinterface.IInterfaces); ok { - return Int32s(v.Interfaces()) - } - // JSON format string value converting. - if checkJsonAndUnmarshalUseNumber(any, &array) { - return array - } - // Not a common type, it then uses reflection for conversion. - originValueAndKind := reflection.OriginValueAndKind(any) - switch originValueAndKind.OriginKind { - case reflect.Slice, reflect.Array: - var ( - length = originValueAndKind.OriginValue.Len() - slice = make([]int32, length) - ) - for i := 0; i < length; i++ { - slice[i] = Int32(originValueAndKind.OriginValue.Index(i).Interface()) - } - return slice - - default: - if originValueAndKind.OriginValue.IsZero() { - return []int32{} - } - return []int32{Int32(any)} - } +func Int32s(any any) []int32 { + result, _ := defaultConverter.SliceInt32(any, SliceOption{ + ContinueOnError: true, + }) + return result } // Int64s converts `any` to []int64. -func Int64s(any interface{}) []int64 { - if any == nil { - return nil - } - var ( - array []int64 = nil - ) - switch value := any.(type) { - case []string: - array = make([]int64, len(value)) - for k, v := range value { - array[k] = Int64(v) - } - case []int: - array = make([]int64, len(value)) - for k, v := range value { - array[k] = int64(v) - } - case []int8: - array = make([]int64, len(value)) - for k, v := range value { - array[k] = int64(v) - } - case []int16: - array = make([]int64, len(value)) - for k, v := range value { - array[k] = int64(v) - } - case []int32: - array = make([]int64, len(value)) - for k, v := range value { - array[k] = int64(v) - } - case []int64: - array = value - case []uint: - array = make([]int64, len(value)) - for k, v := range value { - array[k] = int64(v) - } - case []uint8: - if json.Valid(value) { - _ = json.UnmarshalUseNumber(value, &array) - } else { - array = make([]int64, len(value)) - for k, v := range value { - array[k] = int64(v) - } - } - case []uint16: - array = make([]int64, len(value)) - for k, v := range value { - array[k] = int64(v) - } - case []uint32: - array = make([]int64, len(value)) - for k, v := range value { - array[k] = int64(v) - } - case []uint64: - array = make([]int64, len(value)) - for k, v := range value { - array[k] = int64(v) - } - case []bool: - array = make([]int64, len(value)) - for k, v := range value { - if v { - array[k] = 1 - } else { - array[k] = 0 - } - } - case []float32: - array = make([]int64, len(value)) - for k, v := range value { - array[k] = Int64(v) - } - case []float64: - array = make([]int64, len(value)) - for k, v := range value { - array[k] = Int64(v) - } - case []interface{}: - array = make([]int64, len(value)) - for k, v := range value { - array[k] = Int64(v) - } - case [][]byte: - array = make([]int64, len(value)) - for k, v := range value { - array[k] = Int64(v) - } - } - if array != nil { - return array - } - if v, ok := any.(localinterface.IInts); ok { - return Int64s(v.Ints()) - } - if v, ok := any.(localinterface.IInterfaces); ok { - return Int64s(v.Interfaces()) - } - // JSON format string value converting. - if checkJsonAndUnmarshalUseNumber(any, &array) { - return array - } - // Not a common type, it then uses reflection for conversion. - originValueAndKind := reflection.OriginValueAndKind(any) - switch originValueAndKind.OriginKind { - case reflect.Slice, reflect.Array: - var ( - length = originValueAndKind.OriginValue.Len() - slice = make([]int64, length) - ) - for i := 0; i < length; i++ { - slice[i] = Int64(originValueAndKind.OriginValue.Index(i).Interface()) - } - return slice - - default: - if originValueAndKind.OriginValue.IsZero() { - return []int64{} - } - return []int64{Int64(any)} - } +func Int64s(any any) []int64 { + result, _ := defaultConverter.SliceInt64(any, SliceOption{ + ContinueOnError: true, + }) + return result } diff --git a/util/gconv/gconv_slice_str.go b/util/gconv/gconv_slice_str.go index 405e72ca522..b475dfb0836 100644 --- a/util/gconv/gconv_slice_str.go +++ b/util/gconv/gconv_slice_str.go @@ -6,14 +6,6 @@ package gconv -import ( - "reflect" - - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/internal/reflection" - "github.com/gogf/gf/v2/util/gconv/internal/localinterface" -) - // SliceStr is alias of Strings. func SliceStr(any interface{}) []string { return Strings(any) @@ -21,140 +13,8 @@ func SliceStr(any interface{}) []string { // Strings converts `any` to []string. func Strings(any interface{}) []string { - if any == nil { - return nil - } - var ( - array []string = nil - ) - switch value := any.(type) { - case []int: - array = make([]string, len(value)) - for k, v := range value { - array[k] = String(v) - } - case []int8: - array = make([]string, len(value)) - for k, v := range value { - array[k] = String(v) - } - case []int16: - array = make([]string, len(value)) - for k, v := range value { - array[k] = String(v) - } - case []int32: - array = make([]string, len(value)) - for k, v := range value { - array[k] = String(v) - } - case []int64: - array = make([]string, len(value)) - for k, v := range value { - array[k] = String(v) - } - case []uint: - array = make([]string, len(value)) - for k, v := range value { - array[k] = String(v) - } - case []uint8: - if json.Valid(value) { - _ = json.UnmarshalUseNumber(value, &array) - } - if array == nil { - array = make([]string, len(value)) - for k, v := range value { - array[k] = String(v) - } - return array - } - case string: - byteValue := []byte(value) - if json.Valid(byteValue) { - _ = json.UnmarshalUseNumber(byteValue, &array) - } - if array == nil { - if value == "" { - return []string{} - } - // Prevent strings from being null - // See Issue 3465 for details - return []string{value} - } - case []uint16: - array = make([]string, len(value)) - for k, v := range value { - array[k] = String(v) - } - case []uint32: - array = make([]string, len(value)) - for k, v := range value { - array[k] = String(v) - } - case []uint64: - array = make([]string, len(value)) - for k, v := range value { - array[k] = String(v) - } - case []bool: - array = make([]string, len(value)) - for k, v := range value { - array[k] = String(v) - } - case []float32: - array = make([]string, len(value)) - for k, v := range value { - array[k] = String(v) - } - case []float64: - array = make([]string, len(value)) - for k, v := range value { - array[k] = String(v) - } - case []interface{}: - array = make([]string, len(value)) - for k, v := range value { - array[k] = String(v) - } - case []string: - array = value - case [][]byte: - array = make([]string, len(value)) - for k, v := range value { - array[k] = String(v) - } - } - if array != nil { - return array - } - if v, ok := any.(localinterface.IStrings); ok { - return v.Strings() - } - if v, ok := any.(localinterface.IInterfaces); ok { - return Strings(v.Interfaces()) - } - // JSON format string value converting. - if checkJsonAndUnmarshalUseNumber(any, &array) { - return array - } - // Not a common type, it then uses reflection for conversion. - originValueAndKind := reflection.OriginValueAndKind(any) - switch originValueAndKind.OriginKind { - case reflect.Slice, reflect.Array: - var ( - length = originValueAndKind.OriginValue.Len() - slice = make([]string, length) - ) - for i := 0; i < length; i++ { - slice[i] = String(originValueAndKind.OriginValue.Index(i).Interface()) - } - return slice - - default: - if originValueAndKind.OriginValue.IsZero() { - return []string{} - } - return []string{String(any)} - } + result, _ := defaultConverter.SliceStr(any, SliceOption{ + ContinueOnError: true, + }) + return result } diff --git a/util/gconv/gconv_slice_uint.go b/util/gconv/gconv_slice_uint.go index 8ab15dbf7fa..7ab9b4fdf22 100644 --- a/util/gconv/gconv_slice_uint.go +++ b/util/gconv/gconv_slice_uint.go @@ -6,16 +6,6 @@ package gconv -import ( - "reflect" - "strings" - - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/internal/reflection" - "github.com/gogf/gf/v2/internal/utils" - "github.com/gogf/gf/v2/util/gconv/internal/localinterface" -) - // SliceUint is alias of Uints. func SliceUint(any interface{}) []uint { return Uints(any) @@ -33,405 +23,24 @@ func SliceUint64(any interface{}) []uint64 { // Uints converts `any` to []uint. func Uints(any interface{}) []uint { - if any == nil { - return nil - } - - var ( - array []uint = nil - ) - switch value := any.(type) { - case string: - value = strings.TrimSpace(value) - if value == "" { - return []uint{} - } - if utils.IsNumeric(value) { - return []uint{Uint(value)} - } - - case []string: - array = make([]uint, len(value)) - for k, v := range value { - array[k] = Uint(v) - } - case []int8: - array = make([]uint, len(value)) - for k, v := range value { - array[k] = uint(v) - } - case []int16: - array = make([]uint, len(value)) - for k, v := range value { - array[k] = uint(v) - } - case []int32: - array = make([]uint, len(value)) - for k, v := range value { - array[k] = uint(v) - } - case []int64: - array = make([]uint, len(value)) - for k, v := range value { - array[k] = uint(v) - } - case []uint: - array = value - case []uint8: - if json.Valid(value) { - _ = json.UnmarshalUseNumber(value, &array) - } else { - array = make([]uint, len(value)) - for k, v := range value { - array[k] = uint(v) - } - } - case []uint16: - array = make([]uint, len(value)) - for k, v := range value { - array[k] = uint(v) - } - case []uint32: - array = make([]uint, len(value)) - for k, v := range value { - array[k] = uint(v) - } - case []uint64: - array = make([]uint, len(value)) - for k, v := range value { - array[k] = uint(v) - } - case []bool: - array = make([]uint, len(value)) - for k, v := range value { - if v { - array[k] = 1 - } else { - array[k] = 0 - } - } - case []float32: - array = make([]uint, len(value)) - for k, v := range value { - array[k] = Uint(v) - } - case []float64: - array = make([]uint, len(value)) - for k, v := range value { - array[k] = Uint(v) - } - case []interface{}: - array = make([]uint, len(value)) - for k, v := range value { - array[k] = Uint(v) - } - case [][]byte: - array = make([]uint, len(value)) - for k, v := range value { - array[k] = Uint(v) - } - } - - if array != nil { - return array - } - - // Default handler. - if v, ok := any.(localinterface.IUints); ok { - return v.Uints() - } - if v, ok := any.(localinterface.IInterfaces); ok { - return Uints(v.Interfaces()) - } - // JSON format string value converting. - if checkJsonAndUnmarshalUseNumber(any, &array) { - return array - } - // Not a common type, it then uses reflection for conversion. - originValueAndKind := reflection.OriginValueAndKind(any) - switch originValueAndKind.OriginKind { - case reflect.Slice, reflect.Array: - var ( - length = originValueAndKind.OriginValue.Len() - slice = make([]uint, length) - ) - for i := 0; i < length; i++ { - slice[i] = Uint(originValueAndKind.OriginValue.Index(i).Interface()) - } - return slice - - default: - if originValueAndKind.OriginValue.IsZero() { - return []uint{} - } - return []uint{Uint(any)} - } + result, _ := defaultConverter.SliceUint(any, SliceOption{ + ContinueOnError: true, + }) + return result } // Uint32s converts `any` to []uint32. func Uint32s(any interface{}) []uint32 { - if any == nil { - return nil - } - var ( - array []uint32 = nil - ) - switch value := any.(type) { - case string: - value = strings.TrimSpace(value) - if value == "" { - return []uint32{} - } - if utils.IsNumeric(value) { - return []uint32{Uint32(value)} - } - case []string: - array = make([]uint32, len(value)) - for k, v := range value { - array[k] = Uint32(v) - } - case []int8: - array = make([]uint32, len(value)) - for k, v := range value { - array[k] = uint32(v) - } - case []int16: - array = make([]uint32, len(value)) - for k, v := range value { - array[k] = uint32(v) - } - case []int32: - array = make([]uint32, len(value)) - for k, v := range value { - array[k] = uint32(v) - } - case []int64: - array = make([]uint32, len(value)) - for k, v := range value { - array[k] = uint32(v) - } - case []uint: - array = make([]uint32, len(value)) - for k, v := range value { - array[k] = uint32(v) - } - case []uint8: - if json.Valid(value) { - _ = json.UnmarshalUseNumber(value, &array) - } else { - array = make([]uint32, len(value)) - for k, v := range value { - array[k] = uint32(v) - } - } - case []uint16: - array = make([]uint32, len(value)) - for k, v := range value { - array[k] = uint32(v) - } - case []uint32: - array = value - case []uint64: - array = make([]uint32, len(value)) - for k, v := range value { - array[k] = uint32(v) - } - case []bool: - array = make([]uint32, len(value)) - for k, v := range value { - if v { - array[k] = 1 - } else { - array[k] = 0 - } - } - case []float32: - array = make([]uint32, len(value)) - for k, v := range value { - array[k] = Uint32(v) - } - case []float64: - array = make([]uint32, len(value)) - for k, v := range value { - array[k] = Uint32(v) - } - case []interface{}: - array = make([]uint32, len(value)) - for k, v := range value { - array[k] = Uint32(v) - } - case [][]byte: - array = make([]uint32, len(value)) - for k, v := range value { - array[k] = Uint32(v) - } - } - if array != nil { - return array - } - - // Default handler. - if v, ok := any.(localinterface.IUints); ok { - return Uint32s(v.Uints()) - } - if v, ok := any.(localinterface.IInterfaces); ok { - return Uint32s(v.Interfaces()) - } - // JSON format string value converting. - if checkJsonAndUnmarshalUseNumber(any, &array) { - return array - } - // Not a common type, it then uses reflection for conversion. - originValueAndKind := reflection.OriginValueAndKind(any) - switch originValueAndKind.OriginKind { - case reflect.Slice, reflect.Array: - var ( - length = originValueAndKind.OriginValue.Len() - slice = make([]uint32, length) - ) - for i := 0; i < length; i++ { - slice[i] = Uint32(originValueAndKind.OriginValue.Index(i).Interface()) - } - return slice - - default: - if originValueAndKind.OriginValue.IsZero() { - return []uint32{} - } - return []uint32{Uint32(any)} - } + result, _ := defaultConverter.SliceUint32(any, SliceOption{ + ContinueOnError: true, + }) + return result } // Uint64s converts `any` to []uint64. func Uint64s(any interface{}) []uint64 { - if any == nil { - return nil - } - var ( - array []uint64 = nil - ) - switch value := any.(type) { - case string: - value = strings.TrimSpace(value) - if value == "" { - return []uint64{} - } - if utils.IsNumeric(value) { - return []uint64{Uint64(value)} - } - - case []string: - array = make([]uint64, len(value)) - for k, v := range value { - array[k] = Uint64(v) - } - case []int8: - array = make([]uint64, len(value)) - for k, v := range value { - array[k] = uint64(v) - } - case []int16: - array = make([]uint64, len(value)) - for k, v := range value { - array[k] = uint64(v) - } - case []int32: - array = make([]uint64, len(value)) - for k, v := range value { - array[k] = uint64(v) - } - case []int64: - array = make([]uint64, len(value)) - for k, v := range value { - array[k] = uint64(v) - } - case []uint: - array = make([]uint64, len(value)) - for k, v := range value { - array[k] = uint64(v) - } - case []uint8: - if json.Valid(value) { - _ = json.UnmarshalUseNumber(value, &array) - } else { - array = make([]uint64, len(value)) - for k, v := range value { - array[k] = uint64(v) - } - } - case []uint16: - array = make([]uint64, len(value)) - for k, v := range value { - array[k] = uint64(v) - } - case []uint32: - array = make([]uint64, len(value)) - for k, v := range value { - array[k] = uint64(v) - } - case []uint64: - array = value - case []bool: - array = make([]uint64, len(value)) - for k, v := range value { - if v { - array[k] = 1 - } else { - array[k] = 0 - } - } - case []float32: - array = make([]uint64, len(value)) - for k, v := range value { - array[k] = Uint64(v) - } - case []float64: - array = make([]uint64, len(value)) - for k, v := range value { - array[k] = Uint64(v) - } - case []interface{}: - array = make([]uint64, len(value)) - for k, v := range value { - array[k] = Uint64(v) - } - case [][]byte: - array = make([]uint64, len(value)) - for k, v := range value { - array[k] = Uint64(v) - } - } - if array != nil { - return array - } - // Default handler. - if v, ok := any.(localinterface.IUints); ok { - return Uint64s(v.Uints()) - } - if v, ok := any.(localinterface.IInterfaces); ok { - return Uint64s(v.Interfaces()) - } - // JSON format string value converting. - if checkJsonAndUnmarshalUseNumber(any, &array) { - return array - } - // Not a common type, it then uses reflection for conversion. - originValueAndKind := reflection.OriginValueAndKind(any) - switch originValueAndKind.OriginKind { - case reflect.Slice, reflect.Array: - var ( - length = originValueAndKind.OriginValue.Len() - slice = make([]uint64, length) - ) - for i := 0; i < length; i++ { - slice[i] = Uint64(originValueAndKind.OriginValue.Index(i).Interface()) - } - return slice - - default: - if originValueAndKind.OriginValue.IsZero() { - return []uint64{} - } - return []uint64{Uint64(any)} - } + result, _ := defaultConverter.SliceUint64(any, SliceOption{ + ContinueOnError: true, + }) + return result } diff --git a/util/gconv/gconv_struct.go b/util/gconv/gconv_struct.go index cbb6eb0b0cf..e20b899581d 100644 --- a/util/gconv/gconv_struct.go +++ b/util/gconv/gconv_struct.go @@ -6,19 +6,6 @@ package gconv -import ( - "reflect" - "strings" - - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/internal/empty" - "github.com/gogf/gf/v2/internal/json" - "github.com/gogf/gf/v2/internal/utils" - "github.com/gogf/gf/v2/util/gconv/internal/localinterface" - "github.com/gogf/gf/v2/util/gconv/internal/structcache" -) - // Struct maps the params key-value pairs to the corresponding struct object's attributes. // The third parameter `mapping` is unnecessary, indicating the mapping rules between the // custom key name and the attribute name(case-sensitive). @@ -32,609 +19,17 @@ import ( // It will automatically convert the first letter of the key to uppercase // in mapping procedure to do the matching. // It ignores the map key, if it does not match. -func Struct(params interface{}, pointer interface{}, paramKeyToAttrMap ...map[string]string) (err error) { +func Struct(params any, pointer any, paramKeyToAttrMap ...map[string]string) (err error) { return Scan(params, pointer, paramKeyToAttrMap...) } // StructTag acts as Struct but also with support for priority tag feature, which retrieves the // specified priorityTagAndFieldName for `params` key-value items to struct attribute names mapping. // The parameter `priorityTag` supports multiple priorityTagAndFieldName that can be joined with char ','. -func StructTag(params interface{}, pointer interface{}, priorityTag string) (err error) { - return doStruct(params, pointer, nil, priorityTag) -} - -// doStruct is the core internal converting function for any data to struct. -func doStruct( - params interface{}, pointer interface{}, paramKeyToAttrMap map[string]string, priorityTag string, -) (err error) { - if params == nil { - // If `params` is nil, no conversion. - return nil - } - if pointer == nil { - return gerror.NewCode(gcode.CodeInvalidParameter, "object pointer cannot be nil") - } - - // JSON content converting. - ok, err := doConvertWithJsonCheck(params, pointer) - if err != nil { - return err - } - if ok { - return nil - } - - defer func() { - // Catch the panic, especially the reflection operation panics. - if exception := recover(); exception != nil { - if v, ok := exception.(error); ok && gerror.HasStack(v) { - err = v - } else { - err = gerror.NewCodeSkipf(gcode.CodeInternalPanic, 1, "%+v", exception) - } - } - }() - - var ( - paramsReflectValue reflect.Value - paramsInterface interface{} // DO NOT use `params` directly as it might be type `reflect.Value` - pointerReflectValue reflect.Value - pointerReflectKind reflect.Kind - pointerElemReflectValue reflect.Value // The reflection value to struct element. - ) - if v, ok := params.(reflect.Value); ok { - paramsReflectValue = v - } else { - paramsReflectValue = reflect.ValueOf(params) - } - paramsInterface = paramsReflectValue.Interface() - if v, ok := pointer.(reflect.Value); ok { - pointerReflectValue = v - pointerElemReflectValue = v - } else { - pointerReflectValue = reflect.ValueOf(pointer) - pointerReflectKind = pointerReflectValue.Kind() - if pointerReflectKind != reflect.Ptr { - return gerror.NewCodef( - gcode.CodeInvalidParameter, - "destination pointer should be type of '*struct', but got '%v'", - pointerReflectKind, - ) - } - // Using IsNil on reflect.Ptr variable is OK. - if !pointerReflectValue.IsValid() || pointerReflectValue.IsNil() { - return gerror.NewCode( - gcode.CodeInvalidParameter, - "destination pointer cannot be nil", - ) - } - pointerElemReflectValue = pointerReflectValue.Elem() - } - - // If `params` and `pointer` are the same type, the do directly assignment. - // For performance enhancement purpose. - if ok = doConvertWithTypeCheck(paramsReflectValue, pointerElemReflectValue); ok { - return nil - } - - // custom convert. - if ok, err = callCustomConverter(paramsReflectValue, pointerReflectValue); ok { - return err - } - - // Normal unmarshalling interfaces checks. - if ok, err = bindVarToReflectValueWithInterfaceCheck(pointerReflectValue, paramsInterface); ok { - return err - } - - // It automatically creates struct object if necessary. - // For example, if `pointer` is **User, then `elem` is *User, which is a pointer to User. - if pointerElemReflectValue.Kind() == reflect.Ptr { - if !pointerElemReflectValue.IsValid() || pointerElemReflectValue.IsNil() { - e := reflect.New(pointerElemReflectValue.Type().Elem()) - pointerElemReflectValue.Set(e) - defer func() { - if err != nil { - // If it is converted failed, it reset the `pointer` to nil. - pointerReflectValue.Elem().Set(reflect.Zero(pointerReflectValue.Type().Elem())) - } - }() - } - // if v, ok := pointerElemReflectValue.Interface().(localinterface.IUnmarshalValue); ok { - // return v.UnmarshalValue(params) - // } - // Note that it's `pointerElemReflectValue` here not `pointerReflectValue`. - if ok, err = bindVarToReflectValueWithInterfaceCheck(pointerElemReflectValue, paramsInterface); ok { - return err - } - // Retrieve its element, may be struct at last. - pointerElemReflectValue = pointerElemReflectValue.Elem() - } - paramsMap, ok := paramsInterface.(map[string]interface{}) - if !ok { - // paramsMap is the map[string]interface{} type variable for params. - // DO NOT use MapDeep here. - paramsMap = doMapConvert(paramsInterface, recursiveTypeAuto, true) - if paramsMap == nil { - return gerror.NewCodef( - gcode.CodeInvalidParameter, - `convert params from "%#v" to "map[string]interface{}" failed`, - params, - ) - } - } - // Nothing to be done as the parameters are empty. - if len(paramsMap) == 0 { - return nil - } - // Get struct info from cache or parse struct and cache the struct info. - cachedStructInfo := structcache.GetCachedStructInfo( - pointerElemReflectValue.Type(), priorityTag, - ) - // Nothing to be converted. - if cachedStructInfo == nil { - return nil - } - // For the structure types of 0 tagOrFiledNameToFieldInfoMap, - // they also need to be cached to prevent invalid logic - if cachedStructInfo.HasNoFields() { - return nil - } - var ( - // Indicates that those values have been used and cannot be reused. - usedParamsKeyOrTagNameMap = structcache.GetUsedParamsKeyOrTagNameMapFromPool() - cachedFieldInfo *structcache.CachedFieldInfo - paramsValue interface{} - ) - defer structcache.PutUsedParamsKeyOrTagNameMapToPool(usedParamsKeyOrTagNameMap) - - // Firstly, search according to custom mapping rules. - // If a possible direct assignment is found, reduce the number of subsequent map searches. - for paramKey, fieldName := range paramKeyToAttrMap { - paramsValue, ok = paramsMap[paramKey] - if !ok { - continue - } - cachedFieldInfo = cachedStructInfo.GetFieldInfo(fieldName) - if cachedFieldInfo != nil { - fieldValue := cachedFieldInfo.GetFieldReflectValueFrom(pointerElemReflectValue) - if err = bindVarToStructField( - fieldValue, - paramsValue, - cachedFieldInfo, - paramKeyToAttrMap, - ); err != nil { - return err - } - if len(cachedFieldInfo.OtherSameNameField) > 0 { - if err = setOtherSameNameField( - cachedFieldInfo, paramsValue, pointerReflectValue, paramKeyToAttrMap, - ); err != nil { - return err - } - } - usedParamsKeyOrTagNameMap[paramKey] = struct{}{} - } - } - // Already done converting for given `paramsMap`. - if len(usedParamsKeyOrTagNameMap) == len(paramsMap) { - return nil - } - return bindStructWithLoopFieldInfos( - paramsMap, pointerElemReflectValue, paramKeyToAttrMap, usedParamsKeyOrTagNameMap, cachedStructInfo, - ) -} - -func setOtherSameNameField( - cachedFieldInfo *structcache.CachedFieldInfo, - srcValue any, - structValue reflect.Value, - paramKeyToAttrMap map[string]string, -) (err error) { - // loop the same field name of all sub attributes. - for _, otherFieldInfo := range cachedFieldInfo.OtherSameNameField { - fieldValue := cachedFieldInfo.GetOtherFieldReflectValueFrom(structValue, otherFieldInfo.FieldIndexes) - if err = bindVarToStructField(fieldValue, srcValue, otherFieldInfo, paramKeyToAttrMap); err != nil { - return err - } - } - return nil -} - -func bindStructWithLoopFieldInfos( - paramsMap map[string]any, - structValue reflect.Value, - paramKeyToAttrMap map[string]string, - usedParamsKeyOrTagNameMap map[string]struct{}, - cachedStructInfo *structcache.CachedStructInfo, -) (err error) { - var ( - cachedFieldInfo *structcache.CachedFieldInfo - fuzzLastKey string - fieldValue reflect.Value - paramKey string - paramValue any - matched bool - ok bool - ) - for _, cachedFieldInfo = range cachedStructInfo.FieldConvertInfos { - for _, fieldTag := range cachedFieldInfo.PriorityTagAndFieldName { - if paramValue, ok = paramsMap[fieldTag]; !ok { - continue - } - fieldValue = cachedFieldInfo.GetFieldReflectValueFrom(structValue) - if err = bindVarToStructField( - fieldValue, paramValue, cachedFieldInfo, paramKeyToAttrMap, - ); err != nil { - return err - } - // handle same field name in nested struct. - if len(cachedFieldInfo.OtherSameNameField) > 0 { - if err = setOtherSameNameField( - cachedFieldInfo, paramValue, structValue, paramKeyToAttrMap, - ); err != nil { - return err - } - } - usedParamsKeyOrTagNameMap[fieldTag] = struct{}{} - matched = true - break - } - if matched { - matched = false - continue - } - - fuzzLastKey = cachedFieldInfo.LastFuzzyKey.Load().(string) - if paramValue, ok = paramsMap[fuzzLastKey]; !ok { - paramKey, paramValue = fuzzyMatchingFieldName( - cachedFieldInfo.RemoveSymbolsFieldName, paramsMap, usedParamsKeyOrTagNameMap, - ) - ok = paramKey != "" - cachedFieldInfo.LastFuzzyKey.Store(paramKey) - } - if ok { - fieldValue = cachedFieldInfo.GetFieldReflectValueFrom(structValue) - if paramValue != nil { - if err = bindVarToStructField( - fieldValue, paramValue, cachedFieldInfo, paramKeyToAttrMap, - ); err != nil { - return err - } - // handle same field name in nested struct. - if len(cachedFieldInfo.OtherSameNameField) > 0 { - if err = setOtherSameNameField( - cachedFieldInfo, paramValue, structValue, paramKeyToAttrMap, - ); err != nil { - return err - } - } - } - usedParamsKeyOrTagNameMap[paramKey] = struct{}{} - } - } - return nil -} - -// fuzzy matching rule: -// to match field name and param key in case-insensitive and without symbols. -func fuzzyMatchingFieldName( - fieldName string, - paramsMap map[string]any, - usedParamsKeyMap map[string]struct{}, -) (string, any) { - for paramKey, paramValue := range paramsMap { - if _, ok := usedParamsKeyMap[paramKey]; ok { - continue - } - removeParamKeyUnderline := utils.RemoveSymbols(paramKey) - if strings.EqualFold(fieldName, removeParamKeyUnderline) { - return paramKey, paramValue - } - } - return "", nil -} - -// bindVarToStructField sets value to struct object attribute by name. -func bindVarToStructField( - fieldValue reflect.Value, - srcValue interface{}, - cachedFieldInfo *structcache.CachedFieldInfo, - paramKeyToAttrMap map[string]string, -) (err error) { - if !fieldValue.IsValid() { - return nil - } - // CanSet checks whether attribute is public accessible. - if !fieldValue.CanSet() { - return nil - } - defer func() { - if exception := recover(); exception != nil { - if err = bindVarToReflectValue(fieldValue, srcValue, paramKeyToAttrMap); err != nil { - err = gerror.Wrapf(err, `error binding srcValue to attribute "%s"`, cachedFieldInfo.FieldName()) - } - } - }() - // Directly converting. - if empty.IsNil(srcValue) { - fieldValue.Set(reflect.Zero(fieldValue.Type())) - return nil - } - // Try to call custom converter. - // Issue: https://github.com/gogf/gf/issues/3099 - var ( - customConverterInput reflect.Value - ok bool - ) - if cachedFieldInfo.HasCustomConvert { - if customConverterInput, ok = srcValue.(reflect.Value); !ok { - customConverterInput = reflect.ValueOf(srcValue) - } - if ok, err = callCustomConverter(customConverterInput, fieldValue); ok || err != nil { - return - } - } - if cachedFieldInfo.IsCommonInterface { - if ok, err = bindVarToReflectValueWithInterfaceCheck(fieldValue, srcValue); ok || err != nil { - return - } - } - // Common types use fast assignment logic - if cachedFieldInfo.ConvertFunc != nil { - cachedFieldInfo.ConvertFunc(srcValue, fieldValue) - return nil - } - doConvertWithReflectValueSet(fieldValue, doConvertInput{ - FromValue: srcValue, - ToTypeName: cachedFieldInfo.StructField.Type.String(), - ReferValue: fieldValue, - }) - return nil -} - -// bindVarToReflectValueWithInterfaceCheck does bind using common interfaces checks. -func bindVarToReflectValueWithInterfaceCheck(reflectValue reflect.Value, value interface{}) (bool, error) { - var pointer interface{} - if reflectValue.Kind() != reflect.Ptr && reflectValue.CanAddr() { - reflectValueAddr := reflectValue.Addr() - if reflectValueAddr.IsNil() || !reflectValueAddr.IsValid() { - return false, nil - } - // Not a pointer, but can token address, that makes it can be unmarshalled. - pointer = reflectValue.Addr().Interface() - } else { - if reflectValue.IsNil() || !reflectValue.IsValid() { - return false, nil - } - pointer = reflectValue.Interface() - } - // UnmarshalValue. - if v, ok := pointer.(localinterface.IUnmarshalValue); ok { - return ok, v.UnmarshalValue(value) - } - // UnmarshalText. - if v, ok := pointer.(localinterface.IUnmarshalText); ok { - var valueBytes []byte - if b, ok := value.([]byte); ok { - valueBytes = b - } else if s, ok := value.(string); ok { - valueBytes = []byte(s) - } else if f, ok := value.(localinterface.IString); ok { - valueBytes = []byte(f.String()) - } - if len(valueBytes) > 0 { - return ok, v.UnmarshalText(valueBytes) - } - } - // UnmarshalJSON. - if v, ok := pointer.(localinterface.IUnmarshalJSON); ok { - var valueBytes []byte - if b, ok := value.([]byte); ok { - valueBytes = b - } else if s, ok := value.(string); ok { - valueBytes = []byte(s) - } else if f, ok := value.(localinterface.IString); ok { - valueBytes = []byte(f.String()) - } - - if len(valueBytes) > 0 { - // If it is not a valid JSON string, it then adds char `"` on its both sides to make it is. - if !json.Valid(valueBytes) { - newValueBytes := make([]byte, len(valueBytes)+2) - newValueBytes[0] = '"' - newValueBytes[len(newValueBytes)-1] = '"' - copy(newValueBytes[1:], valueBytes) - valueBytes = newValueBytes - } - return ok, v.UnmarshalJSON(valueBytes) - } - } - if v, ok := pointer.(localinterface.ISet); ok { - v.Set(value) - return ok, nil - } - return false, nil -} - -// bindVarToReflectValue sets `value` to reflect value object `structFieldValue`. -func bindVarToReflectValue( - structFieldValue reflect.Value, value interface{}, paramKeyToAttrMap map[string]string, -) (err error) { - // JSON content converting. - ok, err := doConvertWithJsonCheck(value, structFieldValue) - if err != nil { - return err - } - if ok { - return nil - } - - kind := structFieldValue.Kind() - // Converting using `Set` interface implements, for some types. - switch kind { - case reflect.Slice, reflect.Array, reflect.Ptr, reflect.Interface: - if !structFieldValue.IsNil() { - if v, ok := structFieldValue.Interface().(localinterface.ISet); ok { - v.Set(value) - return nil - } - } - } - - // Converting using reflection by kind. - switch kind { - case reflect.Map: - return doMapToMap(value, structFieldValue, paramKeyToAttrMap) - - case reflect.Struct: - // Recursively converting for struct attribute. - if err = doStruct(value, structFieldValue, nil, ""); err != nil { - // Note there's reflect conversion mechanism here. - structFieldValue.Set(reflect.ValueOf(value).Convert(structFieldValue.Type())) - } - - // Note that the slice element might be type of struct, - // so it uses Struct function doing the converting internally. - case reflect.Slice, reflect.Array: - var ( - reflectArray reflect.Value - reflectValue = reflect.ValueOf(value) - ) - if reflectValue.Kind() == reflect.Slice || reflectValue.Kind() == reflect.Array { - reflectArray = reflect.MakeSlice(structFieldValue.Type(), reflectValue.Len(), reflectValue.Len()) - if reflectValue.Len() > 0 { - var ( - elemType = reflectArray.Index(0).Type() - elemTypeName string - converted bool - ) - for i := 0; i < reflectValue.Len(); i++ { - converted = false - elemTypeName = elemType.Name() - if elemTypeName == "" { - elemTypeName = elemType.String() - } - var elem reflect.Value - if elemType.Kind() == reflect.Ptr { - elem = reflect.New(elemType.Elem()).Elem() - } else { - elem = reflect.New(elemType).Elem() - } - if elem.Kind() == reflect.Struct { - if err = doStruct(reflectValue.Index(i).Interface(), elem, nil, ""); err == nil { - converted = true - } - } - if !converted { - doConvertWithReflectValueSet(elem, doConvertInput{ - FromValue: reflectValue.Index(i).Interface(), - ToTypeName: elemTypeName, - ReferValue: elem, - }) - } - if elemType.Kind() == reflect.Ptr { - // Before it sets the `elem` to array, do pointer converting if necessary. - elem = elem.Addr() - } - reflectArray.Index(i).Set(elem) - } - } - } else { - var ( - elem reflect.Value - elemType = structFieldValue.Type().Elem() - elemTypeName = elemType.Name() - converted bool - ) - switch reflectValue.Kind() { - case reflect.String: - // Value is empty string. - if reflectValue.IsZero() { - var elemKind = elemType.Kind() - // Try to find the original type kind of the slice element. - if elemKind == reflect.Ptr { - elemKind = elemType.Elem().Kind() - } - switch elemKind { - case reflect.String: - // Empty string cannot be assigned to string slice. - return nil - } - } - } - if elemTypeName == "" { - elemTypeName = elemType.String() - } - if elemType.Kind() == reflect.Ptr { - elem = reflect.New(elemType.Elem()).Elem() - } else { - elem = reflect.New(elemType).Elem() - } - if elem.Kind() == reflect.Struct { - if err = doStruct(value, elem, nil, ""); err == nil { - converted = true - } - } - if !converted { - doConvertWithReflectValueSet(elem, doConvertInput{ - FromValue: value, - ToTypeName: elemTypeName, - ReferValue: elem, - }) - } - if elemType.Kind() == reflect.Ptr { - // Before it sets the `elem` to array, do pointer converting if necessary. - elem = elem.Addr() - } - reflectArray = reflect.MakeSlice(structFieldValue.Type(), 1, 1) - reflectArray.Index(0).Set(elem) - } - structFieldValue.Set(reflectArray) - - case reflect.Ptr: - if structFieldValue.IsNil() || structFieldValue.IsZero() { - // Nil or empty pointer, it creates a new one. - item := reflect.New(structFieldValue.Type().Elem()) - if ok, err = bindVarToReflectValueWithInterfaceCheck(item, value); ok { - structFieldValue.Set(item) - return err - } - elem := item.Elem() - if err = bindVarToReflectValue(elem, value, paramKeyToAttrMap); err == nil { - structFieldValue.Set(elem.Addr()) - } - } else { - // Not empty pointer, it assigns values to it. - return bindVarToReflectValue(structFieldValue.Elem(), value, paramKeyToAttrMap) - } - - // It mainly and specially handles the interface of nil value. - case reflect.Interface: - if value == nil { - // Specially. - structFieldValue.Set(reflect.ValueOf((*interface{})(nil))) - } else { - // Note there's reflect conversion mechanism here. - structFieldValue.Set(reflect.ValueOf(value).Convert(structFieldValue.Type())) - } - - default: - defer func() { - if exception := recover(); exception != nil { - err = gerror.NewCodef( - gcode.CodeInternalPanic, - `cannot convert value "%+v" to type "%s":%+v`, - value, - structFieldValue.Type().String(), - exception, - ) - } - }() - // It here uses reflect converting `value` to type of the attribute and assigns - // the result value to the attribute. It might fail and panic if the usual Go - // conversion rules do not allow conversion. - structFieldValue.Set(reflect.ValueOf(value).Convert(structFieldValue.Type())) +func StructTag(params any, pointer any, priorityTag string) (err error) { + option := StructOption{ + PriorityTag: priorityTag, + ContinueOnError: true, } - return nil + return defaultConverter.Struct(params, pointer, option) } diff --git a/util/gconv/gconv_structs.go b/util/gconv/gconv_structs.go index 867fcdd2bbd..3bfd7b42a2b 100644 --- a/util/gconv/gconv_structs.go +++ b/util/gconv/gconv_structs.go @@ -6,128 +6,25 @@ package gconv -import ( - "reflect" - - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" -) - // Structs converts any slice to given struct slice. // Also see Scan, Struct. -func Structs(params interface{}, pointer interface{}, paramKeyToAttrMap ...map[string]string) (err error) { +func Structs(params any, pointer any, paramKeyToAttrMap ...map[string]string) (err error) { return Scan(params, pointer, paramKeyToAttrMap...) } // SliceStruct is alias of Structs. -func SliceStruct(params interface{}, pointer interface{}, mapping ...map[string]string) (err error) { +func SliceStruct(params any, pointer any, mapping ...map[string]string) (err error) { return Structs(params, pointer, mapping...) } // StructsTag acts as Structs but also with support for priority tag feature, which retrieves the // specified priorityTagAndFieldName for `params` key-value items to struct attribute names mapping. // The parameter `priorityTag` supports multiple priorityTagAndFieldName that can be joined with char ','. -func StructsTag(params interface{}, pointer interface{}, priorityTag string) (err error) { - return doStructs(params, pointer, nil, priorityTag) -} - -// doStructs converts any slice to given struct slice. -// -// It automatically checks and converts json string to []map if `params` is string/[]byte. -// -// The parameter `pointer` should be type of pointer to slice of struct. -// Note that if `pointer` is a pointer to another pointer of type of slice of struct, -// it will create the struct/pointer internally. -func doStructs( - params interface{}, pointer interface{}, paramKeyToAttrMap map[string]string, priorityTag string, -) (err error) { - defer func() { - // Catch the panic, especially the reflection operation panics. - if exception := recover(); exception != nil { - if v, ok := exception.(error); ok && gerror.HasStack(v) { - err = v - } else { - err = gerror.NewCodeSkipf(gcode.CodeInternalPanic, 1, "%+v", exception) - } - } - }() - - // Pointer type check. - pointerRv, ok := pointer.(reflect.Value) - if !ok { - pointerRv = reflect.ValueOf(pointer) - if kind := pointerRv.Kind(); kind != reflect.Ptr { - return gerror.NewCodef( - gcode.CodeInvalidParameter, - "pointer should be type of pointer, but got: %v", kind, - ) - } - } - // Converting `params` to map slice. - var ( - paramsList []interface{} - paramsRv = reflect.ValueOf(params) - paramsKind = paramsRv.Kind() - ) - for paramsKind == reflect.Ptr { - paramsRv = paramsRv.Elem() - paramsKind = paramsRv.Kind() - } - switch paramsKind { - case reflect.Slice, reflect.Array: - paramsList = make([]interface{}, paramsRv.Len()) - for i := 0; i < paramsRv.Len(); i++ { - paramsList[i] = paramsRv.Index(i).Interface() - } - default: - var paramsMaps = Maps(params) - paramsList = make([]interface{}, len(paramsMaps)) - for i := 0; i < len(paramsMaps); i++ { - paramsList[i] = paramsMaps[i] - } - } - // If `params` is an empty slice, no conversion. - if len(paramsList) == 0 { - return nil - } - var ( - reflectElemArray = reflect.MakeSlice(pointerRv.Type().Elem(), len(paramsList), len(paramsList)) - itemType = reflectElemArray.Index(0).Type() - itemTypeKind = itemType.Kind() - pointerRvElem = pointerRv.Elem() - pointerRvLength = pointerRvElem.Len() - ) - if itemTypeKind == reflect.Ptr { - // Pointer element. - for i := 0; i < len(paramsList); i++ { - var tempReflectValue reflect.Value - if i < pointerRvLength { - // Might be nil. - tempReflectValue = pointerRvElem.Index(i).Elem() - } - if !tempReflectValue.IsValid() { - tempReflectValue = reflect.New(itemType.Elem()).Elem() - } - if err = doStruct(paramsList[i], tempReflectValue, paramKeyToAttrMap, priorityTag); err != nil { - return err - } - reflectElemArray.Index(i).Set(tempReflectValue.Addr()) - } - } else { - // Struct element. - for i := 0; i < len(paramsList); i++ { - var tempReflectValue reflect.Value - if i < pointerRvLength { - tempReflectValue = pointerRvElem.Index(i) - } else { - tempReflectValue = reflect.New(itemType).Elem() - } - if err = doStruct(paramsList[i], tempReflectValue, paramKeyToAttrMap, priorityTag); err != nil { - return err - } - reflectElemArray.Index(i).Set(tempReflectValue) - } - } - pointerRv.Elem().Set(reflectElemArray) - return nil +func StructsTag(params any, pointer any, priorityTag string) (err error) { + return defaultConverter.Structs(params, pointer, SliceOption{ + ContinueOnError: true, + }, StructOption{ + PriorityTag: priorityTag, + ContinueOnError: true, + }) } diff --git a/util/gconv/gconv_time.go b/util/gconv/gconv_time.go index d42a0639518..1102e0e875e 100644 --- a/util/gconv/gconv_time.go +++ b/util/gconv/gconv_time.go @@ -9,39 +9,21 @@ package gconv import ( "time" - "github.com/gogf/gf/v2/internal/utils" "github.com/gogf/gf/v2/os/gtime" - "github.com/gogf/gf/v2/util/gconv/internal/localinterface" ) // Time converts `any` to time.Time. -func Time(any interface{}, format ...string) time.Time { - // It's already this type. - if len(format) == 0 { - if v, ok := any.(time.Time); ok { - return v - } - } - if t := GTime(any, format...); t != nil { - return t.Time - } - return time.Time{} +func Time(any any, format ...string) time.Time { + t, _ := defaultConverter.Time(any, format...) + return t } // Duration converts `any` to time.Duration. // If `any` is string, then it uses time.ParseDuration to convert it. // If `any` is numeric, then it converts `any` as nanoseconds. -func Duration(any interface{}) time.Duration { - // It's already this type. - if v, ok := any.(time.Duration); ok { - return v - } - s := String(any) - if !utils.IsNumeric(s) { - d, _ := gtime.ParseDuration(s) - return d - } - return time.Duration(Int64(any)) +func Duration(any any) time.Duration { + d, _ := defaultConverter.Duration(any) + return d } // GTime converts `any` to *gtime.Time. @@ -49,43 +31,7 @@ func Duration(any interface{}) time.Duration { // It returns the converted value that matched the first format of the formats slice. // If no `format` given, it converts `any` using gtime.NewFromTimeStamp if `any` is numeric, // or using gtime.StrToTime if `any` is string. -func GTime(any interface{}, format ...string) *gtime.Time { - if any == nil { - return nil - } - if v, ok := any.(localinterface.IGTime); ok { - return v.GTime(format...) - } - // It's already this type. - if len(format) == 0 { - if v, ok := any.(*gtime.Time); ok { - return v - } - if t, ok := any.(time.Time); ok { - return gtime.New(t) - } - if t, ok := any.(*time.Time); ok { - return gtime.New(t) - } - } - s := String(any) - if len(s) == 0 { - return gtime.New() - } - // Priority conversion using given format. - if len(format) > 0 { - for _, item := range format { - t, err := gtime.StrToTimeFormat(s, item) - if t != nil && err == nil { - return t - } - } - return nil - } - if utils.IsNumeric(s) { - return gtime.NewFromTimeStamp(Int64(s)) - } else { - t, _ := gtime.StrToTime(s) - return t - } +func GTime(any any, format ...string) *gtime.Time { + t, _ := defaultConverter.GTime(any, format...) + return t } diff --git a/util/gconv/gconv_uint.go b/util/gconv/gconv_uint.go index 367a71a79a2..b7c9f66fd44 100644 --- a/util/gconv/gconv_uint.go +++ b/util/gconv/gconv_uint.go @@ -6,180 +6,32 @@ package gconv -import ( - "math" - "reflect" - "strconv" - - "github.com/gogf/gf/v2/encoding/gbinary" - "github.com/gogf/gf/v2/errors/gcode" - "github.com/gogf/gf/v2/errors/gerror" - "github.com/gogf/gf/v2/util/gconv/internal/localinterface" -) - // Uint converts `any` to uint. func Uint(any any) uint { - v, _ := doUint(any) + v, _ := defaultConverter.Uint(any) return v } -func doUint(any any) (uint, error) { - if any == nil { - return 0, nil - } - if v, ok := any.(uint); ok { - return v, nil - } - v, err := doUint64(any) - return uint(v), err -} - // Uint8 converts `any` to uint8. func Uint8(any any) uint8 { - v, _ := doUint8(any) + v, _ := defaultConverter.Uint8(any) return v } -func doUint8(any any) (uint8, error) { - if any == nil { - return 0, nil - } - if v, ok := any.(uint8); ok { - return v, nil - } - v, err := doUint64(any) - return uint8(v), err -} - // Uint16 converts `any` to uint16. func Uint16(any any) uint16 { - v, _ := doUint16(any) + v, _ := defaultConverter.Uint16(any) return v } -func doUint16(any any) (uint16, error) { - if any == nil { - return 0, nil - } - if v, ok := any.(uint16); ok { - return v, nil - } - v, err := doUint64(any) - return uint16(v), err -} - // Uint32 converts `any` to uint32. func Uint32(any any) uint32 { - v, _ := doUint32(any) + v, _ := defaultConverter.Uint32(any) return v } -func doUint32(any any) (uint32, error) { - if any == nil { - return 0, nil - } - if v, ok := any.(uint32); ok { - return v, nil - } - v, err := doUint64(any) - return uint32(v), err -} - // Uint64 converts `any` to uint64. func Uint64(any any) uint64 { - v, _ := doUint64(any) + v, _ := defaultConverter.Uint64(any) return v } - -func doUint64(any any) (uint64, error) { - if any == nil { - return 0, nil - } - if v, ok := any.(uint64); ok { - return v, nil - } - rv := reflect.ValueOf(any) - switch rv.Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - val := rv.Int() - if val < 0 { - return uint64(val), gerror.NewCodef( - gcode.CodeInvalidParameter, - `cannot convert negative value "%d" to uint64`, - val, - ) - } - return uint64(val), nil - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - return rv.Uint(), nil - case reflect.Uintptr: - return rv.Uint(), nil - case reflect.Float32, reflect.Float64: - val := rv.Float() - if val < 0 { - return uint64(val), gerror.NewCodef( - gcode.CodeInvalidParameter, - `cannot convert negative value "%f" to uint64`, - val, - ) - } - return uint64(val), nil - case reflect.Bool: - if rv.Bool() { - return 1, nil - } - return 0, nil - case reflect.Ptr: - if rv.IsNil() { - return 0, nil - } - if f, ok := any.(localinterface.IUint64); ok { - return f.Uint64(), nil - } - return doUint64(rv.Elem().Interface()) - case reflect.Slice: - if rv.Type().Elem().Kind() == reflect.Uint8 { - return gbinary.DecodeToUint64(rv.Bytes()), nil - } - return 0, gerror.NewCodef( - gcode.CodeInvalidParameter, - `unsupport slice type "%s" for converting to uint64`, - rv.Type().String(), - ) - case reflect.String: - var s = rv.String() - // Hexadecimal - if len(s) > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X') { - v, err := strconv.ParseUint(s[2:], 16, 64) - if err == nil { - return v, nil - } - return 0, gerror.WrapCodef( - gcode.CodeInvalidParameter, - err, - `cannot convert hexadecimal string "%s" to uint64`, - s, - ) - } - // Decimal - if v, err := strconv.ParseUint(s, 10, 64); err == nil { - return v, nil - } - // Float64 - if v, err := doFloat64(any); err == nil { - if math.IsNaN(v) { - return 0, nil - } - return uint64(v), nil - } - default: - if f, ok := any.(localinterface.IUint64); ok { - return f.Uint64(), nil - } - } - return 0, gerror.NewCodef( - gcode.CodeInvalidParameter, - `unsupport value type "%s" for converting to uint64`, - reflect.TypeOf(any).String(), - ) -} diff --git a/util/gconv/gconv_z_bench_struct_test.go b/util/gconv/gconv_z_bench_struct_test.go index 5fb2efe5928..d091a7dfb3d 100644 --- a/util/gconv/gconv_z_bench_struct_test.go +++ b/util/gconv/gconv_z_bench_struct_test.go @@ -92,7 +92,7 @@ func Benchmark_Struct_Basic(b *testing.B) { func Benchmark_doStruct_Fields8_Basic_MapToStruct(b *testing.B) { for i := 0; i < b.N; i++ { - doStruct(structMapFields8, structPointer8, map[string]string{}, "") + defaultConverter.Struct(structMapFields8, structPointer8, StructOption{}) } } diff --git a/util/gconv/gconv_z_unit_converter_test.go b/util/gconv/gconv_z_unit_converter_test.go index ad88c3175c3..ccaee32b4d3 100644 --- a/util/gconv/gconv_z_unit_converter_test.go +++ b/util/gconv/gconv_z_unit_converter_test.go @@ -7,6 +7,9 @@ package gconv_test import ( + "database/sql" + "fmt" + "reflect" "testing" "github.com/gogf/gf/v2/test/gtest" @@ -84,3 +87,87 @@ func TestConvertWithRefer(t *testing.T) { t.AssertNE(gconv.ConvertWithRefer("1.01", false), false) }) } + +func testAnyToMyInt(from any, to reflect.Value) error { + switch x := from.(type) { + case int: + to.SetInt(123456) + default: + return fmt.Errorf("unsupported type %T(%v)", x, x) + } + return nil +} + +func testAnyToSqlNullType(_ any, to reflect.Value) error { + if to.Kind() != reflect.Ptr { + to = to.Addr() + } + return to.Interface().(sql.Scanner).Scan(123456) +} + +func TestNewConverter(t *testing.T) { + type Dst[T any] struct { + A T + } + gtest.C(t, func(t *gtest.T) { + conv := gconv.NewConverter() + conv.RegisterAnyConverterFunc(testAnyToMyInt, reflect.TypeOf((*myInt)(nil))) + var dst Dst[myInt] + err := conv.Struct(map[string]any{ + "a": 1200, + }, &dst, gconv.StructOption{}) + t.AssertNil(err) + t.Assert(dst, Dst[myInt]{ + A: 123456, + }) + }) + gtest.C(t, func(t *gtest.T) { + conv := gconv.NewConverter() + conv.RegisterAnyConverterFunc(testAnyToMyInt, reflect.TypeOf((myInt)(0))) + var dst Dst[*myInt] + err := conv.Struct(map[string]any{ + "a": 1200, + }, &dst, gconv.StructOption{}) + t.AssertNil(err) + t.Assert(*dst.A, 123456) + }) + + gtest.C(t, func(t *gtest.T) { + conv := gconv.NewConverter() + conv.RegisterAnyConverterFunc(testAnyToSqlNullType, reflect.TypeOf((*sql.Scanner)(nil))) + type sqlNullDst struct { + A sql.Null[int] + B sql.Null[float32] + C sql.NullInt64 + D sql.NullString + + E *sql.Null[int] + F *sql.Null[float32] + G *sql.NullInt64 + H *sql.NullString + } + var dst sqlNullDst + err := conv.Struct(map[string]any{ + "a": 12, + "b": 34, + "c": 56, + "d": "sqlNullString", + "e": 12, + "f": 34, + "g": 56, + "h": "sqlNullString", + }, &dst, gconv.StructOption{}) + t.AssertNil(err) + t.Assert(dst, sqlNullDst{ + A: sql.Null[int]{V: 123456, Valid: true}, + B: sql.Null[float32]{V: 123456, Valid: true}, + C: sql.NullInt64{Int64: 123456, Valid: true}, + D: sql.NullString{String: "123456", Valid: true}, + + E: &sql.Null[int]{V: 123456, Valid: true}, + F: &sql.Null[float32]{V: 123456, Valid: true}, + G: &sql.NullInt64{Int64: 123456, Valid: true}, + H: &sql.NullString{String: "123456", Valid: true}, + }) + }) +} diff --git a/util/gconv/internal/converter/converter.go b/util/gconv/internal/converter/converter.go new file mode 100644 index 00000000000..cd69edda5c7 --- /dev/null +++ b/util/gconv/internal/converter/converter.go @@ -0,0 +1,180 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +// Package converter provides converting utilities for any types of variables. +package converter + +import ( + "reflect" + "time" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/util/gconv/internal/structcache" +) + +// AnyConvertFunc is the type for any type converting function. +type AnyConvertFunc = structcache.AnyConvertFunc + +// RecursiveType is the type for converting recursively. +type RecursiveType string + +const ( + RecursiveTypeAuto RecursiveType = "auto" + RecursiveTypeTrue RecursiveType = "true" +) + +type ( + converterInType = reflect.Type + converterOutType = reflect.Type + converterFunc = reflect.Value +) + +// Converter implements the interface Converter. +type Converter struct { + internalConverter *structcache.Converter + typeConverterFuncMap map[converterInType]map[converterOutType]converterFunc +} + +var ( + // Empty strings. + emptyStringMap = map[string]struct{}{ + "": {}, + "0": {}, + "no": {}, + "off": {}, + "false": {}, + } +) + +// NewConverter creates and returns management object for type converting. +func NewConverter() *Converter { + cf := &Converter{ + internalConverter: structcache.NewConverter(), + typeConverterFuncMap: make(map[converterInType]map[converterOutType]converterFunc), + } + cf.registerBuiltInAnyConvertFunc() + return cf +} + +// RegisterTypeConverterFunc registers custom converter. +// It must be registered before you use this custom converting feature. +// It is suggested to do it in boot procedure of the process. +// +// Note: +// 1. The parameter `fn` must be defined as pattern `func(T1) (T2, error)`. +// It will convert type `T1` to type `T2`. +// 2. The `T1` should not be type of pointer, but the `T2` should be type of pointer. +func (c *Converter) RegisterTypeConverterFunc(f any) (err error) { + var ( + fReflectType = reflect.TypeOf(f) + errType = reflect.TypeOf((*error)(nil)).Elem() + ) + if fReflectType.Kind() != reflect.Func || + fReflectType.NumIn() != 1 || fReflectType.NumOut() != 2 || + !fReflectType.Out(1).Implements(errType) { + err = gerror.NewCodef( + gcode.CodeInvalidParameter, + "parameter must be type of converter function and defined as pattern `func(T1) (T2, error)`, "+ + "but defined as `%s`", + fReflectType.String(), + ) + return + } + + // The Key and Value of the converter map should not be pointer. + var ( + inType = fReflectType.In(0) + outType = fReflectType.Out(0) + ) + if inType.Kind() == reflect.Pointer { + err = gerror.NewCodef( + gcode.CodeInvalidParameter, + "invalid converter function `%s`: invalid input parameter type `%s`, should not be type of pointer", + fReflectType.String(), inType.String(), + ) + return + } + if outType.Kind() != reflect.Pointer { + err = gerror.NewCodef( + gcode.CodeInvalidParameter, + "invalid converter function `%s`: invalid output parameter type `%s` should be type of pointer", + fReflectType.String(), outType.String(), + ) + return + } + + registeredOutTypeMap, ok := c.typeConverterFuncMap[inType] + if !ok { + registeredOutTypeMap = make(map[converterOutType]converterFunc) + c.typeConverterFuncMap[inType] = registeredOutTypeMap + } + if _, ok = registeredOutTypeMap[outType]; ok { + err = gerror.NewCodef( + gcode.CodeInvalidOperation, + "the converter parameter type `%s` to type `%s` has already been registered", + inType.String(), outType.String(), + ) + return + } + registeredOutTypeMap[outType] = reflect.ValueOf(f) + c.internalConverter.MarkTypeConvertFunc(outType) + return +} + +// RegisterAnyConverterFunc registers custom type converting function for specified types. +func (c *Converter) RegisterAnyConverterFunc(convertFunc AnyConvertFunc, types ...reflect.Type) { + for _, t := range types { + c.internalConverter.RegisterAnyConvertFunc(t, convertFunc) + } +} + +func (c *Converter) registerBuiltInAnyConvertFunc() { + var ( + intType = reflect.TypeOf(0) + int8Type = reflect.TypeOf(int8(0)) + int16Type = reflect.TypeOf(int16(0)) + int32Type = reflect.TypeOf(int32(0)) + int64Type = reflect.TypeOf(int64(0)) + uintType = reflect.TypeOf(uint(0)) + uint8Type = reflect.TypeOf(uint8(0)) + uint16Type = reflect.TypeOf(uint16(0)) + uint32Type = reflect.TypeOf(uint32(0)) + uint64Type = reflect.TypeOf(uint64(0)) + float32Type = reflect.TypeOf(float32(0)) + float64Type = reflect.TypeOf(float64(0)) + stringType = reflect.TypeOf("") + bytesType = reflect.TypeOf([]byte{}) + boolType = reflect.TypeOf(false) + timeType = reflect.TypeOf((*time.Time)(nil)).Elem() + gtimeType = reflect.TypeOf((*gtime.Time)(nil)).Elem() + ) + c.RegisterAnyConverterFunc( + c.builtInAnyConvertFuncForInt64, intType, int8Type, int16Type, int32Type, int64Type, + ) + c.RegisterAnyConverterFunc( + c.builtInAnyConvertFuncForUint64, uintType, uint8Type, uint16Type, uint32Type, uint64Type, + ) + c.RegisterAnyConverterFunc( + c.builtInAnyConvertFuncForString, stringType, + ) + c.RegisterAnyConverterFunc( + c.builtInAnyConvertFuncForFloat64, float32Type, float64Type, + ) + c.RegisterAnyConverterFunc( + c.builtInAnyConvertFuncForBool, boolType, + ) + c.RegisterAnyConverterFunc( + c.builtInAnyConvertFuncForBytes, bytesType, + ) + c.RegisterAnyConverterFunc( + c.builtInAnyConvertFuncForTime, timeType, + ) + c.RegisterAnyConverterFunc( + c.builtInAnyConvertFuncForGTime, gtimeType, + ) +} diff --git a/util/gconv/internal/converter/converter_bool.go b/util/gconv/internal/converter/converter_bool.go new file mode 100644 index 00000000000..f8d9ce7c953 --- /dev/null +++ b/util/gconv/internal/converter/converter_bool.go @@ -0,0 +1,75 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "reflect" + "strings" + + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/util/gconv/internal/localinterface" +) + +// Bool converts `any` to bool. +func (c *Converter) Bool(any any) (bool, error) { + if empty.IsNil(any) { + return false, nil + } + switch value := any.(type) { + case bool: + return value, nil + case []byte: + if _, ok := emptyStringMap[strings.ToLower(string(value))]; ok { + return false, nil + } + return true, nil + case string: + if _, ok := emptyStringMap[strings.ToLower(value)]; ok { + return false, nil + } + return true, nil + default: + if f, ok := value.(localinterface.IBool); ok { + return f.Bool(), nil + } + rv := reflect.ValueOf(any) + switch rv.Kind() { + case reflect.Ptr: + if rv.IsNil() { + return false, nil + } + if rv.Type().Elem().Kind() == reflect.Bool { + return rv.Elem().Bool(), nil + } + return c.Bool(rv.Elem().Interface()) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return rv.Int() != 0, nil + case reflect.Uintptr, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return rv.Uint() != 0, nil + case reflect.Float32, reflect.Float64: + return rv.Float() != 0, nil + case reflect.Bool: + return rv.Bool(), nil + // TODO:(Map,Array,Slice,Struct) It might panic here for these types. + case reflect.Map, reflect.Array: + fallthrough + case reflect.Slice: + return rv.Len() != 0, nil + case reflect.Struct: + return true, nil + default: + s, err := c.String(any) + if err != nil { + return false, err + } + if _, ok := emptyStringMap[strings.ToLower(s)]; ok { + return false, nil + } + return true, nil + } + } +} diff --git a/util/gconv/internal/converter/converter_builtin.go b/util/gconv/internal/converter/converter_builtin.go new file mode 100644 index 00000000000..f7ac1cf0e37 --- /dev/null +++ b/util/gconv/internal/converter/converter_builtin.go @@ -0,0 +1,89 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "reflect" + "time" + + "github.com/gogf/gf/v2/os/gtime" +) + +func (c *Converter) builtInAnyConvertFuncForInt64(from any, to reflect.Value) error { + v, err := c.Int64(from) + if err != nil { + return err + } + to.SetInt(v) + return nil +} + +func (c *Converter) builtInAnyConvertFuncForUint64(from any, to reflect.Value) error { + v, err := c.Uint64(from) + if err != nil { + return err + } + to.SetUint(v) + return nil +} + +func (c *Converter) builtInAnyConvertFuncForString(from any, to reflect.Value) error { + v, err := c.String(from) + if err != nil { + return err + } + to.SetString(v) + return nil +} + +func (c *Converter) builtInAnyConvertFuncForFloat64(from any, to reflect.Value) error { + v, err := c.Float64(from) + if err != nil { + return err + } + to.SetFloat(v) + return nil +} + +func (c *Converter) builtInAnyConvertFuncForBool(from any, to reflect.Value) error { + v, err := c.Bool(from) + if err != nil { + return err + } + to.SetBool(v) + return nil +} + +func (c *Converter) builtInAnyConvertFuncForBytes(from any, to reflect.Value) error { + v, err := c.Bytes(from) + if err != nil { + return err + } + to.SetBytes(v) + return nil +} + +func (c *Converter) builtInAnyConvertFuncForTime(from any, to reflect.Value) error { + t, err := c.Time(from) + if err != nil { + return err + } + *to.Addr().Interface().(*time.Time) = t + return nil +} + +func (c *Converter) builtInAnyConvertFuncForGTime(from any, to reflect.Value) error { + v, err := c.GTime(from) + if err != nil { + return err + } + if v == nil { + v = gtime.New() + } + *to.Addr().Interface().(*gtime.Time) = *v + return nil +} diff --git a/util/gconv/internal/converter/converter_bytes.go b/util/gconv/internal/converter/converter_bytes.go new file mode 100644 index 00000000000..79cd23378ec --- /dev/null +++ b/util/gconv/internal/converter/converter_bytes.go @@ -0,0 +1,68 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "math" + "reflect" + + "github.com/gogf/gf/v2/encoding/gbinary" + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/internal/reflection" + "github.com/gogf/gf/v2/util/gconv/internal/localinterface" +) + +// Bytes converts `any` to []byte. +func (c *Converter) Bytes(any any) ([]byte, error) { + if empty.IsNil(any) { + return nil, nil + } + switch value := any.(type) { + case string: + return []byte(value), nil + + case []byte: + return value, nil + + default: + if f, ok := value.(localinterface.IBytes); ok { + return f.Bytes(), nil + } + originValueAndKind := reflection.OriginValueAndKind(any) + switch originValueAndKind.OriginKind { + case reflect.Map: + bytes, err := json.Marshal(any) + if err != nil { + return nil, err + } + return bytes, nil + + case reflect.Array, reflect.Slice: + var ( + ok = true + bytes = make([]byte, originValueAndKind.OriginValue.Len()) + ) + for i := range bytes { + int32Value, err := c.Int32(originValueAndKind.OriginValue.Index(i).Interface()) + if err != nil { + return nil, err + } + if int32Value < 0 || int32Value > math.MaxUint8 { + ok = false + break + } + bytes[i] = byte(int32Value) + } + if ok { + return bytes, nil + } + default: + } + return gbinary.Encode(any), nil + } +} diff --git a/util/gconv/internal/converter/converter_convert.go b/util/gconv/internal/converter/converter_convert.go new file mode 100644 index 00000000000..ec1f545cfdd --- /dev/null +++ b/util/gconv/internal/converter/converter_convert.go @@ -0,0 +1,563 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "reflect" + "time" + + "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/os/gtime" +) + +// ConvertOption is the option for converting. +type ConvertOption struct { + // ExtraParams are extra values for implementing the converting. + ExtraParams []any + SliceOption SliceOption + MapOption MapOption + StructOption StructOption +} + +// ConvertWithTypeName converts the variable `fromValue` to the type `toTypeName`, the type `toTypeName` is specified by string. +func (c *Converter) ConvertWithTypeName(fromValue any, toTypeName string, option ConvertOption) (any, error) { + return c.doConvert( + doConvertInput{ + FromValue: fromValue, + ToTypeName: toTypeName, + ReferValue: nil, + }, + option, + ) +} + +// ConvertWithRefer converts the variable `fromValue` to the type referred by value `referValue`. +func (c *Converter) ConvertWithRefer(fromValue, referValue any, option ConvertOption) (any, error) { + var referValueRf reflect.Value + if v, ok := referValue.(reflect.Value); ok { + referValueRf = v + } else { + referValueRf = reflect.ValueOf(referValue) + } + return c.doConvert( + doConvertInput{ + FromValue: fromValue, + ToTypeName: referValueRf.Type().String(), + ReferValue: referValue, + }, + option, + ) +} + +type doConvertInput struct { + FromValue any // Value that is converted from. + ToTypeName string // Target value type name in string. + ReferValue any // Referred value, a value in type `ToTypeName`. Note that its type might be reflect.Value. + + // Marks that the value is already converted and set to `ReferValue`. Caller can ignore the returned result. + // It is an attribute for internal usage purpose. + alreadySetToReferValue bool +} + +// doConvert does commonly use types converting. +func (c *Converter) doConvert(in doConvertInput, option ConvertOption) (convertedValue any, err error) { + switch in.ToTypeName { + case "int": + return c.Int(in.FromValue) + case "*int": + if _, ok := in.FromValue.(*int); ok { + return in.FromValue, nil + } + v, err := c.Int(in.FromValue) + if err != nil { + return nil, err + } + return &v, nil + + case "int8": + return c.Int8(in.FromValue) + case "*int8": + if _, ok := in.FromValue.(*int8); ok { + return in.FromValue, nil + } + v, err := c.Int8(in.FromValue) + if err != nil { + return nil, err + } + return &v, nil + + case "int16": + return c.Int16(in.FromValue) + case "*int16": + if _, ok := in.FromValue.(*int16); ok { + return in.FromValue, nil + } + v, err := c.Int16(in.FromValue) + if err != nil { + return nil, err + } + return &v, nil + + case "int32": + return c.Int32(in.FromValue) + case "*int32": + if _, ok := in.FromValue.(*int32); ok { + return in.FromValue, nil + } + v, err := c.Int32(in.FromValue) + if err != nil { + return nil, err + } + return &v, nil + + case "int64": + return c.Int64(in.FromValue) + case "*int64": + if _, ok := in.FromValue.(*int64); ok { + return in.FromValue, nil + } + v, err := c.Int64(in.FromValue) + if err != nil { + return nil, err + } + return &v, nil + + case "uint": + return c.Uint(in.FromValue) + case "*uint": + if _, ok := in.FromValue.(*uint); ok { + return in.FromValue, nil + } + v, err := c.Uint(in.FromValue) + if err != nil { + return nil, err + } + return &v, nil + + case "uint8": + return c.Uint8(in.FromValue) + case "*uint8": + if _, ok := in.FromValue.(*uint8); ok { + return in.FromValue, nil + } + v, err := c.Uint8(in.FromValue) + if err != nil { + return nil, err + } + return &v, nil + + case "uint16": + return c.Uint16(in.FromValue) + case "*uint16": + if _, ok := in.FromValue.(*uint16); ok { + return in.FromValue, nil + } + v, err := c.Uint16(in.FromValue) + if err != nil { + return nil, err + } + return &v, nil + + case "uint32": + return c.Uint32(in.FromValue) + case "*uint32": + if _, ok := in.FromValue.(*uint32); ok { + return in.FromValue, nil + } + v, err := c.Uint32(in.FromValue) + if err != nil { + return nil, err + } + return &v, nil + + case "uint64": + return c.Uint64(in.FromValue) + case "*uint64": + if _, ok := in.FromValue.(*uint64); ok { + return in.FromValue, nil + } + v, err := c.Uint64(in.FromValue) + if err != nil { + return nil, err + } + return &v, nil + + case "float32": + return c.Float32(in.FromValue) + case "*float32": + if _, ok := in.FromValue.(*float32); ok { + return in.FromValue, nil + } + v, err := c.Float32(in.FromValue) + if err != nil { + return nil, err + } + return &v, nil + + case "float64": + return c.Float64(in.FromValue) + case "*float64": + if _, ok := in.FromValue.(*float64); ok { + return in.FromValue, nil + } + v, err := c.Float64(in.FromValue) + if err != nil { + return nil, err + } + return &v, nil + + case "bool": + return c.Bool(in.FromValue) + case "*bool": + if _, ok := in.FromValue.(*bool); ok { + return in.FromValue, nil + } + v, err := c.Bool(in.FromValue) + if err != nil { + return nil, err + } + return &v, nil + + case "string": + return c.String(in.FromValue) + case "*string": + if _, ok := in.FromValue.(*string); ok { + return in.FromValue, nil + } + v, err := c.String(in.FromValue) + if err != nil { + return nil, err + } + return &v, nil + + case "[]byte": + return c.Bytes(in.FromValue) + case "[]int": + return c.SliceInt(in.FromValue, option.SliceOption) + case "[]int32": + return c.SliceInt32(in.FromValue, option.SliceOption) + case "[]int64": + return c.SliceInt64(in.FromValue, option.SliceOption) + case "[]uint": + return c.SliceUint(in.FromValue, option.SliceOption) + case "[]uint8": + return c.Bytes(in.FromValue) + case "[]uint32": + return c.SliceUint32(in.FromValue, option.SliceOption) + case "[]uint64": + return c.SliceUint64(in.FromValue, option.SliceOption) + case "[]float32": + return c.SliceFloat32(in.FromValue, option.SliceOption) + case "[]float64": + return c.SliceFloat64(in.FromValue, option.SliceOption) + case "[]string": + return c.SliceStr(in.FromValue, option.SliceOption) + + case "Time", "time.Time": + if len(option.ExtraParams) > 0 { + s, err := c.String(option.ExtraParams[0]) + if err != nil { + return nil, err + } + return c.Time(in.FromValue, s) + } + return c.Time(in.FromValue) + case "*time.Time": + var v time.Time + if len(option.ExtraParams) > 0 { + s, err := c.String(option.ExtraParams[0]) + if err != nil { + return time.Time{}, err + } + v, err = c.Time(in.FromValue, s) + if err != nil { + return time.Time{}, err + } + } else { + if _, ok := in.FromValue.(*time.Time); ok { + return in.FromValue, nil + } + v, err = c.Time(in.FromValue) + if err != nil { + return time.Time{}, err + } + } + return &v, nil + + case "GTime", "gtime.Time": + if len(option.ExtraParams) > 0 { + s, err := c.String(option.ExtraParams[0]) + if err != nil { + return *gtime.New(), err + } + v, err := c.GTime(in.FromValue, s) + if err != nil { + return *gtime.New(), err + } + if v != nil { + return *v, nil + } + return *gtime.New(), nil + } + v, err := c.GTime(in.FromValue) + if err != nil { + return *gtime.New(), err + } + if v != nil { + return *v, nil + } + return *gtime.New(), nil + case "*gtime.Time": + if len(option.ExtraParams) > 0 { + s, err := c.String(option.ExtraParams[0]) + if err != nil { + return gtime.New(), err + } + v, err := c.GTime(in.FromValue, s) + if err != nil { + return gtime.New(), err + } + if v != nil { + return v, nil + } + return gtime.New(), nil + } + v, err := c.GTime(in.FromValue) + if err != nil { + return gtime.New(), err + } + if v != nil { + return v, nil + } + return gtime.New(), nil + + case "Duration", "time.Duration": + return c.Duration(in.FromValue) + case "*time.Duration": + if _, ok := in.FromValue.(*time.Duration); ok { + return in.FromValue, nil + } + v, err := c.Duration(in.FromValue) + if err != nil { + return nil, err + } + return &v, nil + + case "map[string]string": + return c.MapStrStr(in.FromValue, option.MapOption) + + case "map[string]interface {}": + return c.Map(in.FromValue, option.MapOption) + + case "[]map[string]interface {}": + return c.SliceMap(in.FromValue, option.SliceOption, option.MapOption) + + case "RawMessage", "json.RawMessage": + // issue 3449 + bytes, err := json.Marshal(in.FromValue) + if err != nil { + return nil, err + } + return bytes, nil + + default: + return c.doConvertForDefault(in, option) + } +} + +func (c *Converter) doConvertForDefault(in doConvertInput, option ConvertOption) (convertedValue any, err error) { + if in.ReferValue != nil { + var referReflectValue reflect.Value + if v, ok := in.ReferValue.(reflect.Value); ok { + referReflectValue = v + } else { + referReflectValue = reflect.ValueOf(in.ReferValue) + } + var fromReflectValue reflect.Value + if v, ok := in.FromValue.(reflect.Value); ok { + fromReflectValue = v + } else { + fromReflectValue = reflect.ValueOf(in.FromValue) + } + + // custom converter. + dstReflectValue, ok, err := c.callCustomConverterWithRefer(fromReflectValue, referReflectValue) + if err != nil { + return nil, err + } + if ok { + return dstReflectValue.Interface(), nil + } + + defer func() { + if recover() != nil { + in.alreadySetToReferValue = false + if err = c.bindVarToReflectValue(referReflectValue, in.FromValue, option.StructOption); err == nil { + in.alreadySetToReferValue = true + convertedValue = referReflectValue.Interface() + } + } + }() + switch referReflectValue.Kind() { + case reflect.Ptr: + // Type converting for custom type pointers. + // Eg: + // type PayMode int + // type Req struct{ + // Mode *PayMode + // } + // + // Struct(`{"Mode": 1000}`, &req) + originType := referReflectValue.Type().Elem() + switch originType.Kind() { + case reflect.Struct: + // Not support some kinds. + default: + in.ToTypeName = originType.Kind().String() + in.ReferValue = nil + result, err := c.doConvert(in, option) + if err != nil { + return nil, err + } + refElementValue := reflect.ValueOf(result) + originTypeValue := reflect.New(refElementValue.Type()).Elem() + originTypeValue.Set(refElementValue) + in.alreadySetToReferValue = true + return originTypeValue.Addr().Convert(referReflectValue.Type()).Interface(), nil + } + + case reflect.Map: + var targetValue = reflect.New(referReflectValue.Type()).Elem() + if err = c.MapToMap(in.FromValue, targetValue, nil, option.MapOption); err == nil { + in.alreadySetToReferValue = true + } + return targetValue.Interface(), nil + + default: + } + in.ToTypeName = referReflectValue.Kind().String() + in.ReferValue = nil + in.alreadySetToReferValue = true + result, err := c.doConvert(in, option) + if err != nil { + return nil, err + } + convertedValue = reflect.ValueOf(result).Convert(referReflectValue.Type()).Interface() + return convertedValue, nil + } + return in.FromValue, nil +} + +func (c *Converter) doConvertWithReflectValueSet(reflectValue reflect.Value, in doConvertInput, option ConvertOption) error { + convertedValue, err := c.doConvert(in, option) + if err != nil { + return err + } + if !in.alreadySetToReferValue { + reflectValue.Set(reflect.ValueOf(convertedValue)) + } + return err +} + +func (c *Converter) getRegisteredConverterFuncAndSrcType( + srcReflectValue, dstReflectValueForRefer reflect.Value, +) (f converterFunc, srcType reflect.Type, ok bool) { + if len(c.typeConverterFuncMap) == 0 { + return reflect.Value{}, nil, false + } + srcType = srcReflectValue.Type() + for srcType.Kind() == reflect.Pointer { + srcType = srcType.Elem() + } + var registeredOutTypeMap map[converterOutType]converterFunc + // firstly, it searches the map by input parameter type. + registeredOutTypeMap, ok = c.typeConverterFuncMap[srcType] + if !ok { + return reflect.Value{}, nil, false + } + var dstType = dstReflectValueForRefer.Type() + if dstType.Kind() == reflect.Pointer { + // Might be **struct, which is support as designed. + if dstType.Elem().Kind() == reflect.Pointer { + dstType = dstType.Elem() + } + } else if dstReflectValueForRefer.IsValid() && dstReflectValueForRefer.CanAddr() { + dstType = dstReflectValueForRefer.Addr().Type() + } else { + dstType = reflect.PointerTo(dstType) + } + // secondly, it searches the input parameter type map + // and finds the result converter function by the output parameter type. + f, ok = registeredOutTypeMap[dstType] + if !ok { + return reflect.Value{}, nil, false + } + return +} + +func (c *Converter) callCustomConverterWithRefer( + srcReflectValue, referReflectValue reflect.Value, +) (dstReflectValue reflect.Value, converted bool, err error) { + registeredConverterFunc, srcType, ok := c.getRegisteredConverterFuncAndSrcType(srcReflectValue, referReflectValue) + if !ok { + return reflect.Value{}, false, nil + } + dstReflectValue = reflect.New(referReflectValue.Type()).Elem() + converted, err = c.doCallCustomConverter(srcReflectValue, dstReflectValue, registeredConverterFunc, srcType) + return +} + +// callCustomConverter call the custom converter. It will try some possible type. +func (c *Converter) callCustomConverter(srcReflectValue, dstReflectValue reflect.Value) (converted bool, err error) { + registeredConverterFunc, srcType, ok := c.getRegisteredConverterFuncAndSrcType(srcReflectValue, dstReflectValue) + if !ok { + return false, nil + } + return c.doCallCustomConverter(srcReflectValue, dstReflectValue, registeredConverterFunc, srcType) +} + +func (c *Converter) doCallCustomConverter( + srcReflectValue reflect.Value, + dstReflectValue reflect.Value, + registeredConverterFunc converterFunc, + srcType reflect.Type, +) (converted bool, err error) { + // Converter function calling. + for srcReflectValue.Type() != srcType { + srcReflectValue = srcReflectValue.Elem() + } + result := registeredConverterFunc.Call([]reflect.Value{srcReflectValue}) + if !result[1].IsNil() { + return false, result[1].Interface().(error) + } + // The `result[0]` is a pointer. + if result[0].IsNil() { + return false, nil + } + var resultValue = result[0] + for { + if resultValue.Type() == dstReflectValue.Type() && dstReflectValue.CanSet() { + dstReflectValue.Set(resultValue) + converted = true + } else if dstReflectValue.Kind() == reflect.Pointer { + if resultValue.Type() == dstReflectValue.Elem().Type() && dstReflectValue.Elem().CanSet() { + dstReflectValue.Elem().Set(resultValue) + converted = true + } + } + if converted { + break + } + if resultValue.Kind() == reflect.Pointer { + resultValue = resultValue.Elem() + } else { + break + } + } + + return converted, nil +} diff --git a/util/gconv/internal/converter/converter_float.go b/util/gconv/internal/converter/converter_float.go new file mode 100644 index 00000000000..21418100db6 --- /dev/null +++ b/util/gconv/internal/converter/converter_float.go @@ -0,0 +1,147 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "reflect" + "strconv" + + "github.com/gogf/gf/v2/encoding/gbinary" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/util/gconv/internal/localinterface" +) + +// Float32 converts `any` to float32. +func (c *Converter) Float32(any any) (float32, error) { + if empty.IsNil(any) { + return 0, nil + } + switch value := any.(type) { + case float32: + return value, nil + case float64: + return float32(value), nil + case []byte: + // TODO: It might panic here for these types. + return gbinary.DecodeToFloat32(value), nil + default: + rv := reflect.ValueOf(any) + switch rv.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return float32(rv.Int()), nil + case reflect.Uintptr, reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return float32(rv.Uint()), nil + case reflect.Float32, reflect.Float64: + return float32(rv.Float()), nil + case reflect.Bool: + if rv.Bool() { + return 1, nil + } + return 0, nil + case reflect.String: + f, err := strconv.ParseFloat(rv.String(), 32) + if err != nil { + return 0, gerror.WrapCodef( + gcode.CodeInvalidParameter, err, "converting string to float32 failed for: %v", any, + ) + } + return float32(f), nil + case reflect.Ptr: + if rv.IsNil() { + return 0, nil + } + if f, ok := value.(localinterface.IFloat32); ok { + return f.Float32(), nil + } + return c.Float32(rv.Elem().Interface()) + default: + if f, ok := value.(localinterface.IFloat32); ok { + return f.Float32(), nil + } + s, err := c.String(any) + if err != nil { + return 0, err + } + v, err := strconv.ParseFloat(s, 32) + if err != nil { + return 0, gerror.WrapCodef( + gcode.CodeInvalidParameter, err, "converting string to float32 failed for: %v", any, + ) + } + return float32(v), nil + } + } +} + +// Float64 converts `any` to float64. +func (c *Converter) Float64(any any) (float64, error) { + if empty.IsNil(any) { + return 0, nil + } + switch value := any.(type) { + case float32: + return float64(value), nil + case float64: + return value, nil + case []byte: + // TODO: It might panic here for these types. + return gbinary.DecodeToFloat64(value), nil + default: + rv := reflect.ValueOf(any) + switch rv.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return float64(rv.Int()), nil + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return float64(rv.Uint()), nil + case reflect.Uintptr: + return float64(rv.Uint()), nil + case reflect.Float32, reflect.Float64: + // Please Note: + // When the type is float32 or a custom type defined based on float32, + // switching to float64 may result in a few extra decimal places. + return rv.Float(), nil + case reflect.Bool: + if rv.Bool() { + return 1, nil + } + return 0, nil + case reflect.String: + f, err := strconv.ParseFloat(rv.String(), 64) + if err != nil { + return 0, gerror.WrapCodef( + gcode.CodeInvalidParameter, err, "converting string to float64 failed for: %v", any, + ) + } + return f, nil + case reflect.Ptr: + if rv.IsNil() { + return 0, nil + } + if f, ok := value.(localinterface.IFloat64); ok { + return f.Float64(), nil + } + return c.Float64(rv.Elem().Interface()) + default: + if f, ok := value.(localinterface.IFloat64); ok { + return f.Float64(), nil + } + s, err := c.String(any) + if err != nil { + return 0, err + } + v, err := strconv.ParseFloat(s, 64) + if err != nil { + return 0, gerror.WrapCodef( + gcode.CodeInvalidParameter, err, "converting string to float64 failed for: %v", any, + ) + } + return v, nil + } + } +} diff --git a/util/gconv/internal/converter/converter_int.go b/util/gconv/internal/converter/converter_int.go new file mode 100644 index 00000000000..dc82e926cd8 --- /dev/null +++ b/util/gconv/internal/converter/converter_int.go @@ -0,0 +1,157 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "math" + "reflect" + "strconv" + + "github.com/gogf/gf/v2/encoding/gbinary" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/util/gconv/internal/localinterface" +) + +// Int converts `any` to int. +func (c *Converter) Int(any any) (int, error) { + if v, ok := any.(int); ok { + return v, nil + } + v, err := c.Int64(any) + if err != nil { + return 0, err + } + return int(v), nil +} + +// Int8 converts `any` to int8. +func (c *Converter) Int8(any any) (int8, error) { + if v, ok := any.(int8); ok { + return v, nil + } + v, err := c.Int64(any) + if err != nil { + return 0, err + } + return int8(v), nil +} + +// Int16 converts `any` to int16. +func (c *Converter) Int16(any any) (int16, error) { + if v, ok := any.(int16); ok { + return v, nil + } + v, err := c.Int64(any) + if err != nil { + return 0, err + } + return int16(v), nil +} + +// Int32 converts `any` to int32. +func (c *Converter) Int32(any any) (int32, error) { + if v, ok := any.(int32); ok { + return v, nil + } + v, err := c.Int64(any) + if err != nil { + return 0, err + } + return int32(v), nil +} + +// Int64 converts `any` to int64. +func (c *Converter) Int64(any any) (int64, error) { + if empty.IsNil(any) { + return 0, nil + } + if v, ok := any.(int64); ok { + return v, nil + } + rv := reflect.ValueOf(any) + switch rv.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return rv.Int(), nil + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return int64(rv.Uint()), nil + case reflect.Uintptr: + return int64(rv.Uint()), nil + case reflect.Float32, reflect.Float64: + return int64(rv.Float()), nil + case reflect.Bool: + if rv.Bool() { + return 1, nil + } + return 0, nil + case reflect.Ptr: + if rv.IsNil() { + return 0, nil + } + if f, ok := any.(localinterface.IInt64); ok { + return f.Int64(), nil + } + return c.Int64(rv.Elem().Interface()) + case reflect.Slice: + // TODO: It might panic here for these types. + if rv.Type().Elem().Kind() == reflect.Uint8 { + return gbinary.DecodeToInt64(rv.Bytes()), nil + } + case reflect.String: + var ( + s = rv.String() + isMinus = false + ) + if len(s) > 0 { + if s[0] == '-' { + isMinus = true + s = s[1:] + } else if s[0] == '+' { + s = s[1:] + } + } + // Hexadecimal. + if len(s) > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X') { + if v, e := strconv.ParseInt(s[2:], 16, 64); e == nil { + if isMinus { + return -v, nil + } + return v, nil + } + } + // Decimal. + if v, e := strconv.ParseInt(s, 10, 64); e == nil { + if isMinus { + return -v, nil + } + return v, nil + } + // Float64. + valueInt64, err := c.Float64(s) + if err != nil { + return 0, err + } + if math.IsNaN(valueInt64) { + return 0, nil + } else { + if isMinus { + return -int64(valueInt64), nil + } + return int64(valueInt64), nil + } + default: + if f, ok := any.(localinterface.IInt64); ok { + return f.Int64(), nil + } + } + return 0, gerror.NewCodef( + gcode.CodeInvalidParameter, + `unsupport value type for converting to int64: %v`, + reflect.TypeOf(any), + ) +} diff --git a/util/gconv/internal/converter/converter_map.go b/util/gconv/internal/converter/converter_map.go new file mode 100644 index 00000000000..1b8b93e4814 --- /dev/null +++ b/util/gconv/internal/converter/converter_map.go @@ -0,0 +1,646 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "reflect" + "strings" + + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/internal/utils" + "github.com/gogf/gf/v2/util/gconv/internal/localinterface" + "github.com/gogf/gf/v2/util/gtag" +) + +// MapOption specifies the option for map converting. +type MapOption struct { + // Deep marks doing Map function recursively, which means if the attribute of given converting value + // is also a struct/*struct, it automatically calls Map function on this attribute converting it to + // a map[string]any type variable. + Deep bool + + // OmitEmpty ignores the attributes that has json `omitempty` tag. + OmitEmpty bool + + // Tags specifies the converted map key name by struct tag name. + Tags []string + + // ContinueOnError specifies whether to continue converting the next element + // if one element converting fails. + ContinueOnError bool +} + +// Map converts any variable `value` to map[string]any. If the parameter `value` is not a +// map/struct/*struct type, then the conversion will fail and returns nil. +// +// If `value` is a struct/*struct object, the second parameter `priorityTagAndFieldName` specifies the most priority +// priorityTagAndFieldName that will be detected, otherwise it detects the priorityTagAndFieldName in order of: +// gconv, json, field name. +func (c *Converter) Map(value any, option MapOption) (map[string]any, error) { + return c.doMapConvert(value, RecursiveTypeAuto, false, option) +} + +// MapStrStr converts `value` to map[string]string. +// Note that there might be data copy for this map type converting. +func (c *Converter) MapStrStr(value any, option MapOption) (map[string]string, error) { + if r, ok := value.(map[string]string); ok { + return r, nil + } + m, err := c.Map(value, option) + if err != nil && !option.ContinueOnError { + return nil, err + } + if len(m) > 0 { + var ( + s string + vMap = make(map[string]string, len(m)) + ) + for k, v := range m { + s, err = c.String(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + vMap[k] = s + } + return vMap, nil + } + return nil, nil +} + +// MapConvert implements the map converting. +// It automatically checks and converts json string to map if `value` is string/[]byte. +// +// TODO completely implement the recursive converting for all types, especially the map. +func (c *Converter) doMapConvert( + value any, recursive RecursiveType, mustMapReturn bool, option MapOption, +) (map[string]any, error) { + if value == nil { + return nil, nil + } + // It redirects to its underlying value if it has implemented interface iVal. + if v, ok := value.(localinterface.IVal); ok { + value = v.Val() + } + var ( + err error + newTags = gtag.StructTagPriority + ) + if option.Deep { + recursive = RecursiveTypeTrue + } + switch len(option.Tags) { + case 0: + // No need handling. + case 1: + newTags = append(strings.Split(option.Tags[0], ","), gtag.StructTagPriority...) + default: + newTags = append(option.Tags, gtag.StructTagPriority...) + } + // Assert the common combination of types, and finally it uses reflection. + dataMap := make(map[string]interface{}) + switch r := value.(type) { + case string: + // If it is a JSON string, automatically unmarshal it! + if len(r) > 0 && r[0] == '{' && r[len(r)-1] == '}' { + if err = json.UnmarshalUseNumber([]byte(r), &dataMap); err != nil { + return nil, err + } + } else { + return nil, nil + } + case []byte: + // If it is a JSON string, automatically unmarshal it! + if len(r) > 0 && r[0] == '{' && r[len(r)-1] == '}' { + if err = json.UnmarshalUseNumber(r, &dataMap); err != nil { + return nil, err + } + } else { + return nil, nil + } + case map[interface{}]interface{}: + recursiveOption := option + recursiveOption.Tags = newTags + for k, v := range r { + s, err := c.String(k) + if err != nil && !option.ContinueOnError { + return nil, err + } + dataMap[s], err = c.doMapConvertForMapOrStructValue( + doMapConvertForMapOrStructValueInput{ + IsRoot: false, + Value: v, + RecursiveType: recursive, + RecursiveOption: recursive == RecursiveTypeTrue, + Option: recursiveOption, + }, + ) + if err != nil && !option.ContinueOnError { + return nil, err + } + } + case map[interface{}]string: + for k, v := range r { + s, err := c.String(k) + if err != nil && !option.ContinueOnError { + return nil, err + } + dataMap[s] = v + } + case map[interface{}]int: + for k, v := range r { + s, err := c.String(k) + if err != nil && !option.ContinueOnError { + return nil, err + } + dataMap[s] = v + } + case map[interface{}]uint: + for k, v := range r { + s, err := c.String(k) + if err != nil && !option.ContinueOnError { + return nil, err + } + dataMap[s] = v + } + case map[interface{}]float32: + for k, v := range r { + s, err := c.String(k) + if err != nil && !option.ContinueOnError { + return nil, err + } + dataMap[s] = v + } + case map[interface{}]float64: + for k, v := range r { + s, err := c.String(k) + if err != nil && !option.ContinueOnError { + return nil, err + } + dataMap[s] = v + } + case map[string]bool: + for k, v := range r { + dataMap[k] = v + } + case map[string]int: + for k, v := range r { + dataMap[k] = v + } + case map[string]uint: + for k, v := range r { + dataMap[k] = v + } + case map[string]float32: + for k, v := range r { + dataMap[k] = v + } + case map[string]float64: + for k, v := range r { + dataMap[k] = v + } + case map[string]string: + for k, v := range r { + dataMap[k] = v + } + case map[string]interface{}: + if recursive == RecursiveTypeTrue { + recursiveOption := option + recursiveOption.Tags = newTags + // A copy of current map. + for k, v := range r { + dataMap[k], err = c.doMapConvertForMapOrStructValue( + doMapConvertForMapOrStructValueInput{ + IsRoot: false, + Value: v, + RecursiveType: recursive, + RecursiveOption: recursive == RecursiveTypeTrue, + Option: recursiveOption, + }, + ) + if err != nil && !option.ContinueOnError { + return nil, err + } + } + } else { + // It returns the map directly without any changing. + return r, nil + } + case map[int]interface{}: + recursiveOption := option + recursiveOption.Tags = newTags + for k, v := range r { + s, err := c.String(k) + if err != nil && !option.ContinueOnError { + return nil, err + } + dataMap[s], err = c.doMapConvertForMapOrStructValue( + doMapConvertForMapOrStructValueInput{ + IsRoot: false, + Value: v, + RecursiveType: recursive, + RecursiveOption: recursive == RecursiveTypeTrue, + Option: recursiveOption, + }, + ) + if err != nil && !option.ContinueOnError { + return nil, err + } + } + case map[int]string: + for k, v := range r { + s, err := c.String(k) + if err != nil && !option.ContinueOnError { + return nil, err + } + dataMap[s] = v + } + case map[uint]string: + for k, v := range r { + s, err := c.String(k) + if err != nil && !option.ContinueOnError { + return nil, err + } + dataMap[s] = v + } + + default: + // Not a common type, it then uses reflection for conversion. + var reflectValue reflect.Value + if v, ok := value.(reflect.Value); ok { + reflectValue = v + } else { + reflectValue = reflect.ValueOf(value) + } + reflectKind := reflectValue.Kind() + // If it is a pointer, we should find its real data type. + for reflectKind == reflect.Ptr { + reflectValue = reflectValue.Elem() + reflectKind = reflectValue.Kind() + } + switch reflectKind { + // If `value` is type of array, it converts the value of even number index as its key and + // the value of odd number index as its corresponding value, for example: + // []string{"k1","v1","k2","v2"} => map[string]interface{}{"k1":"v1", "k2":"v2"} + // []string{"k1","v1","k2"} => map[string]interface{}{"k1":"v1", "k2":nil} + case reflect.Slice, reflect.Array: + length := reflectValue.Len() + for i := 0; i < length; i += 2 { + s, err := c.String(reflectValue.Index(i).Interface()) + if err != nil && !option.ContinueOnError { + return nil, err + } + if i+1 < length { + dataMap[s] = reflectValue.Index(i + 1).Interface() + } else { + dataMap[s] = nil + } + } + case reflect.Map, reflect.Struct, reflect.Interface: + recursiveOption := option + recursiveOption.Tags = newTags + convertedValue, err := c.doMapConvertForMapOrStructValue( + doMapConvertForMapOrStructValueInput{ + IsRoot: true, + Value: value, + RecursiveType: recursive, + RecursiveOption: recursive == RecursiveTypeTrue, + Option: recursiveOption, + MustMapReturn: mustMapReturn, + }, + ) + if err != nil && !option.ContinueOnError { + return nil, err + } + if m, ok := convertedValue.(map[string]interface{}); ok { + return m, nil + } + return nil, nil + default: + return nil, nil + } + } + return dataMap, nil +} + +type doMapConvertForMapOrStructValueInput struct { + IsRoot bool // It returns directly if it is not root and with no recursive converting. + Value interface{} // Current operation value. + RecursiveType RecursiveType // The type from top function entry. + RecursiveOption bool // Whether convert recursively for `current` operation. + Option MapOption // Map converting option. + MustMapReturn bool // Must return map instead of Value when empty. +} + +func (c *Converter) doMapConvertForMapOrStructValue(in doMapConvertForMapOrStructValueInput) (any, error) { + if !in.IsRoot && !in.RecursiveOption { + return in.Value, nil + } + + var ( + err error + reflectValue reflect.Value + ) + if v, ok := in.Value.(reflect.Value); ok { + reflectValue = v + in.Value = v.Interface() + } else { + reflectValue = reflect.ValueOf(in.Value) + } + reflectKind := reflectValue.Kind() + // If it is a pointer, we should find its real data type. + for reflectKind == reflect.Ptr { + reflectValue = reflectValue.Elem() + reflectKind = reflectValue.Kind() + } + switch reflectKind { + case reflect.Map: + var ( + mapIter = reflectValue.MapRange() + dataMap = make(map[string]interface{}) + ) + for mapIter.Next() { + var ( + mapKeyValue = mapIter.Value() + mapValue interface{} + ) + switch { + case mapKeyValue.IsZero(): + if utils.CanCallIsNil(mapKeyValue) && mapKeyValue.IsNil() { + // quick check for nil value. + mapValue = nil + } else { + // in case of: + // exception recovered: reflect: call of reflect.Value.Interface on zero Value + mapValue = reflect.New(mapKeyValue.Type()).Elem().Interface() + } + default: + mapValue = mapKeyValue.Interface() + } + s, err := c.String(mapIter.Key().Interface()) + if err != nil && !in.Option.ContinueOnError { + return nil, err + } + dataMap[s], err = c.doMapConvertForMapOrStructValue( + doMapConvertForMapOrStructValueInput{ + IsRoot: false, + Value: mapValue, + RecursiveType: in.RecursiveType, + RecursiveOption: in.RecursiveType == RecursiveTypeTrue, + Option: in.Option, + }, + ) + if err != nil && !in.Option.ContinueOnError { + return nil, err + } + } + return dataMap, nil + + case reflect.Struct: + var dataMap = make(map[string]interface{}) + // Map converting interface check. + if v, ok := in.Value.(localinterface.IMapStrAny); ok { + // Value copy, in case of concurrent safety. + for mapK, mapV := range v.MapStrAny() { + if in.RecursiveOption { + dataMap[mapK], err = c.doMapConvertForMapOrStructValue( + doMapConvertForMapOrStructValueInput{ + IsRoot: false, + Value: mapV, + RecursiveType: in.RecursiveType, + RecursiveOption: in.RecursiveType == RecursiveTypeTrue, + Option: in.Option, + }, + ) + if err != nil && !in.Option.ContinueOnError { + return nil, err + } + } else { + dataMap[mapK] = mapV + } + } + if len(dataMap) > 0 { + return dataMap, nil + } + } + // Using reflect for converting. + var ( + rtField reflect.StructField + rvField reflect.Value + reflectType = reflectValue.Type() // attribute value type. + mapKey = "" // mapKey may be the tag name or the struct attribute name. + ) + for i := 0; i < reflectValue.NumField(); i++ { + rtField = reflectType.Field(i) + rvField = reflectValue.Field(i) + // Only convert the public attributes. + fieldName := rtField.Name + if !utils.IsLetterUpper(fieldName[0]) { + continue + } + mapKey = "" + fieldTag := rtField.Tag + for _, tag := range in.Option.Tags { + if mapKey = fieldTag.Get(tag); mapKey != "" { + break + } + } + if mapKey == "" { + mapKey = fieldName + } else { + // Support json tag feature: -, omitempty + mapKey = strings.TrimSpace(mapKey) + if mapKey == "-" { + continue + } + array := strings.Split(mapKey, ",") + if len(array) > 1 { + switch strings.TrimSpace(array[1]) { + case "omitempty": + if in.Option.OmitEmpty && empty.IsEmpty(rvField.Interface()) { + continue + } else { + mapKey = strings.TrimSpace(array[0]) + } + default: + mapKey = strings.TrimSpace(array[0]) + } + } + if mapKey == "" { + mapKey = fieldName + } + } + if in.RecursiveOption || rtField.Anonymous { + // Do map converting recursively. + var ( + rvAttrField = rvField + rvAttrKind = rvField.Kind() + ) + if rvAttrKind == reflect.Ptr { + rvAttrField = rvField.Elem() + rvAttrKind = rvAttrField.Kind() + } + switch rvAttrKind { + case reflect.Struct: + // Embedded struct and has no fields, just ignores it. + // Eg: gmeta.Meta + if rvAttrField.Type().NumField() == 0 { + continue + } + var ( + hasNoTag = mapKey == fieldName + // DO NOT use rvAttrField.Interface() here, + // as it might be changed from pointer to struct. + rvInterface = rvField.Interface() + ) + switch { + case hasNoTag && rtField.Anonymous: + // It means this attribute field has no tag. + // Overwrite the attribute with sub-struct attribute fields. + anonymousValue, err := c.doMapConvertForMapOrStructValue( + doMapConvertForMapOrStructValueInput{ + IsRoot: false, + Value: rvInterface, + RecursiveType: in.RecursiveType, + RecursiveOption: true, + Option: in.Option, + }, + ) + if err != nil && !in.Option.ContinueOnError { + return nil, err + } + if m, ok := anonymousValue.(map[string]interface{}); ok { + for k, v := range m { + dataMap[k] = v + } + } else { + dataMap[mapKey] = rvInterface + } + + // It means this attribute field has desired tag. + case !hasNoTag && rtField.Anonymous: + dataMap[mapKey], err = c.doMapConvertForMapOrStructValue( + doMapConvertForMapOrStructValueInput{ + IsRoot: false, + Value: rvInterface, + RecursiveType: in.RecursiveType, + RecursiveOption: true, + Option: in.Option, + }, + ) + if err != nil && !in.Option.ContinueOnError { + return nil, err + } + + default: + dataMap[mapKey], err = c.doMapConvertForMapOrStructValue( + doMapConvertForMapOrStructValueInput{ + IsRoot: false, + Value: rvInterface, + RecursiveType: in.RecursiveType, + RecursiveOption: in.RecursiveType == RecursiveTypeTrue, + Option: in.Option, + }, + ) + if err != nil && !in.Option.ContinueOnError { + return nil, err + } + } + + // The struct attribute is type of slice. + case reflect.Array, reflect.Slice: + length := rvAttrField.Len() + if length == 0 { + dataMap[mapKey] = rvAttrField.Interface() + break + } + array := make([]interface{}, length) + for arrayIndex := 0; arrayIndex < length; arrayIndex++ { + array[arrayIndex], err = c.doMapConvertForMapOrStructValue( + doMapConvertForMapOrStructValueInput{ + IsRoot: false, + Value: rvAttrField.Index(arrayIndex).Interface(), + RecursiveType: in.RecursiveType, + RecursiveOption: in.RecursiveType == RecursiveTypeTrue, + Option: in.Option, + }, + ) + if err != nil && !in.Option.ContinueOnError { + return nil, err + } + } + dataMap[mapKey] = array + case reflect.Map: + var ( + mapIter = rvAttrField.MapRange() + nestedMap = make(map[string]interface{}) + ) + for mapIter.Next() { + s, err := c.String(mapIter.Key().Interface()) + if err != nil && !in.Option.ContinueOnError { + return nil, err + } + nestedMap[s], err = c.doMapConvertForMapOrStructValue( + doMapConvertForMapOrStructValueInput{ + IsRoot: false, + Value: mapIter.Value().Interface(), + RecursiveType: in.RecursiveType, + RecursiveOption: in.RecursiveType == RecursiveTypeTrue, + Option: in.Option, + }, + ) + if err != nil && !in.Option.ContinueOnError { + return nil, err + } + } + dataMap[mapKey] = nestedMap + default: + if rvField.IsValid() { + dataMap[mapKey] = reflectValue.Field(i).Interface() + } else { + dataMap[mapKey] = nil + } + } + } else { + // No recursive map value converting + if rvField.IsValid() { + dataMap[mapKey] = reflectValue.Field(i).Interface() + } else { + dataMap[mapKey] = nil + } + } + } + if !in.MustMapReturn && len(dataMap) == 0 { + return in.Value, nil + } + return dataMap, nil + + // The given value is type of slice. + case reflect.Array, reflect.Slice: + length := reflectValue.Len() + if length == 0 { + break + } + array := make([]interface{}, reflectValue.Len()) + for i := 0; i < length; i++ { + array[i], err = c.doMapConvertForMapOrStructValue(doMapConvertForMapOrStructValueInput{ + IsRoot: false, + Value: reflectValue.Index(i).Interface(), + RecursiveType: in.RecursiveType, + RecursiveOption: in.RecursiveType == RecursiveTypeTrue, + Option: in.Option, + }) + if err != nil && !in.Option.ContinueOnError { + return nil, err + } + } + return array, nil + + default: + } + return in.Value, nil +} diff --git a/util/gconv/internal/converter/converter_maptomap.go b/util/gconv/internal/converter/converter_maptomap.go new file mode 100644 index 00000000000..2aafabca712 --- /dev/null +++ b/util/gconv/internal/converter/converter_maptomap.go @@ -0,0 +1,140 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "reflect" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" +) + +// MapToMap converts any map type variable `params` to another map type variable `pointer`. +// +// The parameter `params` can be any type of map, like: +// map[string]string, map[string]struct, map[string]*struct, reflect.Value, etc. +// +// The parameter `pointer` should be type of *map, like: +// map[int]string, map[string]struct, map[string]*struct, reflect.Value, etc. +// +// The optional parameter `mapping` is used for struct attribute to map key mapping, which makes +// sense only if the items of original map `params` is type struct. +func (c *Converter) MapToMap( + params, pointer any, mapping map[string]string, option MapOption, +) (err error) { + var ( + paramsRv reflect.Value + paramsKind reflect.Kind + ) + if v, ok := params.(reflect.Value); ok { + paramsRv = v + } else { + paramsRv = reflect.ValueOf(params) + } + paramsKind = paramsRv.Kind() + if paramsKind == reflect.Ptr { + paramsRv = paramsRv.Elem() + paramsKind = paramsRv.Kind() + } + if paramsKind != reflect.Map { + m, err := c.Map(params, option) + if err != nil { + return err + } + return c.MapToMap(m, pointer, mapping, option) + } + // Empty params map, no need continue. + if paramsRv.Len() == 0 { + return nil + } + var pointerRv reflect.Value + if v, ok := pointer.(reflect.Value); ok { + pointerRv = v + } else { + pointerRv = reflect.ValueOf(pointer) + } + pointerKind := pointerRv.Kind() + for pointerKind == reflect.Ptr { + pointerRv = pointerRv.Elem() + pointerKind = pointerRv.Kind() + } + if pointerKind != reflect.Map { + return gerror.NewCodef( + gcode.CodeInvalidParameter, + `destination pointer should be type of *map, but got: %s`, + pointerKind, + ) + } + defer func() { + // Catch the panic, especially the reflection operation panics. + if exception := recover(); exception != nil { + if v, ok := exception.(error); ok && gerror.HasStack(v) { + err = v + } else { + err = gerror.NewCodeSkipf(gcode.CodeInternalPanic, 1, "%+v", exception) + } + } + }() + var ( + paramsKeys = paramsRv.MapKeys() + pointerKeyType = pointerRv.Type().Key() + pointerValueType = pointerRv.Type().Elem() + pointerValueKind = pointerValueType.Kind() + dataMap = reflect.MakeMapWithSize(pointerRv.Type(), len(paramsKeys)) + convertOption = ConvertOption{ + StructOption: StructOption{ContinueOnError: option.ContinueOnError}, + SliceOption: SliceOption{ContinueOnError: option.ContinueOnError}, + MapOption: option, + } + ) + // Retrieve the true element type of target map. + if pointerValueKind == reflect.Ptr { + pointerValueKind = pointerValueType.Elem().Kind() + } + for _, key := range paramsKeys { + mapValue := reflect.New(pointerValueType).Elem() + switch pointerValueKind { + case reflect.Map, reflect.Struct: + structOption := StructOption{ + ParamKeyToAttrMap: mapping, + PriorityTag: "", + ContinueOnError: option.ContinueOnError, + } + if err = c.Struct(paramsRv.MapIndex(key).Interface(), mapValue, structOption); err != nil { + return err + } + default: + convertResult, err := c.doConvert( + doConvertInput{ + FromValue: paramsRv.MapIndex(key).Interface(), + ToTypeName: pointerValueType.String(), + ReferValue: mapValue, + }, + convertOption, + ) + if err != nil { + return err + } + mapValue.Set(reflect.ValueOf(convertResult)) + } + convertResult, err := c.doConvert( + doConvertInput{ + FromValue: key.Interface(), + ToTypeName: pointerKeyType.Name(), + ReferValue: reflect.New(pointerKeyType).Elem().Interface(), + }, + convertOption, + ) + if err != nil { + return err + } + var mapKey = reflect.ValueOf(convertResult) + dataMap.SetMapIndex(mapKey, mapValue) + } + pointerRv.Set(dataMap) + return nil +} diff --git a/util/gconv/internal/converter/converter_maptomaps.go b/util/gconv/internal/converter/converter_maptomaps.go new file mode 100644 index 00000000000..3420934b5b9 --- /dev/null +++ b/util/gconv/internal/converter/converter_maptomaps.go @@ -0,0 +1,122 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "reflect" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" +) + +// MapToMaps converts any map type variable `params` to another map slice variable `pointer`. +// +// The parameter `params` can be type of []map, []*map, []struct, []*struct. +// +// The parameter `pointer` should be type of []map, []*map. +// +// The optional parameter `mapping` is used for struct attribute to map key mapping, which makes +// sense only if the item of `params` is type struct. +func (c *Converter) MapToMaps( + params any, pointer any, paramKeyToAttrMap map[string]string, option MapOption, +) (err error) { + // Params and its element type check. + var ( + paramsRv reflect.Value + paramsKind reflect.Kind + ) + if v, ok := params.(reflect.Value); ok { + paramsRv = v + } else { + paramsRv = reflect.ValueOf(params) + } + paramsKind = paramsRv.Kind() + if paramsKind == reflect.Ptr { + paramsRv = paramsRv.Elem() + paramsKind = paramsRv.Kind() + } + if paramsKind != reflect.Array && paramsKind != reflect.Slice { + return gerror.NewCode( + gcode.CodeInvalidParameter, + "params should be type of slice, example: []map/[]*map/[]struct/[]*struct", + ) + } + var ( + paramsElem = paramsRv.Type().Elem() + paramsElemKind = paramsElem.Kind() + ) + if paramsElemKind == reflect.Ptr { + paramsElem = paramsElem.Elem() + paramsElemKind = paramsElem.Kind() + } + if paramsElemKind != reflect.Map && + paramsElemKind != reflect.Struct && + paramsElemKind != reflect.Interface { + return gerror.NewCodef( + gcode.CodeInvalidParameter, + "params element should be type of map/*map/struct/*struct, but got: %s", + paramsElemKind, + ) + } + // Empty slice, no need continue. + if paramsRv.Len() == 0 { + return nil + } + // Pointer and its element type check. + var ( + pointerRv = reflect.ValueOf(pointer) + pointerKind = pointerRv.Kind() + ) + for pointerKind == reflect.Ptr { + pointerRv = pointerRv.Elem() + pointerKind = pointerRv.Kind() + } + if pointerKind != reflect.Array && pointerKind != reflect.Slice { + return gerror.NewCode(gcode.CodeInvalidParameter, "pointer should be type of *[]map/*[]*map") + } + var ( + pointerElemType = pointerRv.Type().Elem() + pointerElemKind = pointerElemType.Kind() + ) + if pointerElemKind == reflect.Ptr { + pointerElemKind = pointerElemType.Elem().Kind() + } + if pointerElemKind != reflect.Map { + return gerror.NewCode(gcode.CodeInvalidParameter, "pointer element should be type of map/*map") + } + defer func() { + // Catch the panic, especially the reflection operation panics. + if exception := recover(); exception != nil { + if v, ok := exception.(error); ok && gerror.HasStack(v) { + err = v + } else { + err = gerror.NewCodeSkipf(gcode.CodeInternalPanic, 1, "%+v", exception) + } + } + }() + var ( + pointerSlice = reflect.MakeSlice(pointerRv.Type(), paramsRv.Len(), paramsRv.Len()) + ) + for i := 0; i < paramsRv.Len(); i++ { + var item reflect.Value + if pointerElemType.Kind() == reflect.Ptr { + item = reflect.New(pointerElemType.Elem()) + if err = c.MapToMap(paramsRv.Index(i).Interface(), item, paramKeyToAttrMap, option); err != nil { + return err + } + pointerSlice.Index(i).Set(item) + } else { + item = reflect.New(pointerElemType) + if err = c.MapToMap(paramsRv.Index(i).Interface(), item, paramKeyToAttrMap, option); err != nil { + return err + } + pointerSlice.Index(i).Set(item.Elem()) + } + } + pointerRv.Set(pointerSlice) + return +} diff --git a/util/gconv/internal/converter/converter_rune.go b/util/gconv/internal/converter/converter_rune.go new file mode 100644 index 00000000000..e7ea9d5febd --- /dev/null +++ b/util/gconv/internal/converter/converter_rune.go @@ -0,0 +1,31 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +// Rune converts `any` to rune. +func (c *Converter) Rune(any any) (rune, error) { + if v, ok := any.(rune); ok { + return v, nil + } + v, err := c.Int32(any) + if err != nil { + return 0, err + } + return v, nil +} + +// Runes converts `any` to []rune. +func (c *Converter) Runes(any any) ([]rune, error) { + if v, ok := any.([]rune); ok { + return v, nil + } + s, err := c.String(any) + if err != nil { + return nil, err + } + return []rune(s), nil +} diff --git a/util/gconv/internal/converter/converter_scan.go b/util/gconv/internal/converter/converter_scan.go new file mode 100644 index 00000000000..b580e9abedb --- /dev/null +++ b/util/gconv/internal/converter/converter_scan.go @@ -0,0 +1,395 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "reflect" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/util/gconv/internal/localinterface" +) + +// ScanOption is the option for the Scan function. +type ScanOption struct { + // ParamKeyToAttrMap specifies the mapping between parameter keys and struct attribute names. + ParamKeyToAttrMap map[string]string + + // ContinueOnError specifies whether to continue converting the next element + // if one element converting fails. + ContinueOnError bool +} + +// Scan automatically checks the type of `pointer` and converts `params` to `pointer`. +func (c *Converter) Scan(srcValue any, dstPointer any, option ScanOption) (err error) { + // Check if srcValue is nil, in which case no conversion is needed + if srcValue == nil { + return nil + } + // Check if dstPointer is nil, which is an invalid parameter + if dstPointer == nil { + return gerror.NewCode( + gcode.CodeInvalidParameter, + `destination pointer should not be nil`, + ) + } + + // Get the reflection type and value of dstPointer + var ( + dstPointerReflectType reflect.Type + dstPointerReflectValue reflect.Value + ) + if v, ok := dstPointer.(reflect.Value); ok { + dstPointerReflectValue = v + dstPointerReflectType = v.Type() + } else { + dstPointerReflectValue = reflect.ValueOf(dstPointer) + // Do not use dstPointerReflectValue.Type() as dstPointerReflectValue might be zero + dstPointerReflectType = reflect.TypeOf(dstPointer) + } + + // Validate the kind of dstPointer + var dstPointerReflectKind = dstPointerReflectType.Kind() + if dstPointerReflectKind != reflect.Ptr { + // If dstPointer is not a pointer, try to get its address + if dstPointerReflectValue.CanAddr() { + dstPointerReflectValue = dstPointerReflectValue.Addr() + dstPointerReflectType = dstPointerReflectValue.Type() + dstPointerReflectKind = dstPointerReflectType.Kind() + } else { + // If dstPointer is not a pointer and cannot be addressed, return an error + return gerror.NewCodef( + gcode.CodeInvalidParameter, + `destination pointer should be type of pointer, but got type: %v`, + dstPointerReflectType, + ) + } + } + + // Get the reflection value of srcValue + var srcValueReflectValue reflect.Value + if v, ok := srcValue.(reflect.Value); ok { + srcValueReflectValue = v + } else { + srcValueReflectValue = reflect.ValueOf(srcValue) + } + + // Get the element type and kind of dstPointer + var ( + dstPointerReflectValueElem = dstPointerReflectValue.Elem() + dstPointerReflectValueElemKind = dstPointerReflectValueElem.Kind() + ) + // Handle multiple level pointers + if dstPointerReflectValueElemKind == reflect.Ptr { + if dstPointerReflectValueElem.IsNil() { + // Create a new value for the pointer dereference + nextLevelPtr := reflect.New(dstPointerReflectValueElem.Type().Elem()) + // Recursively scan into the dereferenced pointer + if err = c.Scan(srcValueReflectValue, nextLevelPtr, option); err == nil { + dstPointerReflectValueElem.Set(nextLevelPtr) + } + return + } + return c.Scan(srcValueReflectValue, dstPointerReflectValueElem, option) + } + + // Check if srcValue and dstPointer are the same type, in which case direct assignment can be performed + if ok := c.doConvertWithTypeCheck(srcValueReflectValue, dstPointerReflectValueElem); ok { + return nil + } + + // Handle different destination types + switch dstPointerReflectValueElemKind { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + v, err := c.Int64(srcValue) + if err != nil && !option.ContinueOnError { + return err + } + dstPointerReflectValueElem.SetInt(v) + return nil + + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + v, err := c.Uint64(srcValue) + if err != nil && !option.ContinueOnError { + return err + } + dstPointerReflectValueElem.SetUint(v) + return nil + + case reflect.Float32, reflect.Float64: + v, err := c.Float64(srcValue) + if err != nil && !option.ContinueOnError { + return err + } + dstPointerReflectValueElem.SetFloat(v) + return nil + + case reflect.String: + v, err := c.String(srcValue) + if err != nil && !option.ContinueOnError { + return err + } + dstPointerReflectValueElem.SetString(v) + return nil + + case reflect.Bool: + v, err := c.Bool(srcValue) + if err != nil && !option.ContinueOnError { + return err + } + dstPointerReflectValueElem.SetBool(v) + return nil + + case reflect.Slice: + // Handle slice type conversion + var ( + dstElemType = dstPointerReflectValueElem.Type().Elem() + dstElemKind = dstElemType.Kind() + ) + // The slice element might be a pointer type + if dstElemKind == reflect.Ptr { + dstElemType = dstElemType.Elem() + dstElemKind = dstElemType.Kind() + } + // Special handling for struct or map slice elements + if dstElemKind == reflect.Struct || dstElemKind == reflect.Map { + return c.doScanForComplicatedTypes(srcValue, dstPointer, dstPointerReflectType, option) + } + // Handle basic type slice conversions + var srcValueReflectValueKind = srcValueReflectValue.Kind() + if srcValueReflectValueKind == reflect.Slice || srcValueReflectValueKind == reflect.Array { + var ( + srcLen = srcValueReflectValue.Len() + newSlice = reflect.MakeSlice(dstPointerReflectValueElem.Type(), srcLen, srcLen) + ) + for i := 0; i < srcLen; i++ { + srcElem := srcValueReflectValue.Index(i).Interface() + switch dstElemType.Kind() { + case reflect.String: + v, err := c.String(srcElem) + if err != nil && !option.ContinueOnError { + return err + } + newSlice.Index(i).SetString(v) + case reflect.Int: + v, err := c.Int64(srcElem) + if err != nil && !option.ContinueOnError { + return err + } + newSlice.Index(i).SetInt(v) + case reflect.Int64: + v, err := c.Int64(srcElem) + if err != nil && !option.ContinueOnError { + return err + } + newSlice.Index(i).SetInt(v) + case reflect.Float64: + v, err := c.Float64(srcElem) + if err != nil && !option.ContinueOnError { + return err + } + newSlice.Index(i).SetFloat(v) + case reflect.Bool: + v, err := c.Bool(srcElem) + if err != nil && !option.ContinueOnError { + return err + } + newSlice.Index(i).SetBool(v) + default: + return c.Scan( + srcElem, newSlice.Index(i).Addr().Interface(), option, + ) + } + } + dstPointerReflectValueElem.Set(newSlice) + return nil + } + return c.doScanForComplicatedTypes(srcValue, dstPointer, dstPointerReflectType, option) + + default: + // Handle complex types (structs, maps, etc.) + return c.doScanForComplicatedTypes(srcValue, dstPointer, dstPointerReflectType, option) + } +} + +// doScanForComplicatedTypes handles the scanning of complex data types. +// It supports converting between maps, structs, and slices of these types. +// The function first attempts JSON conversion, then falls back to specific type handling. +// +// It supports `pointer` in type of `*map/*[]map/*[]*map/*struct/**struct/*[]struct/*[]*struct` for converting. +// +// Parameters: +// - srcValue: The source value to convert from +// - dstPointer: The destination pointer to convert to +// - dstPointerReflectType: The reflection type of the destination pointer +// - paramKeyToAttrMap: Optional mapping between parameter keys and struct attribute names +func (c *Converter) doScanForComplicatedTypes( + srcValue, dstPointer any, + dstPointerReflectType reflect.Type, + option ScanOption, +) error { + // Try JSON conversion first + ok, err := c.doConvertWithJsonCheck(srcValue, dstPointer) + if err != nil { + return err + } + if ok { + return nil + } + + // Handle specific type conversions + var ( + dstPointerReflectTypeElem = dstPointerReflectType.Elem() + dstPointerReflectTypeElemKind = dstPointerReflectTypeElem.Kind() + keyToAttributeNameMapping = option.ParamKeyToAttrMap + ) + // Handle different destination types + switch dstPointerReflectTypeElemKind { + case reflect.Map: + // Convert map to map + return c.MapToMap(srcValue, dstPointer, keyToAttributeNameMapping, MapOption{ + ContinueOnError: option.ContinueOnError, + }) + + case reflect.Array, reflect.Slice: + var ( + sliceElem = dstPointerReflectTypeElem.Elem() + sliceElemKind = sliceElem.Kind() + ) + // Handle pointer elements + for sliceElemKind == reflect.Ptr { + sliceElem = sliceElem.Elem() + sliceElemKind = sliceElem.Kind() + } + if sliceElemKind == reflect.Map { + // Convert to slice of maps + return c.MapToMaps(srcValue, dstPointer, keyToAttributeNameMapping, MapOption{ + ContinueOnError: option.ContinueOnError, + }) + } + // Convert to slice of structs + var ( + sliceOption = SliceOption{ + ContinueOnError: option.ContinueOnError, + } + mapOption = StructOption{ + ParamKeyToAttrMap: keyToAttributeNameMapping, + ContinueOnError: option.ContinueOnError, + } + ) + return c.Structs(srcValue, dstPointer, sliceOption, mapOption) + + default: + structOption := StructOption{ + ParamKeyToAttrMap: keyToAttributeNameMapping, + PriorityTag: "", + ContinueOnError: option.ContinueOnError, + } + return c.Struct(srcValue, dstPointer, structOption) + } +} + +// doConvertWithTypeCheck supports `pointer` in type of `*map/*[]map/*[]*map/*struct/**struct/*[]struct/*[]*struct` +// for converting. +func (c *Converter) doConvertWithTypeCheck(srcValueReflectValue, dstPointerReflectValueElem reflect.Value) (ok bool) { + if !dstPointerReflectValueElem.IsValid() || !srcValueReflectValue.IsValid() { + return false + } + switch { + // Examples: + // UploadFile => UploadFile + // []UploadFile => []UploadFile + // *UploadFile => *UploadFile + // *[]UploadFile => *[]UploadFile + // map[int][int] => map[int][int] + // []map[int][int] => []map[int][int] + // *[]map[int][int] => *[]map[int][int] + case dstPointerReflectValueElem.Type() == srcValueReflectValue.Type(): + dstPointerReflectValueElem.Set(srcValueReflectValue) + return true + + // Examples: + // UploadFile => *UploadFile + // []UploadFile => *[]UploadFile + // map[int][int] => *map[int][int] + // []map[int][int] => *[]map[int][int] + case dstPointerReflectValueElem.Kind() == reflect.Ptr && + dstPointerReflectValueElem.Elem().IsValid() && + dstPointerReflectValueElem.Elem().Type() == srcValueReflectValue.Type(): + dstPointerReflectValueElem.Elem().Set(srcValueReflectValue) + return true + + // Examples: + // *UploadFile => UploadFile + // *[]UploadFile => []UploadFile + // *map[int][int] => map[int][int] + // *[]map[int][int] => []map[int][int] + case srcValueReflectValue.Kind() == reflect.Ptr && + srcValueReflectValue.Elem().IsValid() && + dstPointerReflectValueElem.Type() == srcValueReflectValue.Elem().Type(): + dstPointerReflectValueElem.Set(srcValueReflectValue.Elem()) + return true + + default: + return false + } +} + +// doConvertWithJsonCheck attempts to convert the source value to the destination +// using JSON marshaling and unmarshaling. This is particularly useful for complex +// types that can be represented as JSON. +// +// Parameters: +// - srcValue: The source value to convert from +// - dstPointer: The destination pointer to convert to +// +// Returns: +// - bool: true if JSON conversion was successful +// - error: any error that occurred during conversion +func (c *Converter) doConvertWithJsonCheck(srcValue any, dstPointer any) (ok bool, err error) { + switch valueResult := srcValue.(type) { + case []byte: + if json.Valid(valueResult) { + if dstPointerReflectType, ok := dstPointer.(reflect.Value); ok { + if dstPointerReflectType.Kind() == reflect.Ptr { + if dstPointerReflectType.IsNil() { + return false, nil + } + return true, json.UnmarshalUseNumber(valueResult, dstPointerReflectType.Interface()) + } else if dstPointerReflectType.CanAddr() { + return true, json.UnmarshalUseNumber(valueResult, dstPointerReflectType.Addr().Interface()) + } + } else { + return true, json.UnmarshalUseNumber(valueResult, dstPointer) + } + } + + case string: + if valueBytes := []byte(valueResult); json.Valid(valueBytes) { + if dstPointerReflectType, ok := dstPointer.(reflect.Value); ok { + if dstPointerReflectType.Kind() == reflect.Ptr { + if dstPointerReflectType.IsNil() { + return false, nil + } + return true, json.UnmarshalUseNumber(valueBytes, dstPointerReflectType.Interface()) + } else if dstPointerReflectType.CanAddr() { + return true, json.UnmarshalUseNumber(valueBytes, dstPointerReflectType.Addr().Interface()) + } + } else { + return true, json.UnmarshalUseNumber(valueBytes, dstPointer) + } + } + + default: + // The `params` might be struct that implements interface function Interface, eg: gvar.Var. + if v, ok := srcValue.(localinterface.IInterface); ok { + return c.doConvertWithJsonCheck(v.Interface(), dstPointer) + } + } + return false, nil +} diff --git a/util/gconv/internal/converter/converter_slice_any.go b/util/gconv/internal/converter/converter_slice_any.go new file mode 100644 index 00000000000..8a0402ec1cb --- /dev/null +++ b/util/gconv/internal/converter/converter_slice_any.go @@ -0,0 +1,143 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "reflect" + + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/internal/reflection" + "github.com/gogf/gf/v2/util/gconv/internal/localinterface" +) + +// SliceOption is the option for Slice type converting. +type SliceOption struct { + // ContinueOnError specifies whether to continue converting the next element + // if one element converting fails. + ContinueOnError bool +} + +// SliceAny converts `any` to []any. +func (c *Converter) SliceAny(any interface{}, option SliceOption) ([]any, error) { + if empty.IsNil(any) { + return nil, nil + } + var ( + err error + array []interface{} + ) + switch value := any.(type) { + case []interface{}: + array = value + case []string: + array = make([]interface{}, len(value)) + for k, v := range value { + array[k] = v + } + case []int: + array = make([]interface{}, len(value)) + for k, v := range value { + array[k] = v + } + case []int8: + array = make([]interface{}, len(value)) + for k, v := range value { + array[k] = v + } + case []int16: + array = make([]interface{}, len(value)) + for k, v := range value { + array[k] = v + } + case []int32: + array = make([]interface{}, len(value)) + for k, v := range value { + array[k] = v + } + case []int64: + array = make([]interface{}, len(value)) + for k, v := range value { + array[k] = v + } + case []uint: + array = make([]interface{}, len(value)) + for k, v := range value { + array[k] = v + } + case []uint8: + if json.Valid(value) { + if err = json.UnmarshalUseNumber(value, &array); array != nil { + return array, err + } + } + array = make([]interface{}, len(value)) + for k, v := range value { + array[k] = v + } + case string: + byteValue := []byte(value) + if json.Valid(byteValue) { + if err = json.UnmarshalUseNumber(byteValue, &array); array != nil { + return array, err + } + } + + case []uint16: + array = make([]interface{}, len(value)) + for k, v := range value { + array[k] = v + } + case []uint32: + for _, v := range value { + array = append(array, v) + } + case []uint64: + array = make([]interface{}, len(value)) + for k, v := range value { + array[k] = v + } + case []bool: + array = make([]interface{}, len(value)) + for k, v := range value { + array[k] = v + } + case []float32: + array = make([]interface{}, len(value)) + for k, v := range value { + array[k] = v + } + case []float64: + array = make([]interface{}, len(value)) + for k, v := range value { + array[k] = v + } + } + if array != nil { + return array, err + } + if v, ok := any.(localinterface.IInterfaces); ok { + return v.Interfaces(), err + } + + // Not a common type, it then uses reflection for conversion. + originValueAndKind := reflection.OriginValueAndKind(any) + switch originValueAndKind.OriginKind { + case reflect.Slice, reflect.Array: + var ( + length = originValueAndKind.OriginValue.Len() + slice = make([]interface{}, length) + ) + for i := 0; i < length; i++ { + slice[i] = originValueAndKind.OriginValue.Index(i).Interface() + } + return slice, err + + default: + return []interface{}{any}, err + } +} diff --git a/util/gconv/internal/converter/converter_slice_float.go b/util/gconv/internal/converter/converter_slice_float.go new file mode 100644 index 00000000000..27d59c6abbc --- /dev/null +++ b/util/gconv/internal/converter/converter_slice_float.go @@ -0,0 +1,417 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "reflect" + + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/internal/reflection" + "github.com/gogf/gf/v2/internal/utils" + "github.com/gogf/gf/v2/util/gconv/internal/localinterface" +) + +// SliceFloat32 converts `any` to []float32. +func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32, error) { + if empty.IsNil(any) { + return nil, nil + } + var ( + err error + f float32 + array []float32 = nil + ) + switch value := any.(type) { + case []string: + array = make([]float32, len(value)) + for k, v := range value { + f, err = c.Float32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []int: + array = make([]float32, len(value)) + for k, v := range value { + f, err = c.Float32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []int8: + array = make([]float32, len(value)) + for k, v := range value { + f, err = c.Float32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []int16: + array = make([]float32, len(value)) + for k, v := range value { + f, err = c.Float32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []int32: + array = make([]float32, len(value)) + for k, v := range value { + f, err = c.Float32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []int64: + array = make([]float32, len(value)) + for k, v := range value { + f, err = c.Float32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []uint: + array = make([]float32, len(value)) + for k, v := range value { + f, err = c.Float32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []uint8: + if json.Valid(value) { + if err = json.UnmarshalUseNumber(value, &array); array != nil { + return array, err + } + } + array = make([]float32, len(value)) + for k, v := range value { + f, err = c.Float32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case string: + byteValue := []byte(value) + if json.Valid(byteValue) { + if err = json.UnmarshalUseNumber(byteValue, &array); array != nil { + return array, err + } + } + if value == "" { + return []float32{}, err + } + if utils.IsNumeric(value) { + f, err = c.Float32(value) + if err != nil && !option.ContinueOnError { + return nil, err + } + return []float32{f}, err + } + case []uint16: + array = make([]float32, len(value)) + for k, v := range value { + f, err = c.Float32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []uint32: + array = make([]float32, len(value)) + for k, v := range value { + f, err = c.Float32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []uint64: + array = make([]float32, len(value)) + for k, v := range value { + f, err = c.Float32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []bool: + array = make([]float32, len(value)) + for k, v := range value { + f, err = c.Float32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []float32: + array = value + case []float64: + array = make([]float32, len(value)) + for k, v := range value { + f, err = c.Float32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []interface{}: + array = make([]float32, len(value)) + for k, v := range value { + f, err = c.Float32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + } + if array != nil { + return array, err + } + if v, ok := any.(localinterface.IFloats); ok { + return c.SliceFloat32(v.Floats(), option) + } + if v, ok := any.(localinterface.IInterfaces); ok { + return c.SliceFloat32(v.Interfaces(), option) + } + // Not a common type, it then uses reflection for conversion. + originValueAndKind := reflection.OriginValueAndKind(any) + switch originValueAndKind.OriginKind { + case reflect.Slice, reflect.Array: + var ( + length = originValueAndKind.OriginValue.Len() + slice = make([]float32, length) + ) + for i := 0; i < length; i++ { + f, err = c.Float32(originValueAndKind.OriginValue.Index(i).Interface()) + if err != nil && !option.ContinueOnError { + return nil, err + } + slice[i] = f + } + return slice, err + + default: + if originValueAndKind.OriginValue.IsZero() { + return []float32{}, err + } + f, err = c.Float32(any) + if err != nil && !option.ContinueOnError { + return nil, err + } + return []float32{f}, err + } +} + +// SliceFloat64 converts `any` to []float64. +func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64, error) { + if empty.IsNil(any) { + return nil, nil + } + var ( + err error + f float64 + array []float64 = nil + ) + switch value := any.(type) { + case []string: + array = make([]float64, len(value)) + for k, v := range value { + f, err = c.Float64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []int: + array = make([]float64, len(value)) + for k, v := range value { + f, err = c.Float64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []int8: + array = make([]float64, len(value)) + for k, v := range value { + f, err = c.Float64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []int16: + array = make([]float64, len(value)) + for k, v := range value { + f, err = c.Float64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []int32: + array = make([]float64, len(value)) + for k, v := range value { + f, err = c.Float64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []int64: + array = make([]float64, len(value)) + for k, v := range value { + f, err = c.Float64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []uint: + array = make([]float64, len(value)) + for k, v := range value { + f, err = c.Float64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []uint8: + if json.Valid(value) { + if err = json.UnmarshalUseNumber(value, &array); array != nil { + return array, err + } + } + array = make([]float64, len(value)) + for k, v := range value { + f, err = c.Float64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case string: + byteValue := []byte(value) + if json.Valid(byteValue) { + if err = json.UnmarshalUseNumber(byteValue, &array); array != nil { + return array, err + } + } + if value == "" { + return []float64{}, err + } + if utils.IsNumeric(value) { + f, err = c.Float64(value) + if err != nil && !option.ContinueOnError { + return nil, err + } + return []float64{f}, err + } + case []uint16: + array = make([]float64, len(value)) + for k, v := range value { + f, err = c.Float64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []uint32: + array = make([]float64, len(value)) + for k, v := range value { + f, err = c.Float64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []uint64: + array = make([]float64, len(value)) + for k, v := range value { + f, err = c.Float64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []bool: + array = make([]float64, len(value)) + for k, v := range value { + f, err = c.Float64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []float32: + array = make([]float64, len(value)) + for k, v := range value { + f, err = c.Float64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + case []float64: + array = value + case []interface{}: + array = make([]float64, len(value)) + for k, v := range value { + f, err = c.Float64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = f + } + } + if array != nil { + return array, err + } + if v, ok := any.(localinterface.IFloats); ok { + return v.Floats(), err + } + if v, ok := any.(localinterface.IInterfaces); ok { + return c.SliceFloat64(v.Interfaces(), option) + } + // Not a common type, it then uses reflection for conversion. + originValueAndKind := reflection.OriginValueAndKind(any) + switch originValueAndKind.OriginKind { + case reflect.Slice, reflect.Array: + var ( + length = originValueAndKind.OriginValue.Len() + slice = make([]float64, length) + ) + for i := 0; i < length; i++ { + f, err = c.Float64(originValueAndKind.OriginValue.Index(i).Interface()) + if err != nil && !option.ContinueOnError { + return nil, err + } + slice[i] = f + } + return slice, err + + default: + if originValueAndKind.OriginValue.IsZero() { + return []float64{}, err + } + f, err = c.Float64(any) + if err != nil && !option.ContinueOnError { + return nil, err + } + return []float64{f}, err + } +} diff --git a/util/gconv/internal/converter/converter_slice_int.go b/util/gconv/internal/converter/converter_slice_int.go new file mode 100644 index 00000000000..b1a769d275a --- /dev/null +++ b/util/gconv/internal/converter/converter_slice_int.go @@ -0,0 +1,536 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "reflect" + + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/internal/reflection" + "github.com/gogf/gf/v2/internal/utils" + "github.com/gogf/gf/v2/util/gconv/internal/localinterface" +) + +// SliceInt converts `any` to []int. +func (c *Converter) SliceInt(any any, option SliceOption) ([]int, error) { + if empty.IsNil(any) { + return nil, nil + } + var ( + err error + ii int + array []int = nil + ) + switch value := any.(type) { + case []string: + array = make([]int, len(value)) + for k, v := range value { + ii, err = c.Int(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ii + } + case []int: + array = value + case []int8: + array = make([]int, len(value)) + for k, v := range value { + array[k] = int(v) + } + case []int16: + array = make([]int, len(value)) + for k, v := range value { + array[k] = int(v) + } + case []int32: + array = make([]int, len(value)) + for k, v := range value { + array[k] = int(v) + } + case []int64: + array = make([]int, len(value)) + for k, v := range value { + array[k] = int(v) + } + case []uint: + array = make([]int, len(value)) + for k, v := range value { + array[k] = int(v) + } + case []uint8: + if json.Valid(value) { + if err = json.UnmarshalUseNumber(value, &array); array != nil { + return array, err + } + } + array = make([]int, len(value)) + for k, v := range value { + array[k] = int(v) + } + case string: + byteValue := []byte(value) + if json.Valid(byteValue) { + if err = json.UnmarshalUseNumber(byteValue, &array); array != nil { + return array, err + } + } + if value == "" { + return []int{}, err + } + if utils.IsNumeric(value) { + ii, err = c.Int(value) + if err != nil && !option.ContinueOnError { + return nil, err + } + return []int{ii}, err + } + case []uint16: + array = make([]int, len(value)) + for k, v := range value { + array[k] = int(v) + } + case []uint32: + array = make([]int, len(value)) + for k, v := range value { + array[k] = int(v) + } + case []uint64: + array = make([]int, len(value)) + for k, v := range value { + array[k] = int(v) + } + case []bool: + array = make([]int, len(value)) + for k, v := range value { + if v { + array[k] = 1 + } else { + array[k] = 0 + } + } + case []float32: + array = make([]int, len(value)) + for k, v := range value { + ii, err = c.Int(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ii + } + case []float64: + array = make([]int, len(value)) + for k, v := range value { + ii, err = c.Int(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ii + } + case []interface{}: + array = make([]int, len(value)) + for k, v := range value { + ii, err = c.Int(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ii + } + case [][]byte: + array = make([]int, len(value)) + for k, v := range value { + ii, err = c.Int(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ii + } + } + if array != nil { + return array, err + } + if v, ok := any.(localinterface.IInts); ok { + return v.Ints(), err + } + if v, ok := any.(localinterface.IInterfaces); ok { + return c.SliceInt(v.Interfaces(), option) + } + // Not a common type, it then uses reflection for conversion. + originValueAndKind := reflection.OriginValueAndKind(any) + switch originValueAndKind.OriginKind { + case reflect.Slice, reflect.Array: + var ( + length = originValueAndKind.OriginValue.Len() + slice = make([]int, length) + ) + for i := 0; i < length; i++ { + ii, err = c.Int(originValueAndKind.OriginValue.Index(i).Interface()) + if err != nil && !option.ContinueOnError { + return nil, err + } + slice[i] = ii + } + return slice, err + + default: + if originValueAndKind.OriginValue.IsZero() { + return []int{}, err + } + ii, err = c.Int(any) + if err != nil && !option.ContinueOnError { + return nil, err + } + return []int{ii}, err + } +} + +// SliceInt32 converts `any` to []int32. +func (c *Converter) SliceInt32(any any, option SliceOption) ([]int32, error) { + if empty.IsNil(any) { + return nil, nil + } + var ( + err error + ii int32 + array []int32 = nil + ) + switch value := any.(type) { + case []string: + array = make([]int32, len(value)) + for k, v := range value { + ii, err = c.Int32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ii + } + case []int: + array = make([]int32, len(value)) + for k, v := range value { + array[k] = int32(v) + } + case []int8: + array = make([]int32, len(value)) + for k, v := range value { + array[k] = int32(v) + } + case []int16: + array = make([]int32, len(value)) + for k, v := range value { + array[k] = int32(v) + } + case []int32: + array = value + case []int64: + array = make([]int32, len(value)) + for k, v := range value { + array[k] = int32(v) + } + case []uint: + array = make([]int32, len(value)) + for k, v := range value { + array[k] = int32(v) + } + case []uint8: + if json.Valid(value) { + if err = json.UnmarshalUseNumber(value, &array); array != nil { + return array, err + } + } + array = make([]int32, len(value)) + for k, v := range value { + array[k] = int32(v) + } + case string: + byteValue := []byte(value) + if json.Valid(byteValue) { + if err = json.UnmarshalUseNumber(byteValue, &array); array != nil { + return array, err + } + } + if value == "" { + return []int32{}, err + } + if utils.IsNumeric(value) { + ii, err = c.Int32(value) + if err != nil && !option.ContinueOnError { + return nil, err + } + return []int32{ii}, err + } + case []uint16: + array = make([]int32, len(value)) + for k, v := range value { + array[k] = int32(v) + } + case []uint32: + array = make([]int32, len(value)) + for k, v := range value { + array[k] = int32(v) + } + case []uint64: + array = make([]int32, len(value)) + for k, v := range value { + array[k] = int32(v) + } + case []bool: + array = make([]int32, len(value)) + for k, v := range value { + if v { + array[k] = 1 + } else { + array[k] = 0 + } + } + case []float32: + array = make([]int32, len(value)) + for k, v := range value { + ii, err = c.Int32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ii + } + case []float64: + array = make([]int32, len(value)) + for k, v := range value { + ii, err = c.Int32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ii + } + case []interface{}: + array = make([]int32, len(value)) + for k, v := range value { + ii, err = c.Int32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ii + } + case [][]byte: + array = make([]int32, len(value)) + for k, v := range value { + ii, err = c.Int32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ii + } + } + if array != nil { + return array, err + } + if v, ok := any.(localinterface.IInts); ok { + return c.SliceInt32(v.Ints(), option) + } + if v, ok := any.(localinterface.IInterfaces); ok { + return c.SliceInt32(v.Interfaces(), option) + } + // Not a common type, it then uses reflection for conversion. + originValueAndKind := reflection.OriginValueAndKind(any) + switch originValueAndKind.OriginKind { + case reflect.Slice, reflect.Array: + var ( + length = originValueAndKind.OriginValue.Len() + slice = make([]int32, length) + ) + for i := 0; i < length; i++ { + ii, err = c.Int32(originValueAndKind.OriginValue.Index(i).Interface()) + if err != nil && !option.ContinueOnError { + return nil, err + } + slice[i] = ii + } + return slice, err + + default: + if originValueAndKind.OriginValue.IsZero() { + return []int32{}, err + } + ii, err = c.Int32(any) + if err != nil && !option.ContinueOnError { + return nil, err + } + return []int32{ii}, err + } +} + +// SliceInt64 converts `any` to []int64. +func (c *Converter) SliceInt64(any any, option SliceOption) ([]int64, error) { + if empty.IsNil(any) { + return nil, nil + } + var ( + err error + ii int64 + array []int64 = nil + ) + switch value := any.(type) { + case []string: + array = make([]int64, len(value)) + for k, v := range value { + ii, err = c.Int64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ii + } + case []int: + array = make([]int64, len(value)) + for k, v := range value { + array[k] = int64(v) + } + case []int8: + array = make([]int64, len(value)) + for k, v := range value { + array[k] = int64(v) + } + case []int16: + array = make([]int64, len(value)) + for k, v := range value { + array[k] = int64(v) + } + case []int32: + array = make([]int64, len(value)) + for k, v := range value { + array[k] = int64(v) + } + case []int64: + array = value + case []uint: + array = make([]int64, len(value)) + for k, v := range value { + array[k] = int64(v) + } + case []uint8: + if json.Valid(value) { + if err = json.UnmarshalUseNumber(value, &array); array != nil { + return array, err + } + } + array = make([]int64, len(value)) + for k, v := range value { + array[k] = int64(v) + } + case string: + byteValue := []byte(value) + if json.Valid(byteValue) { + if err = json.UnmarshalUseNumber(byteValue, &array); array != nil { + return array, err + } + } + if value == "" { + return []int64{}, err + } + if utils.IsNumeric(value) { + ii, err = c.Int64(value) + if err != nil && !option.ContinueOnError { + return nil, err + } + return []int64{ii}, err + } + case []uint16: + array = make([]int64, len(value)) + for k, v := range value { + array[k] = int64(v) + } + case []uint32: + array = make([]int64, len(value)) + for k, v := range value { + array[k] = int64(v) + } + case []uint64: + array = make([]int64, len(value)) + for k, v := range value { + array[k] = int64(v) + } + case []bool: + array = make([]int64, len(value)) + for k, v := range value { + if v { + array[k] = 1 + } else { + array[k] = 0 + } + } + case []float32: + array = make([]int64, len(value)) + for k, v := range value { + ii, err = c.Int64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ii + } + case []float64: + array = make([]int64, len(value)) + for k, v := range value { + ii, err = c.Int64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ii + } + case []interface{}: + array = make([]int64, len(value)) + for k, v := range value { + ii, err = c.Int64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ii + } + case [][]byte: + array = make([]int64, len(value)) + for k, v := range value { + ii, err = c.Int64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ii + } + } + if array != nil { + return array, err + } + if v, ok := any.(localinterface.IInts); ok { + return c.SliceInt64(v.Ints(), option) + } + if v, ok := any.(localinterface.IInterfaces); ok { + return c.SliceInt64(v.Interfaces(), option) + } + // Not a common type, it then uses reflection for conversion. + originValueAndKind := reflection.OriginValueAndKind(any) + switch originValueAndKind.OriginKind { + case reflect.Slice, reflect.Array: + var ( + length = originValueAndKind.OriginValue.Len() + slice = make([]int64, length) + ) + for i := 0; i < length; i++ { + ii, err = c.Int64(originValueAndKind.OriginValue.Index(i).Interface()) + if err != nil && !option.ContinueOnError { + return nil, err + } + slice[i] = ii + } + return slice, err + + default: + if originValueAndKind.OriginValue.IsZero() { + return []int64{}, err + } + ii, err = c.Int64(any) + if err != nil && !option.ContinueOnError { + return nil, err + } + return []int64{ii}, err + } +} diff --git a/util/gconv/internal/converter/converter_slice_map.go b/util/gconv/internal/converter/converter_slice_map.go new file mode 100644 index 00000000000..837f51ab945 --- /dev/null +++ b/util/gconv/internal/converter/converter_slice_map.go @@ -0,0 +1,59 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import "github.com/gogf/gf/v2/internal/json" + +// SliceMap converts `value` to []map[string]any. +// Note that it automatically checks and converts json string to []map if `value` is string/[]byte. +func (c *Converter) SliceMap(value any, sliceOption SliceOption, mapOption MapOption) ([]map[string]any, error) { + if value == nil { + return nil, nil + } + switch r := value.(type) { + case string: + list := make([]map[string]any, 0) + if len(r) > 0 && r[0] == '[' && r[len(r)-1] == ']' { + if err := json.UnmarshalUseNumber([]byte(r), &list); err != nil { + return nil, err + } + return list, nil + } + return nil, nil + + case []byte: + list := make([]map[string]any, 0) + if len(r) > 0 && r[0] == '[' && r[len(r)-1] == ']' { + if err := json.UnmarshalUseNumber(r, &list); err != nil { + return nil, err + } + return list, nil + } + return nil, nil + + case []map[string]any: + return r, nil + + default: + array, err := c.SliceAny(value, sliceOption) + if err != nil { + return nil, err + } + if len(array) == 0 { + return nil, nil + } + list := make([]map[string]any, len(array)) + for k, v := range array { + m, err := c.Map(v, mapOption) + if err != nil && !sliceOption.ContinueOnError { + return nil, err + } + list[k] = m + } + return list, nil + } +} diff --git a/util/gconv/internal/converter/converter_slice_str.go b/util/gconv/internal/converter/converter_slice_str.go new file mode 100644 index 00000000000..e95f70b8a27 --- /dev/null +++ b/util/gconv/internal/converter/converter_slice_str.go @@ -0,0 +1,220 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "reflect" + + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/internal/reflection" + "github.com/gogf/gf/v2/util/gconv/internal/localinterface" +) + +// SliceStr converts `any` to []string. +func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, error) { + if empty.IsNil(any) { + return nil, nil + } + var ( + err error + s string + array []string = nil + ) + switch value := any.(type) { + case []int: + array = make([]string, len(value)) + for k, v := range value { + s, err = c.String(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = s + } + case []int8: + array = make([]string, len(value)) + for k, v := range value { + s, err = c.String(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = s + } + case []int16: + array = make([]string, len(value)) + for k, v := range value { + s, err = c.String(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = s + } + case []int32: + array = make([]string, len(value)) + for k, v := range value { + s, err = c.String(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = s + } + case []int64: + array = make([]string, len(value)) + for k, v := range value { + s, err = c.String(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = s + } + case []uint: + array = make([]string, len(value)) + for k, v := range value { + s, err = c.String(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = s + } + case []uint8: + if json.Valid(value) { + if err = json.UnmarshalUseNumber(value, &array); array != nil { + return array, err + } + } + array = make([]string, len(value)) + for k, v := range value { + s, err = c.String(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = s + } + return array, err + case string: + byteValue := []byte(value) + if json.Valid(byteValue) { + if err = json.UnmarshalUseNumber(byteValue, &array); array != nil { + return array, err + } + } + if value == "" { + return []string{}, err + } + return []string{value}, err + case []uint16: + array = make([]string, len(value)) + for k, v := range value { + s, err = c.String(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = s + } + case []uint32: + array = make([]string, len(value)) + for k, v := range value { + s, err = c.String(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = s + } + case []uint64: + array = make([]string, len(value)) + for k, v := range value { + s, err = c.String(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = s + } + case []bool: + array = make([]string, len(value)) + for k, v := range value { + s, err = c.String(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = s + } + case []float32: + array = make([]string, len(value)) + for k, v := range value { + s, err = c.String(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = s + } + case []float64: + array = make([]string, len(value)) + for k, v := range value { + s, err = c.String(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = s + } + case []interface{}: + array = make([]string, len(value)) + for k, v := range value { + s, err = c.String(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = s + } + case []string: + array = value + case [][]byte: + array = make([]string, len(value)) + for k, v := range value { + s, err = c.String(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = s + } + } + if array != nil { + return array, err + } + if v, ok := any.(localinterface.IStrings); ok { + return v.Strings(), err + } + if v, ok := any.(localinterface.IInterfaces); ok { + return c.SliceStr(v.Interfaces(), option) + } + // Not a common type, it then uses reflection for conversion. + originValueAndKind := reflection.OriginValueAndKind(any) + switch originValueAndKind.OriginKind { + case reflect.Slice, reflect.Array: + var ( + length = originValueAndKind.OriginValue.Len() + slice = make([]string, length) + ) + for i := 0; i < length; i++ { + s, err = c.String(originValueAndKind.OriginValue.Index(i).Interface()) + if err != nil && !option.ContinueOnError { + return nil, err + } + slice[i] = s + } + return slice, err + + default: + if originValueAndKind.OriginValue.IsZero() { + return []string{}, err + } + s, err = c.String(any) + if err != nil && !option.ContinueOnError { + return nil, err + } + return []string{s}, err + } +} diff --git a/util/gconv/internal/converter/converter_slice_uint.go b/util/gconv/internal/converter/converter_slice_uint.go new file mode 100644 index 00000000000..173c96469cd --- /dev/null +++ b/util/gconv/internal/converter/converter_slice_uint.go @@ -0,0 +1,527 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "reflect" + + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/internal/reflection" + "github.com/gogf/gf/v2/internal/utils" + "github.com/gogf/gf/v2/util/gconv/internal/localinterface" +) + +// SliceUint converts `any` to []uint. +func (c *Converter) SliceUint(any interface{}, option SliceOption) ([]uint, error) { + if empty.IsNil(any) { + return nil, nil + } + var ( + err error + ui uint + array []uint = nil + ) + switch value := any.(type) { + case []string: + array = make([]uint, len(value)) + for k, v := range value { + ui, err = c.Uint(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ui + } + case []int8: + array = make([]uint, len(value)) + for k, v := range value { + array[k] = uint(v) + } + case []int16: + array = make([]uint, len(value)) + for k, v := range value { + array[k] = uint(v) + } + case []int32: + array = make([]uint, len(value)) + for k, v := range value { + array[k] = uint(v) + } + case []int64: + array = make([]uint, len(value)) + for k, v := range value { + array[k] = uint(v) + } + case []uint: + array = value + case []uint8: + if json.Valid(value) { + if err = json.UnmarshalUseNumber(value, &array); array != nil { + return array, err + } + } + array = make([]uint, len(value)) + for k, v := range value { + array[k] = uint(v) + } + case string: + byteValue := []byte(value) + if json.Valid(byteValue) { + if err = json.UnmarshalUseNumber(byteValue, &array); array != nil { + return array, err + } + } + if value == "" { + return []uint{}, err + } + if utils.IsNumeric(value) { + ui, err = c.Uint(value) + if err != nil && !option.ContinueOnError { + return nil, err + } + return []uint{ui}, err + } + case []uint16: + array = make([]uint, len(value)) + for k, v := range value { + array[k] = uint(v) + } + case []uint32: + array = make([]uint, len(value)) + for k, v := range value { + array[k] = uint(v) + } + case []uint64: + array = make([]uint, len(value)) + for k, v := range value { + array[k] = uint(v) + } + case []bool: + array = make([]uint, len(value)) + for k, v := range value { + if v { + array[k] = 1 + } else { + array[k] = 0 + } + } + case []float32: + array = make([]uint, len(value)) + for k, v := range value { + ui, err = c.Uint(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ui + } + case []float64: + array = make([]uint, len(value)) + for k, v := range value { + ui, err = c.Uint(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ui + } + case []interface{}: + array = make([]uint, len(value)) + for k, v := range value { + ui, err = c.Uint(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ui + } + case [][]byte: + array = make([]uint, len(value)) + for k, v := range value { + ui, err = c.Uint(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ui + } + } + + if array != nil { + return array, err + } + + // Default handler. + if v, ok := any.(localinterface.IUints); ok { + return v.Uints(), err + } + if v, ok := any.(localinterface.IInterfaces); ok { + return c.SliceUint(v.Interfaces(), option) + } + // Not a common type, it then uses reflection for conversion. + originValueAndKind := reflection.OriginValueAndKind(any) + switch originValueAndKind.OriginKind { + case reflect.Slice, reflect.Array: + var ( + length = originValueAndKind.OriginValue.Len() + slice = make([]uint, length) + ) + for i := 0; i < length; i++ { + ui, err = c.Uint(originValueAndKind.OriginValue.Index(i).Interface()) + if err != nil && !option.ContinueOnError { + return nil, err + } + slice[i] = ui + } + return slice, err + + default: + if originValueAndKind.OriginValue.IsZero() { + return []uint{}, err + } + ui, err = c.Uint(any) + if err != nil && !option.ContinueOnError { + return nil, err + } + return []uint{ui}, err + } +} + +// SliceUint32 converts `any` to []uint32. +func (c *Converter) SliceUint32(any interface{}, option SliceOption) ([]uint32, error) { + if empty.IsNil(any) { + return nil, nil + } + var ( + err error + ui uint32 + array []uint32 = nil + ) + switch value := any.(type) { + case []string: + array = make([]uint32, len(value)) + for k, v := range value { + ui, err = c.Uint32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ui + } + case []int8: + array = make([]uint32, len(value)) + for k, v := range value { + array[k] = uint32(v) + } + case []int16: + array = make([]uint32, len(value)) + for k, v := range value { + array[k] = uint32(v) + } + case []int32: + array = make([]uint32, len(value)) + for k, v := range value { + array[k] = uint32(v) + } + case []int64: + array = make([]uint32, len(value)) + for k, v := range value { + array[k] = uint32(v) + } + case []uint: + array = make([]uint32, len(value)) + for k, v := range value { + array[k] = uint32(v) + } + case []uint8: + if json.Valid(value) { + if err = json.UnmarshalUseNumber(value, &array); array != nil { + return array, err + } + } + array = make([]uint32, len(value)) + for k, v := range value { + array[k] = uint32(v) + } + case string: + byteValue := []byte(value) + if json.Valid(byteValue) { + if err = json.UnmarshalUseNumber(byteValue, &array); array != nil { + return array, err + } + } + if value == "" { + return []uint32{}, err + } + if utils.IsNumeric(value) { + ui, err = c.Uint32(value) + if err != nil && !option.ContinueOnError { + return nil, err + } + return []uint32{ui}, err + } + case []uint16: + array = make([]uint32, len(value)) + for k, v := range value { + array[k] = uint32(v) + } + case []uint32: + array = value + case []uint64: + array = make([]uint32, len(value)) + for k, v := range value { + array[k] = uint32(v) + } + case []bool: + array = make([]uint32, len(value)) + for k, v := range value { + if v { + array[k] = 1 + } else { + array[k] = 0 + } + } + case []float32: + array = make([]uint32, len(value)) + for k, v := range value { + ui, err = c.Uint32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ui + } + case []float64: + array = make([]uint32, len(value)) + for k, v := range value { + ui, err = c.Uint32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ui + } + case []interface{}: + array = make([]uint32, len(value)) + for k, v := range value { + ui, err = c.Uint32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ui + } + case [][]byte: + array = make([]uint32, len(value)) + for k, v := range value { + ui, err = c.Uint32(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ui + } + } + if array != nil { + return array, err + } + + // Default handler. + if v, ok := any.(localinterface.IUints); ok { + return c.SliceUint32(v.Uints(), option) + } + if v, ok := any.(localinterface.IInterfaces); ok { + return c.SliceUint32(v.Interfaces(), option) + } + // Not a common type, it then uses reflection for conversion. + originValueAndKind := reflection.OriginValueAndKind(any) + switch originValueAndKind.OriginKind { + case reflect.Slice, reflect.Array: + var ( + length = originValueAndKind.OriginValue.Len() + slice = make([]uint32, length) + ) + for i := 0; i < length; i++ { + ui, err = c.Uint32(originValueAndKind.OriginValue.Index(i).Interface()) + if err != nil && !option.ContinueOnError { + return nil, err + } + slice[i] = ui + } + return slice, err + + default: + if originValueAndKind.OriginValue.IsZero() { + return []uint32{}, err + } + ui, err = c.Uint32(any) + if err != nil && !option.ContinueOnError { + return nil, err + } + return []uint32{ui}, err + } +} + +// SliceUint64 converts `any` to []uint64. +func (c *Converter) SliceUint64(any interface{}, option SliceOption) ([]uint64, error) { + if empty.IsNil(any) { + return nil, nil + } + var ( + err error + ui uint64 + array []uint64 = nil + ) + switch value := any.(type) { + case []string: + array = make([]uint64, len(value)) + for k, v := range value { + ui, err = c.Uint64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ui + } + case []int8: + array = make([]uint64, len(value)) + for k, v := range value { + array[k] = uint64(v) + } + case []int16: + array = make([]uint64, len(value)) + for k, v := range value { + array[k] = uint64(v) + } + case []int32: + array = make([]uint64, len(value)) + for k, v := range value { + array[k] = uint64(v) + } + case []int64: + array = make([]uint64, len(value)) + for k, v := range value { + array[k] = uint64(v) + } + case []uint: + array = make([]uint64, len(value)) + for k, v := range value { + array[k] = uint64(v) + } + case []uint8: + if json.Valid(value) { + if err = json.UnmarshalUseNumber(value, &array); array != nil { + return array, err + } + } + array = make([]uint64, len(value)) + for k, v := range value { + array[k] = uint64(v) + } + case string: + byteValue := []byte(value) + if json.Valid(byteValue) { + if err = json.UnmarshalUseNumber(byteValue, &array); array != nil { + return array, err + } + } + if value == "" { + return []uint64{}, err + } + if utils.IsNumeric(value) { + ui, err = c.Uint64(value) + if err != nil && !option.ContinueOnError { + return nil, err + } + return []uint64{ui}, err + } + case []uint16: + array = make([]uint64, len(value)) + for k, v := range value { + array[k] = uint64(v) + } + case []uint32: + array = make([]uint64, len(value)) + for k, v := range value { + array[k] = uint64(v) + } + case []uint64: + array = value + case []bool: + array = make([]uint64, len(value)) + for k, v := range value { + if v { + array[k] = 1 + } else { + array[k] = 0 + } + } + case []float32: + array = make([]uint64, len(value)) + for k, v := range value { + ui, err = c.Uint64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ui + } + case []float64: + array = make([]uint64, len(value)) + for k, v := range value { + ui, err = c.Uint64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ui + } + case []interface{}: + array = make([]uint64, len(value)) + for k, v := range value { + ui, err = c.Uint64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ui + } + case [][]byte: + array = make([]uint64, len(value)) + for k, v := range value { + ui, err = c.Uint64(v) + if err != nil && !option.ContinueOnError { + return nil, err + } + array[k] = ui + } + } + if array != nil { + return array, err + } + // Default handler. + if v, ok := any.(localinterface.IUints); ok { + return c.SliceUint64(v.Uints(), option) + } + if v, ok := any.(localinterface.IInterfaces); ok { + return c.SliceUint64(v.Interfaces(), option) + } + // Not a common type, it then uses reflection for conversion. + originValueAndKind := reflection.OriginValueAndKind(any) + switch originValueAndKind.OriginKind { + case reflect.Slice, reflect.Array: + var ( + length = originValueAndKind.OriginValue.Len() + slice = make([]uint64, length) + ) + for i := 0; i < length; i++ { + ui, err = c.Uint64(originValueAndKind.OriginValue.Index(i).Interface()) + if err != nil && !option.ContinueOnError { + return nil, err + } + slice[i] = ui + } + return slice, err + + default: + if originValueAndKind.OriginValue.IsZero() { + return []uint64{}, err + } + ui, err = c.Uint64(any) + if err != nil && !option.ContinueOnError { + return nil, err + } + return []uint64{ui}, err + } +} diff --git a/util/gconv/internal/converter/converter_string.go b/util/gconv/internal/converter/converter_string.go new file mode 100644 index 00000000000..cd9434faaf6 --- /dev/null +++ b/util/gconv/internal/converter/converter_string.go @@ -0,0 +1,135 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "fmt" + "reflect" + "strconv" + "time" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/util/gconv/internal/localinterface" +) + +func (c *Converter) String(any any) (string, error) { + if empty.IsNil(any) { + return "", nil + } + switch value := any.(type) { + case int: + return strconv.Itoa(value), nil + case int8: + return strconv.Itoa(int(value)), nil + case int16: + return strconv.Itoa(int(value)), nil + case int32: + return strconv.Itoa(int(value)), nil + case int64: + return strconv.FormatInt(value, 10), nil + case uint: + return strconv.FormatUint(uint64(value), 10), nil + case uint8: + return strconv.FormatUint(uint64(value), 10), nil + case uint16: + return strconv.FormatUint(uint64(value), 10), nil + case uint32: + return strconv.FormatUint(uint64(value), 10), nil + case uint64: + return strconv.FormatUint(value, 10), nil + case float32: + return strconv.FormatFloat(float64(value), 'f', -1, 32), nil + case float64: + return strconv.FormatFloat(value, 'f', -1, 64), nil + case bool: + return strconv.FormatBool(value), nil + case string: + return value, nil + case []byte: + return string(value), nil + case complex64, complex128: + return fmt.Sprintf("%v", value), nil + case time.Time: + if value.IsZero() { + return "", nil + } + return value.String(), nil + case *time.Time: + if value == nil { + return "", nil + } + return value.String(), nil + case gtime.Time: + if value.IsZero() { + return "", nil + } + return value.String(), nil + case *gtime.Time: + if value == nil { + return "", nil + } + return value.String(), nil + default: + if f, ok := value.(localinterface.IString); ok { + // If the variable implements the String() interface, + // then use that interface to perform the conversion + return f.String(), nil + } + if f, ok := value.(localinterface.IError); ok { + // If the variable implements the Error() interface, + // then use that interface to perform the conversion + return f.Error(), nil + } + // Reflect checks. + var ( + rv = reflect.ValueOf(value) + kind = rv.Kind() + ) + switch kind { + case + reflect.Chan, + reflect.Map, + reflect.Slice, + reflect.Func, + reflect.Interface, + reflect.UnsafePointer: + if rv.IsNil() { + return "", nil + } + case reflect.String: + return rv.String(), nil + case reflect.Ptr: + if rv.IsNil() { + return "", nil + } + return c.String(rv.Elem().Interface()) + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + return strconv.FormatInt(rv.Int(), 10), nil + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return strconv.FormatUint(rv.Uint(), 10), nil + case reflect.Uintptr: + return strconv.FormatUint(rv.Uint(), 10), nil + case reflect.Float32, reflect.Float64: + return strconv.FormatFloat(rv.Float(), 'f', -1, 64), nil + case reflect.Bool: + return strconv.FormatBool(rv.Bool()), nil + default: + } + // Finally, we use json.Marshal to convert. + jsonContent, err := json.Marshal(value) + if err != nil { + return fmt.Sprint(value), gerror.WrapCodef( + gcode.CodeInvalidParameter, err, "error marshaling value to JSON for: %v", value, + ) + } + return string(jsonContent), nil + } +} diff --git a/util/gconv/internal/converter/converter_struct.go b/util/gconv/internal/converter/converter_struct.go new file mode 100644 index 00000000000..6bf8c6913d1 --- /dev/null +++ b/util/gconv/internal/converter/converter_struct.go @@ -0,0 +1,662 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "reflect" + "strings" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/internal/utils" + "github.com/gogf/gf/v2/util/gconv/internal/localinterface" + "github.com/gogf/gf/v2/util/gconv/internal/structcache" +) + +// StructOption is the option for Struct converting. +type StructOption struct { + // ParamKeyToAttrMap is the map for custom parameter key to attribute name mapping. + ParamKeyToAttrMap map[string]string + + // PriorityTag is the priority tag for struct converting. + PriorityTag string + + // ContinueOnError specifies whether to continue converting the next element + // if one element converting fails. + ContinueOnError bool +} + +// Struct is the core internal converting function for any data to struct. +func (c *Converter) Struct(params, pointer any, option StructOption) (err error) { + if params == nil { + // If `params` is nil, no conversion. + return nil + } + if pointer == nil { + return gerror.NewCode(gcode.CodeInvalidParameter, "object pointer cannot be nil") + } + + // JSON content converting. + ok, err := c.doConvertWithJsonCheck(params, pointer) + if err != nil { + return err + } + if ok { + return nil + } + + defer func() { + // Catch the panic, especially the reflection operation panics. + if exception := recover(); exception != nil { + if v, ok := exception.(error); ok && gerror.HasStack(v) { + err = v + } else { + err = gerror.NewCodeSkipf(gcode.CodeInternalPanic, 1, "%+v", exception) + } + } + }() + + var ( + paramsReflectValue reflect.Value + paramsInterface any // DO NOT use `params` directly as it might be type `reflect.Value` + pointerReflectValue reflect.Value + pointerReflectKind reflect.Kind + pointerElemReflectValue reflect.Value // The reflection value to struct element. + ) + if v, ok := params.(reflect.Value); ok { + paramsReflectValue = v + } else { + paramsReflectValue = reflect.ValueOf(params) + } + paramsInterface = paramsReflectValue.Interface() + if v, ok := pointer.(reflect.Value); ok { + pointerReflectValue = v + pointerElemReflectValue = v + } else { + pointerReflectValue = reflect.ValueOf(pointer) + pointerReflectKind = pointerReflectValue.Kind() + if pointerReflectKind != reflect.Ptr { + return gerror.NewCodef( + gcode.CodeInvalidParameter, + "destination pointer should be type of '*struct', but got '%v'", + pointerReflectKind, + ) + } + // Using IsNil on reflect.Ptr variable is OK. + if !pointerReflectValue.IsValid() || pointerReflectValue.IsNil() { + return gerror.NewCode( + gcode.CodeInvalidParameter, + "destination pointer cannot be nil", + ) + } + pointerElemReflectValue = pointerReflectValue.Elem() + } + + // If `params` and `pointer` are the same type, the do directly assignment. + // For performance enhancement purpose. + if ok = c.doConvertWithTypeCheck(paramsReflectValue, pointerElemReflectValue); ok { + return nil + } + + // custom convert. + if ok, err = c.callCustomConverter(paramsReflectValue, pointerReflectValue); ok { + return err + } + + // Normal unmarshalling interfaces checks. + if ok, err = bindVarToReflectValueWithInterfaceCheck(pointerReflectValue, paramsInterface); ok { + return err + } + + // It automatically creates struct object if necessary. + // For example, if `pointer` is **User, then `elem` is *User, which is a pointer to User. + if pointerElemReflectValue.Kind() == reflect.Ptr { + if !pointerElemReflectValue.IsValid() || pointerElemReflectValue.IsNil() { + e := reflect.New(pointerElemReflectValue.Type().Elem()) + pointerElemReflectValue.Set(e) + defer func() { + if err != nil { + // If it is converted failed, it reset the `pointer` to nil. + pointerReflectValue.Elem().Set(reflect.Zero(pointerReflectValue.Type().Elem())) + } + }() + } + // if v, ok := pointerElemReflectValue.Interface().(localinterface.IUnmarshalValue); ok { + // return v.UnmarshalValue(params) + // } + // Note that it's `pointerElemReflectValue` here not `pointerReflectValue`. + if ok, err = bindVarToReflectValueWithInterfaceCheck(pointerElemReflectValue, paramsInterface); ok { + return err + } + // Retrieve its element, may be struct at last. + pointerElemReflectValue = pointerElemReflectValue.Elem() + } + paramsMap, ok := paramsInterface.(map[string]any) + if !ok { + // paramsMap is the map[string]any type variable for params. + // DO NOT use MapDeep here. + paramsMap, err = c.doMapConvert(paramsInterface, RecursiveTypeAuto, true, MapOption{ + ContinueOnError: option.ContinueOnError, + }) + if err != nil { + return err + } + if paramsMap == nil { + return gerror.NewCodef( + gcode.CodeInvalidParameter, + `convert params from "%#v" to "map[string]any" failed`, + params, + ) + } + } + // Nothing to be done as the parameters are empty. + if len(paramsMap) == 0 { + return nil + } + // Get struct info from cache or parse struct and cache the struct info. + cachedStructInfo := c.internalConverter.GetCachedStructInfo( + pointerElemReflectValue.Type(), option.PriorityTag, + ) + // Nothing to be converted. + if cachedStructInfo == nil { + return nil + } + // For the structure types of 0 tagOrFiledNameToFieldInfoMap, + // they also need to be cached to prevent invalid logic + if cachedStructInfo.HasNoFields() { + return nil + } + var ( + // Indicates that those values have been used and cannot be reused. + usedParamsKeyOrTagNameMap = structcache.GetUsedParamsKeyOrTagNameMapFromPool() + cachedFieldInfo *structcache.CachedFieldInfo + paramsValue any + ) + defer structcache.PutUsedParamsKeyOrTagNameMapToPool(usedParamsKeyOrTagNameMap) + + // Firstly, search according to custom mapping rules. + // If a possible direct assignment is found, reduce the number of subsequent map searches. + for paramKey, fieldName := range option.ParamKeyToAttrMap { + paramsValue, ok = paramsMap[paramKey] + if !ok { + continue + } + cachedFieldInfo = cachedStructInfo.GetFieldInfo(fieldName) + if cachedFieldInfo != nil { + fieldValue := cachedFieldInfo.GetFieldReflectValueFrom(pointerElemReflectValue) + if err = c.bindVarToStructField( + cachedFieldInfo, + fieldValue, + paramsValue, + option, + ); err != nil { + return err + } + if len(cachedFieldInfo.OtherSameNameField) > 0 { + if err = c.setOtherSameNameField( + cachedFieldInfo, paramsValue, pointerReflectValue, option, + ); err != nil { + return err + } + } + usedParamsKeyOrTagNameMap[paramKey] = struct{}{} + } + } + // Already done converting for given `paramsMap`. + if len(usedParamsKeyOrTagNameMap) == len(paramsMap) { + return nil + } + return c.bindStructWithLoopFieldInfos( + paramsMap, pointerElemReflectValue, + usedParamsKeyOrTagNameMap, cachedStructInfo, + option, + ) +} + +func (c *Converter) setOtherSameNameField( + cachedFieldInfo *structcache.CachedFieldInfo, + srcValue any, + structValue reflect.Value, + option StructOption, +) (err error) { + // loop the same field name of all sub attributes. + for _, otherFieldInfo := range cachedFieldInfo.OtherSameNameField { + fieldValue := cachedFieldInfo.GetOtherFieldReflectValueFrom(structValue, otherFieldInfo.FieldIndexes) + if err = c.bindVarToStructField(otherFieldInfo, fieldValue, srcValue, option); err != nil { + return err + } + } + return nil +} + +func (c *Converter) bindStructWithLoopFieldInfos( + paramsMap map[string]any, + structValue reflect.Value, + usedParamsKeyOrTagNameMap map[string]struct{}, + cachedStructInfo *structcache.CachedStructInfo, + option StructOption, +) (err error) { + var ( + cachedFieldInfo *structcache.CachedFieldInfo + fuzzLastKey string + fieldValue reflect.Value + paramKey string + paramValue any + matched bool + ok bool + ) + for _, cachedFieldInfo = range cachedStructInfo.GetFieldConvertInfos() { + for _, fieldTag := range cachedFieldInfo.PriorityTagAndFieldName { + if paramValue, ok = paramsMap[fieldTag]; !ok { + continue + } + fieldValue = cachedFieldInfo.GetFieldReflectValueFrom(structValue) + if err = c.bindVarToStructField( + cachedFieldInfo, fieldValue, paramValue, option, + ); err != nil && !option.ContinueOnError { + return err + } + // handle same field name in nested struct. + if len(cachedFieldInfo.OtherSameNameField) > 0 { + if err = c.setOtherSameNameField( + cachedFieldInfo, paramValue, structValue, option, + ); err != nil && !option.ContinueOnError { + return err + } + } + usedParamsKeyOrTagNameMap[fieldTag] = struct{}{} + matched = true + break + } + if matched { + matched = false + continue + } + + fuzzLastKey = cachedFieldInfo.LastFuzzyKey.Load().(string) + if paramValue, ok = paramsMap[fuzzLastKey]; !ok { + paramKey, paramValue = fuzzyMatchingFieldName( + cachedFieldInfo.RemoveSymbolsFieldName, paramsMap, usedParamsKeyOrTagNameMap, + ) + ok = paramKey != "" + cachedFieldInfo.LastFuzzyKey.Store(paramKey) + } + if ok { + fieldValue = cachedFieldInfo.GetFieldReflectValueFrom(structValue) + if paramValue != nil { + if err = c.bindVarToStructField( + cachedFieldInfo, fieldValue, paramValue, option, + ); err != nil && !option.ContinueOnError { + return err + } + // handle same field name in nested struct. + if len(cachedFieldInfo.OtherSameNameField) > 0 { + if err = c.setOtherSameNameField( + cachedFieldInfo, paramValue, structValue, option, + ); err != nil && !option.ContinueOnError { + return err + } + } + } + usedParamsKeyOrTagNameMap[paramKey] = struct{}{} + } + } + return nil +} + +// fuzzy matching rule: +// to match field name and param key in case-insensitive and without symbols. +func fuzzyMatchingFieldName( + fieldName string, + paramsMap map[string]any, + usedParamsKeyMap map[string]struct{}, +) (string, any) { + for paramKey, paramValue := range paramsMap { + if _, ok := usedParamsKeyMap[paramKey]; ok { + continue + } + removeParamKeyUnderline := utils.RemoveSymbols(paramKey) + if strings.EqualFold(fieldName, removeParamKeyUnderline) { + return paramKey, paramValue + } + } + return "", nil +} + +// bindVarToStructField sets value to struct object attribute by name. +// each value to attribute converting comes into in this function. +func (c *Converter) bindVarToStructField( + cachedFieldInfo *structcache.CachedFieldInfo, + fieldValue reflect.Value, + srcValue any, + option StructOption, +) (err error) { + if !fieldValue.IsValid() { + return nil + } + // CanSet checks whether attribute is public accessible. + if !fieldValue.CanSet() { + return nil + } + defer func() { + if exception := recover(); exception != nil { + if err = c.bindVarToReflectValue(fieldValue, srcValue, option); err != nil { + err = gerror.Wrapf(err, `error binding srcValue to attribute "%s"`, cachedFieldInfo.FieldName()) + } + } + }() + // Directly converting. + if empty.IsNil(srcValue) { + fieldValue.Set(reflect.Zero(fieldValue.Type())) + return nil + } + // Try to call custom converter. + // Issue: https://github.com/gogf/gf/issues/3099 + var ( + customConverterInput reflect.Value + ok bool + ) + if cachedFieldInfo.HasCustomConvert { + if customConverterInput, ok = srcValue.(reflect.Value); !ok { + customConverterInput = reflect.ValueOf(srcValue) + } + if ok, err = c.callCustomConverter(customConverterInput, fieldValue); ok || err != nil { + return + } + } + if cachedFieldInfo.IsCommonInterface { + if ok, err = bindVarToReflectValueWithInterfaceCheck(fieldValue, srcValue); ok || err != nil { + return + } + } + // Common types use fast assignment logic + if cachedFieldInfo.ConvertFunc != nil { + return cachedFieldInfo.ConvertFunc(srcValue, fieldValue) + } + convertOption := ConvertOption{ + StructOption: option, + SliceOption: SliceOption{ContinueOnError: option.ContinueOnError}, + MapOption: MapOption{ContinueOnError: option.ContinueOnError}, + } + err = c.doConvertWithReflectValueSet( + fieldValue, doConvertInput{ + FromValue: srcValue, + ToTypeName: cachedFieldInfo.StructField.Type.String(), + ReferValue: fieldValue, + }, + convertOption, + ) + return err +} + +// bindVarToReflectValueWithInterfaceCheck does bind using common interfaces checks. +func bindVarToReflectValueWithInterfaceCheck(reflectValue reflect.Value, value any) (bool, error) { + var pointer any + if reflectValue.Kind() != reflect.Ptr && reflectValue.CanAddr() { + reflectValueAddr := reflectValue.Addr() + if reflectValueAddr.IsNil() || !reflectValueAddr.IsValid() { + return false, nil + } + // Not a pointer, but can token address, that makes it can be unmarshalled. + pointer = reflectValue.Addr().Interface() + } else { + if reflectValue.IsNil() || !reflectValue.IsValid() { + return false, nil + } + pointer = reflectValue.Interface() + } + // UnmarshalValue. + if v, ok := pointer.(localinterface.IUnmarshalValue); ok { + return ok, v.UnmarshalValue(value) + } + // UnmarshalText. + if v, ok := pointer.(localinterface.IUnmarshalText); ok { + var valueBytes []byte + if b, ok := value.([]byte); ok { + valueBytes = b + } else if s, ok := value.(string); ok { + valueBytes = []byte(s) + } else if f, ok := value.(localinterface.IString); ok { + valueBytes = []byte(f.String()) + } + if len(valueBytes) > 0 { + return ok, v.UnmarshalText(valueBytes) + } + } + // UnmarshalJSON. + if v, ok := pointer.(localinterface.IUnmarshalJSON); ok { + var valueBytes []byte + if b, ok := value.([]byte); ok { + valueBytes = b + } else if s, ok := value.(string); ok { + valueBytes = []byte(s) + } else if f, ok := value.(localinterface.IString); ok { + valueBytes = []byte(f.String()) + } + + if len(valueBytes) > 0 { + // If it is not a valid JSON string, it then adds char `"` on its both sides to make it is. + if !json.Valid(valueBytes) { + newValueBytes := make([]byte, len(valueBytes)+2) + newValueBytes[0] = '"' + newValueBytes[len(newValueBytes)-1] = '"' + copy(newValueBytes[1:], valueBytes) + valueBytes = newValueBytes + } + return ok, v.UnmarshalJSON(valueBytes) + } + } + if v, ok := pointer.(localinterface.ISet); ok { + v.Set(value) + return ok, nil + } + return false, nil +} + +// bindVarToReflectValue sets `value` to reflect value object `structFieldValue`. +func (c *Converter) bindVarToReflectValue(structFieldValue reflect.Value, value any, option StructOption) (err error) { + // JSON content converting. + ok, err := c.doConvertWithJsonCheck(value, structFieldValue) + if err != nil { + return err + } + if ok { + return nil + } + + kind := structFieldValue.Kind() + // Converting using `Set` interface implements, for some types. + switch kind { + case reflect.Slice, reflect.Array, reflect.Ptr, reflect.Interface: + if !structFieldValue.IsNil() { + if v, ok := structFieldValue.Interface().(localinterface.ISet); ok { + v.Set(value) + return nil + } + } + default: + } + + // Converting using reflection by kind. + switch kind { + case reflect.Map: + return c.MapToMap(value, structFieldValue, option.ParamKeyToAttrMap, MapOption{ + ContinueOnError: option.ContinueOnError, + }) + + case reflect.Struct: + // Recursively converting for struct attribute. + if err = c.Struct(value, structFieldValue, option); err != nil { + // Note there's reflect conversion mechanism here. + structFieldValue.Set(reflect.ValueOf(value).Convert(structFieldValue.Type())) + } + + // Note that the slice element might be type of struct, + // so it uses Struct function doing the converting internally. + case reflect.Slice, reflect.Array: + var ( + reflectArray reflect.Value + reflectValue = reflect.ValueOf(value) + convertOption = ConvertOption{ + StructOption: option, + SliceOption: SliceOption{ContinueOnError: option.ContinueOnError}, + MapOption: MapOption{ContinueOnError: option.ContinueOnError}, + } + ) + if reflectValue.Kind() == reflect.Slice || reflectValue.Kind() == reflect.Array { + reflectArray = reflect.MakeSlice(structFieldValue.Type(), reflectValue.Len(), reflectValue.Len()) + if reflectValue.Len() > 0 { + var ( + elemType = reflectArray.Index(0).Type() + elemTypeName string + converted bool + ) + for i := 0; i < reflectValue.Len(); i++ { + converted = false + elemTypeName = elemType.Name() + if elemTypeName == "" { + elemTypeName = elemType.String() + } + var elem reflect.Value + if elemType.Kind() == reflect.Ptr { + elem = reflect.New(elemType.Elem()).Elem() + } else { + elem = reflect.New(elemType).Elem() + } + if elem.Kind() == reflect.Struct { + if err = c.Struct(reflectValue.Index(i).Interface(), elem, option); err == nil { + converted = true + } + } + if !converted { + err = c.doConvertWithReflectValueSet( + elem, doConvertInput{ + FromValue: reflectValue.Index(i).Interface(), + ToTypeName: elemTypeName, + ReferValue: elem, + }, + convertOption, + ) + if err != nil { + return err + } + } + if elemType.Kind() == reflect.Ptr { + // Before it sets the `elem` to array, do pointer converting if necessary. + elem = elem.Addr() + } + reflectArray.Index(i).Set(elem) + } + } + } else { + var ( + elem reflect.Value + elemType = structFieldValue.Type().Elem() + elemTypeName = elemType.Name() + converted bool + ) + switch reflectValue.Kind() { + case reflect.String: + // Value is empty string. + if reflectValue.IsZero() { + var elemKind = elemType.Kind() + // Try to find the original type kind of the slice element. + if elemKind == reflect.Ptr { + elemKind = elemType.Elem().Kind() + } + switch elemKind { + case reflect.String: + // Empty string cannot be assigned to string slice. + return nil + default: + } + } + default: + } + if elemTypeName == "" { + elemTypeName = elemType.String() + } + if elemType.Kind() == reflect.Ptr { + elem = reflect.New(elemType.Elem()).Elem() + } else { + elem = reflect.New(elemType).Elem() + } + if elem.Kind() == reflect.Struct { + if err = c.Struct(value, elem, option); err == nil { + converted = true + } + } + if !converted { + err = c.doConvertWithReflectValueSet( + elem, doConvertInput{ + FromValue: value, + ToTypeName: elemTypeName, + ReferValue: elem, + }, + convertOption, + ) + if err != nil { + return err + } + } + if elemType.Kind() == reflect.Ptr { + // Before it sets the `elem` to array, do pointer converting if necessary. + elem = elem.Addr() + } + reflectArray = reflect.MakeSlice(structFieldValue.Type(), 1, 1) + reflectArray.Index(0).Set(elem) + } + structFieldValue.Set(reflectArray) + + case reflect.Ptr: + if structFieldValue.IsNil() || structFieldValue.IsZero() { + // Nil or empty pointer, it creates a new one. + item := reflect.New(structFieldValue.Type().Elem()) + if ok, err = bindVarToReflectValueWithInterfaceCheck(item, value); ok { + structFieldValue.Set(item) + return err + } + elem := item.Elem() + if err = c.bindVarToReflectValue(elem, value, option); err == nil { + structFieldValue.Set(elem.Addr()) + } + } else { + // Not empty pointer, it assigns values to it. + return c.bindVarToReflectValue(structFieldValue.Elem(), value, option) + } + + // It mainly and specially handles the interface of nil value. + case reflect.Interface: + if value == nil { + // Specially. + structFieldValue.Set(reflect.ValueOf((*any)(nil))) + } else { + // Note there's reflect conversion mechanism here. + structFieldValue.Set(reflect.ValueOf(value).Convert(structFieldValue.Type())) + } + + default: + defer func() { + if exception := recover(); exception != nil { + err = gerror.NewCodef( + gcode.CodeInternalPanic, + `cannot convert value "%+v" to type "%s":%+v`, + value, + structFieldValue.Type().String(), + exception, + ) + } + }() + // It here uses reflect converting `value` to type of the attribute and assigns + // the result value to the attribute. It might fail and panic if the usual Go + // conversion rules do not allow conversion. + structFieldValue.Set(reflect.ValueOf(value).Convert(structFieldValue.Type())) + } + return nil +} diff --git a/util/gconv/internal/converter/converter_structs.go b/util/gconv/internal/converter/converter_structs.go new file mode 100644 index 00000000000..d2eeec733fb --- /dev/null +++ b/util/gconv/internal/converter/converter_structs.go @@ -0,0 +1,120 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "reflect" + + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" +) + +// Structs converts any slice to given struct slice. +// +// It automatically checks and converts json string to []map if `params` is string/[]byte. +// +// The parameter `pointer` should be type of pointer to slice of struct. +// Note that if `pointer` is a pointer to another pointer of type of slice of struct, +// it will create the struct/pointer internally. +func (c *Converter) Structs( + params any, pointer any, sliceOption SliceOption, structOption StructOption, +) (err error) { + defer func() { + // Catch the panic, especially the reflection operation panics. + if exception := recover(); exception != nil { + if v, ok := exception.(error); ok && gerror.HasStack(v) { + err = v + } else { + err = gerror.NewCodeSkipf(gcode.CodeInternalPanic, 1, "%+v", exception) + } + } + }() + + // Pointer type check. + pointerRv, ok := pointer.(reflect.Value) + if !ok { + pointerRv = reflect.ValueOf(pointer) + if kind := pointerRv.Kind(); kind != reflect.Ptr { + return gerror.NewCodef( + gcode.CodeInvalidParameter, + "pointer should be type of pointer, but got: %v", kind, + ) + } + } + // Converting `params` to map slice. + var ( + paramsList []any + paramsRv = reflect.ValueOf(params) + paramsKind = paramsRv.Kind() + ) + for paramsKind == reflect.Ptr { + paramsRv = paramsRv.Elem() + paramsKind = paramsRv.Kind() + } + switch paramsKind { + case reflect.Slice, reflect.Array: + paramsList = make([]any, paramsRv.Len()) + for i := 0; i < paramsRv.Len(); i++ { + paramsList[i] = paramsRv.Index(i).Interface() + } + default: + paramsMaps, err := c.SliceMap(params, sliceOption, MapOption{ + ContinueOnError: structOption.ContinueOnError, + }) + if err != nil { + return err + } + paramsList = make([]any, len(paramsMaps)) + for i := 0; i < len(paramsMaps); i++ { + paramsList[i] = paramsMaps[i] + } + } + // If `params` is an empty slice, no conversion. + if len(paramsList) == 0 { + return nil + } + var ( + reflectElemArray = reflect.MakeSlice(pointerRv.Type().Elem(), len(paramsList), len(paramsList)) + itemType = reflectElemArray.Index(0).Type() + itemTypeKind = itemType.Kind() + pointerRvElem = pointerRv.Elem() + pointerRvLength = pointerRvElem.Len() + ) + if itemTypeKind == reflect.Ptr { + // Pointer element. + for i := 0; i < len(paramsList); i++ { + var tempReflectValue reflect.Value + if i < pointerRvLength { + // Might be nil. + tempReflectValue = pointerRvElem.Index(i).Elem() + } + if !tempReflectValue.IsValid() { + tempReflectValue = reflect.New(itemType.Elem()).Elem() + } + if err = c.Struct(paramsList[i], tempReflectValue, structOption); err != nil { + return err + } + reflectElemArray.Index(i).Set(tempReflectValue.Addr()) + } + } else { + // Struct element. + for i := 0; i < len(paramsList); i++ { + var tempReflectValue reflect.Value + if i < pointerRvLength { + tempReflectValue = pointerRvElem.Index(i) + } else { + tempReflectValue = reflect.New(itemType).Elem() + } + if err = c.Struct(paramsList[i], tempReflectValue, structOption); err != nil { + return err + } + reflectElemArray.Index(i).Set(tempReflectValue) + } + } + pointerRv.Elem().Set(reflectElemArray) + return nil +} diff --git a/util/gconv/internal/converter/converter_time.go b/util/gconv/internal/converter/converter_time.go new file mode 100644 index 00000000000..05eae209faa --- /dev/null +++ b/util/gconv/internal/converter/converter_time.go @@ -0,0 +1,111 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "time" + + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/internal/utils" + "github.com/gogf/gf/v2/os/gtime" + "github.com/gogf/gf/v2/util/gconv/internal/localinterface" +) + +// Time converts `any` to time.Time. +func (c *Converter) Time(any interface{}, format ...string) (time.Time, error) { + // It's already this type. + if len(format) == 0 { + if v, ok := any.(time.Time); ok { + return v, nil + } + } + t, err := c.GTime(any, format...) + if err != nil { + return time.Time{}, err + } + if t != nil { + return t.Time, nil + } + return time.Time{}, nil +} + +// Duration converts `any` to time.Duration. +// If `any` is string, then it uses time.ParseDuration to convert it. +// If `any` is numeric, then it converts `any` as nanoseconds. +func (c *Converter) Duration(any interface{}) (time.Duration, error) { + // It's already this type. + if v, ok := any.(time.Duration); ok { + return v, nil + } + s, err := c.String(any) + if err != nil { + return 0, err + } + if !utils.IsNumeric(s) { + return gtime.ParseDuration(s) + } + i, err := c.Int64(any) + if err != nil { + return 0, err + } + return time.Duration(i), nil +} + +// GTime converts `any` to *gtime.Time. +// The parameter `format` can be used to specify the format of `any`. +// It returns the converted value that matched the first format of the formats slice. +// If no `format` given, it converts `any` using gtime.NewFromTimeStamp if `any` is numeric, +// or using gtime.StrToTime if `any` is string. +func (c *Converter) GTime(any interface{}, format ...string) (*gtime.Time, error) { + if empty.IsNil(any) { + return nil, nil + } + if v, ok := any.(localinterface.IGTime); ok { + return v.GTime(format...), nil + } + // It's already this type. + if len(format) == 0 { + if v, ok := any.(*gtime.Time); ok { + return v, nil + } + if t, ok := any.(time.Time); ok { + return gtime.New(t), nil + } + if t, ok := any.(*time.Time); ok { + return gtime.New(t), nil + } + } + s, err := c.String(any) + if err != nil { + return nil, err + } + if len(s) == 0 { + return gtime.New(), nil + } + // Priority conversion using given format. + if len(format) > 0 { + for _, item := range format { + t, err := gtime.StrToTimeFormat(s, item) + if err != nil { + return nil, err + } + if t != nil { + return t, nil + } + } + return nil, nil + } + if utils.IsNumeric(s) { + i, err := c.Int64(s) + if err != nil { + return nil, err + } + return gtime.NewFromTimeStamp(i), nil + } else { + return gtime.StrToTime(s) + } +} diff --git a/util/gconv/internal/converter/converter_uint.go b/util/gconv/internal/converter/converter_uint.go new file mode 100644 index 00000000000..2055b0c0cb2 --- /dev/null +++ b/util/gconv/internal/converter/converter_uint.go @@ -0,0 +1,161 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package converter + +import ( + "math" + "reflect" + "strconv" + + "github.com/gogf/gf/v2/encoding/gbinary" + "github.com/gogf/gf/v2/errors/gcode" + "github.com/gogf/gf/v2/errors/gerror" + "github.com/gogf/gf/v2/internal/empty" + "github.com/gogf/gf/v2/util/gconv/internal/localinterface" +) + +// Uint converts `any` to uint. +func (c *Converter) Uint(any any) (uint, error) { + if empty.IsNil(any) { + return 0, nil + } + if v, ok := any.(uint); ok { + return v, nil + } + v, err := c.Uint64(any) + return uint(v), err +} + +// Uint8 converts `any` to uint8. +func (c *Converter) Uint8(any any) (uint8, error) { + if empty.IsNil(any) { + return 0, nil + } + if v, ok := any.(uint8); ok { + return v, nil + } + v, err := c.Uint64(any) + return uint8(v), err +} + +// Uint16 converts `any` to uint16. +func (c *Converter) Uint16(any any) (uint16, error) { + if empty.IsNil(any) { + return 0, nil + } + if v, ok := any.(uint16); ok { + return v, nil + } + v, err := c.Uint64(any) + return uint16(v), err +} + +// Uint32 converts `any` to uint32. +func (c *Converter) Uint32(any any) (uint32, error) { + if empty.IsNil(any) { + return 0, nil + } + if v, ok := any.(uint32); ok { + return v, nil + } + v, err := c.Uint64(any) + return uint32(v), err +} + +// Uint64 converts `any` to uint64. +func (c *Converter) Uint64(any any) (uint64, error) { + if empty.IsNil(any) { + return 0, nil + } + if v, ok := any.(uint64); ok { + return v, nil + } + rv := reflect.ValueOf(any) + switch rv.Kind() { + case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: + val := rv.Int() + if val < 0 { + return uint64(val), gerror.NewCodef( + gcode.CodeInvalidParameter, + `cannot convert negative value "%d" to uint64`, + val, + ) + } + return uint64(val), nil + case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: + return rv.Uint(), nil + case reflect.Uintptr: + return rv.Uint(), nil + case reflect.Float32, reflect.Float64: + val := rv.Float() + if val < 0 { + return uint64(val), gerror.NewCodef( + gcode.CodeInvalidParameter, + `cannot convert negative value "%f" to uint64`, + val, + ) + } + return uint64(val), nil + case reflect.Bool: + if rv.Bool() { + return 1, nil + } + return 0, nil + case reflect.Ptr: + if rv.IsNil() { + return 0, nil + } + if f, ok := any.(localinterface.IUint64); ok { + return f.Uint64(), nil + } + return c.Uint64(rv.Elem().Interface()) + case reflect.Slice: + if rv.Type().Elem().Kind() == reflect.Uint8 { + return gbinary.DecodeToUint64(rv.Bytes()), nil + } + return 0, gerror.NewCodef( + gcode.CodeInvalidParameter, + `unsupport slice type "%s" for converting to uint64`, + rv.Type().String(), + ) + case reflect.String: + var s = rv.String() + // Hexadecimal + if len(s) > 2 && s[0] == '0' && (s[1] == 'x' || s[1] == 'X') { + v, err := strconv.ParseUint(s[2:], 16, 64) + if err == nil { + return v, nil + } + return 0, gerror.WrapCodef( + gcode.CodeInvalidParameter, + err, + `cannot convert hexadecimal string "%s" to uint64`, + s, + ) + } + // Decimal + if v, err := strconv.ParseUint(s, 10, 64); err == nil { + return v, nil + } + // Float64 + if v, err := c.Float64(any); err == nil { + if math.IsNaN(v) { + return 0, nil + } + return uint64(v), nil + } + default: + if f, ok := any.(localinterface.IUint64); ok { + return f.Uint64(), nil + } + } + return 0, gerror.NewCodef( + gcode.CodeInvalidParameter, + `unsupport value type "%s" for converting to uint64`, + reflect.TypeOf(any).String(), + ) +} diff --git a/util/gconv/internal/localinterface/localinterface.go b/util/gconv/internal/localinterface/localinterface.go index 63ef7d0789d..d6821b2c48f 100644 --- a/util/gconv/internal/localinterface/localinterface.go +++ b/util/gconv/internal/localinterface/localinterface.go @@ -9,9 +9,9 @@ package localinterface import "github.com/gogf/gf/v2/os/gtime" -// IVal is used for type assert api for String(). +// IVal is used for type assert api for Val(). type IVal interface { - Val() interface{} + Val() any } // IString is used for type assert api for String(). @@ -56,12 +56,12 @@ type IBytes interface { // IInterface is used for type assert api for Interface(). type IInterface interface { - Interface() interface{} + Interface() any } // IInterfaces is used for type assert api for Interfaces(). type IInterfaces interface { - Interfaces() []interface{} + Interfaces() []any } // IFloats is used for type assert api for Floats(). @@ -86,7 +86,7 @@ type IUints interface { // IMapStrAny is the interface support for converting struct parameter to map. type IMapStrAny interface { - MapStrAny() map[string]interface{} + MapStrAny() map[string]any } // IUnmarshalText is the interface for custom defined types customizing value assignment. @@ -104,12 +104,12 @@ type IUnmarshalJSON interface { // IUnmarshalValue is the interface for custom defined types customizing value assignment. // Note that only pointer can implement interface IUnmarshalValue. type IUnmarshalValue interface { - UnmarshalValue(interface{}) error + UnmarshalValue(any) error } // ISet is the interface for custom value assignment. type ISet interface { - Set(value interface{}) (old interface{}) + Set(value any) (old any) } // IGTime is the interface for gtime.Time converting. diff --git a/util/gconv/internal/structcache/structcache.go b/util/gconv/internal/structcache/structcache.go index cdb97388dad..044f8a93526 100644 --- a/util/gconv/internal/structcache/structcache.go +++ b/util/gconv/internal/structcache/structcache.go @@ -9,24 +9,80 @@ package structcache import ( "reflect" + "sync" "github.com/gogf/gf/v2/util/gconv/internal/localinterface" ) -var ( - // customConvertTypeMap is used to store whether field types are registered to custom conversions - // For example: - // func (src *TypeA) (dst *TypeB,err error) - // This map will store `TypeB` for quick judgment during assignment. - customConvertTypeMap = map[reflect.Type]struct{}{} -) +type interfaceTypeConverter struct { + interfaceType reflect.Type + convertFunc AnyConvertFunc +} + +// Converter is the configuration for type converting. +type Converter struct { + // map[reflect.Type]*CachedStructInfo + cachedStructsInfoMap sync.Map + + // anyToTypeConvertMap for custom type converting from any to its reflect.Value. + anyToTypeConvertMap map[reflect.Type]AnyConvertFunc + + // interfaceToTypeConvertMap used for converting any interface type + // the reason why map is not used here, is because interface types cannot be instantiated + interfaceToTypeConvertMap []interfaceTypeConverter + + // typeConverterFuncMarkMap is used to store whether field types are registered to custom conversions + typeConverterFuncMarkMap map[reflect.Type]struct{} +} + +// AnyConvertFunc is the function type for converting any to specified type. +type AnyConvertFunc func(from any, to reflect.Value) error + +// NewConverter creates and returns a new Converter object. +func NewConverter() *Converter { + return &Converter{ + cachedStructsInfoMap: sync.Map{}, + typeConverterFuncMarkMap: make(map[reflect.Type]struct{}), + anyToTypeConvertMap: make(map[reflect.Type]AnyConvertFunc), + } +} -// RegisterCustomConvertType registers custom -func RegisterCustomConvertType(fieldType reflect.Type) { +// MarkTypeConvertFunc marks converting function registered for custom type. +func (cf *Converter) MarkTypeConvertFunc(fieldType reflect.Type) { if fieldType.Kind() == reflect.Ptr { fieldType = fieldType.Elem() } - customConvertTypeMap[fieldType] = struct{}{} + cf.typeConverterFuncMarkMap[fieldType] = struct{}{} +} + +// RegisterAnyConvertFunc registers custom type converting function for specified type. +func (cf *Converter) RegisterAnyConvertFunc(t reflect.Type, convertFunc AnyConvertFunc) { + if t == nil || convertFunc == nil { + return + } + for t.Kind() == reflect.Ptr { + t = t.Elem() + } + if t.Kind() == reflect.Interface { + cf.interfaceToTypeConvertMap = append(cf.interfaceToTypeConvertMap, interfaceTypeConverter{ + interfaceType: t, + convertFunc: convertFunc, + }) + return + } + cf.anyToTypeConvertMap[t] = convertFunc +} + +func (cf *Converter) checkTypeImplInterface(t reflect.Type) AnyConvertFunc { + if t.Kind() != reflect.Ptr { + t = reflect.PointerTo(t) + } + for _, inter := range cf.interfaceToTypeConvertMap { + if t.Implements(inter.interfaceType) { + return inter.convertFunc + } + } + return nil } var ( diff --git a/util/gconv/internal/structcache/structcache_cached.go b/util/gconv/internal/structcache/structcache_cached.go index 1c7d4cf322b..041b3c79be6 100644 --- a/util/gconv/internal/structcache/structcache_cached.go +++ b/util/gconv/internal/structcache/structcache_cached.go @@ -8,48 +8,19 @@ package structcache import ( "reflect" - "sync" - "time" "github.com/gogf/gf/v2/internal/utils" - "github.com/gogf/gf/v2/os/gtime" "github.com/gogf/gf/v2/util/gtag" ) -// CommonConverter holds some converting functions of common types for internal usage. -type CommonConverter struct { - Int64 func(any interface{}) int64 - Uint64 func(any interface{}) uint64 - String func(any interface{}) string - Float32 func(any interface{}) float32 - Float64 func(any interface{}) float64 - Time func(any interface{}, format ...string) time.Time - GTime func(any interface{}, format ...string) *gtime.Time - Bytes func(any interface{}) []byte - Bool func(any interface{}) bool -} - -var ( - // map[reflect.Type]*CachedStructInfo - cachedStructsInfoMap = sync.Map{} - - // localCommonConverter holds some converting functions of common types for internal usage. - localCommonConverter CommonConverter -) - -// RegisterCommonConverter registers the CommonConverter for local usage. -func RegisterCommonConverter(commonConverter CommonConverter) { - localCommonConverter = commonConverter -} - // GetCachedStructInfo retrieves or parses and returns a cached info for certain struct type. // The given `structType` should be type of struct. -func GetCachedStructInfo(structType reflect.Type, priorityTag string) *CachedStructInfo { +func (cf *Converter) GetCachedStructInfo(structType reflect.Type, priorityTag string) *CachedStructInfo { if structType.Kind() != reflect.Struct { return nil } // check if it has been cached. - cachedStructInfo, ok := getCachedConvertStructInfo(structType) + cachedStructInfo, ok := cf.getCachedConvertStructInfo(structType) if ok { // directly returns the cached struct info if already exists. return cachedStructInfo @@ -58,9 +29,7 @@ func GetCachedStructInfo(structType reflect.Type, priorityTag string) *CachedStr // else create one. // it parses and generates a cache info for given struct type. - cachedStructInfo = &CachedStructInfo{ - tagOrFiledNameToFieldInfoMap: make(map[string]*CachedFieldInfo), - } + cachedStructInfo = NewCachedStructInfo(cf) var ( priorityTagArray []string parentIndex = make([]int, 0) @@ -70,19 +39,19 @@ func GetCachedStructInfo(structType reflect.Type, priorityTag string) *CachedStr } else { priorityTagArray = gtag.StructTagPriority } - parseStructToCachedStructInfo(structType, parentIndex, cachedStructInfo, priorityTagArray) - storeCachedStructInfo(structType, cachedStructInfo) + cf.parseStructToCachedStructInfo(structType, parentIndex, cachedStructInfo, priorityTagArray) + cf.storeCachedStructInfo(structType, cachedStructInfo) return cachedStructInfo } -func storeCachedStructInfo(structType reflect.Type, cachedStructInfo *CachedStructInfo) { +func (cf *Converter) storeCachedStructInfo(structType reflect.Type, cachedStructInfo *CachedStructInfo) { // Temporarily enabled as an experimental feature - cachedStructsInfoMap.Store(structType, cachedStructInfo) + cf.cachedStructsInfoMap.Store(structType, cachedStructInfo) } -func getCachedConvertStructInfo(structType reflect.Type) (*CachedStructInfo, bool) { +func (cf *Converter) getCachedConvertStructInfo(structType reflect.Type) (*CachedStructInfo, bool) { // Temporarily enabled as an experimental feature - v, ok := cachedStructsInfoMap.Load(structType) + v, ok := cf.cachedStructsInfoMap.Load(structType) if ok { return v.(*CachedStructInfo), ok } @@ -91,7 +60,7 @@ func getCachedConvertStructInfo(structType reflect.Type) (*CachedStructInfo, boo // parseStructToCachedStructInfo parses given struct reflection type and stores its fields info into given CachedStructInfo. // It stores nothing into CachedStructInfo if given struct reflection type has no fields. -func parseStructToCachedStructInfo( +func (cf *Converter) parseStructToCachedStructInfo( structType reflect.Type, fieldIndexes []int, cachedStructInfo *CachedStructInfo, @@ -136,7 +105,7 @@ func parseStructToCachedStructInfo( // Do not add anonymous structures without tags cachedStructInfo.AddField(structField, append(copyFieldIndexes, i), priorityTagArray) } - parseStructToCachedStructInfo(fieldType, append(copyFieldIndexes, i), cachedStructInfo, priorityTagArray) + cf.parseStructToCachedStructInfo(fieldType, append(copyFieldIndexes, i), cachedStructInfo, priorityTagArray) continue } // Do not directly use append(fieldIndexes, i) diff --git a/util/gconv/internal/structcache/structcache_cached_field_info.go b/util/gconv/internal/structcache/structcache_cached_field_info.go index 6b07cae15cc..084b609bb45 100644 --- a/util/gconv/internal/structcache/structcache_cached_field_info.go +++ b/util/gconv/internal/structcache/structcache_cached_field_info.go @@ -51,6 +51,8 @@ type CachedFieldInfoBase struct { IsCommonInterface bool // HasCustomConvert marks there custom converting function for this field type. + // A custom converting function is a function that user defined for converting specified type + // to another type. HasCustomConvert bool // StructField is the type info of this field. @@ -74,7 +76,7 @@ type CachedFieldInfoBase struct { OtherSameNameField []*CachedFieldInfo // ConvertFunc is the converting function for this field. - ConvertFunc func(from any, to reflect.Value) + ConvertFunc AnyConvertFunc // The last fuzzy matching key for this field. // The fuzzy matching occurs only if there are no direct tag and field name matching in the params map. diff --git a/util/gconv/internal/structcache/structcache_cached_struct_info.go b/util/gconv/internal/structcache/structcache_cached_struct_info.go index bf6a10aad91..f3ff52d5d54 100644 --- a/util/gconv/internal/structcache/structcache_cached_struct_info.go +++ b/util/gconv/internal/structcache/structcache_cached_struct_info.go @@ -9,14 +9,17 @@ package structcache import ( "reflect" "strings" - "time" "github.com/gogf/gf/v2/internal/utils" - "github.com/gogf/gf/v2/os/gtime" ) // CachedStructInfo holds the cached info for certain struct. type CachedStructInfo struct { + // All sub attributes field info slice. + fieldConvertInfos []*CachedFieldInfo + + converter *Converter + // This map field is mainly used in the bindStructWithLoopParamsMap method // key = field's name // Will save all field names and PriorityTagAndFieldName @@ -25,9 +28,19 @@ type CachedStructInfo struct { // // It will be stored twice, which keys are `name` and `field`. tagOrFiledNameToFieldInfoMap map[string]*CachedFieldInfo +} - // All sub attributes field info slice. - FieldConvertInfos []*CachedFieldInfo +// NewCachedStructInfo creates and returns a new CachedStructInfo object. +func NewCachedStructInfo(converter *Converter) *CachedStructInfo { + return &CachedStructInfo{ + tagOrFiledNameToFieldInfoMap: make(map[string]*CachedFieldInfo), + fieldConvertInfos: make([]*CachedFieldInfo, 0), + converter: converter, + } +} + +func (csi *CachedStructInfo) GetFieldConvertInfos() []*CachedFieldInfo { + return csi.fieldConvertInfos } func (csi *CachedStructInfo) HasNoFields() bool { @@ -46,7 +59,7 @@ func (csi *CachedStructInfo) AddField(field reflect.StructField, fieldIndexes [] field, fieldIndexes, priorityTags, cachedFieldInfo, tagOrFieldName, ) if newFieldInfo.IsField { - csi.FieldConvertInfos = append(csi.FieldConvertInfos, newFieldInfo) + csi.fieldConvertInfos = append(csi.fieldConvertInfos, newFieldInfo) } // if the field info by `tagOrFieldName` already cached, // it so adds this new field info to other same name field. @@ -82,7 +95,9 @@ func (csi *CachedStructInfo) makeOrCopyCachedInfo( // copyCachedInfoWithFieldIndexes copies and returns a new CachedFieldInfo based on given CachedFieldInfo, but different // FieldIndexes. Mainly used for copying fields with the same name and type. -func (csi *CachedStructInfo) copyCachedInfoWithFieldIndexes(cfi *CachedFieldInfo, fieldIndexes []int) *CachedFieldInfo { +func (csi *CachedStructInfo) copyCachedInfoWithFieldIndexes( + cfi *CachedFieldInfo, fieldIndexes []int, +) *CachedFieldInfo { base := CachedFieldInfoBase{} base = *cfi.CachedFieldInfoBase base.FieldIndexes = fieldIndexes @@ -98,7 +113,7 @@ func (csi *CachedStructInfo) makeCachedFieldInfo( IsCommonInterface: checkTypeIsCommonInterface(field), StructField: field, FieldIndexes: fieldIndexes, - ConvertFunc: csi.genFieldConvertFunc(field.Type.String()), + ConvertFunc: csi.genFieldConvertFunc(field.Type), HasCustomConvert: csi.checkTypeHasCustomConvert(field.Type), PriorityTagAndFieldName: csi.genPriorityTagAndFieldName(field, priorityTags), RemoveSymbolsFieldName: utils.RemoveSymbols(field.Name), @@ -109,58 +124,27 @@ func (csi *CachedStructInfo) makeCachedFieldInfo( } } -func (csi *CachedStructInfo) genFieldConvertFunc(fieldType string) (convertFunc func(from any, to reflect.Value)) { - if fieldType[0] == '*' { - convertFunc = csi.genFieldConvertFunc(fieldType[1:]) - if convertFunc == nil { - return nil - } - return csi.genPtrConvertFunc(convertFunc) +func (csi *CachedStructInfo) genFieldConvertFunc(fieldType reflect.Type) (convertFunc AnyConvertFunc) { + ptr := 0 + for fieldType.Kind() == reflect.Ptr { + fieldType = fieldType.Elem() + ptr++ } - switch fieldType { - case "int", "int8", "int16", "int32", "int64": - convertFunc = func(from any, to reflect.Value) { - to.SetInt(localCommonConverter.Int64(from)) - } - case "uint", "uint8", "uint16", "uint32", "uint64": - convertFunc = func(from any, to reflect.Value) { - to.SetUint(localCommonConverter.Uint64(from)) - } - case "string": - convertFunc = func(from any, to reflect.Value) { - to.SetString(localCommonConverter.String(from)) - } - case "float32": - convertFunc = func(from any, to reflect.Value) { - to.SetFloat(float64(localCommonConverter.Float32(from))) - } - case "float64": - convertFunc = func(from any, to reflect.Value) { - to.SetFloat(localCommonConverter.Float64(from)) - } - case "Time", "time.Time": - convertFunc = func(from any, to reflect.Value) { - *to.Addr().Interface().(*time.Time) = localCommonConverter.Time(from) - } - case "GTime", "gtime.Time": - convertFunc = func(from any, to reflect.Value) { - v := localCommonConverter.GTime(from) - if v == nil { - v = gtime.New() - } - *to.Addr().Interface().(*gtime.Time) = *v - } - case "bool": - convertFunc = func(from any, to reflect.Value) { - to.SetBool(localCommonConverter.Bool(from)) - } - case "[]byte": - convertFunc = func(from any, to reflect.Value) { - to.SetBytes(localCommonConverter.Bytes(from)) - } - default: + convertFunc = csi.converter.anyToTypeConvertMap[fieldType] + if convertFunc == nil { + // If the registered custom implementation cannot be found, + // try to check if there is an implementation interface + convertFunc = csi.converter.checkTypeImplInterface(fieldType) + } + // if the registered type is not found and + // the corresponding interface is not implemented, return directly + if convertFunc == nil { return nil } + for i := 0; i < ptr; i++ { + // If it is a pointer type, it needs to be packaged + convertFunc = genPtrConvertFunc(convertFunc) + } return convertFunc } @@ -188,21 +172,19 @@ func (csi *CachedStructInfo) genPriorityTagAndFieldName( return } +func genPtrConvertFunc(convertFunc AnyConvertFunc) AnyConvertFunc { + return func(from any, to reflect.Value) error { + if to.IsNil() { + to.Set(reflect.New(to.Type().Elem())) + } + return convertFunc(from, to.Elem()) + } +} + func (csi *CachedStructInfo) checkTypeHasCustomConvert(fieldType reflect.Type) bool { if fieldType.Kind() == reflect.Ptr { fieldType = fieldType.Elem() } - _, ok := customConvertTypeMap[fieldType] + _, ok := csi.converter.typeConverterFuncMarkMap[fieldType] return ok } - -func (csi *CachedStructInfo) genPtrConvertFunc( - convertFunc func(from any, to reflect.Value), -) func(from any, to reflect.Value) { - return func(from any, to reflect.Value) { - if to.IsNil() { - to.Set(reflect.New(to.Type().Elem())) - } - convertFunc(from, to.Elem()) - } -} From a8a055f122d618548d40e0c59a6802a489783f14 Mon Sep 17 00:00:00 2001 From: wln32 <49137144+wln32@users.noreply.github.com> Date: Fri, 7 Mar 2025 13:52:12 +0800 Subject: [PATCH 093/102] fix(util/gvalid): lots of memory consumed when `required` validation on big binary field (#4097) --- util/gvalid/gvalid_validator_check_value.go | 52 +++++++++++++-------- util/gvalid/gvalid_z_unit_issue_test.go | 35 ++++++++++++++ 2 files changed, 68 insertions(+), 19 deletions(-) diff --git a/util/gvalid/gvalid_validator_check_value.go b/util/gvalid/gvalid_validator_check_value.go index 759e97239af..cd1c4021047 100644 --- a/util/gvalid/gvalid_validator_check_value.go +++ b/util/gvalid/gvalid_validator_check_value.go @@ -287,26 +287,40 @@ func (v *Validator) doCheckValueRecursively(ctx context.Context, in doCheckValue } case reflect.Slice, reflect.Array: - var array []interface{} - if gjson.Valid(in.Value) { - array = gconv.Interfaces(gconv.Bytes(in.Value)) - } else { - array = gconv.Interfaces(in.Value) - } - if len(array) == 0 { - return + loop := false + switch in.Type.Elem().Kind() { + // []struct []map + case reflect.Struct, reflect.Map: + loop = true + case reflect.Ptr: + loop = true } - for _, item := range array { - v.doCheckValueRecursively(ctx, doCheckValueRecursivelyInput{ - Value: item, - Type: in.Type.Elem(), - Kind: in.Type.Elem().Kind(), - ErrorMaps: in.ErrorMaps, - ResultSequenceRules: in.ResultSequenceRules, - }) - // Bail feature. - if v.bail && len(in.ErrorMaps) > 0 { - break + // When it is a base type array, + // there is no need for recursive loop validation, + // otherwise it will cause memory leakage + // https://github.com/gogf/gf/issues/4092 + if loop { + var array []interface{} + if gjson.Valid(in.Value) { + array = gconv.Interfaces(gconv.Bytes(in.Value)) + } else { + array = gconv.Interfaces(in.Value) + } + if len(array) == 0 { + return + } + for _, item := range array { + v.doCheckValueRecursively(ctx, doCheckValueRecursivelyInput{ + Value: item, + Type: in.Type.Elem(), + Kind: in.Type.Elem().Kind(), + ErrorMaps: in.ErrorMaps, + ResultSequenceRules: in.ResultSequenceRules, + }) + // Bail feature. + if v.bail && len(in.ErrorMaps) > 0 { + break + } } } } diff --git a/util/gvalid/gvalid_z_unit_issue_test.go b/util/gvalid/gvalid_z_unit_issue_test.go index 3e9490226ec..80449e3426c 100644 --- a/util/gvalid/gvalid_z_unit_issue_test.go +++ b/util/gvalid/gvalid_z_unit_issue_test.go @@ -9,6 +9,7 @@ package gvalid_test import ( "context" "fmt" + "runtime" "testing" "time" @@ -114,3 +115,37 @@ func Test_Issue3636(t *testing.T) { ) }) } + +// https://github.com/gogf/gf/issues/4092 +func Test_Issue4092(t *testing.T) { + type Model struct { + Raw []byte `v:"required"` + Test []byte `v:"foreach|in:1,2,3"` + } + gtest.C(t, func(t *gtest.T) { + const kb = 1024 + const mb = 1024 * kb + raw := make([]byte, 50*mb) + in := &Model{ + Raw: raw, + Test: []byte{40, 5, 6}, + } + err := g.Validator(). + Data(in). + Run(context.Background()) + t.Assert(err, "The Test value `6` is not in acceptable range: 1,2,3") + allocMb := getMemAlloc() + t.AssertLE(allocMb, 110) + }) +} + +func getMemAlloc() uint64 { + byteToMb := func(b uint64) uint64 { + return b / 1024 / 1024 + } + var m runtime.MemStats + runtime.ReadMemStats(&m) + // For info on each, see: https://golang.org/pkg/runtime/#MemStats + alloc := byteToMb(m.Alloc) + return alloc +} From bcda48bf82eae2197bb86e167adcec6c6d1c6b15 Mon Sep 17 00:00:00 2001 From: River Date: Sat, 8 Mar 2025 20:56:27 +0800 Subject: [PATCH 094/102] fix(net/ghttp):check parameter existence to determine using default or front-end value. (#4182) --- net/ghttp/ghttp_request_param.go | 1 - net/ghttp/ghttp_request_param_request.go | 76 +++++-------- ...ghttp_z_unit_feature_request_param_test.go | 106 ++++++++++++++++-- net/ghttp/ghttp_z_unit_issue_test.go | 48 ++++++++ 4 files changed, 168 insertions(+), 63 deletions(-) diff --git a/net/ghttp/ghttp_request_param.go b/net/ghttp/ghttp_request_param.go index b7f7e67e45c..6e44814c049 100644 --- a/net/ghttp/ghttp_request_param.go +++ b/net/ghttp/ghttp_request_param.go @@ -107,7 +107,6 @@ func (r *Request) doParse(pointer interface{}, requestType int) error { return err } } - // TODO: https://github.com/gogf/gf/pull/2450 // Validation. if err = gvalid.New(). Bail(). diff --git a/net/ghttp/ghttp_request_param_request.go b/net/ghttp/ghttp_request_param_request.go index 601e3f06a92..622590f0905 100644 --- a/net/ghttp/ghttp_request_param_request.go +++ b/net/ghttp/ghttp_request_param_request.go @@ -8,7 +8,6 @@ package ghttp import ( "github.com/gogf/gf/v2/container/gvar" - "github.com/gogf/gf/v2/internal/empty" "github.com/gogf/gf/v2/net/goai" "github.com/gogf/gf/v2/os/gstructs" "github.com/gogf/gf/v2/util/gconv" @@ -178,15 +177,17 @@ func (r *Request) doGetRequestStruct(pointer interface{}, mapping ...map[string] if data == nil { data = map[string]interface{}{} } - // Default struct values. - if err = r.mergeDefaultStructValue(data, pointer); err != nil { - return data, nil - } + // `in` Tag Struct values. if err = r.mergeInTagStructValue(data); err != nil { return data, nil } + // Default struct values. + if err = r.mergeDefaultStructValue(data, pointer); err != nil { + return data, nil + } + return data, gconv.Struct(data, pointer, mapping...) } @@ -194,20 +195,9 @@ func (r *Request) doGetRequestStruct(pointer interface{}, mapping ...map[string] func (r *Request) mergeDefaultStructValue(data map[string]interface{}, pointer interface{}) error { fields := r.serveHandler.Handler.Info.ReqStructFields if len(fields) > 0 { - var ( - foundKey string - foundValue interface{} - ) for _, field := range fields { if tagValue := field.TagDefault(); tagValue != "" { - foundKey, foundValue = gutil.MapPossibleItemByKey(data, field.Name()) - if foundKey == "" { - data[field.Name()] = tagValue - } else { - if empty.IsEmpty(foundValue) { - data[foundKey] = tagValue - } - } + mergeTagValueWithFoundKey(data, false, field.Name(), field.Name(), tagValue) } } return nil @@ -219,19 +209,8 @@ func (r *Request) mergeDefaultStructValue(data map[string]interface{}, pointer i return err } if len(tagFields) > 0 { - var ( - foundKey string - foundValue interface{} - ) for _, field := range tagFields { - foundKey, foundValue = gutil.MapPossibleItemByKey(data, field.Name()) - if foundKey == "" { - data[field.Name()] = field.TagValue - } else { - if empty.IsEmpty(foundValue) { - data[foundKey] = field.TagValue - } - } + mergeTagValueWithFoundKey(data, false, field.Name(), field.Name(), field.TagValue) } } @@ -261,34 +240,29 @@ func (r *Request) mergeInTagStructValue(data map[string]interface{}) error { for _, field := range fields { if tagValue := field.TagIn(); tagValue != "" { + findKey := field.TagPriorityName() switch tagValue { case goai.ParameterInHeader: - foundHeaderKey, foundHeaderValue := gutil.MapPossibleItemByKey(headerMap, field.TagPriorityName()) - if foundHeaderKey != "" { - foundKey, foundValue = gutil.MapPossibleItemByKey(data, foundHeaderKey) - if foundKey == "" { - data[field.Name()] = foundHeaderValue - } else { - if empty.IsEmpty(foundValue) { - data[foundKey] = foundHeaderValue - } - } - } + foundKey, foundValue = gutil.MapPossibleItemByKey(headerMap, findKey) case goai.ParameterInCookie: - foundCookieKey, foundCookieValue := gutil.MapPossibleItemByKey(cookieMap, field.TagPriorityName()) - if foundCookieKey != "" { - foundKey, foundValue = gutil.MapPossibleItemByKey(data, foundCookieKey) - if foundKey == "" { - data[field.Name()] = foundCookieValue - } else { - if empty.IsEmpty(foundValue) { - data[foundKey] = foundCookieValue - } - } - } + foundKey, foundValue = gutil.MapPossibleItemByKey(cookieMap, findKey) + } + if foundKey != "" { + mergeTagValueWithFoundKey(data, true, foundKey, field.Name(), foundValue) } } } } return nil } + +// mergeTagValueWithFoundKey merges the request parameters when the key does not exist in the map or overwritten is true or the value is nil. +func mergeTagValueWithFoundKey(data map[string]interface{}, overwritten bool, findKey string, fieldName string, tagValue interface{}) { + if foundKey, foundValue := gutil.MapPossibleItemByKey(data, findKey); foundKey == "" { + data[fieldName] = tagValue + } else { + if overwritten || foundValue == nil { + data[foundKey] = tagValue + } + } +} diff --git a/net/ghttp/ghttp_z_unit_feature_request_param_test.go b/net/ghttp/ghttp_z_unit_feature_request_param_test.go index b8d77767325..3b9000c7469 100644 --- a/net/ghttp/ghttp_z_unit_feature_request_param_test.go +++ b/net/ghttp/ghttp_z_unit_feature_request_param_test.go @@ -13,34 +13,34 @@ import ( "github.com/gogf/gf/v2/util/guid" ) -type UserReq struct { +// UserTagInReq struct tag "in" supports: header, cookie +type UserTagInReq struct { g.Meta `path:"/user" tags:"User" method:"post" summary:"user api" title:"api title"` Id int `v:"required" d:"1"` Name string `v:"required" in:"cookie"` Age string `v:"required" in:"header"` - // header,query,cookie,form } -type UserRes struct { +type UserTagInRes struct { g.Meta `mime:"text/html" example:"string"` } var ( - User = cUser{} + UserTagIn = cUserTagIn{} ) -type cUser struct{} +type cUserTagIn struct{} -func (c *cUser) User(ctx context.Context, req *UserReq) (res *UserRes, err error) { +func (c *cUserTagIn) User(ctx context.Context, req *UserTagInReq) (res *UserTagInRes, err error) { g.RequestFromCtx(ctx).Response.WriteJson(req) return } -func Test_Params_Tag(t *testing.T) { +func Test_ParamsTagIn(t *testing.T) { s := g.Server(guid.S()) s.Group("/", func(group *ghttp.RouterGroup) { group.Middleware(ghttp.MiddlewareHandlerResponse) - group.Bind(User) + group.Bind(UserTagIn) }) s.SetDumpRouterMap(false) s.Start() @@ -56,17 +56,101 @@ func Test_Params_Tag(t *testing.T) { client.SetHeader("age", "18") t.Assert(client.PostContent(ctx, "/user"), `{"Id":1,"Name":"john","Age":"18"}`) - t.Assert(client.PostContent(ctx, "/user", "name=&age=&id="), `{"Id":1,"Name":"john","Age":"18"}`) + t.Assert(client.PostContent(ctx, "/user", "name=&age="), `{"Id":1,"Name":"john","Age":"18"}`) }) } -func Benchmark_ParamTag(b *testing.B) { +type UserTagDefaultReq struct { + g.Meta `path:"/user-default" method:"post,get" summary:"user default tag api"` + Id int `v:"required" d:"1"` + Name string `d:"john"` + Age int `d:"18"` + Score float64 `d:"99.9"` + IsVip bool `d:"true"` + NickName string `p:"nickname" d:"nickname-default"` + EmptyStr string `d:""` + Email string + Address string +} + +type UserTagDefaultRes struct { + g.Meta `mime:"application/json" example:"string"` +} + +var ( + UserTagDefault = cUserTagDefault{} +) + +type cUserTagDefault struct{} + +func (c *cUserTagDefault) User(ctx context.Context, req *UserTagDefaultReq) (res *UserTagDefaultRes, err error) { + g.RequestFromCtx(ctx).Response.WriteJson(req) + return +} + +func Test_ParamsTagDefault(t *testing.T) { + s := g.Server(guid.S()) + s.Group("/", func(group *ghttp.RouterGroup) { + group.Middleware(ghttp.MiddlewareHandlerResponse) + group.Bind(UserTagDefault) + }) + s.SetDumpRouterMap(false) + s.Start() + defer s.Shutdown() + + time.Sleep(100 * time.Millisecond) + + gtest.C(t, func(t *gtest.T) { + prefix := fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort()) + client := g.Client() + client.SetPrefix(prefix) + + // Test with no parameters, should use all default values + resp := client.GetContent(ctx, "/user-default") + t.Assert(resp, `{"Id":1,"Name":"john","Age":18,"Score":99.9,"IsVip":true,"NickName":"nickname-default","EmptyStr":"","Email":"","Address":""}`) + + // Test with partial parameters (query method), should use partial default values + resp = client.GetContent(ctx, "/user-default?id=100&name=smith") + t.Assert(resp, `{"Id":100,"Name":"smith","Age":18,"Score":99.9,"IsVip":true,"NickName":"nickname-default","EmptyStr":"","Email":"","Address":""}`) + + // Test with partial parameters (query method), should use partial default values + resp = client.GetContent(ctx, "/user-default?id=100&name=smith&age") + t.Assert(resp, `{"Id":100,"Name":"smith","Age":18,"Score":99.9,"IsVip":true,"NickName":"nickname-default","EmptyStr":"","Email":"","Address":""}`) + + // Test providing partial parameters via POST form + resp = client.PostContent(ctx, "/user-default", "id=200&age=30&nickname=jack") + t.Assert(resp, `{"Id":200,"Name":"john","Age":30,"Score":99.9,"IsVip":true,"NickName":"jack","EmptyStr":"","Email":"","Address":""}`) + + // Test providing partial parameters via POST JSON + resp = client.ContentJson().PostContent(ctx, "/user-default", g.Map{ + "id": 300, + "name": "bob", + "score": 88.8, + "address": "beijing", + }) + t.Assert(resp, `{"Id":300,"Name":"bob","Age":18,"Score":88.8,"IsVip":true,"NickName":"nickname-default","EmptyStr":"","Email":"","Address":"beijing"}`) + + // Test providing JSON content via GET request + resp = client.ContentJson().PostContent(ctx, "/user-default", `{"id":500,"isVip":false}`) + t.Assert(resp, `{"Id":500,"Name":"john","Age":18,"Score":99.9,"IsVip":false,"NickName":"nickname-default","EmptyStr":"","Email":"","Address":""}`) + + // Test providing empty values, should use default values + resp = client.PostContent(ctx, "/user-default", "id=400&name=&age=") + t.Assert(resp, `{"Id":400,"Name":"","Age":0,"Score":99.9,"IsVip":true,"NickName":"nickname-default","EmptyStr":"","Email":"","Address":""}`) + + // Test providing JSON content via GET request + resp = client.ContentJson().GetContent(ctx, "/user-default", `{"id":500,"isVip":false}`) + t.Assert(resp, `{"Id":500,"Name":"john","Age":18,"Score":99.9,"IsVip":false,"NickName":"nickname-default","EmptyStr":"","Email":"","Address":""}`) + }) +} + +func Benchmark_ParamTagIn(b *testing.B) { b.StopTimer() s := g.Server(guid.S()) s.Group("/", func(group *ghttp.RouterGroup) { group.Middleware(ghttp.MiddlewareHandlerResponse) - group.Bind(User) + group.Bind(UserTagIn) }) s.SetDumpRouterMap(false) s.SetAccessLogEnabled(false) diff --git a/net/ghttp/ghttp_z_unit_issue_test.go b/net/ghttp/ghttp_z_unit_issue_test.go index df5838301d6..92f761ce963 100644 --- a/net/ghttp/ghttp_z_unit_issue_test.go +++ b/net/ghttp/ghttp_z_unit_issue_test.go @@ -678,3 +678,51 @@ func Test_Issue4047(t *testing.T) { t.Assert(s.Logger(), nil) }) } + +// Issue4093Req +type Issue4093Req struct { + g.Meta `path:"/test" method:"post"` + Page int `json:"page" example:"10" d:"1" v:"min:1#页码最小值不能低于1" dc:"当前页码"` + PerPage int `json:"pageSize" example:"1" d:"10" v:"min:1|max:200#每页数量最小值不能低于1|最大值不能大于200" dc:"每页数量"` + Pagination bool `json:"pagination" d:"true" dc:"是否需要进行分页"` + Name string `json:"name" d:"john"` + Number int `json:"number" d:"1"` +} + +type Issue4093Res struct { + g.Meta `mime:"text/html" example:"string"` +} + +var ( + Issue4093 = cIssue4093{} +) + +type cIssue4093 struct{} + +func (c *cIssue4093) User(ctx context.Context, req *Issue4093Req) (res *Issue4093Res, err error) { + g.RequestFromCtx(ctx).Response.WriteJson(req) + return +} + +// https://github.com/gogf/gf/issues/4093 +func Test_Issue4093(t *testing.T) { + s := g.Server(guid.S()) + s.Group("/", func(group *ghttp.RouterGroup) { + group.Middleware(ghttp.MiddlewareHandlerResponse) + group.Bind(Issue4093) + }) + s.SetDumpRouterMap(false) + s.Start() + defer s.Shutdown() + + time.Sleep(100 * time.Millisecond) + + gtest.C(t, func(t *gtest.T) { + prefix := fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort()) + client := g.Client().ContentJson() + client.SetPrefix(prefix) + + t.Assert(client.PostContent(ctx, "/test", `{"pagination":false,"name":"","number":0}`), `{"page":1,"pageSize":10,"pagination":false,"name":"","number":0}`) + t.Assert(client.PostContent(ctx, "/test"), `{"page":1,"pageSize":10,"pagination":true,"name":"john","number":1}`) + }) +} From f8331bad6eba0aa6827fbe332fb2458cd36845bc Mon Sep 17 00:00:00 2001 From: PandaPy <37057546+PandaPy@users.noreply.github.com> Date: Sun, 9 Mar 2025 11:17:41 +0800 Subject: [PATCH 095/102] feat(net/ghttp): add `Request.GetMetaTag` to retrieve specific meta tag value (#4185) --- .github/workflows/ci-main.sh | 6 +-- examples | 2 +- net/ghttp/ghttp_request.go | 25 ++++++++++- .../ghttp_z_unit_feature_request_test.go | 41 +++++++++++++++++++ os/gstructs/gstructs.go | 20 +++++++-- util/gmeta/gmeta.go | 17 ++++---- 6 files changed, 96 insertions(+), 15 deletions(-) diff --git a/.github/workflows/ci-main.sh b/.github/workflows/ci-main.sh index 7123b851ad3..1c8b36d02a2 100644 --- a/.github/workflows/ci-main.sh +++ b/.github/workflows/ci-main.sh @@ -3,7 +3,7 @@ coverage=$1 # update code of submodules -make subup +git clone https://github.com/gogf/examples # find all path that contains go.mod. for file in `find . -name go.mod`; do @@ -22,14 +22,14 @@ for file in `find . -name go.mod`; do fi # Check if it's a contrib directory or examples directory - if [[ $dirpath =~ "/contrib/" ]] || [ "examples" = $(basename $dirpath) ]; then + if [[ $dirpath =~ "/contrib/" ]] || [[ $dirpath =~ "/examples/" ]]; then # Check if go version meets the requirement if ! go version | grep -qE "go${LATEST_GO_VERSION}"; then echo "ignore path $dirpath as go version is not ${LATEST_GO_VERSION}: $(go version)" continue 1 fi # If it's examples directory, only build without tests - if [ "examples" = $(basename $dirpath) ]; then + if [[ $dirpath =~ "/examples/" ]]; then echo "the examples directory only needs to be built, not unit tests and coverage tests." cd $dirpath go mod tidy diff --git a/examples b/examples index c454db2549a..bf0ab5ac16f 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit c454db2549ac7ecce844b687c1e610461818830d +Subproject commit bf0ab5ac16fbf654fc424baf45e96e541a037cb3 diff --git a/net/ghttp/ghttp_request.go b/net/ghttp/ghttp_request.go index 73801995b3d..30690448710 100644 --- a/net/ghttp/ghttp_request.go +++ b/net/ghttp/ghttp_request.go @@ -19,6 +19,7 @@ import ( "github.com/gogf/gf/v2/os/gview" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" + "github.com/gogf/gf/v2/util/gmeta" "github.com/gogf/gf/v2/util/guid" ) @@ -40,7 +41,7 @@ type Request struct { // ================================================================================================================= handlers []*HandlerItemParsed // All matched handlers containing handler, hook and middleware for this request. - serveHandler *HandlerItemParsed // Real handler serving for this request, not hook or middleware. + serveHandler *HandlerItemParsed // Real business handler serving for this request, not hook or middleware handler. handlerResponse interface{} // Handler response object for Request/Response handler. hasHookHandler bool // A bool marking whether there's hook handler in the handlers for performance purpose. hasServeHandler bool // A bool marking whether there's serving handler in the handlers for performance purpose. @@ -288,3 +289,25 @@ func (r *Request) GetHandlerResponse() interface{} { func (r *Request) GetServeHandler() *HandlerItemParsed { return r.serveHandler } + +// GetMetaTag retrieves and returns the metadata value associated with the given key from the request struct. +// The meta value is from struct tags from g.Meta/gmeta.Meta type. +// For example: +// +// type GetMetaTagReq struct { +// g.Meta `path:"/test" method:"post" summary:"meta_tag" tags:"meta"` +// // ... +// } +// +// r.GetMetaTag("summary") // returns "meta_tag" +// r.GetMetaTag("method") // returns "post" +func (r *Request) GetMetaTag(key string) string { + if r.serveHandler == nil || r.serveHandler.Handler == nil { + return "" + } + metaValue := gmeta.Get(r.serveHandler.Handler.Info.Type.In(1), key) + if metaValue != nil { + return metaValue.String() + } + return "" +} diff --git a/net/ghttp/ghttp_z_unit_feature_request_test.go b/net/ghttp/ghttp_z_unit_feature_request_test.go index 2aa07dc6f21..1d08b19dd43 100644 --- a/net/ghttp/ghttp_z_unit_feature_request_test.go +++ b/net/ghttp/ghttp_z_unit_feature_request_test.go @@ -8,6 +8,7 @@ package ghttp_test import ( "bytes" + "context" "fmt" "io" "testing" @@ -861,3 +862,43 @@ func Test_Params_GetRequestMapStrVar(t *testing.T) { t.Assert(client.GetContent(ctx, "/GetRequestMapStrVar", "id=1"), 1) }) } + +type GetMetaTagReq struct { + g.Meta `path:"/test" method:"post" summary:"meta_tag" tags:"meta"` + Name string +} +type GetMetaTagRes struct{} + +type GetMetaTagSt struct{} + +func (r GetMetaTagSt) PostTest(ctx context.Context, req *GetMetaTagReq) (*GetMetaTagRes, error) { + return &GetMetaTagRes{}, nil +} + +func TestRequest_GetMetaTag(t *testing.T) { + s := g.Server(guid.S()) + s.Use(func(r *ghttp.Request) { + r.Response.Writef( + "summary:%s,method:%s", + r.GetMetaTag("summary"), r.GetMetaTag("method"), + ) + }) + s.Group("/", func(grp *ghttp.RouterGroup) { + grp.Bind(GetMetaTagSt{}) + }) + s.SetDumpRouterMap(false) + s.Start() + defer s.Shutdown() + time.Sleep(1000 * time.Millisecond) + + s.SetDumpRouterMap(false) + s.Start() + defer s.Shutdown() + time.Sleep(100 * time.Millisecond) + + gtest.C(t, func(t *gtest.T) { + client := g.Client() + client.SetPrefix(fmt.Sprintf("http://127.0.0.1:%d", s.GetListenedPort())) + t.Assert(client.PostContent(ctx, "/test", "name=john"), "summary:meta_tag,method:post") + }) +} diff --git a/os/gstructs/gstructs.go b/os/gstructs/gstructs.go index 71006b75c16..b0ac1550cc5 100644 --- a/os/gstructs/gstructs.go +++ b/os/gstructs/gstructs.go @@ -36,7 +36,7 @@ type Field struct { type FieldsInput struct { // Pointer should be type of struct/*struct. // TODO this attribute name is not suitable, which would make confuse. - Pointer interface{} + Pointer any // RecursiveOption specifies the way retrieving the fields recursively if the attribute // is an embedded struct. It is RecursiveOptionNone in default. @@ -47,7 +47,7 @@ type FieldsInput struct { type FieldMapInput struct { // Pointer should be type of struct/*struct. // TODO this attribute name is not suitable, which would make confuse. - Pointer interface{} + Pointer any // PriorityTagArray specifies the priority tag array for retrieving from high to low. // If it's given `nil`, it returns map[name]Field, of which the `name` is attribute name. @@ -123,6 +123,7 @@ func Fields(in FieldsInput) ([]Field, error) { } } continue + default: } } continue @@ -194,6 +195,7 @@ func FieldMap(in FieldMapInput) (map[string]Field, error) { mapField[k] = tempV } } + default: } } else { mapField[field.Name()] = tempField @@ -205,7 +207,19 @@ func FieldMap(in FieldMapInput) (map[string]Field, error) { // StructType retrieves and returns the struct Type of specified struct/*struct. // The parameter `object` should be either type of struct/*struct/[]struct/[]*struct. -func StructType(object interface{}) (*Type, error) { +func StructType(object any) (*Type, error) { + // if already reflect.Type + if reflectType, ok := object.(reflect.Type); ok { + for reflectType.Kind() == reflect.Ptr { + reflectType = reflectType.Elem() + } + if reflectType.Kind() == reflect.Struct { + return &Type{ + Type: reflectType, + }, nil + } + } + var ( reflectValue reflect.Value reflectKind reflect.Kind diff --git a/util/gmeta/gmeta.go b/util/gmeta/gmeta.go index 936a22d4f20..7d73ca925a2 100644 --- a/util/gmeta/gmeta.go +++ b/util/gmeta/gmeta.go @@ -8,6 +8,8 @@ package gmeta import ( + "reflect" + "github.com/gogf/gf/v2/container/gvar" "github.com/gogf/gf/v2/os/gstructs" ) @@ -15,19 +17,20 @@ import ( // Meta is used as an embedded attribute for struct to enabled metadata feature. type Meta struct{} -const ( - metaAttributeName = "Meta" // metaAttributeName is the attribute name of metadata in struct. - metaTypeName = "gmeta.Meta" // metaTypeName is for type string comparison. -) +// metaAttributeName is the attribute name of metadata in struct. +const metaAttributeName = "Meta" + +// metaType holds the reflection. Type of Meta, used for efficient type comparison. +var metaType = reflect.TypeOf(Meta{}) // Data retrieves and returns all metadata from `object`. -func Data(object interface{}) map[string]string { +func Data(object any) map[string]string { reflectType, err := gstructs.StructType(object) if err != nil { return nil } if field, ok := reflectType.FieldByName(metaAttributeName); ok { - if field.Type.String() == metaTypeName { + if field.Type == metaType { return gstructs.ParseTag(string(field.Tag)) } } @@ -35,7 +38,7 @@ func Data(object interface{}) map[string]string { } // Get retrieves and returns specified metadata by `key` from `object`. -func Get(object interface{}, key string) *gvar.Var { +func Get(object any, key string) *gvar.Var { v, ok := Data(object)[key] if !ok { return nil From 029f324c5c2c3963db02f6890974c83590cdd445 Mon Sep 17 00:00:00 2001 From: John Guo Date: Sun, 9 Mar 2025 22:31:20 +0800 Subject: [PATCH 096/102] feat: version v2.9.0-beta (#4189) --- .github/workflows/ci-main.yml | 6 +- .github/workflows/ci-sub.yml | 4 +- .github/workflows/doc-build.yml | 38 --------- .../workflows/{ => scripts}/before_script.sh | 0 .github/workflows/{ => scripts}/ci-main.sh | 3 + .github/workflows/{ => scripts}/ci-sub.sh | 0 .../scripts/replace_examples_gomod.sh | 81 +++++++++++++++++++ .make_tidy.sh | 33 ++++++++ .set_version.sh => .make_version.sh | 18 +++-- Makefile | 14 +--- README.MD | 2 +- cmd/gf/go.mod | 24 +++--- cmd/gf/go.sum | 53 ++++++------ cmd/gf/go.work | 2 +- contrib/config/apollo/go.mod | 4 +- contrib/config/consul/go.mod | 4 +- contrib/config/kubecm/go.mod | 4 +- contrib/config/nacos/go.mod | 4 +- contrib/config/polaris/go.mod | 4 +- contrib/drivers/clickhouse/go.mod | 4 +- contrib/drivers/dm/go.mod | 4 +- contrib/drivers/mssql/go.mod | 4 +- contrib/drivers/mysql/go.mod | 4 +- contrib/drivers/oracle/go.mod | 4 +- contrib/drivers/pgsql/go.mod | 4 +- contrib/drivers/sqlite/go.mod | 4 +- contrib/drivers/sqlitecgo/go.mod | 4 +- contrib/metric/otelmetric/go.mod | 2 +- contrib/nosql/redis/go.mod | 4 +- contrib/registry/consul/go.mod | 4 +- contrib/registry/etcd/go.mod | 2 +- contrib/registry/file/go.mod | 4 +- contrib/registry/nacos/go.mod | 4 +- contrib/registry/polaris/go.mod | 4 +- contrib/registry/zookeeper/go.mod | 4 +- contrib/rpc/grpcx/go.mod | 6 +- contrib/sdk/httpclient/go.mod | 4 +- contrib/trace/otlpgrpc/go.mod | 4 +- contrib/trace/otlphttp/go.mod | 4 +- version.go | 2 +- 40 files changed, 207 insertions(+), 171 deletions(-) delete mode 100644 .github/workflows/doc-build.yml rename .github/workflows/{ => scripts}/before_script.sh (100%) rename .github/workflows/{ => scripts}/ci-main.sh (92%) rename .github/workflows/{ => scripts}/ci-sub.sh (100%) create mode 100755 .github/workflows/scripts/replace_examples_gomod.sh create mode 100755 .make_tidy.sh rename .set_version.sh => .make_version.sh (83%) diff --git a/.github/workflows/ci-main.yml b/.github/workflows/ci-main.yml index 3f5cf22e536..68afee40efc 100644 --- a/.github/workflows/ci-main.yml +++ b/.github/workflows/ci-main.yml @@ -239,15 +239,15 @@ jobs: export PATH="$PATH:$(go env GOPATH)/bin" - name: Before Script - run: bash .github/workflows/before_script.sh + run: bash .github/workflows/scripts/before_script.sh - name: Build & Test if: ${{ (github.event_name == 'push' && github.ref != 'refs/heads/master') || github.event_name == 'pull_request' }} - run: bash .github/workflows/ci-main.sh + run: bash .github/workflows/scripts/ci-main.sh - name: Build & Test & Coverage if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }} - run: bash .github/workflows/ci-main.sh coverage + run: bash .github/workflows/scripts/ci-main.sh coverage - name: Stop Redis Cluster Containers run: docker compose -f ".github/workflows/redis/docker-compose.yml" down diff --git a/.github/workflows/ci-sub.yml b/.github/workflows/ci-sub.yml index 6a1244385c1..0989af14327 100644 --- a/.github/workflows/ci-sub.yml +++ b/.github/workflows/ci-sub.yml @@ -64,9 +64,9 @@ jobs: cache-dependency-path: '**/go.sum' - name: Before Script - run: bash .github/workflows/before_script.sh + run: bash .github/workflows/scripts/before_script.sh - name: Build & Test - run: bash .github/workflows/ci-sub.sh + run: bash .github/workflows/scripts/ci-sub.sh diff --git a/.github/workflows/doc-build.yml b/.github/workflows/doc-build.yml deleted file mode 100644 index 32d6f7d1a5b..00000000000 --- a/.github/workflows/doc-build.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Deploy to GitHub Pages - -on: - push: - branches: - - 'doc-build' - schedule: - - cron: '0 15 * * *' - -jobs: - deploy: - name: Deploy to GitHub Pages - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v4 - with: - ref: doc-build - - uses: actions/setup-node@v4 - with: - node-version: 18 - cache: npm - - name: Set Up Golang Environment - uses: actions/setup-go@v5 - with: - go-version: 1.23.4 - cache: false - - name: download goframe docs - run: ./download.sh - - name: Install dependencies - run: npm ci - - name: Build website - run: npm run build - - name: Deploy to GitHub Pages - uses: peaceiris/actions-gh-pages@v4 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./build - cname: pages.goframe.org diff --git a/.github/workflows/before_script.sh b/.github/workflows/scripts/before_script.sh similarity index 100% rename from .github/workflows/before_script.sh rename to .github/workflows/scripts/before_script.sh diff --git a/.github/workflows/ci-main.sh b/.github/workflows/scripts/ci-main.sh similarity index 92% rename from .github/workflows/ci-main.sh rename to .github/workflows/scripts/ci-main.sh index 1c8b36d02a2..c75552f715a 100644 --- a/.github/workflows/ci-main.sh +++ b/.github/workflows/scripts/ci-main.sh @@ -5,6 +5,9 @@ coverage=$1 # update code of submodules git clone https://github.com/gogf/examples +# update go.mod in examples directory to replace github.com/gogf/gf packages with local directory +bash .github/workflows/scripts/replace_examples_gomod.sh + # find all path that contains go.mod. for file in `find . -name go.mod`; do dirpath=$(dirname $file) diff --git a/.github/workflows/ci-sub.sh b/.github/workflows/scripts/ci-sub.sh similarity index 100% rename from .github/workflows/ci-sub.sh rename to .github/workflows/scripts/ci-sub.sh diff --git a/.github/workflows/scripts/replace_examples_gomod.sh b/.github/workflows/scripts/replace_examples_gomod.sh new file mode 100755 index 00000000000..a34fc1abc3f --- /dev/null +++ b/.github/workflows/scripts/replace_examples_gomod.sh @@ -0,0 +1,81 @@ +#!/usr/bin/env bash + +# Get the absolute path to the repository root +repo_root=$(pwd) +workdir=$repo_root/examples + +echo "Prepare to process go.mod files in the ${workdir} directory" + +# Check if examples directory exists +if [ ! -d "${workdir}" ]; then + echo "Error: examples directory not found at ${workdir}" + exit 1 +fi + +# Check if find command is available +if ! command -v find &> /dev/null; then + echo "Error: find command not found!" + exit 1 +fi + +for file in `find ${workdir} -name go.mod`; do + goModPath=$(dirname $file) + echo "" + echo "Processing dir: $goModPath" + + # Calculate relative path to root + # First get the relative path from go.mod to repo root + relativePath="" + current="$goModPath" + while [ "$current" != "$repo_root" ]; do + relativePath="../$relativePath" + current=$(dirname "$current") + done + relativePath=${relativePath%/} # Remove trailing slash + echo "Relative path to root: $relativePath" + + # Get all github.com/gogf/gf dependencies + # Use awk to get package names without version numbers + dependencies=$(awk '/^[[:space:]]*github\.com\/gogf\/gf\// {print $1}' "$file" | sort -u) + + if [ -n "$dependencies" ]; then + echo "Found GoFrame dependencies:" + echo "$dependencies" + echo "Adding replace directives..." + + # Create temporary file + temp_file="${file}.tmp" + # Remove existing replace directives and copy to temp file + sed '/^replace.*github\.com\/gogf\/gf.*/d' "$file" > "$temp_file" + + # Add new replace block + echo "" >> "$temp_file" + echo "replace (" >> "$temp_file" + + while IFS= read -r dep; do + # Skip empty lines + [ -z "$dep" ] && continue + + # Calculate the relative path for the replacement + if [[ "$dep" == "github.com/gogf/gf/v2" ]]; then + replacement="$relativePath" + else + # Extract the path after v2 and remove trailing version + subpath=$(echo "$dep" | sed -E 's/github\.com\/gogf\/gf\/(contrib\/[^/]+\/[^/]+)\/v2.*/\1/') + replacement="$relativePath/$subpath" + fi + + echo " $dep => $replacement/" >> "$temp_file" + done <<< "$dependencies" + + echo ")" >> "$temp_file" + + # Replace original file with temporary file + mv "$temp_file" "$file" + echo "Replace directives added to $file" + else + echo "No GoFrame dependencies found in $file" + fi +done + +echo "\nAll go.mod files have been processed successfully." diff --git a/.make_tidy.sh b/.make_tidy.sh new file mode 100755 index 00000000000..e14d2dd85c2 --- /dev/null +++ b/.make_tidy.sh @@ -0,0 +1,33 @@ +#!/usr/bin/env bash + +workdir=. +echo "Prepare to tidy all go.mod files in the ${workdir} directory" + +# check find command support or not +output=$(find "${workdir}" -name go.mod 2>&1) +if [[ $? -ne 0 ]]; then + echo "Error: please use bash or zsh to run!" + exit 1 +fi + +for file in `find ${workdir} -name go.mod`; do + goModPath=$(dirname $file) + echo "" + echo "processing dir: $goModPath" + + if [[ $goModPath =~ "/testdata/" ]]; then + echo "ignore testdata path $goModPath" + continue 1 + fi + + if [[ $goModPath =~ "/examples/" ]]; then + echo "ignore examples path $goModPath" + continue 1 + fi + + cd $goModPath + go mod tidy + # Remove toolchain line if exists + sed -i '' '/^toolchain/d' go.mod + cd - > /dev/null +done diff --git a/.set_version.sh b/.make_version.sh similarity index 83% rename from .set_version.sh rename to .make_version.sh index ceedac620b1..95f9de8fe59 100755 --- a/.set_version.sh +++ b/.make_version.sh @@ -17,7 +17,7 @@ fi workdir=. newVersion=$2 -echo "Prepare to replace the GF library version numbers in all go.mod files in the ${workdir} directory with ${newVersion}" +echo "Prepare to replace the GoFrame library version numbers in all go.mod files in the ${workdir} directory with ${newVersion}" # check find command support or not output=$(find "${workdir}" -name go.mod 2>&1) @@ -49,6 +49,11 @@ for file in `find ${workdir} -name go.mod`; do continue 1 fi + if [[ $goModPath =~ "/examples/" ]]; then + echo "ignore examples path $goModPath" + continue 1 + fi + cd $goModPath if [ $goModPath = "./cmd/gf" ]; then mv go.work go.work.version.bak @@ -59,15 +64,18 @@ for file in `find ${workdir} -name go.mod`; do go mod edit -replace github.com/gogf/gf/contrib/drivers/oracle/v2=../../contrib/drivers/oracle go mod edit -replace github.com/gogf/gf/contrib/drivers/pgsql/v2=../../contrib/drivers/pgsql go mod edit -replace github.com/gogf/gf/contrib/drivers/sqlite/v2=../../contrib/drivers/sqlite - # else - # cd - - # continue 1 fi go mod tidy - # Upgrading only GF related libraries, sometimes even if a version number is specified, it may not be possible to successfully upgrade. Please confirm before submitting the code + # Remove toolchain line if exists + sed -i '' '/^toolchain/d' go.mod + + # Upgrading only GoFrame related libraries, sometimes even if a version number is specified, + # it may not be possible to successfully upgrade. Please confirm before submitting the code go list -f "{{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion}{{end}}" -m all | grep "^github.com/gogf/gf" go list -f "{{if and (not .Indirect) (not .Main)}}{{.Path}}@${newVersion}{{end}}" -m all | grep "^github.com/gogf/gf" | xargs -L1 go get -v go mod tidy + # Remove toolchain line if exists + sed -i '' '/^toolchain/d' go.mod if [ $goModPath = "./cmd/gf" ]; then go mod edit -dropreplace github.com/gogf/gf/v2 go mod edit -dropreplace github.com/gogf/gf/contrib/drivers/clickhouse/v2 diff --git a/Makefile b/Makefile index 03f69483951..d0cd1cc8ec2 100644 --- a/Makefile +++ b/Makefile @@ -3,17 +3,7 @@ SHELL := /bin/bash # execute "go mod tidy" on all folders that have go.mod file .PHONY: tidy tidy: - $(eval files=$(shell find . -name go.mod)) - @set -e; \ - for file in ${files}; do \ - goModPath=$$(dirname $$file); \ - if ! echo $$goModPath | grep -q "testdata"; then \ - echo "handle: $$goModPath"; \ - cd $$goModPath; \ - go mod tidy; \ - cd -; \ - fi \ - done + ./.make_tidy.sh # execute "golangci-lint" to check code style .PHONY: lint @@ -25,7 +15,7 @@ lint: version: @set -e; \ newVersion=$(to); \ - ./.set_version.sh ./ $$newVersion; \ + ./.make_version.sh ./ $$newVersion; \ echo "make version to=$(to) done" diff --git a/README.MD b/README.MD index 37dc8a5aa81..3fc372015bf 100644 --- a/README.MD +++ b/README.MD @@ -36,7 +36,7 @@ A powerful framework for faster, easier, and more efficient project development. 💖 [Thanks to all the contributors who made GoFrame possible](https://github.com/gogf/gf/graphs/contributors) 💖 -goframe contributors +goframe contributors # License diff --git a/cmd/gf/go.mod b/cmd/gf/go.mod index ae17a9e1090..b12cae08acf 100644 --- a/cmd/gf/go.mod +++ b/cmd/gf/go.mod @@ -1,15 +1,15 @@ module github.com/gogf/gf/cmd/gf/v2 -go 1.20 +go 1.22 require ( - github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.8.3 - github.com/gogf/gf/contrib/drivers/mssql/v2 v2.8.3 - github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.3 - github.com/gogf/gf/contrib/drivers/oracle/v2 v2.8.3 - github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.8.3 - github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.8.3 - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.9.0-beta + github.com/gogf/gf/contrib/drivers/mssql/v2 v2.9.0-beta + github.com/gogf/gf/contrib/drivers/mysql/v2 v2.9.0-beta + github.com/gogf/gf/contrib/drivers/oracle/v2 v2.9.0-beta + github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.9.0-beta + github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0-beta github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f github.com/olekukonko/tablewriter v0.0.5 github.com/schollz/progressbar/v3 v3.15.0 @@ -48,10 +48,10 @@ require ( github.com/rivo/uniseg v0.4.7 // indirect github.com/shopspring/decimal v1.3.1 // indirect github.com/sijms/go-ora/v2 v2.7.10 // indirect - go.opentelemetry.io/otel v1.24.0 // indirect - go.opentelemetry.io/otel/metric v1.24.0 // indirect - go.opentelemetry.io/otel/sdk v1.24.0 // indirect - go.opentelemetry.io/otel/trace v1.24.0 // indirect + go.opentelemetry.io/otel v1.32.0 // indirect + go.opentelemetry.io/otel/metric v1.32.0 // indirect + go.opentelemetry.io/otel/sdk v1.32.0 // indirect + go.opentelemetry.io/otel/trace v1.32.0 // indirect golang.org/x/crypto v0.31.0 // indirect golang.org/x/net v0.33.0 // indirect golang.org/x/sync v0.10.0 // indirect diff --git a/cmd/gf/go.sum b/cmd/gf/go.sum index e29244f933b..f250a44e65a 100644 --- a/cmd/gf/go.sum +++ b/cmd/gf/go.sum @@ -1,11 +1,17 @@ aead.dev/minisign v0.2.0 h1:kAWrq/hBRu4AARY6AlciO83xhNnW9UaC8YipS2uhLPk= aead.dev/minisign v0.2.0/go.mod h1:zdq6LdSd9TbuSxchxwhpA9zEb9YXcVGoE8JakuiGaIQ= github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1 h1:lGlwhPtrX6EVml1hO0ivjkUxsSyl4dsiw9qcA1k/3IQ= +github.com/Azure/azure-sdk-for-go/sdk/azcore v1.9.1/go.mod h1:RKUqNu35KJYcVG/fqTRqmuXJZYNhYkBrnC/hX7yGbTA= github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1 h1:sO0/P7g68FrryJzljemN+6GTssUXdANk6aJ7T1ZxnsQ= +github.com/Azure/azure-sdk-for-go/sdk/azidentity v1.5.1/go.mod h1:h8hyGFDsU5HMivxiS2iYFZsgDbU9OnnJ163x5UGVKYo= github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1 h1:6oNBlSdi1QqM1PNW7FPA6xOGA5UNsXnkaYZz9vdPGhA= +github.com/Azure/azure-sdk-for-go/sdk/internal v1.5.1/go.mod h1:s4kgfzA0covAXNicZHDMN58jExvcng2mC/DepXiF1EI= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.1 h1:MyVTgWR8qd/Jw1Le0NZebGBUCLbtak3bJ3z1OlqZBpw= +github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/azkeys v1.0.1/go.mod h1:GpPjLhVR9dnUoJMyHWSPy71xY9/lcmpzIPZXmF0FCVY= github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.0.0 h1:D3occbWoio4EBLkbkevetNMAVX197GkzbUMtqjGWn80= +github.com/Azure/azure-sdk-for-go/sdk/security/keyvault/internal v1.0.0/go.mod h1:bTSOgj05NGRuHHhQwAdPnYr9TOdNmKlZTgGLL6nyAdI= github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1 h1:DzHpqpoJVaCgOUdVHxE8QB52S6NiVdDQvGlny1qvPqA= +github.com/AzureAD/microsoft-authentication-library-for-go v1.2.1/go.mod h1:wP83P5OoQ5p6ip3ScPr0BAq0BvuPAvacpEuSzyouqAI= github.com/BurntSushi/toml v1.4.0 h1:kuoIxZQy2WRRk1pttg9asf+WVv6tWQuBNVmK8+nqPr0= github.com/BurntSushi/toml v1.4.0/go.mod h1:ukJfTF/6rtPPRCnwkur4qwRxa8vTRFBF0uk2lLoLwho= github.com/ClickHouse/clickhouse-go v1.5.4/go.mod h1:EaI/sW7Azgz9UATzd5ZdZHRUhHgv5+JMS9NSr2smCJI= @@ -40,24 +46,11 @@ github.com/go-ole/go-ole v1.2.6/go.mod h1:pprOEPIfldk/42T2oK7lQ4v4JSDwmV0As9GaiU github.com/go-sql-driver/mysql v1.4.0/go.mod h1:zAC/RDZ24gD3HViQzih4MyKcchzm+sOG5ZlKdlhCg5w= github.com/go-sql-driver/mysql v1.7.1 h1:lUIinVbN1DY0xBg0eMOzmmtGoHwWBbvnWubQUrtU8EI= github.com/go-sql-driver/mysql v1.7.1/go.mod h1:OXbVy3sEdcQ2Doequ6Z5BW6fXNQTmx+9S1MCJN5yJMI= -github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.8.3 h1:b/AQMTxiHKPHsidEdk471AC5pkfoK88a5cPmKnzE53U= -github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.8.3/go.mod h1:qYrF+x5urXLhce3pMcUAyccIsw3Oec0htynoDE4Boi4= -github.com/gogf/gf/contrib/drivers/mssql/v2 v2.8.3 h1:F7Gt1y6YsYOIvgrUlRK07H29BL77dEgLPXilTqqVC80= -github.com/gogf/gf/contrib/drivers/mssql/v2 v2.8.3/go.mod h1:K5prIMZwHANSZrqZbfm6PoEIMfLtd0PwR7u+hZD9HFs= -github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.3 h1:RtoBg5HWACFrgIrFkpzH94kxSd5EWefNAq5k6olNY6c= -github.com/gogf/gf/contrib/drivers/mysql/v2 v2.8.3/go.mod h1:elZjckHRCejwml5Kdx2zfhOUDiAV3r5i4BgXcKAeH00= -github.com/gogf/gf/contrib/drivers/oracle/v2 v2.8.3 h1:10/RCoWmvQ6PSm+leoS6CsKijH4dB38HOXLgP5+aScQ= -github.com/gogf/gf/contrib/drivers/oracle/v2 v2.8.3/go.mod h1:XSaHf3/vTlzj/zioUbzKmaffPuoKvPV639fT91caheM= -github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.8.3 h1:DvpoiVac1cwGVDTqC6wzFbDb+gXNzcceRgZUIcuTmaI= -github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.8.3/go.mod h1:zugvYVb6c/X9rJ8Gb6b5WkMe+bFz2BsxQ5OLf4RSZos= -github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.8.3 h1:3pdibfm4UOiTGGh6UD8jfMyGZBGH9ikrrIMU8i/XANA= -github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.8.3/go.mod h1:G5rfcFkBhtmZT4+CU7A3fJH3sNmP4WRIaJ+4JFeVE08= -github.com/gogf/gf/v2 v2.8.3 h1:h9Px3lqJnnH6It0AqHRz4/1hx0JmvaSf1IvUir5x1rA= -github.com/gogf/gf/v2 v2.8.3/go.mod h1:n++xPYGUUMadw6IygLEgGZqc6y6DRLrJKg5kqCrPLWY= github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f h1:7xfXR/BhG3JDqO1s45n65Oyx9t4E/UqDOXep6jXdLCM= github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f/go.mod h1:HnYoio6S7VaFJdryKcD/r9HgX+4QzYfr00XiXUo/xz0= github.com/gogo/protobuf v1.3.2/go.mod h1:P1XiOD3dCwIKUDQYPy72D8LYyHL2YPYrpS2s69NZV8Q= github.com/golang-jwt/jwt/v5 v5.2.0 h1:d/ix8ftRUorsN+5eMIlF4T6J8CAt9rch3My2winC1Jw= +github.com/golang-jwt/jwt/v5 v5.2.0/go.mod h1:pqrtFR0X4osieyHYxtmOUWsAWrfe1Q5UVIyoH402zdk= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9 h1:au07oEsX2xN0ktxqI+Sida1w446QrXBRJ0nee3SNZlA= github.com/golang-sql/civil v0.0.0-20220223132316-b832511892a9/go.mod h1:8vg3r2VgvsThLBIFL93Qb5yWzgyZWhEmBwUJWevAkK0= github.com/golang-sql/sqlexp v0.1.0 h1:ZCD6MBpcuOVfGVqsEmY5/4FtYiKz6tSyUv9LPEDei6A= @@ -66,7 +59,9 @@ github.com/golang/protobuf v1.5.0/go.mod h1:FsONVRAS9T7sI+LIUmWTfcYkHO4aIWwzhcaS github.com/google/go-cmp v0.5.5/go.mod h1:v8dTdLbMG2kIc/vJvl+f65V22dbkXbowE6jgT/gNBxE= github.com/google/go-cmp v0.5.7/go.mod h1:n+brtR0CgQNWTVd5ZUFpTBC8YFBDLK/h/bpaJ8/DtOE= github.com/google/go-cmp v0.6.0 h1:ofyhxvXcZhMsU5ulbFiLKl/XBFqE1GSq7atu8tAmTRI= +github.com/google/go-cmp v0.6.0/go.mod h1:17dUlkBOakJ0+DkrSSNjCkIjxS6bF9zb3elmeNGIjoY= github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26 h1:Xim43kblpZXfIBQsbuBVKCudVG457BR2GZFIz3uw3hQ= +github.com/google/pprof v0.0.0-20221118152302-e6195bd50e26/go.mod h1:dDKJzRmX4S37WGHujM7tX//fmj1uioxKzKxz3lo4HJo= github.com/google/uuid v1.3.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0= github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo= @@ -80,7 +75,12 @@ github.com/jmoiron/sqlx v1.2.0/go.mod h1:1FEQNm3xlJgrMD+FBdI9+xvCksHtbpVBBw5dYhB github.com/k0kubun/go-ansi v0.0.0-20180517002512-3bf9e2903213/go.mod h1:vNUNkEQ1e29fT/6vq2aBdFsgNPmy8qMdSay1npru+Sw= github.com/kisielk/errcheck v1.5.0/go.mod h1:pFxgyoBC7bSaBwPgfKdkLd5X25qrDl4LWUI2bnpBCr8= github.com/kisielk/gotool v1.0.0/go.mod h1:XhKaO+MFFWcvkIS/tQcRk01m1F5IRFswLeQ+oQHNcck= +github.com/kr/pretty v0.3.1 h1:flRD4NNwYAUpkphVc1HcthR4KEIFJ65n8Mw5qdRn3LE= +github.com/kr/pretty v0.3.1/go.mod h1:hoEshYVHaxMs3cyo3Yncou5ZscifuDolrwPKZanG3xk= +github.com/kr/text v0.2.0 h1:5Nx0Ya0ZqY2ygV366QzturHI13Jq95ApcVaJBhpS+AY= +github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE= github.com/kylelemons/godebug v1.1.0 h1:RPNrshWIDI6G2gRW9EHilWtl7Z6Sb1BR0xunSBf0SNc= +github.com/kylelemons/godebug v1.1.0/go.mod h1:9/0rRGxNHcop5bhtWyNeEfOS8JIWk580+fNqagV/RAw= github.com/lib/pq v1.0.0/go.mod h1:5WUZQaWbwv1U+lTReE5YruASi9Al49XbQIvNi/34Woo= github.com/lib/pq v1.10.9 h1:YXG7RB+JIjhP29X+OtkiDnYaXQwpS4JEWq7dtCCRUEw= github.com/lib/pq v1.10.9/go.mod h1:AlVN5x4E4T544tWzH6hKfbfQvm3HdbOxrmggDNAPY9o= @@ -109,6 +109,7 @@ github.com/pierrec/lz4 v2.0.5+incompatible/go.mod h1:pdkljMzZIN41W+lC3N2tnIh5sFi github.com/pierrec/lz4/v4 v4.1.14 h1:+fL8AQEZtz/ijeNnpduH0bROTu0O3NZAlPjQxGn8LwE= github.com/pierrec/lz4/v4 v4.1.14/go.mod h1:gZWDp/Ze/IJXGXf23ltt2EXimqmTUXEy0GFuRQyBid4= github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c h1:+mdjkGKdHQG3305AYmdv1U2eRNDiU2ErMBj1gwrq8eQ= +github.com/pkg/browser v0.0.0-20240102092130-5ac0b6a4141c/go.mod h1:7rwL4CYBLnjLxUqIJNnCWiEdr3bn6IUYi15bNlnbCCU= github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM= github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= github.com/remyoudompheng/bigfft v0.0.0-20200410134404-eec4a21b6bb0/go.mod h1:qqbHyh8v60DhA7CoWK5oRCqLrMHRGoxYCSS9EjAz6Eo= @@ -117,6 +118,8 @@ github.com/remyoudompheng/bigfft v0.0.0-20230129092748-24d4a6f8daec/go.mod h1:qq github.com/rivo/uniseg v0.2.0/go.mod h1:J6wj4VEh+S6ZtnVlnTBMWIodfgj8LQOQFoIToxlJtxc= github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/rivo/uniseg v0.4.7/go.mod h1:FN3SvrM+Zdj16jyLfmOkMNblXMcoc8DfTHruCPUcx88= +github.com/rogpeppe/go-internal v1.13.1 h1:KvO1DLK/DRN07sQ1LQKScxyZJuNnedQ5/wKSR38lUII= +github.com/rogpeppe/go-internal v1.13.1/go.mod h1:uMEvuHeurkdAXX61udpOXGD/AzZDWNMNyH2VO9fmH0o= github.com/schollz/progressbar/v3 v3.15.0 h1:cNZmcNiVyea6oofBTg80ZhVXxf3wG/JoAhqCCwopkQo= github.com/schollz/progressbar/v3 v3.15.0/go.mod h1:ncBdc++eweU0dQoeZJ3loXoAc+bjaallHRIm8pVVeQM= github.com/shirou/gopsutil v2.19.11+incompatible/go.mod h1:5b4v6he4MtMOwMlS0TUMTu2PcXUg8+E1lC7eC3UO/RA= @@ -131,22 +134,23 @@ github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UV github.com/stretchr/testify v1.4.0/go.mod h1:j7eGeouHqKxXV5pUuKE4zz7dFj8WfuZ+81PSLYec5m4= github.com/stretchr/testify v1.7.1/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg= github.com/stretchr/testify v1.7.2/go.mod h1:R6va5+xMeoiuVRoj+gSkQ7d3FALtqAAGI1FQKckRals= -github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= +github.com/stretchr/testify v1.10.0 h1:Xv5erBjTwe/5IxqUQTdXv5kgmIvbHo3QQyRwhJsOfJA= +github.com/stretchr/testify v1.10.0/go.mod h1:r2ic/lqez/lEtzL7wO/rwa5dbSLXVDPFyf8C91i36aY= github.com/tklauser/go-sysconf v0.3.10/go.mod h1:C8XykCvCb+Gn0oNCWPIlcb0RuglQTYaQ2hGm7jmxEFk= github.com/tklauser/numcpus v0.4.0/go.mod h1:1+UI3pD8NW14VMwdgJNJ1ESk2UnwhAnz5hMwiKKqXCQ= github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74= github.com/yusufpapurcu/wmi v1.2.2/go.mod h1:SBZ9tNy3G9/m5Oi98Zks0QjeHVDvuK0qfxQmPyzfmi0= go.opentelemetry.io/otel v1.7.0/go.mod h1:5BdUoMIz5WEs0vt0CUEMtSSaTSHBBVwrhnz7+nrD5xk= -go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= -go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= -go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= -go.opentelemetry.io/otel/metric v1.24.0/go.mod h1:VYhLe1rFfxuTXLgj4CBiyz+9WYBA8pNGJgDcSFRKBco= -go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= -go.opentelemetry.io/otel/sdk v1.24.0/go.mod h1:KVrIYw6tEubO9E96HQpcmpTKDVn9gdv35HoYiQWGDFg= +go.opentelemetry.io/otel v1.32.0 h1:WnBN+Xjcteh0zdk01SVqV55d/m62NJLJdIyb4y/WO5U= +go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= +go.opentelemetry.io/otel/metric v1.32.0 h1:xV2umtmNcThh2/a/aCP+h64Xx5wsj8qqnkYZktzNa0M= +go.opentelemetry.io/otel/metric v1.32.0/go.mod h1:jH7CIbbK6SH2V2wE16W05BHCtIDzauciCRLoc/SyMv8= +go.opentelemetry.io/otel/sdk v1.32.0 h1:RNxepc9vK59A8XsgZQouW8ue8Gkb4jpWtJm9ge5lEG4= +go.opentelemetry.io/otel/sdk v1.32.0/go.mod h1:LqgegDBjKMmb2GC6/PrTnteJG39I8/vJCAP9LlJXEjU= go.opentelemetry.io/otel/trace v1.7.0/go.mod h1:fzLSB9nqR2eXzxPXb2JW9IKE+ScyXA48yyE4TNvoHqU= -go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= -go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +go.opentelemetry.io/otel/trace v1.32.0 h1:WIC9mYrXf8TmY/EXuULKc8hR17vE+Hjv2cssQDe03fM= +go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w= golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI= golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto= @@ -202,8 +206,9 @@ golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8T golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= google.golang.org/protobuf v1.26.0-rc.1/go.mod h1:jlhhOSvTdKEhbULTjvd4ARK9grFBp09yW+WbY/TyQbw= google.golang.org/protobuf v1.27.1/go.mod h1:9q0QmTI4eRPtz6boOQmLYwt+qCgq0jsYwAQnmE0givc= -gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM= gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c h1:Hei/4ADfdWqJk1ZMxUNpqntNwaWcugrBjAiHlqqRiVk= +gopkg.in/check.v1 v1.0.0-20201130134442-10cb98267c6c/go.mod h1:JHkPIbrfpd72SG/EVd6muEfDQjcINNoR0C8j2r3qZ4Q= gopkg.in/yaml.v2 v2.2.2/go.mod h1:hI93XBmqTisBFMUTm0b8Fm+jr3Dg1NNxqwp+5A1VGuI= gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM= gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA= diff --git a/cmd/gf/go.work b/cmd/gf/go.work index 19bee584aad..32a45696a9b 100644 --- a/cmd/gf/go.work +++ b/cmd/gf/go.work @@ -1,4 +1,4 @@ -go 1.20 +go 1.22 use ( ./ diff --git a/contrib/config/apollo/go.mod b/contrib/config/apollo/go.mod index 5c8aa52f773..be2ef8f5357 100644 --- a/contrib/config/apollo/go.mod +++ b/contrib/config/apollo/go.mod @@ -2,11 +2,9 @@ module github.com/gogf/gf/contrib/config/apollo/v2 go 1.22 -toolchain go1.22.0 - require ( github.com/apolloconfig/agollo/v4 v4.3.1 - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta ) require ( diff --git a/contrib/config/consul/go.mod b/contrib/config/consul/go.mod index b59d1c85691..53212a7513b 100644 --- a/contrib/config/consul/go.mod +++ b/contrib/config/consul/go.mod @@ -2,10 +2,8 @@ module github.com/gogf/gf/contrib/config/consul/v2 go 1.22 -toolchain go1.22.0 - require ( - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta github.com/hashicorp/consul/api v1.24.0 github.com/hashicorp/go-cleanhttp v0.5.2 ) diff --git a/contrib/config/kubecm/go.mod b/contrib/config/kubecm/go.mod index e21e6e46d36..2c0b5f09ad6 100644 --- a/contrib/config/kubecm/go.mod +++ b/contrib/config/kubecm/go.mod @@ -2,10 +2,8 @@ module github.com/gogf/gf/contrib/config/kubecm/v2 go 1.22 -toolchain go1.22.0 - require ( - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta k8s.io/api v0.27.4 k8s.io/apimachinery v0.27.4 k8s.io/client-go v0.27.4 diff --git a/contrib/config/nacos/go.mod b/contrib/config/nacos/go.mod index beb5ce58eb1..31b3b6b748e 100644 --- a/contrib/config/nacos/go.mod +++ b/contrib/config/nacos/go.mod @@ -2,10 +2,8 @@ module github.com/gogf/gf/contrib/config/nacos/v2 go 1.22 -toolchain go1.22.0 - require ( - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta github.com/nacos-group/nacos-sdk-go/v2 v2.2.5 ) diff --git a/contrib/config/polaris/go.mod b/contrib/config/polaris/go.mod index 0d11a9bed82..e1d0e95d232 100644 --- a/contrib/config/polaris/go.mod +++ b/contrib/config/polaris/go.mod @@ -2,10 +2,8 @@ module github.com/gogf/gf/contrib/config/polaris/v2 go 1.22 -toolchain go1.22.0 - require ( - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta github.com/polarismesh/polaris-go v1.5.8 ) diff --git a/contrib/drivers/clickhouse/go.mod b/contrib/drivers/clickhouse/go.mod index 06b84525680..5b708024945 100644 --- a/contrib/drivers/clickhouse/go.mod +++ b/contrib/drivers/clickhouse/go.mod @@ -2,11 +2,9 @@ module github.com/gogf/gf/contrib/drivers/clickhouse/v2 go 1.22 -toolchain go1.22.0 - require ( github.com/ClickHouse/clickhouse-go/v2 v2.0.15 - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta github.com/google/uuid v1.6.0 github.com/shopspring/decimal v1.3.1 ) diff --git a/contrib/drivers/dm/go.mod b/contrib/drivers/dm/go.mod index 5182d9399af..c3b1efc7782 100644 --- a/contrib/drivers/dm/go.mod +++ b/contrib/drivers/dm/go.mod @@ -2,13 +2,11 @@ module github.com/gogf/gf/contrib/drivers/dm/v2 go 1.22 -toolchain go1.22.0 - replace github.com/gogf/gf/v2 => ../../../ require ( gitee.com/chunanyong/dm v1.8.12 - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta ) require ( diff --git a/contrib/drivers/mssql/go.mod b/contrib/drivers/mssql/go.mod index 80b7e8a0bbb..7bb9d011db7 100644 --- a/contrib/drivers/mssql/go.mod +++ b/contrib/drivers/mssql/go.mod @@ -2,10 +2,8 @@ module github.com/gogf/gf/contrib/drivers/mssql/v2 go 1.22 -toolchain go1.22.0 - require ( - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta github.com/microsoft/go-mssqldb v1.7.1 ) diff --git a/contrib/drivers/mysql/go.mod b/contrib/drivers/mysql/go.mod index 39f0c0f60d4..330074afb94 100644 --- a/contrib/drivers/mysql/go.mod +++ b/contrib/drivers/mysql/go.mod @@ -2,11 +2,9 @@ module github.com/gogf/gf/contrib/drivers/mysql/v2 go 1.22 -toolchain go1.22.0 - require ( github.com/go-sql-driver/mysql v1.7.1 - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta ) require ( diff --git a/contrib/drivers/oracle/go.mod b/contrib/drivers/oracle/go.mod index 39bb2f25971..845f18ec40e 100644 --- a/contrib/drivers/oracle/go.mod +++ b/contrib/drivers/oracle/go.mod @@ -2,10 +2,8 @@ module github.com/gogf/gf/contrib/drivers/oracle/v2 go 1.22 -toolchain go1.22.0 - require ( - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta github.com/sijms/go-ora/v2 v2.7.10 ) diff --git a/contrib/drivers/pgsql/go.mod b/contrib/drivers/pgsql/go.mod index edbfa4ea18c..4bfa51c0c05 100644 --- a/contrib/drivers/pgsql/go.mod +++ b/contrib/drivers/pgsql/go.mod @@ -2,10 +2,8 @@ module github.com/gogf/gf/contrib/drivers/pgsql/v2 go 1.22 -toolchain go1.22.0 - require ( - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta github.com/lib/pq v1.10.9 ) diff --git a/contrib/drivers/sqlite/go.mod b/contrib/drivers/sqlite/go.mod index 60f434a7242..51bd021b368 100644 --- a/contrib/drivers/sqlite/go.mod +++ b/contrib/drivers/sqlite/go.mod @@ -2,11 +2,9 @@ module github.com/gogf/gf/contrib/drivers/sqlite/v2 go 1.22 -toolchain go1.22.0 - require ( github.com/glebarez/go-sqlite v1.21.2 - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta ) require ( diff --git a/contrib/drivers/sqlitecgo/go.mod b/contrib/drivers/sqlitecgo/go.mod index b806153942a..8b30e68555c 100644 --- a/contrib/drivers/sqlitecgo/go.mod +++ b/contrib/drivers/sqlitecgo/go.mod @@ -2,10 +2,8 @@ module github.com/gogf/gf/contrib/drivers/sqlitecgo/v2 go 1.22 -toolchain go1.22.0 - require ( - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta github.com/mattn/go-sqlite3 v1.14.17 ) diff --git a/contrib/metric/otelmetric/go.mod b/contrib/metric/otelmetric/go.mod index f9c8a27466e..4c0fabb57ac 100644 --- a/contrib/metric/otelmetric/go.mod +++ b/contrib/metric/otelmetric/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/metric/otelmetric/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta github.com/prometheus/client_golang v1.19.1 go.opentelemetry.io/contrib/instrumentation/runtime v0.49.0 go.opentelemetry.io/otel v1.32.0 diff --git a/contrib/nosql/redis/go.mod b/contrib/nosql/redis/go.mod index aede72deca0..3ff89b71777 100644 --- a/contrib/nosql/redis/go.mod +++ b/contrib/nosql/redis/go.mod @@ -2,10 +2,8 @@ module github.com/gogf/gf/contrib/nosql/redis/v2 go 1.22 -toolchain go1.22.0 - require ( - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta github.com/redis/go-redis/v9 v9.7.0 go.opentelemetry.io/otel v1.32.0 go.opentelemetry.io/otel/trace v1.32.0 diff --git a/contrib/registry/consul/go.mod b/contrib/registry/consul/go.mod index 2c44f517087..d1cce99324e 100644 --- a/contrib/registry/consul/go.mod +++ b/contrib/registry/consul/go.mod @@ -2,10 +2,8 @@ module github.com/gogf/gf/contrib/registry/consul/v2 go 1.22 -toolchain go1.22.0 - require ( - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta github.com/hashicorp/consul/api v1.26.1 ) diff --git a/contrib/registry/etcd/go.mod b/contrib/registry/etcd/go.mod index 8b7dacc217d..0ee6e218b50 100644 --- a/contrib/registry/etcd/go.mod +++ b/contrib/registry/etcd/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/etcd/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta go.etcd.io/etcd/client/v3 v3.5.17 google.golang.org/grpc v1.59.0 ) diff --git a/contrib/registry/file/go.mod b/contrib/registry/file/go.mod index d2533732fa6..c5a61244fbb 100644 --- a/contrib/registry/file/go.mod +++ b/contrib/registry/file/go.mod @@ -2,9 +2,7 @@ module github.com/gogf/gf/contrib/registry/file/v2 go 1.22 -toolchain go1.22.0 - -require github.com/gogf/gf/v2 v2.8.3 +require github.com/gogf/gf/v2 v2.9.0-beta require ( github.com/BurntSushi/toml v1.4.0 // indirect diff --git a/contrib/registry/nacos/go.mod b/contrib/registry/nacos/go.mod index 768b3aa447b..4b9e42d19dc 100644 --- a/contrib/registry/nacos/go.mod +++ b/contrib/registry/nacos/go.mod @@ -2,10 +2,8 @@ module github.com/gogf/gf/contrib/registry/nacos/v2 go 1.22 -toolchain go1.22.0 - require ( - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta github.com/nacos-group/nacos-sdk-go/v2 v2.2.7 ) diff --git a/contrib/registry/polaris/go.mod b/contrib/registry/polaris/go.mod index cc7ac6c19d7..b4415b6e15c 100644 --- a/contrib/registry/polaris/go.mod +++ b/contrib/registry/polaris/go.mod @@ -2,10 +2,8 @@ module github.com/gogf/gf/contrib/registry/polaris/v2 go 1.22 -toolchain go1.22.0 - require ( - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta github.com/polarismesh/polaris-go v1.5.8 ) diff --git a/contrib/registry/zookeeper/go.mod b/contrib/registry/zookeeper/go.mod index 7f1f3466c22..15908c239ee 100644 --- a/contrib/registry/zookeeper/go.mod +++ b/contrib/registry/zookeeper/go.mod @@ -2,11 +2,9 @@ module github.com/gogf/gf/contrib/registry/zookeeper/v2 go 1.22 -toolchain go1.22.0 - require ( github.com/go-zookeeper/zk v1.0.3 - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta golang.org/x/sync v0.10.0 ) diff --git a/contrib/rpc/grpcx/go.mod b/contrib/rpc/grpcx/go.mod index 9d9705297c2..72919a9d20f 100644 --- a/contrib/rpc/grpcx/go.mod +++ b/contrib/rpc/grpcx/go.mod @@ -2,11 +2,9 @@ module github.com/gogf/gf/contrib/rpc/grpcx/v2 go 1.22 -toolchain go1.22.0 - require ( - github.com/gogf/gf/contrib/registry/file/v2 v2.8.3 - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/contrib/registry/file/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0-beta go.opentelemetry.io/otel v1.32.0 go.opentelemetry.io/otel/trace v1.32.0 google.golang.org/grpc v1.64.1 diff --git a/contrib/sdk/httpclient/go.mod b/contrib/sdk/httpclient/go.mod index e2abac29eb4..5dfb326fff3 100644 --- a/contrib/sdk/httpclient/go.mod +++ b/contrib/sdk/httpclient/go.mod @@ -2,9 +2,7 @@ module github.com/gogf/gf/contrib/sdk/httpclient/v2 go 1.22 -toolchain go1.22.0 - -require github.com/gogf/gf/v2 v2.8.3 +require github.com/gogf/gf/v2 v2.9.0-beta require ( github.com/BurntSushi/toml v1.4.0 // indirect diff --git a/contrib/trace/otlpgrpc/go.mod b/contrib/trace/otlpgrpc/go.mod index 7e77a80f1d0..29d16faefc7 100644 --- a/contrib/trace/otlpgrpc/go.mod +++ b/contrib/trace/otlpgrpc/go.mod @@ -2,10 +2,8 @@ module github.com/gogf/gf/contrib/trace/otlpgrpc/v2 go 1.22 -toolchain go1.22.0 - require ( - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta go.opentelemetry.io/otel v1.32.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 diff --git a/contrib/trace/otlphttp/go.mod b/contrib/trace/otlphttp/go.mod index 6d7038d4f60..616865c314c 100644 --- a/contrib/trace/otlphttp/go.mod +++ b/contrib/trace/otlphttp/go.mod @@ -2,10 +2,8 @@ module github.com/gogf/gf/contrib/trace/otlphttp/v2 go 1.22 -toolchain go1.22.0 - require ( - github.com/gogf/gf/v2 v2.8.3 + github.com/gogf/gf/v2 v2.9.0-beta go.opentelemetry.io/otel v1.32.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 diff --git a/version.go b/version.go index f27c3be0482..34f3242801e 100644 --- a/version.go +++ b/version.go @@ -2,5 +2,5 @@ package gf const ( // VERSION is the current GoFrame version. - VERSION = "v2.8.3" + VERSION = "v2.9.0-beta" ) From bb696bb2817e6af945c51834d33a80e2e4a911d0 Mon Sep 17 00:00:00 2001 From: John Guo Date: Wed, 12 Mar 2025 21:55:35 +0800 Subject: [PATCH 097/102] refract(net/ghttp): move `Request.GetMetaTag` to `HandlerItemParsed.GetMetaTag` (#4191) --- net/ghttp/ghttp_request.go | 33 --------------- net/ghttp/ghttp_request_param_handler.go | 41 +++++++++++++++++++ net/ghttp/ghttp_server_router_serve.go | 4 +- .../ghttp_z_unit_feature_request_test.go | 5 ++- 4 files changed, 46 insertions(+), 37 deletions(-) create mode 100644 net/ghttp/ghttp_request_param_handler.go diff --git a/net/ghttp/ghttp_request.go b/net/ghttp/ghttp_request.go index 30690448710..e17857f44d8 100644 --- a/net/ghttp/ghttp_request.go +++ b/net/ghttp/ghttp_request.go @@ -19,7 +19,6 @@ import ( "github.com/gogf/gf/v2/os/gview" "github.com/gogf/gf/v2/text/gregex" "github.com/gogf/gf/v2/text/gstr" - "github.com/gogf/gf/v2/util/gmeta" "github.com/gogf/gf/v2/util/guid" ) @@ -279,35 +278,3 @@ func (r *Request) ReloadParam() { r.parsedQuery = false r.bodyContent = nil } - -// GetHandlerResponse retrieves and returns the handler response object and its error. -func (r *Request) GetHandlerResponse() interface{} { - return r.handlerResponse -} - -// GetServeHandler retrieves and returns the user defined handler used to serve this request. -func (r *Request) GetServeHandler() *HandlerItemParsed { - return r.serveHandler -} - -// GetMetaTag retrieves and returns the metadata value associated with the given key from the request struct. -// The meta value is from struct tags from g.Meta/gmeta.Meta type. -// For example: -// -// type GetMetaTagReq struct { -// g.Meta `path:"/test" method:"post" summary:"meta_tag" tags:"meta"` -// // ... -// } -// -// r.GetMetaTag("summary") // returns "meta_tag" -// r.GetMetaTag("method") // returns "post" -func (r *Request) GetMetaTag(key string) string { - if r.serveHandler == nil || r.serveHandler.Handler == nil { - return "" - } - metaValue := gmeta.Get(r.serveHandler.Handler.Info.Type.In(1), key) - if metaValue != nil { - return metaValue.String() - } - return "" -} diff --git a/net/ghttp/ghttp_request_param_handler.go b/net/ghttp/ghttp_request_param_handler.go new file mode 100644 index 00000000000..f931d14e45a --- /dev/null +++ b/net/ghttp/ghttp_request_param_handler.go @@ -0,0 +1,41 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + +package ghttp + +import "github.com/gogf/gf/v2/util/gmeta" + +// GetHandlerResponse retrieves and returns the handler response object and its error. +func (r *Request) GetHandlerResponse() interface{} { + return r.handlerResponse +} + +// GetServeHandler retrieves and returns the user defined handler used to serve this request. +func (r *Request) GetServeHandler() *HandlerItemParsed { + return r.serveHandler +} + +// GetMetaTag retrieves and returns the metadata value associated with the given key from the request struct. +// The meta value is from struct tags from g.Meta/gmeta.Meta type. +// For example: +// +// type GetMetaTagReq struct { +// g.Meta `path:"/test" method:"post" summary:"meta_tag" tags:"meta"` +// // ... +// } +// +// r.GetServeHandler().GetMetaTag("summary") // returns "meta_tag" +// r.GetServeHandler().GetMetaTag("method") // returns "post" +func (h *HandlerItemParsed) GetMetaTag(key string) string { + if h == nil || h.Handler == nil { + return "" + } + metaValue := gmeta.Get(h.Handler.Info.Type.In(1), key) + if metaValue != nil { + return metaValue.String() + } + return "" +} diff --git a/net/ghttp/ghttp_server_router_serve.go b/net/ghttp/ghttp_server_router_serve.go index a4297414d81..e9e6d9d489b 100644 --- a/net/ghttp/ghttp_server_router_serve.go +++ b/net/ghttp/ghttp_server_router_serve.go @@ -286,6 +286,6 @@ func (item HandlerItem) MarshalJSON() ([]byte, error) { } // MarshalJSON implements the interface MarshalJSON for json.Marshal. -func (item HandlerItemParsed) MarshalJSON() ([]byte, error) { - return json.Marshal(item.Handler) +func (h *HandlerItemParsed) MarshalJSON() ([]byte, error) { + return json.Marshal(h.Handler) } diff --git a/net/ghttp/ghttp_z_unit_feature_request_test.go b/net/ghttp/ghttp_z_unit_feature_request_test.go index 1d08b19dd43..bc60d8f508c 100644 --- a/net/ghttp/ghttp_z_unit_feature_request_test.go +++ b/net/ghttp/ghttp_z_unit_feature_request_test.go @@ -875,12 +875,13 @@ func (r GetMetaTagSt) PostTest(ctx context.Context, req *GetMetaTagReq) (*GetMet return &GetMetaTagRes{}, nil } -func TestRequest_GetMetaTag(t *testing.T) { +func TestRequest_GetServeHandler_GetMetaTag(t *testing.T) { s := g.Server(guid.S()) s.Use(func(r *ghttp.Request) { r.Response.Writef( "summary:%s,method:%s", - r.GetMetaTag("summary"), r.GetMetaTag("method"), + r.GetServeHandler().GetMetaTag("summary"), + r.GetServeHandler().GetMetaTag("method"), ) }) s.Group("/", func(grp *ghttp.RouterGroup) { From bc1e1019c57334bf91254cb3d43b0cdb23100802 Mon Sep 17 00:00:00 2001 From: John Guo Date: Fri, 14 Mar 2025 18:23:07 +0800 Subject: [PATCH 098/102] refract(util/gconv): change `Converter` interface definition for more convenient usage (#4202) --- .github/workflows/issue-check-inactive.yml | 2 +- .gitignore | 1 + database/gdb/gdb_type_result.go | 9 +- examples | 2 +- ...ghttp_z_unit_feature_request_param_test.go | 6 + util/gconv/gconv.go | 52 +++++---- util/gconv/gconv_maps.go | 14 ++- util/gconv/gconv_structs.go | 15 ++- util/gconv/gconv_z_unit_converter_test.go | 69 ++++++++++++ util/gconv/gconv_z_unit_map_test.go | 2 +- .../internal/converter/converter_convert.go | 104 ++++++++++++++---- .../gconv/internal/converter/converter_map.go | 24 ++-- .../internal/converter/converter_maptomap.go | 15 +-- .../internal/converter/converter_maptomaps.go | 6 +- .../internal/converter/converter_scan.go | 47 +++++--- .../internal/converter/converter_slice_any.go | 9 +- .../converter/converter_slice_float.go | 92 ++++++++-------- .../internal/converter/converter_slice_int.go | 85 +++++++------- .../internal/converter/converter_slice_map.go | 22 +++- .../internal/converter/converter_slice_str.go | 45 ++++---- .../converter/converter_slice_uint.go | 85 +++++++------- .../internal/converter/converter_struct.go | 28 +++-- .../internal/converter/converter_structs.go | 35 ++++-- .../gconv/internal/structcache/structcache.go | 36 ++++-- 24 files changed, 528 insertions(+), 277 deletions(-) diff --git a/.github/workflows/issue-check-inactive.yml b/.github/workflows/issue-check-inactive.yml index 4b16b4f9a80..274f86d45fe 100644 --- a/.github/workflows/issue-check-inactive.yml +++ b/.github/workflows/issue-check-inactive.yml @@ -23,6 +23,6 @@ jobs: with: actions: 'check-inactive' inactive-label: 'inactive' - inactive-day: 7 + inactive-day: 30 issue-state: open exclude-labels: 'bug,planned,$exclude-empty' \ No newline at end of file diff --git a/.gitignore b/.gitignore index d18d5fc4aee..bc6df0d61c2 100644 --- a/.gitignore +++ b/.gitignore @@ -23,3 +23,4 @@ go.work.sum node_modules .docusaurus output +.example/ \ No newline at end of file diff --git a/database/gdb/gdb_type_result.go b/database/gdb/gdb_type_result.go index 8c02d828c8c..e1bff6184cc 100644 --- a/database/gdb/gdb_type_result.go +++ b/database/gdb/gdb_type_result.go @@ -201,11 +201,14 @@ func (r Result) Structs(pointer interface{}) (err error) { return nil } var ( - sliceOption = gconv.SliceOption{ContinueOnError: true} - mapOption = gconv.StructOption{ + sliceOption = gconv.SliceOption{ContinueOnError: true} + structOption = gconv.StructOption{ PriorityTag: OrmTagForStruct, ContinueOnError: true, } ) - return converter.Structs(r, pointer, sliceOption, mapOption) + return converter.Structs(r, pointer, gconv.StructsOption{ + SliceOption: sliceOption, + StructOption: structOption, + }) } diff --git a/examples b/examples index bf0ab5ac16f..b57e4575ce9 160000 --- a/examples +++ b/examples @@ -1 +1 @@ -Subproject commit bf0ab5ac16fbf654fc424baf45e96e541a037cb3 +Subproject commit b57e4575ce971e6a6e581b1de0e77eccf61705c4 diff --git a/net/ghttp/ghttp_z_unit_feature_request_param_test.go b/net/ghttp/ghttp_z_unit_feature_request_param_test.go index 3b9000c7469..041886225a6 100644 --- a/net/ghttp/ghttp_z_unit_feature_request_param_test.go +++ b/net/ghttp/ghttp_z_unit_feature_request_param_test.go @@ -1,3 +1,9 @@ +// Copyright GoFrame Author(https://goframe.org). All Rights Reserved. +// +// This Source Code Form is subject to the terms of the MIT License. +// If a copy of the MIT was not distributed with this file, +// You can obtain one at https://github.com/gogf/gf. + package ghttp_test import ( diff --git a/util/gconv/gconv.go b/util/gconv/gconv.go index 38302b1e3cf..20e2cb844c5 100644 --- a/util/gconv/gconv.go +++ b/util/gconv/gconv.go @@ -35,7 +35,7 @@ type Converter interface { // ConverterForBasic is the basic converting interface. type ConverterForBasic interface { - Scan(srcValue, dstPointer any, option ScanOption) (err error) + Scan(srcValue, dstPointer any, option ...ScanOption) (err error) String(any any) (string, error) Bool(any any) (bool, error) Rune(any any) (rune, error) @@ -74,37 +74,37 @@ type ConverterForFloat interface { // ConverterForMap is the converting interface for map. type ConverterForMap interface { - Map(v any, option MapOption) (map[string]any, error) - MapStrStr(v any, option MapOption) (map[string]string, error) + Map(v any, option ...MapOption) (map[string]any, error) + MapStrStr(v any, option ...MapOption) (map[string]string, error) } // ConverterForSlice is the converting interface for slice. type ConverterForSlice interface { Bytes(v any) ([]byte, error) Runes(v any) ([]rune, error) - SliceAny(v any, option SliceOption) ([]any, error) - SliceFloat32(v any, option SliceOption) ([]float32, error) - SliceFloat64(v any, option SliceOption) ([]float64, error) - SliceInt(v any, option SliceOption) ([]int, error) - SliceInt32(v any, option SliceOption) ([]int32, error) - SliceInt64(v any, option SliceOption) ([]int64, error) - SliceUint(v any, option SliceOption) ([]uint, error) - SliceUint32(v any, option SliceOption) ([]uint32, error) - SliceUint64(v any, option SliceOption) ([]uint64, error) - SliceStr(v any, option SliceOption) ([]string, error) - SliceMap(v any, sliceOption SliceOption, mapOption MapOption) ([]map[string]any, error) + SliceAny(v any, option ...SliceOption) ([]any, error) + SliceFloat32(v any, option ...SliceOption) ([]float32, error) + SliceFloat64(v any, option ...SliceOption) ([]float64, error) + SliceInt(v any, option ...SliceOption) ([]int, error) + SliceInt32(v any, option ...SliceOption) ([]int32, error) + SliceInt64(v any, option ...SliceOption) ([]int64, error) + SliceUint(v any, option ...SliceOption) ([]uint, error) + SliceUint32(v any, option ...SliceOption) ([]uint32, error) + SliceUint64(v any, option ...SliceOption) ([]uint64, error) + SliceStr(v any, option ...SliceOption) ([]string, error) + SliceMap(v any, option ...SliceMapOption) ([]map[string]any, error) } // ConverterForStruct is the converting interface for struct. type ConverterForStruct interface { - Struct(params, pointer any, option StructOption) (err error) - Structs(params, pointer any, sliceOption SliceOption, structOption StructOption) (err error) + Struct(params, pointer any, option ...StructOption) (err error) + Structs(params, pointer any, option ...StructsOption) (err error) } // ConverterForConvert is the converting interface for custom converting. type ConverterForConvert interface { - ConvertWithRefer(fromValue, referValue any, option ConvertOption) (any, error) - ConvertWithTypeName(fromValue any, toTypeName string, option ConvertOption) (any, error) + ConvertWithRefer(fromValue, referValue any, option ...ConvertOption) (any, error) + ConvertWithTypeName(fromValue any, toTypeName string, option ...ConvertOption) (any, error) } // ConverterForRegister is the converting interface for custom converter registration. @@ -123,12 +123,18 @@ type ( // SliceOption is the option for Slice type converting. SliceOption = converter.SliceOption + // SliceMapOption is the option for SliceMap function. + SliceMapOption = converter.SliceMapOption + // ScanOption is the option for the Scan function. ScanOption = converter.ScanOption // StructOption is the option for Struct converting. StructOption = converter.StructOption + // StructsOption is the option for Structs function. + StructsOption = converter.StructsOption + // ConvertOption is the option for converting. ConvertOption = converter.ConvertOption ) @@ -142,11 +148,6 @@ var ( defaultConverter = converter.NewConverter() ) -// RegisterAnyConverterFunc registers custom type converting function for specified type. -func RegisterAnyConverterFunc(f AnyConvertFunc, types ...reflect.Type) { - defaultConverter.RegisterAnyConverterFunc(f, types...) -} - // NewConverter creates and returns management object for type converting. func NewConverter() Converter { return converter.NewConverter() @@ -162,3 +163,8 @@ func RegisterConverter(fn any) (err error) { func RegisterTypeConverterFunc(fn any) (err error) { return defaultConverter.RegisterTypeConverterFunc(fn) } + +// RegisterAnyConverterFunc registers custom type converting function for specified type. +func RegisterAnyConverterFunc(f AnyConvertFunc, types ...reflect.Type) { + defaultConverter.RegisterAnyConverterFunc(f, types...) +} diff --git a/util/gconv/gconv_maps.go b/util/gconv/gconv_maps.go index b2d57499458..6b3a237a22b 100644 --- a/util/gconv/gconv_maps.go +++ b/util/gconv/gconv_maps.go @@ -6,7 +6,10 @@ package gconv -import "github.com/gogf/gf/v2/internal/json" +import ( + "github.com/gogf/gf/v2/internal/json" + "github.com/gogf/gf/v2/util/gconv/internal/converter" +) // SliceMap is alias of Maps. func SliceMap(any any, option ...MapOption) []map[string]any { @@ -28,9 +31,12 @@ func Maps(value any, option ...MapOption) []map[string]any { if len(option) > 0 { mapOption = option[0] } - result, _ := defaultConverter.SliceMap(value, SliceOption{ - ContinueOnError: true, - }, mapOption) + result, _ := defaultConverter.SliceMap(value, SliceMapOption{ + MapOption: mapOption, + SliceOption: converter.SliceOption{ + ContinueOnError: true, + }, + }) return result } diff --git a/util/gconv/gconv_structs.go b/util/gconv/gconv_structs.go index 3bfd7b42a2b..9cc1c07716b 100644 --- a/util/gconv/gconv_structs.go +++ b/util/gconv/gconv_structs.go @@ -6,6 +6,8 @@ package gconv +import "github.com/gogf/gf/v2/util/gconv/internal/converter" + // Structs converts any slice to given struct slice. // Also see Scan, Struct. func Structs(params any, pointer any, paramKeyToAttrMap ...map[string]string) (err error) { @@ -21,10 +23,13 @@ func SliceStruct(params any, pointer any, mapping ...map[string]string) (err err // specified priorityTagAndFieldName for `params` key-value items to struct attribute names mapping. // The parameter `priorityTag` supports multiple priorityTagAndFieldName that can be joined with char ','. func StructsTag(params any, pointer any, priorityTag string) (err error) { - return defaultConverter.Structs(params, pointer, SliceOption{ - ContinueOnError: true, - }, StructOption{ - PriorityTag: priorityTag, - ContinueOnError: true, + return defaultConverter.Structs(params, pointer, StructsOption{ + SliceOption: converter.SliceOption{ + ContinueOnError: true, + }, + StructOption: converter.StructOption{ + PriorityTag: priorityTag, + ContinueOnError: true, + }, }) } diff --git a/util/gconv/gconv_z_unit_converter_test.go b/util/gconv/gconv_z_unit_converter_test.go index ccaee32b4d3..3565eb4de89 100644 --- a/util/gconv/gconv_z_unit_converter_test.go +++ b/util/gconv/gconv_z_unit_converter_test.go @@ -171,3 +171,72 @@ func TestNewConverter(t *testing.T) { }) }) } + +type UserInput struct { + Name string + Age int + IsActive bool +} + +type UserModel struct { + ID int + FullName string + Age int + Status int +} + +func userInput2Model(in any, out reflect.Value) error { + if out.Type() == reflect.TypeOf(&UserModel{}) { + if input, ok := in.(UserInput); ok { + model := UserModel{ + ID: 1, + FullName: input.Name, + Age: input.Age, + Status: 0, + } + if input.IsActive { + model.Status = 1 + } + out.Elem().Set(reflect.ValueOf(model)) + return nil + } + return fmt.Errorf("unsupported type %T to UserModel", in) + } + return fmt.Errorf("unsupported type %s", out.Type()) +} + +func TestConverter_RegisterAnyConverterFunc(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + converter := gconv.NewConverter() + converter.RegisterAnyConverterFunc(userInput2Model, reflect.TypeOf(UserModel{})) + var ( + model UserModel + input = UserInput{Name: "sam", Age: 30, IsActive: true} + ) + err := converter.Scan(input, &model) + t.AssertNil(err) + t.Assert(model, UserModel{ + ID: 1, + FullName: "sam", + Age: 30, + Status: 1, + }) + }) + + gtest.C(t, func(t *gtest.T) { + converter := gconv.NewConverter() + converter.RegisterAnyConverterFunc(userInput2Model, reflect.TypeOf(&UserModel{})) + var ( + model UserModel + input = UserInput{Name: "sam", Age: 30, IsActive: true} + ) + err := converter.Scan(input, &model) + t.AssertNil(err) + t.Assert(model, UserModel{ + ID: 1, + FullName: "sam", + Age: 30, + Status: 1, + }) + }) +} diff --git a/util/gconv/gconv_z_unit_map_test.go b/util/gconv/gconv_z_unit_map_test.go index 4619e703a27..ac30b0ae565 100644 --- a/util/gconv/gconv_z_unit_map_test.go +++ b/util/gconv/gconv_z_unit_map_test.go @@ -345,7 +345,7 @@ func TestMapToMapExtra(t *testing.T) { expect = make(map[string]interface{}) ) err = gconv.MapToMap(value, &expect) - t.Assert(err, nil) + t.AssertNil(err) t.Assert(value["k1"], expect["k1"]) }) diff --git a/util/gconv/internal/converter/converter_convert.go b/util/gconv/internal/converter/converter_convert.go index ec1f545cfdd..33ea78c282c 100644 --- a/util/gconv/internal/converter/converter_convert.go +++ b/util/gconv/internal/converter/converter_convert.go @@ -23,20 +23,27 @@ type ConvertOption struct { StructOption StructOption } +func (c *Converter) getConvertOption(option ...ConvertOption) ConvertOption { + if len(option) > 0 { + return option[0] + } + return ConvertOption{} +} + // ConvertWithTypeName converts the variable `fromValue` to the type `toTypeName`, the type `toTypeName` is specified by string. -func (c *Converter) ConvertWithTypeName(fromValue any, toTypeName string, option ConvertOption) (any, error) { +func (c *Converter) ConvertWithTypeName(fromValue any, toTypeName string, option ...ConvertOption) (any, error) { return c.doConvert( doConvertInput{ FromValue: fromValue, ToTypeName: toTypeName, ReferValue: nil, }, - option, + c.getConvertOption(option...), ) } // ConvertWithRefer converts the variable `fromValue` to the type referred by value `referValue`. -func (c *Converter) ConvertWithRefer(fromValue, referValue any, option ConvertOption) (any, error) { +func (c *Converter) ConvertWithRefer(fromValue, referValue any, option ...ConvertOption) (any, error) { var referValueRf reflect.Value if v, ok := referValue.(reflect.Value); ok { referValueRf = v @@ -49,7 +56,7 @@ func (c *Converter) ConvertWithRefer(fromValue, referValue any, option ConvertOp ToTypeName: referValueRf.Type().String(), ReferValue: referValue, }, - option, + c.getConvertOption(option...), ) } @@ -354,7 +361,10 @@ func (c *Converter) doConvert(in doConvertInput, option ConvertOption) (converte return c.Map(in.FromValue, option.MapOption) case "[]map[string]interface {}": - return c.SliceMap(in.FromValue, option.SliceOption, option.MapOption) + return c.SliceMap(in.FromValue, SliceMapOption{ + SliceOption: option.SliceOption, + MapOption: option.MapOption, + }) case "RawMessage", "json.RawMessage": // issue 3449 @@ -463,7 +473,53 @@ func (c *Converter) doConvertWithReflectValueSet(reflectValue reflect.Value, in return err } -func (c *Converter) getRegisteredConverterFuncAndSrcType( +// callCustomConverter call the custom converter. It will try some possible type. +func (c *Converter) callCustomConverter(srcReflectValue, dstReflectValue reflect.Value) (converted bool, err error) { + // search type converter function. + registeredConverterFunc, srcType, ok := c.getRegisteredTypeConverterFuncAndSrcType(srcReflectValue, dstReflectValue) + if ok { + return c.doCallCustomTypeConverter(srcReflectValue, dstReflectValue, registeredConverterFunc, srcType) + } + + // search any converter function. + anyConverterFunc := c.getRegisteredAnyConverterFunc(dstReflectValue) + if anyConverterFunc == nil { + return false, nil + } + err = anyConverterFunc(srcReflectValue.Interface(), dstReflectValue) + if err != nil { + return false, err + } + return true, nil +} + +func (c *Converter) callCustomConverterWithRefer( + srcReflectValue, referReflectValue reflect.Value, +) (dstReflectValue reflect.Value, converted bool, err error) { + // search type converter function. + registeredConverterFunc, srcType, ok := c.getRegisteredTypeConverterFuncAndSrcType( + srcReflectValue, referReflectValue, + ) + if ok { + dstReflectValue = reflect.New(referReflectValue.Type()).Elem() + converted, err = c.doCallCustomTypeConverter(srcReflectValue, dstReflectValue, registeredConverterFunc, srcType) + return + } + + // search any converter function. + anyConverterFunc := c.getRegisteredAnyConverterFunc(referReflectValue) + if anyConverterFunc == nil { + return reflect.Value{}, false, nil + } + dstReflectValue = reflect.New(referReflectValue.Type()).Elem() + err = anyConverterFunc(srcReflectValue.Interface(), dstReflectValue) + if err != nil { + return reflect.Value{}, false, err + } + return dstReflectValue, true, nil +} + +func (c *Converter) getRegisteredTypeConverterFuncAndSrcType( srcReflectValue, dstReflectValueForRefer reflect.Value, ) (f converterFunc, srcType reflect.Type, ok bool) { if len(c.typeConverterFuncMap) == 0 { @@ -499,28 +555,28 @@ func (c *Converter) getRegisteredConverterFuncAndSrcType( return } -func (c *Converter) callCustomConverterWithRefer( - srcReflectValue, referReflectValue reflect.Value, -) (dstReflectValue reflect.Value, converted bool, err error) { - registeredConverterFunc, srcType, ok := c.getRegisteredConverterFuncAndSrcType(srcReflectValue, referReflectValue) - if !ok { - return reflect.Value{}, false, nil +func (c *Converter) getRegisteredAnyConverterFunc(dstReflectValueForRefer reflect.Value) (f AnyConvertFunc) { + if c.internalConverter.IsAnyConvertFuncEmpty() { + return nil } - dstReflectValue = reflect.New(referReflectValue.Type()).Elem() - converted, err = c.doCallCustomConverter(srcReflectValue, dstReflectValue, registeredConverterFunc, srcType) - return -} - -// callCustomConverter call the custom converter. It will try some possible type. -func (c *Converter) callCustomConverter(srcReflectValue, dstReflectValue reflect.Value) (converted bool, err error) { - registeredConverterFunc, srcType, ok := c.getRegisteredConverterFuncAndSrcType(srcReflectValue, dstReflectValue) - if !ok { - return false, nil + if !dstReflectValueForRefer.IsValid() { + return nil + } + var dstType = dstReflectValueForRefer.Type() + if dstType.Kind() == reflect.Pointer { + // Might be **struct, which is support as designed. + if dstType.Elem().Kind() == reflect.Pointer { + dstType = dstType.Elem() + } + } else if dstReflectValueForRefer.IsValid() && dstReflectValueForRefer.CanAddr() { + dstType = dstReflectValueForRefer.Addr().Type() + } else { + dstType = reflect.PointerTo(dstType) } - return c.doCallCustomConverter(srcReflectValue, dstReflectValue, registeredConverterFunc, srcType) + return c.internalConverter.GetAnyConvertFuncByType(dstType) } -func (c *Converter) doCallCustomConverter( +func (c *Converter) doCallCustomTypeConverter( srcReflectValue reflect.Value, dstReflectValue reflect.Value, registeredConverterFunc converterFunc, diff --git a/util/gconv/internal/converter/converter_map.go b/util/gconv/internal/converter/converter_map.go index 1b8b93e4814..aff38393894 100644 --- a/util/gconv/internal/converter/converter_map.go +++ b/util/gconv/internal/converter/converter_map.go @@ -35,34 +35,42 @@ type MapOption struct { ContinueOnError bool } +func (c *Converter) getMapOption(option ...MapOption) MapOption { + if len(option) > 0 { + return option[0] + } + return MapOption{} +} + // Map converts any variable `value` to map[string]any. If the parameter `value` is not a // map/struct/*struct type, then the conversion will fail and returns nil. // // If `value` is a struct/*struct object, the second parameter `priorityTagAndFieldName` specifies the most priority // priorityTagAndFieldName that will be detected, otherwise it detects the priorityTagAndFieldName in order of: // gconv, json, field name. -func (c *Converter) Map(value any, option MapOption) (map[string]any, error) { - return c.doMapConvert(value, RecursiveTypeAuto, false, option) +func (c *Converter) Map(value any, option ...MapOption) (map[string]any, error) { + return c.doMapConvert(value, RecursiveTypeAuto, false, c.getMapOption(option...)) } // MapStrStr converts `value` to map[string]string. // Note that there might be data copy for this map type converting. -func (c *Converter) MapStrStr(value any, option MapOption) (map[string]string, error) { +func (c *Converter) MapStrStr(value any, option ...MapOption) (map[string]string, error) { if r, ok := value.(map[string]string); ok { return r, nil } - m, err := c.Map(value, option) - if err != nil && !option.ContinueOnError { + m, err := c.Map(value, option...) + if err != nil { return nil, err } if len(m) > 0 { var ( - s string - vMap = make(map[string]string, len(m)) + s string + vMap = make(map[string]string, len(m)) + mapOption = c.getMapOption(option...) ) for k, v := range m { s, err = c.String(v) - if err != nil && !option.ContinueOnError { + if err != nil && !mapOption.ContinueOnError { return nil, err } vMap[k] = s diff --git a/util/gconv/internal/converter/converter_maptomap.go b/util/gconv/internal/converter/converter_maptomap.go index 2aafabca712..35fa3121942 100644 --- a/util/gconv/internal/converter/converter_maptomap.go +++ b/util/gconv/internal/converter/converter_maptomap.go @@ -24,7 +24,7 @@ import ( // The optional parameter `mapping` is used for struct attribute to map key mapping, which makes // sense only if the items of original map `params` is type struct. func (c *Converter) MapToMap( - params, pointer any, mapping map[string]string, option MapOption, + params, pointer any, mapping map[string]string, option ...MapOption, ) (err error) { var ( paramsRv reflect.Value @@ -41,11 +41,11 @@ func (c *Converter) MapToMap( paramsKind = paramsRv.Kind() } if paramsKind != reflect.Map { - m, err := c.Map(params, option) + m, err := c.Map(params, option...) if err != nil { return err } - return c.MapToMap(m, pointer, mapping, option) + return c.MapToMap(m, pointer, mapping, option...) } // Empty params map, no need continue. if paramsRv.Len() == 0 { @@ -85,10 +85,11 @@ func (c *Converter) MapToMap( pointerValueType = pointerRv.Type().Elem() pointerValueKind = pointerValueType.Kind() dataMap = reflect.MakeMapWithSize(pointerRv.Type(), len(paramsKeys)) + mapOption = c.getMapOption(option...) convertOption = ConvertOption{ - StructOption: StructOption{ContinueOnError: option.ContinueOnError}, - SliceOption: SliceOption{ContinueOnError: option.ContinueOnError}, - MapOption: option, + StructOption: StructOption{ContinueOnError: mapOption.ContinueOnError}, + SliceOption: SliceOption{ContinueOnError: mapOption.ContinueOnError}, + MapOption: mapOption, } ) // Retrieve the true element type of target map. @@ -102,7 +103,7 @@ func (c *Converter) MapToMap( structOption := StructOption{ ParamKeyToAttrMap: mapping, PriorityTag: "", - ContinueOnError: option.ContinueOnError, + ContinueOnError: mapOption.ContinueOnError, } if err = c.Struct(paramsRv.MapIndex(key).Interface(), mapValue, structOption); err != nil { return err diff --git a/util/gconv/internal/converter/converter_maptomaps.go b/util/gconv/internal/converter/converter_maptomaps.go index 3420934b5b9..cb940c40766 100644 --- a/util/gconv/internal/converter/converter_maptomaps.go +++ b/util/gconv/internal/converter/converter_maptomaps.go @@ -22,7 +22,7 @@ import ( // The optional parameter `mapping` is used for struct attribute to map key mapping, which makes // sense only if the item of `params` is type struct. func (c *Converter) MapToMaps( - params any, pointer any, paramKeyToAttrMap map[string]string, option MapOption, + params any, pointer any, paramKeyToAttrMap map[string]string, option ...MapOption, ) (err error) { // Params and its element type check. var ( @@ -105,13 +105,13 @@ func (c *Converter) MapToMaps( var item reflect.Value if pointerElemType.Kind() == reflect.Ptr { item = reflect.New(pointerElemType.Elem()) - if err = c.MapToMap(paramsRv.Index(i).Interface(), item, paramKeyToAttrMap, option); err != nil { + if err = c.MapToMap(paramsRv.Index(i).Interface(), item, paramKeyToAttrMap, option...); err != nil { return err } pointerSlice.Index(i).Set(item) } else { item = reflect.New(pointerElemType) - if err = c.MapToMap(paramsRv.Index(i).Interface(), item, paramKeyToAttrMap, option); err != nil { + if err = c.MapToMap(paramsRv.Index(i).Interface(), item, paramKeyToAttrMap, option...); err != nil { return err } pointerSlice.Index(i).Set(item.Elem()) diff --git a/util/gconv/internal/converter/converter_scan.go b/util/gconv/internal/converter/converter_scan.go index b580e9abedb..9630ffb2ab1 100644 --- a/util/gconv/internal/converter/converter_scan.go +++ b/util/gconv/internal/converter/converter_scan.go @@ -25,8 +25,15 @@ type ScanOption struct { ContinueOnError bool } +func (c *Converter) getScanOption(option ...ScanOption) ScanOption { + if len(option) > 0 { + return option[0] + } + return ScanOption{} +} + // Scan automatically checks the type of `pointer` and converts `params` to `pointer`. -func (c *Converter) Scan(srcValue any, dstPointer any, option ScanOption) (err error) { +func (c *Converter) Scan(srcValue any, dstPointer any, option ...ScanOption) (err error) { // Check if srcValue is nil, in which case no conversion is needed if srcValue == nil { return nil @@ -90,12 +97,12 @@ func (c *Converter) Scan(srcValue any, dstPointer any, option ScanOption) (err e // Create a new value for the pointer dereference nextLevelPtr := reflect.New(dstPointerReflectValueElem.Type().Elem()) // Recursively scan into the dereferenced pointer - if err = c.Scan(srcValueReflectValue, nextLevelPtr, option); err == nil { + if err = c.Scan(srcValueReflectValue, nextLevelPtr, option...); err == nil { dstPointerReflectValueElem.Set(nextLevelPtr) } return } - return c.Scan(srcValueReflectValue, dstPointerReflectValueElem, option) + return c.Scan(srcValueReflectValue, dstPointerReflectValueElem, option...) } // Check if srcValue and dstPointer are the same type, in which case direct assignment can be performed @@ -103,11 +110,12 @@ func (c *Converter) Scan(srcValue any, dstPointer any, option ScanOption) (err e return nil } + scanOption := c.getScanOption(option...) // Handle different destination types switch dstPointerReflectValueElemKind { case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: v, err := c.Int64(srcValue) - if err != nil && !option.ContinueOnError { + if err != nil && !scanOption.ContinueOnError { return err } dstPointerReflectValueElem.SetInt(v) @@ -115,7 +123,7 @@ func (c *Converter) Scan(srcValue any, dstPointer any, option ScanOption) (err e case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: v, err := c.Uint64(srcValue) - if err != nil && !option.ContinueOnError { + if err != nil && !scanOption.ContinueOnError { return err } dstPointerReflectValueElem.SetUint(v) @@ -123,7 +131,7 @@ func (c *Converter) Scan(srcValue any, dstPointer any, option ScanOption) (err e case reflect.Float32, reflect.Float64: v, err := c.Float64(srcValue) - if err != nil && !option.ContinueOnError { + if err != nil && !scanOption.ContinueOnError { return err } dstPointerReflectValueElem.SetFloat(v) @@ -131,7 +139,7 @@ func (c *Converter) Scan(srcValue any, dstPointer any, option ScanOption) (err e case reflect.String: v, err := c.String(srcValue) - if err != nil && !option.ContinueOnError { + if err != nil && !scanOption.ContinueOnError { return err } dstPointerReflectValueElem.SetString(v) @@ -139,7 +147,7 @@ func (c *Converter) Scan(srcValue any, dstPointer any, option ScanOption) (err e case reflect.Bool: v, err := c.Bool(srcValue) - if err != nil && !option.ContinueOnError { + if err != nil && !scanOption.ContinueOnError { return err } dstPointerReflectValueElem.SetBool(v) @@ -158,7 +166,7 @@ func (c *Converter) Scan(srcValue any, dstPointer any, option ScanOption) (err e } // Special handling for struct or map slice elements if dstElemKind == reflect.Struct || dstElemKind == reflect.Map { - return c.doScanForComplicatedTypes(srcValue, dstPointer, dstPointerReflectType, option) + return c.doScanForComplicatedTypes(srcValue, dstPointer, dstPointerReflectType, scanOption) } // Handle basic type slice conversions var srcValueReflectValueKind = srcValueReflectValue.Kind() @@ -172,48 +180,48 @@ func (c *Converter) Scan(srcValue any, dstPointer any, option ScanOption) (err e switch dstElemType.Kind() { case reflect.String: v, err := c.String(srcElem) - if err != nil && !option.ContinueOnError { + if err != nil && !scanOption.ContinueOnError { return err } newSlice.Index(i).SetString(v) case reflect.Int: v, err := c.Int64(srcElem) - if err != nil && !option.ContinueOnError { + if err != nil && !scanOption.ContinueOnError { return err } newSlice.Index(i).SetInt(v) case reflect.Int64: v, err := c.Int64(srcElem) - if err != nil && !option.ContinueOnError { + if err != nil && !scanOption.ContinueOnError { return err } newSlice.Index(i).SetInt(v) case reflect.Float64: v, err := c.Float64(srcElem) - if err != nil && !option.ContinueOnError { + if err != nil && !scanOption.ContinueOnError { return err } newSlice.Index(i).SetFloat(v) case reflect.Bool: v, err := c.Bool(srcElem) - if err != nil && !option.ContinueOnError { + if err != nil && !scanOption.ContinueOnError { return err } newSlice.Index(i).SetBool(v) default: return c.Scan( - srcElem, newSlice.Index(i).Addr().Interface(), option, + srcElem, newSlice.Index(i).Addr().Interface(), option..., ) } } dstPointerReflectValueElem.Set(newSlice) return nil } - return c.doScanForComplicatedTypes(srcValue, dstPointer, dstPointerReflectType, option) + return c.doScanForComplicatedTypes(srcValue, dstPointer, dstPointerReflectType, scanOption) default: // Handle complex types (structs, maps, etc.) - return c.doScanForComplicatedTypes(srcValue, dstPointer, dstPointerReflectType, option) + return c.doScanForComplicatedTypes(srcValue, dstPointer, dstPointerReflectType, scanOption) } } @@ -282,7 +290,10 @@ func (c *Converter) doScanForComplicatedTypes( ContinueOnError: option.ContinueOnError, } ) - return c.Structs(srcValue, dstPointer, sliceOption, mapOption) + return c.Structs(srcValue, dstPointer, StructsOption{ + SliceOption: sliceOption, + StructOption: mapOption, + }) default: structOption := StructOption{ diff --git a/util/gconv/internal/converter/converter_slice_any.go b/util/gconv/internal/converter/converter_slice_any.go index 8a0402ec1cb..673c9afdf82 100644 --- a/util/gconv/internal/converter/converter_slice_any.go +++ b/util/gconv/internal/converter/converter_slice_any.go @@ -22,8 +22,15 @@ type SliceOption struct { ContinueOnError bool } +func (c *Converter) getSliceOption(option ...SliceOption) SliceOption { + if len(option) > 0 { + return option[0] + } + return SliceOption{} +} + // SliceAny converts `any` to []any. -func (c *Converter) SliceAny(any interface{}, option SliceOption) ([]any, error) { +func (c *Converter) SliceAny(any interface{}, _ ...SliceOption) ([]any, error) { if empty.IsNil(any) { return nil, nil } diff --git a/util/gconv/internal/converter/converter_slice_float.go b/util/gconv/internal/converter/converter_slice_float.go index 27d59c6abbc..382ca764e6d 100644 --- a/util/gconv/internal/converter/converter_slice_float.go +++ b/util/gconv/internal/converter/converter_slice_float.go @@ -17,21 +17,22 @@ import ( ) // SliceFloat32 converts `any` to []float32. -func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32, error) { +func (c *Converter) SliceFloat32(any interface{}, option ...SliceOption) ([]float32, error) { if empty.IsNil(any) { return nil, nil } var ( - err error - f float32 - array []float32 = nil + err error + f float32 + array []float32 = nil + sliceOption = c.getSliceOption(option...) ) switch value := any.(type) { case []string: array = make([]float32, len(value)) for k, v := range value { f, err = c.Float32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -40,7 +41,7 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 array = make([]float32, len(value)) for k, v := range value { f, err = c.Float32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -49,7 +50,7 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 array = make([]float32, len(value)) for k, v := range value { f, err = c.Float32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -58,7 +59,7 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 array = make([]float32, len(value)) for k, v := range value { f, err = c.Float32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -67,7 +68,7 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 array = make([]float32, len(value)) for k, v := range value { f, err = c.Float32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -76,7 +77,7 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 array = make([]float32, len(value)) for k, v := range value { f, err = c.Float32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -85,7 +86,7 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 array = make([]float32, len(value)) for k, v := range value { f, err = c.Float32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -99,7 +100,7 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 array = make([]float32, len(value)) for k, v := range value { f, err = c.Float32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -116,7 +117,7 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 } if utils.IsNumeric(value) { f, err = c.Float32(value) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } return []float32{f}, err @@ -125,7 +126,7 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 array = make([]float32, len(value)) for k, v := range value { f, err = c.Float32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -134,7 +135,7 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 array = make([]float32, len(value)) for k, v := range value { f, err = c.Float32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -143,7 +144,7 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 array = make([]float32, len(value)) for k, v := range value { f, err = c.Float32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -152,7 +153,7 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 array = make([]float32, len(value)) for k, v := range value { f, err = c.Float32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -163,7 +164,7 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 array = make([]float32, len(value)) for k, v := range value { f, err = c.Float32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -172,7 +173,7 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 array = make([]float32, len(value)) for k, v := range value { f, err = c.Float32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -182,10 +183,10 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 return array, err } if v, ok := any.(localinterface.IFloats); ok { - return c.SliceFloat32(v.Floats(), option) + return c.SliceFloat32(v.Floats(), option...) } if v, ok := any.(localinterface.IInterfaces); ok { - return c.SliceFloat32(v.Interfaces(), option) + return c.SliceFloat32(v.Interfaces(), option...) } // Not a common type, it then uses reflection for conversion. originValueAndKind := reflection.OriginValueAndKind(any) @@ -197,7 +198,7 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 ) for i := 0; i < length; i++ { f, err = c.Float32(originValueAndKind.OriginValue.Index(i).Interface()) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } slice[i] = f @@ -209,7 +210,7 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 return []float32{}, err } f, err = c.Float32(any) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } return []float32{f}, err @@ -217,21 +218,22 @@ func (c *Converter) SliceFloat32(any interface{}, option SliceOption) ([]float32 } // SliceFloat64 converts `any` to []float64. -func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64, error) { +func (c *Converter) SliceFloat64(any interface{}, option ...SliceOption) ([]float64, error) { if empty.IsNil(any) { return nil, nil } var ( - err error - f float64 - array []float64 = nil + err error + f float64 + array []float64 = nil + sliceOption = c.getSliceOption(option...) ) switch value := any.(type) { case []string: array = make([]float64, len(value)) for k, v := range value { f, err = c.Float64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -240,7 +242,7 @@ func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64 array = make([]float64, len(value)) for k, v := range value { f, err = c.Float64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -249,7 +251,7 @@ func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64 array = make([]float64, len(value)) for k, v := range value { f, err = c.Float64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -258,7 +260,7 @@ func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64 array = make([]float64, len(value)) for k, v := range value { f, err = c.Float64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -267,7 +269,7 @@ func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64 array = make([]float64, len(value)) for k, v := range value { f, err = c.Float64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -276,7 +278,7 @@ func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64 array = make([]float64, len(value)) for k, v := range value { f, err = c.Float64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -285,7 +287,7 @@ func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64 array = make([]float64, len(value)) for k, v := range value { f, err = c.Float64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -299,7 +301,7 @@ func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64 array = make([]float64, len(value)) for k, v := range value { f, err = c.Float64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -316,7 +318,7 @@ func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64 } if utils.IsNumeric(value) { f, err = c.Float64(value) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } return []float64{f}, err @@ -325,7 +327,7 @@ func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64 array = make([]float64, len(value)) for k, v := range value { f, err = c.Float64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -334,7 +336,7 @@ func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64 array = make([]float64, len(value)) for k, v := range value { f, err = c.Float64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -343,7 +345,7 @@ func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64 array = make([]float64, len(value)) for k, v := range value { f, err = c.Float64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -352,7 +354,7 @@ func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64 array = make([]float64, len(value)) for k, v := range value { f, err = c.Float64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -361,7 +363,7 @@ func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64 array = make([]float64, len(value)) for k, v := range value { f, err = c.Float64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -372,7 +374,7 @@ func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64 array = make([]float64, len(value)) for k, v := range value { f, err = c.Float64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = f @@ -385,7 +387,7 @@ func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64 return v.Floats(), err } if v, ok := any.(localinterface.IInterfaces); ok { - return c.SliceFloat64(v.Interfaces(), option) + return c.SliceFloat64(v.Interfaces(), option...) } // Not a common type, it then uses reflection for conversion. originValueAndKind := reflection.OriginValueAndKind(any) @@ -397,7 +399,7 @@ func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64 ) for i := 0; i < length; i++ { f, err = c.Float64(originValueAndKind.OriginValue.Index(i).Interface()) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } slice[i] = f @@ -409,7 +411,7 @@ func (c *Converter) SliceFloat64(any interface{}, option SliceOption) ([]float64 return []float64{}, err } f, err = c.Float64(any) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } return []float64{f}, err diff --git a/util/gconv/internal/converter/converter_slice_int.go b/util/gconv/internal/converter/converter_slice_int.go index b1a769d275a..388c2075a82 100644 --- a/util/gconv/internal/converter/converter_slice_int.go +++ b/util/gconv/internal/converter/converter_slice_int.go @@ -17,21 +17,22 @@ import ( ) // SliceInt converts `any` to []int. -func (c *Converter) SliceInt(any any, option SliceOption) ([]int, error) { +func (c *Converter) SliceInt(any any, option ...SliceOption) ([]int, error) { if empty.IsNil(any) { return nil, nil } var ( - err error - ii int - array []int = nil + err error + ii int + array []int = nil + sliceOption = c.getSliceOption(option...) ) switch value := any.(type) { case []string: array = make([]int, len(value)) for k, v := range value { ii, err = c.Int(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ii @@ -85,7 +86,7 @@ func (c *Converter) SliceInt(any any, option SliceOption) ([]int, error) { } if utils.IsNumeric(value) { ii, err = c.Int(value) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } return []int{ii}, err @@ -118,7 +119,7 @@ func (c *Converter) SliceInt(any any, option SliceOption) ([]int, error) { array = make([]int, len(value)) for k, v := range value { ii, err = c.Int(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ii @@ -127,7 +128,7 @@ func (c *Converter) SliceInt(any any, option SliceOption) ([]int, error) { array = make([]int, len(value)) for k, v := range value { ii, err = c.Int(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ii @@ -136,7 +137,7 @@ func (c *Converter) SliceInt(any any, option SliceOption) ([]int, error) { array = make([]int, len(value)) for k, v := range value { ii, err = c.Int(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ii @@ -145,7 +146,7 @@ func (c *Converter) SliceInt(any any, option SliceOption) ([]int, error) { array = make([]int, len(value)) for k, v := range value { ii, err = c.Int(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ii @@ -158,7 +159,7 @@ func (c *Converter) SliceInt(any any, option SliceOption) ([]int, error) { return v.Ints(), err } if v, ok := any.(localinterface.IInterfaces); ok { - return c.SliceInt(v.Interfaces(), option) + return c.SliceInt(v.Interfaces(), option...) } // Not a common type, it then uses reflection for conversion. originValueAndKind := reflection.OriginValueAndKind(any) @@ -170,7 +171,7 @@ func (c *Converter) SliceInt(any any, option SliceOption) ([]int, error) { ) for i := 0; i < length; i++ { ii, err = c.Int(originValueAndKind.OriginValue.Index(i).Interface()) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } slice[i] = ii @@ -182,7 +183,7 @@ func (c *Converter) SliceInt(any any, option SliceOption) ([]int, error) { return []int{}, err } ii, err = c.Int(any) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } return []int{ii}, err @@ -190,21 +191,22 @@ func (c *Converter) SliceInt(any any, option SliceOption) ([]int, error) { } // SliceInt32 converts `any` to []int32. -func (c *Converter) SliceInt32(any any, option SliceOption) ([]int32, error) { +func (c *Converter) SliceInt32(any any, option ...SliceOption) ([]int32, error) { if empty.IsNil(any) { return nil, nil } var ( - err error - ii int32 - array []int32 = nil + err error + ii int32 + array []int32 = nil + sliceOption = c.getSliceOption(option...) ) switch value := any.(type) { case []string: array = make([]int32, len(value)) for k, v := range value { ii, err = c.Int32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ii @@ -258,7 +260,7 @@ func (c *Converter) SliceInt32(any any, option SliceOption) ([]int32, error) { } if utils.IsNumeric(value) { ii, err = c.Int32(value) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } return []int32{ii}, err @@ -291,7 +293,7 @@ func (c *Converter) SliceInt32(any any, option SliceOption) ([]int32, error) { array = make([]int32, len(value)) for k, v := range value { ii, err = c.Int32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ii @@ -300,7 +302,7 @@ func (c *Converter) SliceInt32(any any, option SliceOption) ([]int32, error) { array = make([]int32, len(value)) for k, v := range value { ii, err = c.Int32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ii @@ -309,7 +311,7 @@ func (c *Converter) SliceInt32(any any, option SliceOption) ([]int32, error) { array = make([]int32, len(value)) for k, v := range value { ii, err = c.Int32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ii @@ -318,7 +320,7 @@ func (c *Converter) SliceInt32(any any, option SliceOption) ([]int32, error) { array = make([]int32, len(value)) for k, v := range value { ii, err = c.Int32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ii @@ -328,10 +330,10 @@ func (c *Converter) SliceInt32(any any, option SliceOption) ([]int32, error) { return array, err } if v, ok := any.(localinterface.IInts); ok { - return c.SliceInt32(v.Ints(), option) + return c.SliceInt32(v.Ints(), option...) } if v, ok := any.(localinterface.IInterfaces); ok { - return c.SliceInt32(v.Interfaces(), option) + return c.SliceInt32(v.Interfaces(), option...) } // Not a common type, it then uses reflection for conversion. originValueAndKind := reflection.OriginValueAndKind(any) @@ -343,7 +345,7 @@ func (c *Converter) SliceInt32(any any, option SliceOption) ([]int32, error) { ) for i := 0; i < length; i++ { ii, err = c.Int32(originValueAndKind.OriginValue.Index(i).Interface()) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } slice[i] = ii @@ -355,7 +357,7 @@ func (c *Converter) SliceInt32(any any, option SliceOption) ([]int32, error) { return []int32{}, err } ii, err = c.Int32(any) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } return []int32{ii}, err @@ -363,21 +365,22 @@ func (c *Converter) SliceInt32(any any, option SliceOption) ([]int32, error) { } // SliceInt64 converts `any` to []int64. -func (c *Converter) SliceInt64(any any, option SliceOption) ([]int64, error) { +func (c *Converter) SliceInt64(any any, option ...SliceOption) ([]int64, error) { if empty.IsNil(any) { return nil, nil } var ( - err error - ii int64 - array []int64 = nil + err error + ii int64 + array []int64 = nil + sliceOption = c.getSliceOption(option...) ) switch value := any.(type) { case []string: array = make([]int64, len(value)) for k, v := range value { ii, err = c.Int64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ii @@ -431,7 +434,7 @@ func (c *Converter) SliceInt64(any any, option SliceOption) ([]int64, error) { } if utils.IsNumeric(value) { ii, err = c.Int64(value) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } return []int64{ii}, err @@ -464,7 +467,7 @@ func (c *Converter) SliceInt64(any any, option SliceOption) ([]int64, error) { array = make([]int64, len(value)) for k, v := range value { ii, err = c.Int64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ii @@ -473,7 +476,7 @@ func (c *Converter) SliceInt64(any any, option SliceOption) ([]int64, error) { array = make([]int64, len(value)) for k, v := range value { ii, err = c.Int64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ii @@ -482,7 +485,7 @@ func (c *Converter) SliceInt64(any any, option SliceOption) ([]int64, error) { array = make([]int64, len(value)) for k, v := range value { ii, err = c.Int64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ii @@ -491,7 +494,7 @@ func (c *Converter) SliceInt64(any any, option SliceOption) ([]int64, error) { array = make([]int64, len(value)) for k, v := range value { ii, err = c.Int64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ii @@ -501,10 +504,10 @@ func (c *Converter) SliceInt64(any any, option SliceOption) ([]int64, error) { return array, err } if v, ok := any.(localinterface.IInts); ok { - return c.SliceInt64(v.Ints(), option) + return c.SliceInt64(v.Ints(), option...) } if v, ok := any.(localinterface.IInterfaces); ok { - return c.SliceInt64(v.Interfaces(), option) + return c.SliceInt64(v.Interfaces(), option...) } // Not a common type, it then uses reflection for conversion. originValueAndKind := reflection.OriginValueAndKind(any) @@ -516,7 +519,7 @@ func (c *Converter) SliceInt64(any any, option SliceOption) ([]int64, error) { ) for i := 0; i < length; i++ { ii, err = c.Int64(originValueAndKind.OriginValue.Index(i).Interface()) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } slice[i] = ii @@ -528,7 +531,7 @@ func (c *Converter) SliceInt64(any any, option SliceOption) ([]int64, error) { return []int64{}, err } ii, err = c.Int64(any) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } return []int64{ii}, err diff --git a/util/gconv/internal/converter/converter_slice_map.go b/util/gconv/internal/converter/converter_slice_map.go index 837f51ab945..fb45d3c370f 100644 --- a/util/gconv/internal/converter/converter_slice_map.go +++ b/util/gconv/internal/converter/converter_slice_map.go @@ -8,9 +8,22 @@ package converter import "github.com/gogf/gf/v2/internal/json" +// SliceMapOption is the option for SliceMap function. +type SliceMapOption struct { + SliceOption SliceOption + MapOption MapOption +} + +func (c *Converter) getSliceMapOption(option ...SliceMapOption) SliceMapOption { + if len(option) > 0 { + return option[0] + } + return SliceMapOption{} +} + // SliceMap converts `value` to []map[string]any. // Note that it automatically checks and converts json string to []map if `value` is string/[]byte. -func (c *Converter) SliceMap(value any, sliceOption SliceOption, mapOption MapOption) ([]map[string]any, error) { +func (c *Converter) SliceMap(value any, option ...SliceMapOption) ([]map[string]any, error) { if value == nil { return nil, nil } @@ -39,7 +52,8 @@ func (c *Converter) SliceMap(value any, sliceOption SliceOption, mapOption MapOp return r, nil default: - array, err := c.SliceAny(value, sliceOption) + sliceMapOption := c.getSliceMapOption(option...) + array, err := c.SliceAny(value, sliceMapOption.SliceOption) if err != nil { return nil, err } @@ -48,8 +62,8 @@ func (c *Converter) SliceMap(value any, sliceOption SliceOption, mapOption MapOp } list := make([]map[string]any, len(array)) for k, v := range array { - m, err := c.Map(v, mapOption) - if err != nil && !sliceOption.ContinueOnError { + m, err := c.Map(v, sliceMapOption.MapOption) + if err != nil && !sliceMapOption.SliceOption.ContinueOnError { return nil, err } list[k] = m diff --git a/util/gconv/internal/converter/converter_slice_str.go b/util/gconv/internal/converter/converter_slice_str.go index e95f70b8a27..87fa83dbd3b 100644 --- a/util/gconv/internal/converter/converter_slice_str.go +++ b/util/gconv/internal/converter/converter_slice_str.go @@ -16,21 +16,22 @@ import ( ) // SliceStr converts `any` to []string. -func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, error) { +func (c *Converter) SliceStr(any interface{}, option ...SliceOption) ([]string, error) { if empty.IsNil(any) { return nil, nil } var ( - err error - s string - array []string = nil + err error + s string + array []string = nil + sliceOption = c.getSliceOption(option...) ) switch value := any.(type) { case []int: array = make([]string, len(value)) for k, v := range value { s, err = c.String(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = s @@ -39,7 +40,7 @@ func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, err array = make([]string, len(value)) for k, v := range value { s, err = c.String(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = s @@ -48,7 +49,7 @@ func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, err array = make([]string, len(value)) for k, v := range value { s, err = c.String(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = s @@ -57,7 +58,7 @@ func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, err array = make([]string, len(value)) for k, v := range value { s, err = c.String(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = s @@ -66,7 +67,7 @@ func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, err array = make([]string, len(value)) for k, v := range value { s, err = c.String(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = s @@ -75,7 +76,7 @@ func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, err array = make([]string, len(value)) for k, v := range value { s, err = c.String(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = s @@ -89,7 +90,7 @@ func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, err array = make([]string, len(value)) for k, v := range value { s, err = c.String(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = s @@ -110,7 +111,7 @@ func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, err array = make([]string, len(value)) for k, v := range value { s, err = c.String(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = s @@ -119,7 +120,7 @@ func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, err array = make([]string, len(value)) for k, v := range value { s, err = c.String(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = s @@ -128,7 +129,7 @@ func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, err array = make([]string, len(value)) for k, v := range value { s, err = c.String(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = s @@ -137,7 +138,7 @@ func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, err array = make([]string, len(value)) for k, v := range value { s, err = c.String(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = s @@ -146,7 +147,7 @@ func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, err array = make([]string, len(value)) for k, v := range value { s, err = c.String(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = s @@ -155,7 +156,7 @@ func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, err array = make([]string, len(value)) for k, v := range value { s, err = c.String(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = s @@ -164,7 +165,7 @@ func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, err array = make([]string, len(value)) for k, v := range value { s, err = c.String(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = s @@ -175,7 +176,7 @@ func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, err array = make([]string, len(value)) for k, v := range value { s, err = c.String(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = s @@ -188,7 +189,7 @@ func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, err return v.Strings(), err } if v, ok := any.(localinterface.IInterfaces); ok { - return c.SliceStr(v.Interfaces(), option) + return c.SliceStr(v.Interfaces(), option...) } // Not a common type, it then uses reflection for conversion. originValueAndKind := reflection.OriginValueAndKind(any) @@ -200,7 +201,7 @@ func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, err ) for i := 0; i < length; i++ { s, err = c.String(originValueAndKind.OriginValue.Index(i).Interface()) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } slice[i] = s @@ -212,7 +213,7 @@ func (c *Converter) SliceStr(any interface{}, option SliceOption) ([]string, err return []string{}, err } s, err = c.String(any) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } return []string{s}, err diff --git a/util/gconv/internal/converter/converter_slice_uint.go b/util/gconv/internal/converter/converter_slice_uint.go index 173c96469cd..d6d1921943f 100644 --- a/util/gconv/internal/converter/converter_slice_uint.go +++ b/util/gconv/internal/converter/converter_slice_uint.go @@ -17,21 +17,22 @@ import ( ) // SliceUint converts `any` to []uint. -func (c *Converter) SliceUint(any interface{}, option SliceOption) ([]uint, error) { +func (c *Converter) SliceUint(any interface{}, option ...SliceOption) ([]uint, error) { if empty.IsNil(any) { return nil, nil } var ( - err error - ui uint - array []uint = nil + err error + ui uint + array []uint = nil + sliceOption = c.getSliceOption(option...) ) switch value := any.(type) { case []string: array = make([]uint, len(value)) for k, v := range value { ui, err = c.Uint(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ui @@ -80,7 +81,7 @@ func (c *Converter) SliceUint(any interface{}, option SliceOption) ([]uint, erro } if utils.IsNumeric(value) { ui, err = c.Uint(value) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } return []uint{ui}, err @@ -113,7 +114,7 @@ func (c *Converter) SliceUint(any interface{}, option SliceOption) ([]uint, erro array = make([]uint, len(value)) for k, v := range value { ui, err = c.Uint(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ui @@ -122,7 +123,7 @@ func (c *Converter) SliceUint(any interface{}, option SliceOption) ([]uint, erro array = make([]uint, len(value)) for k, v := range value { ui, err = c.Uint(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ui @@ -131,7 +132,7 @@ func (c *Converter) SliceUint(any interface{}, option SliceOption) ([]uint, erro array = make([]uint, len(value)) for k, v := range value { ui, err = c.Uint(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ui @@ -140,7 +141,7 @@ func (c *Converter) SliceUint(any interface{}, option SliceOption) ([]uint, erro array = make([]uint, len(value)) for k, v := range value { ui, err = c.Uint(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ui @@ -156,7 +157,7 @@ func (c *Converter) SliceUint(any interface{}, option SliceOption) ([]uint, erro return v.Uints(), err } if v, ok := any.(localinterface.IInterfaces); ok { - return c.SliceUint(v.Interfaces(), option) + return c.SliceUint(v.Interfaces(), option...) } // Not a common type, it then uses reflection for conversion. originValueAndKind := reflection.OriginValueAndKind(any) @@ -168,7 +169,7 @@ func (c *Converter) SliceUint(any interface{}, option SliceOption) ([]uint, erro ) for i := 0; i < length; i++ { ui, err = c.Uint(originValueAndKind.OriginValue.Index(i).Interface()) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } slice[i] = ui @@ -180,7 +181,7 @@ func (c *Converter) SliceUint(any interface{}, option SliceOption) ([]uint, erro return []uint{}, err } ui, err = c.Uint(any) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } return []uint{ui}, err @@ -188,21 +189,22 @@ func (c *Converter) SliceUint(any interface{}, option SliceOption) ([]uint, erro } // SliceUint32 converts `any` to []uint32. -func (c *Converter) SliceUint32(any interface{}, option SliceOption) ([]uint32, error) { +func (c *Converter) SliceUint32(any interface{}, option ...SliceOption) ([]uint32, error) { if empty.IsNil(any) { return nil, nil } var ( - err error - ui uint32 - array []uint32 = nil + err error + ui uint32 + array []uint32 = nil + sliceOption = c.getSliceOption(option...) ) switch value := any.(type) { case []string: array = make([]uint32, len(value)) for k, v := range value { ui, err = c.Uint32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ui @@ -254,7 +256,7 @@ func (c *Converter) SliceUint32(any interface{}, option SliceOption) ([]uint32, } if utils.IsNumeric(value) { ui, err = c.Uint32(value) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } return []uint32{ui}, err @@ -284,7 +286,7 @@ func (c *Converter) SliceUint32(any interface{}, option SliceOption) ([]uint32, array = make([]uint32, len(value)) for k, v := range value { ui, err = c.Uint32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ui @@ -293,7 +295,7 @@ func (c *Converter) SliceUint32(any interface{}, option SliceOption) ([]uint32, array = make([]uint32, len(value)) for k, v := range value { ui, err = c.Uint32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ui @@ -302,7 +304,7 @@ func (c *Converter) SliceUint32(any interface{}, option SliceOption) ([]uint32, array = make([]uint32, len(value)) for k, v := range value { ui, err = c.Uint32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ui @@ -311,7 +313,7 @@ func (c *Converter) SliceUint32(any interface{}, option SliceOption) ([]uint32, array = make([]uint32, len(value)) for k, v := range value { ui, err = c.Uint32(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ui @@ -323,10 +325,10 @@ func (c *Converter) SliceUint32(any interface{}, option SliceOption) ([]uint32, // Default handler. if v, ok := any.(localinterface.IUints); ok { - return c.SliceUint32(v.Uints(), option) + return c.SliceUint32(v.Uints(), option...) } if v, ok := any.(localinterface.IInterfaces); ok { - return c.SliceUint32(v.Interfaces(), option) + return c.SliceUint32(v.Interfaces(), option...) } // Not a common type, it then uses reflection for conversion. originValueAndKind := reflection.OriginValueAndKind(any) @@ -338,7 +340,7 @@ func (c *Converter) SliceUint32(any interface{}, option SliceOption) ([]uint32, ) for i := 0; i < length; i++ { ui, err = c.Uint32(originValueAndKind.OriginValue.Index(i).Interface()) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } slice[i] = ui @@ -350,7 +352,7 @@ func (c *Converter) SliceUint32(any interface{}, option SliceOption) ([]uint32, return []uint32{}, err } ui, err = c.Uint32(any) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } return []uint32{ui}, err @@ -358,21 +360,22 @@ func (c *Converter) SliceUint32(any interface{}, option SliceOption) ([]uint32, } // SliceUint64 converts `any` to []uint64. -func (c *Converter) SliceUint64(any interface{}, option SliceOption) ([]uint64, error) { +func (c *Converter) SliceUint64(any interface{}, option ...SliceOption) ([]uint64, error) { if empty.IsNil(any) { return nil, nil } var ( - err error - ui uint64 - array []uint64 = nil + err error + ui uint64 + array []uint64 = nil + sliceOption = c.getSliceOption(option...) ) switch value := any.(type) { case []string: array = make([]uint64, len(value)) for k, v := range value { ui, err = c.Uint64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ui @@ -424,7 +427,7 @@ func (c *Converter) SliceUint64(any interface{}, option SliceOption) ([]uint64, } if utils.IsNumeric(value) { ui, err = c.Uint64(value) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } return []uint64{ui}, err @@ -454,7 +457,7 @@ func (c *Converter) SliceUint64(any interface{}, option SliceOption) ([]uint64, array = make([]uint64, len(value)) for k, v := range value { ui, err = c.Uint64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ui @@ -463,7 +466,7 @@ func (c *Converter) SliceUint64(any interface{}, option SliceOption) ([]uint64, array = make([]uint64, len(value)) for k, v := range value { ui, err = c.Uint64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ui @@ -472,7 +475,7 @@ func (c *Converter) SliceUint64(any interface{}, option SliceOption) ([]uint64, array = make([]uint64, len(value)) for k, v := range value { ui, err = c.Uint64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ui @@ -481,7 +484,7 @@ func (c *Converter) SliceUint64(any interface{}, option SliceOption) ([]uint64, array = make([]uint64, len(value)) for k, v := range value { ui, err = c.Uint64(v) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } array[k] = ui @@ -492,10 +495,10 @@ func (c *Converter) SliceUint64(any interface{}, option SliceOption) ([]uint64, } // Default handler. if v, ok := any.(localinterface.IUints); ok { - return c.SliceUint64(v.Uints(), option) + return c.SliceUint64(v.Uints(), option...) } if v, ok := any.(localinterface.IInterfaces); ok { - return c.SliceUint64(v.Interfaces(), option) + return c.SliceUint64(v.Interfaces(), option...) } // Not a common type, it then uses reflection for conversion. originValueAndKind := reflection.OriginValueAndKind(any) @@ -507,7 +510,7 @@ func (c *Converter) SliceUint64(any interface{}, option SliceOption) ([]uint64, ) for i := 0; i < length; i++ { ui, err = c.Uint64(originValueAndKind.OriginValue.Index(i).Interface()) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } slice[i] = ui @@ -519,7 +522,7 @@ func (c *Converter) SliceUint64(any interface{}, option SliceOption) ([]uint64, return []uint64{}, err } ui, err = c.Uint64(any) - if err != nil && !option.ContinueOnError { + if err != nil && !sliceOption.ContinueOnError { return nil, err } return []uint64{ui}, err diff --git a/util/gconv/internal/converter/converter_struct.go b/util/gconv/internal/converter/converter_struct.go index 6bf8c6913d1..1a84e41b688 100644 --- a/util/gconv/internal/converter/converter_struct.go +++ b/util/gconv/internal/converter/converter_struct.go @@ -32,8 +32,15 @@ type StructOption struct { ContinueOnError bool } +func (c *Converter) getStructOption(option ...StructOption) StructOption { + if len(option) > 0 { + return option[0] + } + return StructOption{} +} + // Struct is the core internal converting function for any data to struct. -func (c *Converter) Struct(params, pointer any, option StructOption) (err error) { +func (c *Converter) Struct(params, pointer any, option ...StructOption) (err error) { if params == nil { // If `params` is nil, no conversion. return nil @@ -63,6 +70,7 @@ func (c *Converter) Struct(params, pointer any, option StructOption) (err error) }() var ( + structOption = c.getStructOption(option...) paramsReflectValue reflect.Value paramsInterface any // DO NOT use `params` directly as it might be type `reflect.Value` pointerReflectValue reflect.Value @@ -105,9 +113,13 @@ func (c *Converter) Struct(params, pointer any, option StructOption) (err error) } // custom convert. - if ok, err = c.callCustomConverter(paramsReflectValue, pointerReflectValue); ok { + ok, err = c.callCustomConverter(paramsReflectValue, pointerReflectValue) + if err != nil && !structOption.ContinueOnError { return err } + if ok { + return nil + } // Normal unmarshalling interfaces checks. if ok, err = bindVarToReflectValueWithInterfaceCheck(pointerReflectValue, paramsInterface); ok { @@ -142,7 +154,7 @@ func (c *Converter) Struct(params, pointer any, option StructOption) (err error) // paramsMap is the map[string]any type variable for params. // DO NOT use MapDeep here. paramsMap, err = c.doMapConvert(paramsInterface, RecursiveTypeAuto, true, MapOption{ - ContinueOnError: option.ContinueOnError, + ContinueOnError: structOption.ContinueOnError, }) if err != nil { return err @@ -161,7 +173,7 @@ func (c *Converter) Struct(params, pointer any, option StructOption) (err error) } // Get struct info from cache or parse struct and cache the struct info. cachedStructInfo := c.internalConverter.GetCachedStructInfo( - pointerElemReflectValue.Type(), option.PriorityTag, + pointerElemReflectValue.Type(), structOption.PriorityTag, ) // Nothing to be converted. if cachedStructInfo == nil { @@ -182,7 +194,7 @@ func (c *Converter) Struct(params, pointer any, option StructOption) (err error) // Firstly, search according to custom mapping rules. // If a possible direct assignment is found, reduce the number of subsequent map searches. - for paramKey, fieldName := range option.ParamKeyToAttrMap { + for paramKey, fieldName := range structOption.ParamKeyToAttrMap { paramsValue, ok = paramsMap[paramKey] if !ok { continue @@ -194,13 +206,13 @@ func (c *Converter) Struct(params, pointer any, option StructOption) (err error) cachedFieldInfo, fieldValue, paramsValue, - option, + structOption, ); err != nil { return err } if len(cachedFieldInfo.OtherSameNameField) > 0 { if err = c.setOtherSameNameField( - cachedFieldInfo, paramsValue, pointerReflectValue, option, + cachedFieldInfo, paramsValue, pointerReflectValue, structOption, ); err != nil { return err } @@ -215,7 +227,7 @@ func (c *Converter) Struct(params, pointer any, option StructOption) (err error) return c.bindStructWithLoopFieldInfos( paramsMap, pointerElemReflectValue, usedParamsKeyOrTagNameMap, cachedStructInfo, - option, + structOption, ) } diff --git a/util/gconv/internal/converter/converter_structs.go b/util/gconv/internal/converter/converter_structs.go index d2eeec733fb..f164382bdc6 100644 --- a/util/gconv/internal/converter/converter_structs.go +++ b/util/gconv/internal/converter/converter_structs.go @@ -13,6 +13,19 @@ import ( "github.com/gogf/gf/v2/errors/gerror" ) +// StructsOption is the option for Structs function. +type StructsOption struct { + SliceOption SliceOption + StructOption StructOption +} + +func (c *Converter) getStructsOption(option ...StructsOption) StructsOption { + if len(option) > 0 { + return option[0] + } + return StructsOption{} +} + // Structs converts any slice to given struct slice. // // It automatically checks and converts json string to []map if `params` is string/[]byte. @@ -20,9 +33,7 @@ import ( // The parameter `pointer` should be type of pointer to slice of struct. // Note that if `pointer` is a pointer to another pointer of type of slice of struct, // it will create the struct/pointer internally. -func (c *Converter) Structs( - params any, pointer any, sliceOption SliceOption, structOption StructOption, -) (err error) { +func (c *Converter) Structs(params any, pointer any, option ...StructsOption) (err error) { defer func() { // Catch the panic, especially the reflection operation panics. if exception := recover(); exception != nil { @@ -47,9 +58,10 @@ func (c *Converter) Structs( } // Converting `params` to map slice. var ( - paramsList []any - paramsRv = reflect.ValueOf(params) - paramsKind = paramsRv.Kind() + paramsList []any + paramsRv = reflect.ValueOf(params) + paramsKind = paramsRv.Kind() + structsOption = c.getStructsOption(option...) ) for paramsKind == reflect.Ptr { paramsRv = paramsRv.Elem() @@ -62,8 +74,11 @@ func (c *Converter) Structs( paramsList[i] = paramsRv.Index(i).Interface() } default: - paramsMaps, err := c.SliceMap(params, sliceOption, MapOption{ - ContinueOnError: structOption.ContinueOnError, + paramsMaps, err := c.SliceMap(params, SliceMapOption{ + SliceOption: structsOption.SliceOption, + MapOption: MapOption{ + ContinueOnError: structsOption.StructOption.ContinueOnError, + }, }) if err != nil { return err @@ -95,7 +110,7 @@ func (c *Converter) Structs( if !tempReflectValue.IsValid() { tempReflectValue = reflect.New(itemType.Elem()).Elem() } - if err = c.Struct(paramsList[i], tempReflectValue, structOption); err != nil { + if err = c.Struct(paramsList[i], tempReflectValue, structsOption.StructOption); err != nil { return err } reflectElemArray.Index(i).Set(tempReflectValue.Addr()) @@ -109,7 +124,7 @@ func (c *Converter) Structs( } else { tempReflectValue = reflect.New(itemType).Elem() } - if err = c.Struct(paramsList[i], tempReflectValue, structOption); err != nil { + if err = c.Struct(paramsList[i], tempReflectValue, structsOption.StructOption); err != nil { return err } reflectElemArray.Index(i).Set(tempReflectValue) diff --git a/util/gconv/internal/structcache/structcache.go b/util/gconv/internal/structcache/structcache.go index 044f8a93526..99f6d236287 100644 --- a/util/gconv/internal/structcache/structcache.go +++ b/util/gconv/internal/structcache/structcache.go @@ -8,9 +8,12 @@ package structcache import ( + "context" "reflect" + "runtime" "sync" + "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/util/gconv/internal/localinterface" ) @@ -36,6 +39,7 @@ type Converter struct { } // AnyConvertFunc is the function type for converting any to specified type. +// Note that the parameter `to` is usually a pointer type. type AnyConvertFunc func(from any, to reflect.Value) error // NewConverter creates and returns a new Converter object. @@ -56,21 +60,39 @@ func (cf *Converter) MarkTypeConvertFunc(fieldType reflect.Type) { } // RegisterAnyConvertFunc registers custom type converting function for specified type. -func (cf *Converter) RegisterAnyConvertFunc(t reflect.Type, convertFunc AnyConvertFunc) { - if t == nil || convertFunc == nil { +func (cf *Converter) RegisterAnyConvertFunc(dstType reflect.Type, convertFunc AnyConvertFunc) { + if dstType == nil || convertFunc == nil { return } - for t.Kind() == reflect.Ptr { - t = t.Elem() + for dstType.Kind() == reflect.Ptr { + dstType = dstType.Elem() } - if t.Kind() == reflect.Interface { + if dstType.Kind() == reflect.Interface { cf.interfaceToTypeConvertMap = append(cf.interfaceToTypeConvertMap, interfaceTypeConverter{ - interfaceType: t, + interfaceType: dstType, convertFunc: convertFunc, }) return } - cf.anyToTypeConvertMap[t] = convertFunc + cf.anyToTypeConvertMap[dstType] = convertFunc + intlog.Printf( + context.Background(), + `RegisterAnyConvertFunc: %s -> %s`, + dstType.String(), runtime.FuncForPC(reflect.ValueOf(convertFunc).Pointer()).Name(), + ) +} + +// GetAnyConvertFuncByType retrieves and returns the converting function for specified type. +func (cf *Converter) GetAnyConvertFuncByType(dstType reflect.Type) AnyConvertFunc { + if dstType.Kind() == reflect.Ptr { + dstType = dstType.Elem() + } + return cf.anyToTypeConvertMap[dstType] +} + +// IsAnyConvertFuncEmpty checks whether there's any converting function registered. +func (cf *Converter) IsAnyConvertFuncEmpty() bool { + return len(cf.anyToTypeConvertMap) == 0 } func (cf *Converter) checkTypeImplInterface(t reflect.Type) AnyConvertFunc { From 07696fc77997b7626b63a86bb6693c68079606bb Mon Sep 17 00:00:00 2001 From: John Guo Date: Mon, 17 Mar 2025 09:21:00 +0800 Subject: [PATCH 099/102] feat(net/ghttp): add `GetMetaTag` function to retrieve metadata value for `HandlerItem` (#4206) --- net/ghttp/ghttp.go | 6 +- net/ghttp/ghttp_request_param_handler.go | 24 -------- net/ghttp/ghttp_server_router_serve.go | 56 +++++++++++++++---- ...tp_z_unit_feature_router_standard_test.go} | 47 ++++++++++++++-- 4 files changed, 89 insertions(+), 44 deletions(-) rename net/ghttp/{ghttp_z_unit_feature_router_strict_test.go => ghttp_z_unit_feature_router_standard_test.go} (91%) diff --git a/net/ghttp/ghttp.go b/net/ghttp/ghttp.go index bc823307eb8..dd5e0290682 100644 --- a/net/ghttp/ghttp.go +++ b/net/ghttp/ghttp.go @@ -64,11 +64,11 @@ type ( Handler *HandlerItem // The handler. Server string // Server name. Address string // Listening address. - Domain string // Bound domain. + Domain string // Bound domain, eg: example.com Type HandlerType // Route handler type. Middleware string // Bound middleware. - Method string // Handler method name. - Route string // Route URI. + Method string // Handler method name, eg: get, post. + Route string // Route URI, eg: /api/v1/user/{id}. Priority int // Just for reference. IsServiceHandler bool // Is a service handler. } diff --git a/net/ghttp/ghttp_request_param_handler.go b/net/ghttp/ghttp_request_param_handler.go index f931d14e45a..3863da8b5bc 100644 --- a/net/ghttp/ghttp_request_param_handler.go +++ b/net/ghttp/ghttp_request_param_handler.go @@ -6,8 +6,6 @@ package ghttp -import "github.com/gogf/gf/v2/util/gmeta" - // GetHandlerResponse retrieves and returns the handler response object and its error. func (r *Request) GetHandlerResponse() interface{} { return r.handlerResponse @@ -17,25 +15,3 @@ func (r *Request) GetHandlerResponse() interface{} { func (r *Request) GetServeHandler() *HandlerItemParsed { return r.serveHandler } - -// GetMetaTag retrieves and returns the metadata value associated with the given key from the request struct. -// The meta value is from struct tags from g.Meta/gmeta.Meta type. -// For example: -// -// type GetMetaTagReq struct { -// g.Meta `path:"/test" method:"post" summary:"meta_tag" tags:"meta"` -// // ... -// } -// -// r.GetServeHandler().GetMetaTag("summary") // returns "meta_tag" -// r.GetServeHandler().GetMetaTag("method") // returns "post" -func (h *HandlerItemParsed) GetMetaTag(key string) string { - if h == nil || h.Handler == nil { - return "" - } - metaValue := gmeta.Get(h.Handler.Info.Type.In(1), key) - if metaValue != nil { - return metaValue.String() - } - return "" -} diff --git a/net/ghttp/ghttp_server_router_serve.go b/net/ghttp/ghttp_server_router_serve.go index e9e6d9d489b..abb9bd590e4 100644 --- a/net/ghttp/ghttp_server_router_serve.go +++ b/net/ghttp/ghttp_server_router_serve.go @@ -18,6 +18,7 @@ import ( "github.com/gogf/gf/v2/internal/intlog" "github.com/gogf/gf/v2/internal/json" "github.com/gogf/gf/v2/text/gregex" + "github.com/gogf/gf/v2/util/gmeta" ) // handlerCacheItem is an item just for internal router searching cache. @@ -252,34 +253,34 @@ func (s *Server) searchHandlers(method, path, domain string) (parsedItems []*Han } // MarshalJSON implements the interface MarshalJSON for json.Marshal. -func (item HandlerItem) MarshalJSON() ([]byte, error) { - switch item.Type { +func (h *HandlerItem) MarshalJSON() ([]byte, error) { + switch h.Type { case HandlerTypeHook: return json.Marshal( fmt.Sprintf( `%s %s:%s (%s)`, - item.Router.Uri, - item.Router.Domain, - item.Router.Method, - item.HookName, + h.Router.Uri, + h.Router.Domain, + h.Router.Method, + h.HookName, ), ) case HandlerTypeMiddleware: return json.Marshal( fmt.Sprintf( `%s %s:%s (MIDDLEWARE)`, - item.Router.Uri, - item.Router.Domain, - item.Router.Method, + h.Router.Uri, + h.Router.Domain, + h.Router.Method, ), ) default: return json.Marshal( fmt.Sprintf( `%s %s:%s`, - item.Router.Uri, - item.Router.Domain, - item.Router.Method, + h.Router.Uri, + h.Router.Domain, + h.Router.Method, ), ) } @@ -289,3 +290,34 @@ func (item HandlerItem) MarshalJSON() ([]byte, error) { func (h *HandlerItemParsed) MarshalJSON() ([]byte, error) { return json.Marshal(h.Handler) } + +// GetMetaTag retrieves and returns the metadata value associated with the given key from the request struct. +// The meta value is from struct tags from g.Meta/gmeta.Meta type. +func (h *HandlerItem) GetMetaTag(key string) string { + if h == nil { + return "" + } + metaValue := gmeta.Get(h.Info.Type.In(1), key) + if metaValue != nil { + return metaValue.String() + } + return "" +} + +// GetMetaTag retrieves and returns the metadata value associated with the given key from the request struct. +// The meta value is from struct tags from g.Meta/gmeta.Meta type. +// For example: +// +// type GetMetaTagReq struct { +// g.Meta `path:"/test" method:"post" summary:"meta_tag" tags:"meta"` +// // ... +// } +// +// r.GetServeHandler().GetMetaTag("summary") // returns "meta_tag" +// r.GetServeHandler().GetMetaTag("method") // returns "post" +func (h *HandlerItemParsed) GetMetaTag(key string) string { + if h == nil || h.Handler == nil { + return "" + } + return h.Handler.GetMetaTag(key) +} diff --git a/net/ghttp/ghttp_z_unit_feature_router_strict_test.go b/net/ghttp/ghttp_z_unit_feature_router_standard_test.go similarity index 91% rename from net/ghttp/ghttp_z_unit_feature_router_strict_test.go rename to net/ghttp/ghttp_z_unit_feature_router_standard_test.go index c193c35a4b8..286bfb15d71 100644 --- a/net/ghttp/ghttp_z_unit_feature_router_strict_test.go +++ b/net/ghttp/ghttp_z_unit_feature_router_standard_test.go @@ -21,7 +21,7 @@ import ( "github.com/gogf/gf/v2/util/guid" ) -func Test_Router_Handler_Strict_WithObject(t *testing.T) { +func Test_Router_Handler_Standard_WithObject(t *testing.T) { type TestReq struct { Age int Name string @@ -137,7 +137,7 @@ func (ControllerForHandlerWithObjectAndMeta2) Test4(ctx context.Context, req *Te }, nil } -func Test_Router_Handler_Strict_WithObjectAndMeta(t *testing.T) { +func Test_Router_Handler_Standard_WithObjectAndMeta(t *testing.T) { s := g.Server(guid.S()) s.Use(ghttp.MiddlewareHandlerResponse) s.Group("/", func(group *ghttp.RouterGroup) { @@ -159,7 +159,7 @@ func Test_Router_Handler_Strict_WithObjectAndMeta(t *testing.T) { }) } -func Test_Router_Handler_Strict_Group_Bind(t *testing.T) { +func Test_Router_Handler_Standard_Group_Bind(t *testing.T) { s := g.Server(guid.S()) s.Use(ghttp.MiddlewareHandlerResponse) s.Group("/api/v1", func(group *ghttp.RouterGroup) { @@ -300,7 +300,7 @@ func Test_Custom_Slice_Type_Attribute(t *testing.T) { }) } -func Test_Router_Handler_Strict_WithGeneric(t *testing.T) { +func Test_Router_Handler_Standard_WithGeneric(t *testing.T) { type TestReq struct { Age int } @@ -397,7 +397,7 @@ func (c *ParameterCaseSensitiveController) Path( return &ParameterCaseSensitiveControllerPathRes{Path: req.Path}, nil } -func Test_Router_Handler_Strict_ParameterCaseSensitive(t *testing.T) { +func Test_Router_Handler_Standard_ParameterCaseSensitive(t *testing.T) { s := g.Server(guid.S()) s.Use(ghttp.MiddlewareHandlerResponse) s.Group("/", func(group *ghttp.RouterGroup) { @@ -534,3 +534,40 @@ func Test_NullString_Issue3465(t *testing.T) { }) } + +type testHandlerItemGetMetaTagReq struct { + g.Meta `path:"/test" method:"get" sm:"hello" tags:"示例"` +} +type testHandlerItemGetMetaTagRes struct{} + +type testHandlerItemGetMetaTag struct { +} + +func (t *testHandlerItemGetMetaTag) Test(ctx context.Context, req *testHandlerItemGetMetaTagReq) (res *testHandlerItemGetMetaTagRes, err error) { + return nil, nil +} + +func TestHandlerItem_GetMetaTag(t *testing.T) { + s := g.Server(guid.S()) + s.Use(ghttp.MiddlewareHandlerResponse) + s.Group("/", func(group *ghttp.RouterGroup) { + group.Bind(new(testHandlerItemGetMetaTag)) + }) + s.SetDumpRouterMap(false) + s.Start() + defer s.Shutdown() + + time.Sleep(100 * time.Millisecond) + gtest.C(t, func(t *gtest.T) { + routes := s.GetRoutes() + for _, route := range routes { + if !route.IsServiceHandler { + continue + } + t.Assert(route.Handler.GetMetaTag("path"), "/test") + t.Assert(route.Handler.GetMetaTag("method"), "get") + t.Assert(route.Handler.GetMetaTag("sm"), "hello") + t.Assert(route.Handler.GetMetaTag("tags"), "示例") + } + }) +} From abf77fac50e54f1cf7c2647ca8112f039faf0f51 Mon Sep 17 00:00:00 2001 From: hailaz <739476267@qq.com> Date: Mon, 17 Mar 2025 13:48:54 +0800 Subject: [PATCH 100/102] fix(cmd/gf): invalid binary suffix after installing binary using custom renamed file name that has suffix with `.` character (#4207) --- cmd/gf/internal/service/install.go | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cmd/gf/internal/service/install.go b/cmd/gf/internal/service/install.go index fb44a72932e..63f4ee361c3 100644 --- a/cmd/gf/internal/service/install.go +++ b/cmd/gf/internal/service/install.go @@ -162,8 +162,14 @@ func (s serviceInstall) getGoPathBin() string { func (s serviceInstall) getAvailablePaths() []serviceInstallAvailablePath { var ( folderPaths []serviceInstallAvailablePath - binaryFileName = "gf" + gfile.Ext(gfile.SelfPath()) + binaryFileName = "gf" ) + + // Windows binary file name suffix. + if runtime.GOOS == "windows" { + binaryFileName += ".exe" + } + // $GOPATH/bin if goPathBin := s.getGoPathBin(); goPathBin != "" { folderPaths = s.checkAndAppendToAvailablePath( From 9a61a6970f6144cfe64a6f1d660b42a5a3d39168 Mon Sep 17 00:00:00 2001 From: John Guo Date: Mon, 17 Mar 2025 14:50:07 +0800 Subject: [PATCH 101/102] fix(database/gdb): fix transaction propagation feature (#4199) --- .../mysql/mysql_z_unit_transaction_test.go | 60 +++++++++++++++---- database/gdb/gdb_core_transaction.go | 42 ++++++------- database/gdb/gdb_core_txcore.go | 8 ++- database/gdb/gdb_core_underlying.go | 2 +- database/gdb/gdb_model_utility.go | 4 +- 5 files changed, 80 insertions(+), 36 deletions(-) diff --git a/contrib/drivers/mysql/mysql_z_unit_transaction_test.go b/contrib/drivers/mysql/mysql_z_unit_transaction_test.go index e9c3315b447..0c583d964af 100644 --- a/contrib/drivers/mysql/mysql_z_unit_transaction_test.go +++ b/contrib/drivers/mysql/mysql_z_unit_transaction_test.go @@ -1286,8 +1286,7 @@ func Test_Transaction_Propagation(t *testing.T) { Propagation: gdb.PropagationNotSupported, }, func(ctx context.Context, tx2 gdb.TX) error { // Should execute without transaction - t.Assert(tx2, nil) - _, err := db.Insert(ctx, table, g.Map{ + _, err = db.Insert(ctx, table, g.Map{ "id": 9, "passport": "non_tx_record", }) @@ -1346,8 +1345,6 @@ func Test_Transaction_Propagation(t *testing.T) { err := db.TransactionWithOptions(ctx, gdb.TxOptions{ Propagation: gdb.PropagationNever, }, func(ctx context.Context, tx gdb.TX) error { - // Should execute without transaction - t.Assert(tx, nil) _, err := db.Insert(ctx, table, g.Map{ "id": 11, "passport": "never", @@ -1369,6 +1366,51 @@ func Test_Transaction_Propagation(t *testing.T) { }) } +func Test_Transaction_Propagation_PropagationSupports(t *testing.T) { + gtest.C(t, func(t *gtest.T) { + table := createTable() + defer dropTable(table) + + // scenario1: when in a transaction, use PropagationSupports to execute a transaction + err := db.Transaction(ctx, func(ctx context.Context, tx gdb.TX) error { + // insert in outer tx. + _, err := tx.Insert(table, g.Map{ + "id": 1, + }) + if err != nil { + return err + } + err = tx.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationSupports, + }, func(ctx context.Context, tx2 gdb.TX) error { + _, err = tx2.Insert(table, g.Map{ + "id": 2, + }) + return gerror.New("error") + }) + return err + }) + t.AssertNE(err, nil) + + // scenario2: when not in a transaction, do not use transaction but direct db link. + err = db.TransactionWithOptions(ctx, gdb.TxOptions{ + Propagation: gdb.PropagationSupports, + }, func(ctx context.Context, tx gdb.TX) error { + _, err = tx.Insert(table, g.Map{ + "id": 3, + }) + return err + }) + t.AssertNil(err) + + // 查询结果 + result, err := db.Model(table).OrderAsc("id").All() + t.AssertNil(err) + t.Assert(len(result), 1) + t.Assert(result[0]["id"], 3) + }) +} + func Test_Transaction_Propagation_Complex(t *testing.T) { gtest.C(t, func(t *gtest.T) { table1 := createTable() @@ -1389,7 +1431,7 @@ func Test_Transaction_Propagation_Complex(t *testing.T) { err = tx1.TransactionWithOptions(ctx, gdb.TxOptions{ Propagation: gdb.PropagationNested, }, func(ctx context.Context, tx2 gdb.TX) error { - _, err := tx2.Insert(table1, g.Map{ + _, err = tx2.Insert(table1, g.Map{ "id": 2, "passport": "nested1", }) @@ -1427,10 +1469,7 @@ func Test_Transaction_Propagation_Complex(t *testing.T) { err = tx1.TransactionWithOptions(ctx, gdb.TxOptions{ Propagation: gdb.PropagationNotSupported, }, func(ctx context.Context, tx2 gdb.TX) error { - // Should execute without transaction - t.Assert(tx2, nil) - - _, err := db.Insert(ctx, table2, g.Map{ + _, err = db.Insert(ctx, table2, g.Map{ "id": 5, "passport": "not_supported", }) @@ -1489,9 +1528,6 @@ func Test_Transaction_Propagation_Complex(t *testing.T) { err = tx1.TransactionWithOptions(ctx, gdb.TxOptions{ Propagation: gdb.PropagationNotSupported, }, func(ctx context.Context, tx2 gdb.TX) error { - // Should execute without transaction - t.Assert(tx2, nil) - // Start a new independent transaction return db.Transaction(ctx, func(ctx context.Context, tx3 gdb.TX) error { _, err := tx3.Insert(table, g.Map{ diff --git a/database/gdb/gdb_core_transaction.go b/database/gdb/gdb_core_transaction.go index 1faa73a6205..c4cbfa6165b 100644 --- a/database/gdb/gdb_core_transaction.go +++ b/database/gdb/gdb_core_transaction.go @@ -19,9 +19,15 @@ import ( type Propagation string const ( + // PropagationNested starts a nested transaction if already in a transaction, + // or behaves like PropagationRequired if not in a transaction. + // + // It is the default behavior. + PropagationNested Propagation = "NESTED" + // PropagationRequired starts a new transaction if not in a transaction, // or uses the existing transaction if already in a transaction. - PropagationRequired Propagation = "" // REQUIRED + PropagationRequired Propagation = "REQUIRED" // PropagationSupports executes within the existing transaction if present, // otherwise executes without transaction. @@ -30,10 +36,6 @@ const ( // PropagationRequiresNew starts a new transaction, and suspends the current transaction if one exists. PropagationRequiresNew Propagation = "REQUIRES_NEW" - // PropagationNested starts a nested transaction if already in a transaction, - // or behaves like PropagationRequired if not in a transaction. - PropagationNested Propagation = "NESTED" - // PropagationNotSupported executes non-transactional, suspends any existing transaction. PropagationNotSupported Propagation = "NOT_SUPPORTED" @@ -66,7 +68,8 @@ var transactionIdGenerator = gtype.NewUint64() // DefaultTxOptions returns the default transaction options. func DefaultTxOptions() TxOptions { return TxOptions{ - Propagation: PropagationRequired, + // Note the default propagation type is PropagationNested not PropagationRequired. + Propagation: PropagationNested, } } @@ -138,11 +141,14 @@ func (c *Core) TransactionWithOptions( switch opts.Propagation { case PropagationRequired: if currentTx != nil { - return currentTx.Transaction(ctx, f) + return f(ctx, currentTx) } return c.createNewTransaction(ctx, opts, f) case PropagationSupports: + if currentTx == nil { + currentTx = c.newEmptyTX() + } return f(ctx, currentTx) case PropagationMandatory: @@ -160,7 +166,7 @@ func (c *Core) TransactionWithOptions( case PropagationNotSupported: ctx = WithoutTX(ctx, group) - return f(ctx, nil) + return f(ctx, c.newEmptyTX()) case PropagationNever: if currentTx != nil { @@ -169,22 +175,12 @@ func (c *Core) TransactionWithOptions( "transaction propagation NEVER cannot run within an existing transaction", ) } - return f(ctx, nil) + ctx = WithoutTX(ctx, group) + return f(ctx, c.newEmptyTX()) case PropagationNested: if currentTx != nil { - // Create savepoint for nested transaction - if err = currentTx.Begin(); err != nil { - return err - } - defer func() { - if err != nil { - if rbErr := currentTx.Rollback(); rbErr != nil { - err = gerror.Wrap(err, rbErr.Error()) - } - } - }() - return f(ctx, currentTx) + return currentTx.Transaction(ctx, f) } return c.createNewTransaction(ctx, opts, f) @@ -280,6 +276,10 @@ func TXFromCtx(ctx context.Context, group string) TX { if tx.IsClosed() { return nil } + // no underlying sql tx. + if tx.GetSqlTX() == nil { + return nil + } tx = tx.Ctx(ctx) return tx } diff --git a/database/gdb/gdb_core_txcore.go b/database/gdb/gdb_core_txcore.go index 79154068f13..492d1338044 100644 --- a/database/gdb/gdb_core_txcore.go +++ b/database/gdb/gdb_core_txcore.go @@ -46,6 +46,12 @@ type TXCore struct { cancelFunc context.CancelFunc } +func (c *Core) newEmptyTX() TX { + return &TXCore{ + db: c.db, + } +} + // transactionKeyForNestedPoint forms and returns the transaction key at current save point. func (tx *TXCore) transactionKeyForNestedPoint() string { return tx.db.GetCore().QuoteWord( @@ -427,5 +433,5 @@ func (tx *TXCore) IsOnMaster() bool { // IsTransaction implements interface function Link.IsTransaction. func (tx *TXCore) IsTransaction() bool { - return true + return tx != nil } diff --git a/database/gdb/gdb_core_underlying.go b/database/gdb/gdb_core_underlying.go index d7d8d1c510c..481e870e86a 100644 --- a/database/gdb/gdb_core_underlying.go +++ b/database/gdb/gdb_core_underlying.go @@ -103,7 +103,7 @@ func (c *Core) DoExec(ctx context.Context, link Link, sql string, args ...interf return nil, err } } else if !link.IsTransaction() { - // If current link is not transaction link, it checks and retrieves transaction from context. + // If current link is not transaction link, it tries retrieving transaction object from context. if tx := TXFromCtx(ctx, c.db.GetGroup()); tx != nil { link = &txLink{tx.GetSqlTX()} } diff --git a/database/gdb/gdb_model_utility.go b/database/gdb/gdb_model_utility.go index 3532396230e..b9782f7fa11 100644 --- a/database/gdb/gdb_model_utility.go +++ b/database/gdb/gdb_model_utility.go @@ -247,7 +247,9 @@ func (m *Model) doMappingAndFilterForInsertOrUpdateDataMap(data Map, allowOmitEm // The parameter `master` specifies whether using the master node if master-slave configured. func (m *Model) getLink(master bool) Link { if m.tx != nil { - return &txLink{m.tx.GetSqlTX()} + if sqlTx := m.tx.GetSqlTX(); sqlTx != nil { + return &txLink{sqlTx} + } } linkType := m.linkType if linkType == 0 { From 69e3362d0d6a1676e4b6c035bb17d27c322b88ff Mon Sep 17 00:00:00 2001 From: John Guo Date: Mon, 17 Mar 2025 15:52:26 +0800 Subject: [PATCH 102/102] feat: new version v2.9.0 (#4204) --- README.MD | 2 +- cmd/gf/go.mod | 14 +++++++------- cmd/gf/internal/cmd/testdata/build/varmap/go.mod | 6 +++--- cmd/gf/internal/cmd/testdata/build/varmap/go.sum | 2 ++ contrib/config/apollo/go.mod | 2 +- contrib/config/consul/go.mod | 2 +- contrib/config/kubecm/go.mod | 2 +- contrib/config/nacos/go.mod | 2 +- contrib/config/polaris/go.mod | 2 +- contrib/drivers/clickhouse/go.mod | 2 +- contrib/drivers/dm/go.mod | 2 +- contrib/drivers/mssql/go.mod | 2 +- contrib/drivers/mysql/go.mod | 2 +- contrib/drivers/oracle/go.mod | 2 +- contrib/drivers/pgsql/go.mod | 2 +- contrib/drivers/sqlite/go.mod | 2 +- contrib/drivers/sqlitecgo/go.mod | 2 +- contrib/metric/otelmetric/go.mod | 2 +- contrib/nosql/redis/go.mod | 2 +- contrib/registry/consul/go.mod | 2 +- contrib/registry/etcd/go.mod | 2 +- contrib/registry/file/go.mod | 2 +- contrib/registry/nacos/go.mod | 2 +- contrib/registry/polaris/go.mod | 2 +- contrib/registry/zookeeper/go.mod | 2 +- contrib/rpc/grpcx/go.mod | 4 ++-- contrib/sdk/httpclient/go.mod | 2 +- contrib/trace/otlpgrpc/go.mod | 2 +- contrib/trace/otlphttp/go.mod | 2 +- version.go | 2 +- 30 files changed, 40 insertions(+), 38 deletions(-) diff --git a/README.MD b/README.MD index 3fc372015bf..ddf70404ec4 100644 --- a/README.MD +++ b/README.MD @@ -36,7 +36,7 @@ A powerful framework for faster, easier, and more efficient project development. 💖 [Thanks to all the contributors who made GoFrame possible](https://github.com/gogf/gf/graphs/contributors) 💖 -goframe contributors +goframe contributors # License diff --git a/cmd/gf/go.mod b/cmd/gf/go.mod index b12cae08acf..239932a1eca 100644 --- a/cmd/gf/go.mod +++ b/cmd/gf/go.mod @@ -3,13 +3,13 @@ module github.com/gogf/gf/cmd/gf/v2 go 1.22 require ( - github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.9.0-beta - github.com/gogf/gf/contrib/drivers/mssql/v2 v2.9.0-beta - github.com/gogf/gf/contrib/drivers/mysql/v2 v2.9.0-beta - github.com/gogf/gf/contrib/drivers/oracle/v2 v2.9.0-beta - github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.9.0-beta - github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.9.0-beta - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/contrib/drivers/clickhouse/v2 v2.9.0 + github.com/gogf/gf/contrib/drivers/mssql/v2 v2.9.0 + github.com/gogf/gf/contrib/drivers/mysql/v2 v2.9.0 + github.com/gogf/gf/contrib/drivers/oracle/v2 v2.9.0 + github.com/gogf/gf/contrib/drivers/pgsql/v2 v2.9.0 + github.com/gogf/gf/contrib/drivers/sqlite/v2 v2.9.0 + github.com/gogf/gf/v2 v2.9.0 github.com/gogf/selfupdate v0.0.0-20231215043001-5c48c528462f github.com/olekukonko/tablewriter v0.0.5 github.com/schollz/progressbar/v3 v3.15.0 diff --git a/cmd/gf/internal/cmd/testdata/build/varmap/go.mod b/cmd/gf/internal/cmd/testdata/build/varmap/go.mod index d2d0e9e4f0b..fce4e908903 100644 --- a/cmd/gf/internal/cmd/testdata/build/varmap/go.mod +++ b/cmd/gf/internal/cmd/testdata/build/varmap/go.mod @@ -1,12 +1,12 @@ module github.com/gogf/gf/cmd/gf/cmd/gf/testdata/vardump/v2 -go 1.18 +go 1.22 require github.com/gogf/gf/v2 v2.8.2 require ( - go.opentelemetry.io/otel v1.24.0 // indirect - go.opentelemetry.io/otel/trace v1.24.0 // indirect + go.opentelemetry.io/otel v1.32.0 // indirect + go.opentelemetry.io/otel/trace v1.32.0 // indirect ) replace github.com/gogf/gf/v2 => ../../../../../../../ diff --git a/cmd/gf/internal/cmd/testdata/build/varmap/go.sum b/cmd/gf/internal/cmd/testdata/build/varmap/go.sum index 4f2c0c5da1c..45664b4328a 100644 --- a/cmd/gf/internal/cmd/testdata/build/varmap/go.sum +++ b/cmd/gf/internal/cmd/testdata/build/varmap/go.sum @@ -19,10 +19,12 @@ github.com/rivo/uniseg v0.4.7 h1:WUdvkW8uEhrYfLC4ZzdpI2ztxP1I582+49Oc5Mq64VQ= github.com/stretchr/testify v1.8.4 h1:CcVxjf3Q8PM0mHUKJCdn+eZZtm5yQwehR5yeSVQQcUk= go.opentelemetry.io/otel v1.24.0 h1:0LAOdjNmQeSTzGBzduGe/rU4tZhMwL5rWgtp9Ku5Jfo= go.opentelemetry.io/otel v1.24.0/go.mod h1:W7b9Ozg4nkF5tWI5zsXkaKKDjdVjpD4oAt9Qi/MArHo= +go.opentelemetry.io/otel v1.32.0/go.mod h1:00DCVSB0RQcnzlwyTfqtxSm+DRr9hpYrHjNGiBHVQIg= go.opentelemetry.io/otel/metric v1.24.0 h1:6EhoGWWK28x1fbpA4tYTOWBkPefTDQnb8WSGXlc88kI= go.opentelemetry.io/otel/sdk v1.24.0 h1:YMPPDNymmQN3ZgczicBY3B6sf9n62Dlj9pWD3ucgoDw= go.opentelemetry.io/otel/trace v1.24.0 h1:CsKnnL4dUAr/0llH9FKuc698G04IrpWV0MQA/Y1YELI= go.opentelemetry.io/otel/trace v1.24.0/go.mod h1:HPc3Xr/cOApsBI154IU0OI0HJexz+aw5uPdbs3UCjNU= +go.opentelemetry.io/otel/trace v1.32.0/go.mod h1:+i4rkvCraA+tG6AzwloGaCtkx53Fa+L+V8e9a7YvhT8= golang.org/x/net v0.27.0 h1:5K3Njcw06/l2y9vpGCSdcxWOYHOUk3dVNGDXN+FvAys= golang.org/x/sys v0.22.0 h1:RI27ohtqKCnwULzJLqkv897zojh5/DwS/ENaMzUOaWI= golang.org/x/text v0.16.0 h1:a94ExnEXNtEwYLGJSIUxnWoxoRz/ZcCsV63ROupILh4= diff --git a/contrib/config/apollo/go.mod b/contrib/config/apollo/go.mod index be2ef8f5357..8000cdbccfb 100644 --- a/contrib/config/apollo/go.mod +++ b/contrib/config/apollo/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( github.com/apolloconfig/agollo/v4 v4.3.1 - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 ) require ( diff --git a/contrib/config/consul/go.mod b/contrib/config/consul/go.mod index 53212a7513b..49528da785f 100644 --- a/contrib/config/consul/go.mod +++ b/contrib/config/consul/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/consul/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 github.com/hashicorp/consul/api v1.24.0 github.com/hashicorp/go-cleanhttp v0.5.2 ) diff --git a/contrib/config/kubecm/go.mod b/contrib/config/kubecm/go.mod index 2c0b5f09ad6..0ae701bd3e6 100644 --- a/contrib/config/kubecm/go.mod +++ b/contrib/config/kubecm/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/kubecm/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 k8s.io/api v0.27.4 k8s.io/apimachinery v0.27.4 k8s.io/client-go v0.27.4 diff --git a/contrib/config/nacos/go.mod b/contrib/config/nacos/go.mod index 31b3b6b748e..6f64a34b111 100644 --- a/contrib/config/nacos/go.mod +++ b/contrib/config/nacos/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/nacos/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 github.com/nacos-group/nacos-sdk-go/v2 v2.2.5 ) diff --git a/contrib/config/polaris/go.mod b/contrib/config/polaris/go.mod index e1d0e95d232..0f6c978ef53 100644 --- a/contrib/config/polaris/go.mod +++ b/contrib/config/polaris/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/config/polaris/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 github.com/polarismesh/polaris-go v1.5.8 ) diff --git a/contrib/drivers/clickhouse/go.mod b/contrib/drivers/clickhouse/go.mod index 5b708024945..3debc69911e 100644 --- a/contrib/drivers/clickhouse/go.mod +++ b/contrib/drivers/clickhouse/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( github.com/ClickHouse/clickhouse-go/v2 v2.0.15 - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 github.com/google/uuid v1.6.0 github.com/shopspring/decimal v1.3.1 ) diff --git a/contrib/drivers/dm/go.mod b/contrib/drivers/dm/go.mod index c3b1efc7782..6b487eb40d5 100644 --- a/contrib/drivers/dm/go.mod +++ b/contrib/drivers/dm/go.mod @@ -6,7 +6,7 @@ replace github.com/gogf/gf/v2 => ../../../ require ( gitee.com/chunanyong/dm v1.8.12 - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 ) require ( diff --git a/contrib/drivers/mssql/go.mod b/contrib/drivers/mssql/go.mod index 7bb9d011db7..9547e8453f9 100644 --- a/contrib/drivers/mssql/go.mod +++ b/contrib/drivers/mssql/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/mssql/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 github.com/microsoft/go-mssqldb v1.7.1 ) diff --git a/contrib/drivers/mysql/go.mod b/contrib/drivers/mysql/go.mod index 330074afb94..70fff809cfe 100644 --- a/contrib/drivers/mysql/go.mod +++ b/contrib/drivers/mysql/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( github.com/go-sql-driver/mysql v1.7.1 - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 ) require ( diff --git a/contrib/drivers/oracle/go.mod b/contrib/drivers/oracle/go.mod index 845f18ec40e..02e0750daab 100644 --- a/contrib/drivers/oracle/go.mod +++ b/contrib/drivers/oracle/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/oracle/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 github.com/sijms/go-ora/v2 v2.7.10 ) diff --git a/contrib/drivers/pgsql/go.mod b/contrib/drivers/pgsql/go.mod index 4bfa51c0c05..2e3c9c3cf96 100644 --- a/contrib/drivers/pgsql/go.mod +++ b/contrib/drivers/pgsql/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/pgsql/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 github.com/lib/pq v1.10.9 ) diff --git a/contrib/drivers/sqlite/go.mod b/contrib/drivers/sqlite/go.mod index 51bd021b368..f867d83616e 100644 --- a/contrib/drivers/sqlite/go.mod +++ b/contrib/drivers/sqlite/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( github.com/glebarez/go-sqlite v1.21.2 - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 ) require ( diff --git a/contrib/drivers/sqlitecgo/go.mod b/contrib/drivers/sqlitecgo/go.mod index 8b30e68555c..e223c7ad7b4 100644 --- a/contrib/drivers/sqlitecgo/go.mod +++ b/contrib/drivers/sqlitecgo/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/drivers/sqlitecgo/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 github.com/mattn/go-sqlite3 v1.14.17 ) diff --git a/contrib/metric/otelmetric/go.mod b/contrib/metric/otelmetric/go.mod index 4c0fabb57ac..c0a503a8164 100644 --- a/contrib/metric/otelmetric/go.mod +++ b/contrib/metric/otelmetric/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/metric/otelmetric/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 github.com/prometheus/client_golang v1.19.1 go.opentelemetry.io/contrib/instrumentation/runtime v0.49.0 go.opentelemetry.io/otel v1.32.0 diff --git a/contrib/nosql/redis/go.mod b/contrib/nosql/redis/go.mod index 3ff89b71777..3f3f713158c 100644 --- a/contrib/nosql/redis/go.mod +++ b/contrib/nosql/redis/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/nosql/redis/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 github.com/redis/go-redis/v9 v9.7.0 go.opentelemetry.io/otel v1.32.0 go.opentelemetry.io/otel/trace v1.32.0 diff --git a/contrib/registry/consul/go.mod b/contrib/registry/consul/go.mod index d1cce99324e..41b1ba6320c 100644 --- a/contrib/registry/consul/go.mod +++ b/contrib/registry/consul/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/consul/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 github.com/hashicorp/consul/api v1.26.1 ) diff --git a/contrib/registry/etcd/go.mod b/contrib/registry/etcd/go.mod index 0ee6e218b50..a2711193e35 100644 --- a/contrib/registry/etcd/go.mod +++ b/contrib/registry/etcd/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/etcd/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 go.etcd.io/etcd/client/v3 v3.5.17 google.golang.org/grpc v1.59.0 ) diff --git a/contrib/registry/file/go.mod b/contrib/registry/file/go.mod index c5a61244fbb..64f466eb2d9 100644 --- a/contrib/registry/file/go.mod +++ b/contrib/registry/file/go.mod @@ -2,7 +2,7 @@ module github.com/gogf/gf/contrib/registry/file/v2 go 1.22 -require github.com/gogf/gf/v2 v2.9.0-beta +require github.com/gogf/gf/v2 v2.9.0 require ( github.com/BurntSushi/toml v1.4.0 // indirect diff --git a/contrib/registry/nacos/go.mod b/contrib/registry/nacos/go.mod index 4b9e42d19dc..11fe63708f3 100644 --- a/contrib/registry/nacos/go.mod +++ b/contrib/registry/nacos/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/nacos/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 github.com/nacos-group/nacos-sdk-go/v2 v2.2.7 ) diff --git a/contrib/registry/polaris/go.mod b/contrib/registry/polaris/go.mod index b4415b6e15c..6ff2a3b3846 100644 --- a/contrib/registry/polaris/go.mod +++ b/contrib/registry/polaris/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/registry/polaris/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 github.com/polarismesh/polaris-go v1.5.8 ) diff --git a/contrib/registry/zookeeper/go.mod b/contrib/registry/zookeeper/go.mod index 15908c239ee..ce597fc998b 100644 --- a/contrib/registry/zookeeper/go.mod +++ b/contrib/registry/zookeeper/go.mod @@ -4,7 +4,7 @@ go 1.22 require ( github.com/go-zookeeper/zk v1.0.3 - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 golang.org/x/sync v0.10.0 ) diff --git a/contrib/rpc/grpcx/go.mod b/contrib/rpc/grpcx/go.mod index 72919a9d20f..eff02630b63 100644 --- a/contrib/rpc/grpcx/go.mod +++ b/contrib/rpc/grpcx/go.mod @@ -3,8 +3,8 @@ module github.com/gogf/gf/contrib/rpc/grpcx/v2 go 1.22 require ( - github.com/gogf/gf/contrib/registry/file/v2 v2.9.0-beta - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/contrib/registry/file/v2 v2.9.0 + github.com/gogf/gf/v2 v2.9.0 go.opentelemetry.io/otel v1.32.0 go.opentelemetry.io/otel/trace v1.32.0 google.golang.org/grpc v1.64.1 diff --git a/contrib/sdk/httpclient/go.mod b/contrib/sdk/httpclient/go.mod index 5dfb326fff3..c871476e94f 100644 --- a/contrib/sdk/httpclient/go.mod +++ b/contrib/sdk/httpclient/go.mod @@ -2,7 +2,7 @@ module github.com/gogf/gf/contrib/sdk/httpclient/v2 go 1.22 -require github.com/gogf/gf/v2 v2.9.0-beta +require github.com/gogf/gf/v2 v2.9.0 require ( github.com/BurntSushi/toml v1.4.0 // indirect diff --git a/contrib/trace/otlpgrpc/go.mod b/contrib/trace/otlpgrpc/go.mod index 29d16faefc7..29db122bb14 100644 --- a/contrib/trace/otlpgrpc/go.mod +++ b/contrib/trace/otlpgrpc/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/trace/otlpgrpc/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 go.opentelemetry.io/otel v1.32.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracegrpc v1.24.0 diff --git a/contrib/trace/otlphttp/go.mod b/contrib/trace/otlphttp/go.mod index 616865c314c..df8b34db908 100644 --- a/contrib/trace/otlphttp/go.mod +++ b/contrib/trace/otlphttp/go.mod @@ -3,7 +3,7 @@ module github.com/gogf/gf/contrib/trace/otlphttp/v2 go 1.22 require ( - github.com/gogf/gf/v2 v2.9.0-beta + github.com/gogf/gf/v2 v2.9.0 go.opentelemetry.io/otel v1.32.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace v1.24.0 go.opentelemetry.io/otel/exporters/otlp/otlptrace/otlptracehttp v1.24.0 diff --git a/version.go b/version.go index 34f3242801e..cd0daf596c5 100644 --- a/version.go +++ b/version.go @@ -2,5 +2,5 @@ package gf const ( // VERSION is the current GoFrame version. - VERSION = "v2.9.0-beta" + VERSION = "v2.9.0" )