From 05760d1eac73bb8de0d4a35d3183ef47af0f22a3 Mon Sep 17 00:00:00 2001 From: John Date: Mon, 30 Mar 2020 20:47:50 +0800 Subject: [PATCH] fix usage for garray.PopRand --- net/ghttp/ghttp_unit_client_test.go | 18 ++++----- net/ghttp/ghttp_unit_context_test.go | 2 +- net/ghttp/ghttp_unit_cookie_test.go | 2 +- net/ghttp/ghttp_unit_log_test.go | 2 +- net/ghttp/ghttp_unit_mess_test.go | 2 +- net/ghttp/ghttp_unit_middleware_basic_test.go | 38 +++++++++---------- net/ghttp/ghttp_unit_middleware_cors_test.go | 4 +- net/ghttp/ghttp_unit_param_file_test.go | 6 +-- net/ghttp/ghttp_unit_param_json_test.go | 4 +- net/ghttp/ghttp_unit_param_page_test.go | 2 +- net/ghttp/ghttp_unit_param_struct_test.go | 2 +- net/ghttp/ghttp_unit_param_test.go | 6 +-- net/ghttp/ghttp_unit_param_xml_test.go | 2 +- net/ghttp/ghttp_unit_pprof_test.go | 2 +- net/ghttp/ghttp_unit_router_basic_test.go | 14 +++---- .../ghttp_unit_router_controller_rest_test.go | 2 +- .../ghttp_unit_router_controller_test.go | 6 +-- .../ghttp_unit_router_domain_basic_test.go | 12 +++--- ...unit_router_domain_controller_rest_test.go | 2 +- ...http_unit_router_domain_controller_test.go | 6 +-- ...ttp_unit_router_domain_object_rest_test.go | 2 +- .../ghttp_unit_router_domain_object_test.go | 6 +-- net/ghttp/ghttp_unit_router_exit_test.go | 6 +-- .../ghttp_unit_router_group_group_test.go | 2 +- .../ghttp_unit_router_group_hook_test.go | 6 +-- .../ghttp_unit_router_group_rest_test.go | 2 +- net/ghttp/ghttp_unit_router_group_test.go | 8 ++-- net/ghttp/ghttp_unit_router_hook_test.go | 8 ++-- net/ghttp/ghttp_unit_router_names_test.go | 8 ++-- .../ghttp_unit_router_object_rest1_test.go | 2 +- .../ghttp_unit_router_object_rest2_test.go | 2 +- net/ghttp/ghttp_unit_router_object_test.go | 6 +-- net/ghttp/ghttp_unit_session_test.go | 6 +-- net/ghttp/ghttp_unit_static_test.go | 24 ++++++------ net/ghttp/ghttp_unit_template_test.go | 10 ++--- net/ghttp/ghttp_unit_websocket_test.go | 2 +- net/gtcp/gtcp_unit_pkg_test.go | 6 +-- net/gtcp/gtcp_unit_pool_pkg_test.go | 6 +-- net/gtcp/gtcp_unit_pool_test.go | 4 +- net/gudp/gudp_unit_basic_test.go | 4 +- 40 files changed, 127 insertions(+), 127 deletions(-) diff --git a/net/ghttp/ghttp_unit_client_test.go b/net/ghttp/ghttp_unit_client_test.go index 74c631bf6..f66c62a54 100644 --- a/net/ghttp/ghttp_unit_client_test.go +++ b/net/ghttp/ghttp_unit_client_test.go @@ -18,7 +18,7 @@ import ( ) func Test_Client_Basic(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/hello", func(r *ghttp.Request) { r.Response.Write("hello") @@ -43,7 +43,7 @@ func Test_Client_Basic(t *testing.T) { } func Test_Client_BasicAuth(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/auth", func(r *ghttp.Request) { if r.BasicAuth("admin", "admin") { @@ -67,7 +67,7 @@ func Test_Client_BasicAuth(t *testing.T) { } func Test_Client_Cookie(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/cookie", func(r *ghttp.Request) { r.Response.Write(r.Cookie.Get("test")) @@ -88,7 +88,7 @@ func Test_Client_Cookie(t *testing.T) { } func Test_Client_Cookies(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/cookie", func(r *ghttp.Request) { r.Cookie.Set("test1", "1") @@ -121,7 +121,7 @@ func Test_Client_Cookies(t *testing.T) { } func Test_Client_Chain_Header(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/header1", func(r *ghttp.Request) { r.Response.Write(r.Header.Get("test1")) @@ -146,7 +146,7 @@ func Test_Client_Chain_Header(t *testing.T) { } func Test_Client_Chain_Context(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/context", func(r *ghttp.Request) { time.Sleep(1 * time.Second) @@ -171,7 +171,7 @@ func Test_Client_Chain_Context(t *testing.T) { } func Test_Client_Chain_Timeout(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/timeout", func(r *ghttp.Request) { time.Sleep(1 * time.Second) @@ -192,7 +192,7 @@ func Test_Client_Chain_Timeout(t *testing.T) { } func Test_Client_Chain_ContentJson(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/json", func(r *ghttp.Request) { r.Response.Write(r.Get("name"), r.Get("score")) @@ -221,7 +221,7 @@ func Test_Client_Chain_ContentJson(t *testing.T) { } func Test_Client_Chain_ContentXml(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/xml", func(r *ghttp.Request) { r.Response.Write(r.Get("name"), r.Get("score")) diff --git a/net/ghttp/ghttp_unit_context_test.go b/net/ghttp/ghttp_unit_context_test.go index 9ed049862..8caab6091 100644 --- a/net/ghttp/ghttp_unit_context_test.go +++ b/net/ghttp/ghttp_unit_context_test.go @@ -17,7 +17,7 @@ import ( ) func Test_Context(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Group("/", func(group *ghttp.RouterGroup) { group.Middleware(func(r *ghttp.Request) { diff --git a/net/ghttp/ghttp_unit_cookie_test.go b/net/ghttp/ghttp_unit_cookie_test.go index 2a0be679f..a2f8ca40b 100644 --- a/net/ghttp/ghttp_unit_cookie_test.go +++ b/net/ghttp/ghttp_unit_cookie_test.go @@ -17,7 +17,7 @@ import ( ) func Test_Cookie(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/set", func(r *ghttp.Request) { r.Cookie.Set(r.GetString("k"), r.GetString("v")) diff --git a/net/ghttp/ghttp_unit_log_test.go b/net/ghttp/ghttp_unit_log_test.go index 496002c00..1265d2681 100644 --- a/net/ghttp/ghttp_unit_log_test.go +++ b/net/ghttp/ghttp_unit_log_test.go @@ -24,7 +24,7 @@ import ( func Test_Log(t *testing.T) { gtest.C(t, func(t *gtest.T) { logDir := gfile.TempDir(gtime.TimestampNanoStr()) - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/hello", func(r *ghttp.Request) { r.Response.Write("hello") diff --git a/net/ghttp/ghttp_unit_mess_test.go b/net/ghttp/ghttp_unit_mess_test.go index 6c4c4acda..b9d4e678f 100644 --- a/net/ghttp/ghttp_unit_mess_test.go +++ b/net/ghttp/ghttp_unit_mess_test.go @@ -17,7 +17,7 @@ import ( ) func Test_GetUrl(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/url", func(r *ghttp.Request) { r.Response.Write(r.GetUrl()) diff --git a/net/ghttp/ghttp_unit_middleware_basic_test.go b/net/ghttp/ghttp_unit_middleware_basic_test.go index 3f0eac47e..36410f323 100644 --- a/net/ghttp/ghttp_unit_middleware_basic_test.go +++ b/net/ghttp/ghttp_unit_middleware_basic_test.go @@ -20,7 +20,7 @@ import ( ) func Test_BindMiddleware_Basic1(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/test/test", func(r *ghttp.Request) { r.Response.Write("test") @@ -60,7 +60,7 @@ func Test_BindMiddleware_Basic1(t *testing.T) { } func Test_BindMiddleware_Basic2(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/test/test", func(r *ghttp.Request) { r.Response.Write("test") @@ -87,7 +87,7 @@ func Test_BindMiddleware_Basic2(t *testing.T) { } func Test_BindMiddleware_Basic3(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/test/test", func(r *ghttp.Request) { r.Response.Write("test") @@ -131,7 +131,7 @@ func Test_BindMiddleware_Basic3(t *testing.T) { } func Test_BindMiddleware_Basic4(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Group("/", func(group *ghttp.RouterGroup) { group.Middleware(func(r *ghttp.Request) { @@ -163,7 +163,7 @@ func Test_BindMiddleware_Basic4(t *testing.T) { } func Test_Middleware_With_Static(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Group("/", func(group *ghttp.RouterGroup) { group.Middleware(func(r *ghttp.Request) { @@ -193,7 +193,7 @@ func Test_Middleware_With_Static(t *testing.T) { } func Test_Middleware_Status(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Group("/", func(group *ghttp.RouterGroup) { group.Middleware(func(r *ghttp.Request) { @@ -224,7 +224,7 @@ func Test_Middleware_Status(t *testing.T) { } func Test_Middleware_Hook_With_Static(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) a := garray.New(true) s.Group("/", func(group *ghttp.RouterGroup) { @@ -278,7 +278,7 @@ func Test_Middleware_Hook_With_Static(t *testing.T) { } func Test_BindMiddleware_Status(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/test/test", func(r *ghttp.Request) { r.Response.Write("test") @@ -304,7 +304,7 @@ func Test_BindMiddleware_Status(t *testing.T) { } func Test_BindMiddlewareDefault_Basic1(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/test/test", func(r *ghttp.Request) { r.Response.Write("test") @@ -335,7 +335,7 @@ func Test_BindMiddlewareDefault_Basic1(t *testing.T) { } func Test_BindMiddlewareDefault_Basic2(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("PUT:/test/test", func(r *ghttp.Request) { r.Response.Write("test") @@ -368,7 +368,7 @@ func Test_BindMiddlewareDefault_Basic2(t *testing.T) { } func Test_BindMiddlewareDefault_Basic3(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/test/test", func(r *ghttp.Request) { r.Response.Write("test") @@ -397,7 +397,7 @@ func Test_BindMiddlewareDefault_Basic3(t *testing.T) { } func Test_BindMiddlewareDefault_Basic4(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/test/test", func(r *ghttp.Request) { r.Response.Write("test") @@ -426,7 +426,7 @@ func Test_BindMiddlewareDefault_Basic4(t *testing.T) { } func Test_BindMiddlewareDefault_Basic5(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/test/test", func(r *ghttp.Request) { r.Response.Write("test") @@ -455,7 +455,7 @@ func Test_BindMiddlewareDefault_Basic5(t *testing.T) { } func Test_BindMiddlewareDefault_Status(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/test/test", func(r *ghttp.Request) { r.Response.Write("test") @@ -501,7 +501,7 @@ func (o *ObjectMiddleware) Info(r *ghttp.Request) { } func Test_BindMiddlewareDefault_Basic6(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindObject("/", new(ObjectMiddleware)) s.BindMiddlewareDefault(func(r *ghttp.Request) { @@ -534,7 +534,7 @@ func Test_BindMiddlewareDefault_Basic6(t *testing.T) { } func Test_Hook_Middleware_Basic1(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/test/test", func(r *ghttp.Request) { r.Response.Write("test") @@ -591,7 +591,7 @@ func MiddlewareCORS(r *ghttp.Request) { } func Test_Middleware_CORSAndAuth(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Use(MiddlewareCORS) s.Group("/api.v2", func(group *ghttp.RouterGroup) { @@ -645,7 +645,7 @@ func MiddlewareScope3(r *ghttp.Request) { } func Test_Middleware_Scope(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Group("/", func(group *ghttp.RouterGroup) { group.Middleware(MiddlewareScope1) @@ -682,7 +682,7 @@ func Test_Middleware_Scope(t *testing.T) { } func Test_Middleware_Panic(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) i := 0 s.Group("/", func(group *ghttp.RouterGroup) { diff --git a/net/ghttp/ghttp_unit_middleware_cors_test.go b/net/ghttp/ghttp_unit_middleware_cors_test.go index 81498ab45..10dd657d6 100644 --- a/net/ghttp/ghttp_unit_middleware_cors_test.go +++ b/net/ghttp/ghttp_unit_middleware_cors_test.go @@ -16,7 +16,7 @@ import ( ) func Test_Middleware_CORS1(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Group("/api.v2", func(group *ghttp.RouterGroup) { group.Middleware(MiddlewareCORS) @@ -79,7 +79,7 @@ func Test_Middleware_CORS1(t *testing.T) { } func Test_Middleware_CORS2(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Group("/api.v2", func(group *ghttp.RouterGroup) { group.Middleware(MiddlewareCORS) diff --git a/net/ghttp/ghttp_unit_param_file_test.go b/net/ghttp/ghttp_unit_param_file_test.go index dbb952d2e..00ff39d93 100644 --- a/net/ghttp/ghttp_unit_param_file_test.go +++ b/net/ghttp/ghttp_unit_param_file_test.go @@ -22,7 +22,7 @@ import ( func Test_Params_File_Single(t *testing.T) { dstDirPath := gfile.TempDir(gtime.TimestampNanoStr()) - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/upload/single", func(r *ghttp.Request) { file := r.GetUploadFile("file") @@ -76,7 +76,7 @@ func Test_Params_File_Single(t *testing.T) { func Test_Params_File_CustomName(t *testing.T) { dstDirPath := gfile.TempDir(gtime.TimestampNanoStr()) - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/upload/single", func(r *ghttp.Request) { file := r.GetUploadFile("file") @@ -113,7 +113,7 @@ func Test_Params_File_CustomName(t *testing.T) { func Test_Params_File_Batch(t *testing.T) { dstDirPath := gfile.TempDir(gtime.TimestampNanoStr()) - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/upload/batch", func(r *ghttp.Request) { files := r.GetUploadFiles("file") diff --git a/net/ghttp/ghttp_unit_param_json_test.go b/net/ghttp/ghttp_unit_param_json_test.go index 61112a2e1..0435be4ad 100644 --- a/net/ghttp/ghttp_unit_param_json_test.go +++ b/net/ghttp/ghttp_unit_param_json_test.go @@ -25,7 +25,7 @@ func Test_Params_Json_Request(t *testing.T) { Pass1 string `p:"password1"` Pass2 string `p:"password2" v:"required|length:2,20|password3|same:password1#||密码强度不足|两次密码不一致"` } - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/get", func(r *ghttp.Request) { r.Response.WriteExit(r.Get("id"), r.Get("name")) @@ -71,7 +71,7 @@ func Test_Params_Json_Response(t *testing.T) { Pass2 string `json:"password2"` } - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/json1", func(r *ghttp.Request) { r.Response.WriteJson(User{ diff --git a/net/ghttp/ghttp_unit_param_page_test.go b/net/ghttp/ghttp_unit_param_page_test.go index fd4d04fb3..b9917ea7d 100644 --- a/net/ghttp/ghttp_unit_param_page_test.go +++ b/net/ghttp/ghttp_unit_param_page_test.go @@ -17,7 +17,7 @@ import ( ) func Test_Params_Page(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Group("/", func(group *ghttp.RouterGroup) { group.GET("/list", func(r *ghttp.Request) { diff --git a/net/ghttp/ghttp_unit_param_struct_test.go b/net/ghttp/ghttp_unit_param_struct_test.go index eebdd1408..a717d28bb 100644 --- a/net/ghttp/ghttp_unit_param_struct_test.go +++ b/net/ghttp/ghttp_unit_param_struct_test.go @@ -26,7 +26,7 @@ func Test_Params_Struct(t *testing.T) { Pass1 string `p:"password1"` Pass2 string `p:"password2" v:"passwd1 @required|length:2,20|password3#||密码强度不足"` } - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/struct1", func(r *ghttp.Request) { if m := r.GetMap(); len(m) > 0 { diff --git a/net/ghttp/ghttp_unit_param_test.go b/net/ghttp/ghttp_unit_param_test.go index a118d0c08..8ffc3a2df 100644 --- a/net/ghttp/ghttp_unit_param_test.go +++ b/net/ghttp/ghttp_unit_param_test.go @@ -23,7 +23,7 @@ func Test_Params_Basic(t *testing.T) { Pass1 string `params:"password1"` Pass2 string `params:"password2"` } - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) // GET s.BindHandler("/get", func(r *ghttp.Request) { @@ -405,7 +405,7 @@ func Test_Params_Basic(t *testing.T) { } func Test_Params_SupportChars(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/form-value", func(r *ghttp.Request) { r.Response.Write(r.GetQuery("test-value")) @@ -430,7 +430,7 @@ func Test_Params_SupportChars(t *testing.T) { } func Test_Params_Priority(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/query", func(r *ghttp.Request) { r.Response.Write(r.GetQuery("a")) diff --git a/net/ghttp/ghttp_unit_param_xml_test.go b/net/ghttp/ghttp_unit_param_xml_test.go index 3dc118a9b..ec47c5d8a 100644 --- a/net/ghttp/ghttp_unit_param_xml_test.go +++ b/net/ghttp/ghttp_unit_param_xml_test.go @@ -24,7 +24,7 @@ func Test_Params_Xml_Request(t *testing.T) { Pass1 string `p:"password1"` Pass2 string `p:"password2" v:"required|length:2,20|password3|same:password1#||密码强度不足|两次密码不一致"` } - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/get", func(r *ghttp.Request) { r.Response.WriteExit(r.Get("id"), r.Get("name")) diff --git a/net/ghttp/ghttp_unit_pprof_test.go b/net/ghttp/ghttp_unit_pprof_test.go index f44a8dbf7..ca22ef250 100644 --- a/net/ghttp/ghttp_unit_pprof_test.go +++ b/net/ghttp/ghttp_unit_pprof_test.go @@ -20,7 +20,7 @@ import ( func TestServer_EnablePProf(t *testing.T) { C(t, func(t *T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.EnablePProf("/pprof") s.SetDumpRouterMap(false) diff --git a/net/ghttp/ghttp_unit_router_basic_test.go b/net/ghttp/ghttp_unit_router_basic_test.go index 9b4386fdb..f034d3359 100644 --- a/net/ghttp/ghttp_unit_router_basic_test.go +++ b/net/ghttp/ghttp_unit_router_basic_test.go @@ -17,7 +17,7 @@ import ( ) func Test_Router_Basic(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/:name", func(r *ghttp.Request) { r.Response.Write("/:name") @@ -52,7 +52,7 @@ func Test_Router_Basic(t *testing.T) { // HTTP method register. func Test_Router_Method(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("GET:/get", func(r *ghttp.Request) { @@ -94,7 +94,7 @@ func Test_Router_Method(t *testing.T) { // Extra char '/' of the router. func Test_Router_ExtraChar(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Group("/api", func(group *ghttp.RouterGroup) { group.GET("/test", func(r *ghttp.Request) { @@ -119,7 +119,7 @@ func Test_Router_ExtraChar(t *testing.T) { // Custom status handler. func Test_Router_Status(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/200", func(r *ghttp.Request) { r.Response.WriteStatus(200) @@ -171,7 +171,7 @@ func Test_Router_Status(t *testing.T) { } func Test_Router_CustomStatusHandler(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/", func(r *ghttp.Request) { r.Response.Write("hello") @@ -200,7 +200,7 @@ func Test_Router_CustomStatusHandler(t *testing.T) { // 404 not found router. func Test_Router_404(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/", func(r *ghttp.Request) { r.Response.Write("hello") @@ -224,7 +224,7 @@ func Test_Router_404(t *testing.T) { } func Test_Router_Priority(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/admin", func(r *ghttp.Request) { r.Response.Write("admin") diff --git a/net/ghttp/ghttp_unit_router_controller_rest_test.go b/net/ghttp/ghttp_unit_router_controller_rest_test.go index f56f9d0d3..552bc8904 100644 --- a/net/ghttp/ghttp_unit_router_controller_rest_test.go +++ b/net/ghttp/ghttp_unit_router_controller_rest_test.go @@ -52,7 +52,7 @@ func (c *ControllerRest) Head() { // 控制器注册测试 func Test_Router_ControllerRest(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindControllerRest("/", new(ControllerRest)) s.BindControllerRest("/{.struct}/{.method}", new(ControllerRest)) diff --git a/net/ghttp/ghttp_unit_router_controller_test.go b/net/ghttp/ghttp_unit_router_controller_test.go index 12a3591bf..60f4fea09 100644 --- a/net/ghttp/ghttp_unit_router_controller_test.go +++ b/net/ghttp/ghttp_unit_router_controller_test.go @@ -44,7 +44,7 @@ func (c *Controller) Info() { } func Test_Router_Controller1(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindController("/", new(Controller)) s.BindController("/{.struct}/{.method}", new(Controller)) @@ -75,7 +75,7 @@ func Test_Router_Controller1(t *testing.T) { } func Test_Router_Controller2(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindController("/controller", new(Controller), "Show, Info") s.SetPort(p) @@ -101,7 +101,7 @@ func Test_Router_Controller2(t *testing.T) { } func Test_Router_ControllerMethod(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindControllerMethod("/controller-info", new(Controller), "Info") s.SetPort(p) diff --git a/net/ghttp/ghttp_unit_router_domain_basic_test.go b/net/ghttp/ghttp_unit_router_domain_basic_test.go index 17a2fa05e..701fb8c31 100644 --- a/net/ghttp/ghttp_unit_router_domain_basic_test.go +++ b/net/ghttp/ghttp_unit_router_domain_basic_test.go @@ -18,7 +18,7 @@ import ( ) func Test_Router_DomainBasic(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) d := s.Domain("localhost, local") d.BindHandler("/:name", func(r *ghttp.Request) { @@ -69,7 +69,7 @@ func Test_Router_DomainBasic(t *testing.T) { } func Test_Router_DomainMethod(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) d := s.Domain("localhost, local") d.BindHandler("GET:/get", func(r *ghttp.Request) { @@ -161,7 +161,7 @@ func Test_Router_DomainMethod(t *testing.T) { } func Test_Router_DomainStatus(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) d := s.Domain("localhost, local") d.BindHandler("/200", func(r *ghttp.Request) { @@ -257,7 +257,7 @@ func Test_Router_DomainStatus(t *testing.T) { } func Test_Router_DomainCustomStatusHandler(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) d := s.Domain("localhost, local") d.BindHandler("/", func(r *ghttp.Request) { @@ -296,7 +296,7 @@ func Test_Router_DomainCustomStatusHandler(t *testing.T) { } func Test_Router_Domain404(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) d := s.Domain("localhost, local") d.BindHandler("/", func(r *ghttp.Request) { @@ -329,7 +329,7 @@ func Test_Router_Domain404(t *testing.T) { } func Test_Router_DomainGroup(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) d := s.Domain("localhost, local") d.Group("/", func(group *ghttp.RouterGroup) { diff --git a/net/ghttp/ghttp_unit_router_domain_controller_rest_test.go b/net/ghttp/ghttp_unit_router_domain_controller_rest_test.go index f8f191ecb..585785ea1 100644 --- a/net/ghttp/ghttp_unit_router_domain_controller_rest_test.go +++ b/net/ghttp/ghttp_unit_router_domain_controller_rest_test.go @@ -60,7 +60,7 @@ func (c *DomainControllerRest) Head() { // 控制器注册测试 func Test_Router_DomainControllerRest(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) d := s.Domain("localhost, local") d.BindControllerRest("/", new(DomainControllerRest)) diff --git a/net/ghttp/ghttp_unit_router_domain_controller_test.go b/net/ghttp/ghttp_unit_router_domain_controller_test.go index 756417989..94161175c 100644 --- a/net/ghttp/ghttp_unit_router_domain_controller_test.go +++ b/net/ghttp/ghttp_unit_router_domain_controller_test.go @@ -43,7 +43,7 @@ func (c *DomainController) Info() { } func Test_Router_DomainController1(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Domain("localhost, local").BindController("/", new(DomainController)) s.SetPort(p) @@ -93,7 +93,7 @@ func Test_Router_DomainController1(t *testing.T) { } func Test_Router_DomainController2(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Domain("localhost, local").BindController("/controller", new(DomainController), "Show, Info") s.SetPort(p) @@ -146,7 +146,7 @@ func Test_Router_DomainController2(t *testing.T) { } func Test_Router_DomainControllerMethod(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Domain("localhost, local").BindControllerMethod("/controller-info", new(DomainController), "Info") s.SetPort(p) diff --git a/net/ghttp/ghttp_unit_router_domain_object_rest_test.go b/net/ghttp/ghttp_unit_router_domain_object_rest_test.go index 6f3dbf1c9..adc5a0ed8 100644 --- a/net/ghttp/ghttp_unit_router_domain_object_rest_test.go +++ b/net/ghttp/ghttp_unit_router_domain_object_rest_test.go @@ -55,7 +55,7 @@ func (o *DomainObjectRest) Head(r *ghttp.Request) { } func Test_Router_DomainObjectRest(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) d := s.Domain("localhost, local") d.BindObjectRest("/", new(DomainObjectRest)) diff --git a/net/ghttp/ghttp_unit_router_domain_object_test.go b/net/ghttp/ghttp_unit_router_domain_object_test.go index 5b67aeeb1..8cf13749d 100644 --- a/net/ghttp/ghttp_unit_router_domain_object_test.go +++ b/net/ghttp/ghttp_unit_router_domain_object_test.go @@ -39,7 +39,7 @@ func (o *DomainObject) Info(r *ghttp.Request) { } func Test_Router_DomainObject1(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Domain("localhost, local").BindObject("/", new(DomainObject)) s.SetPort(p) @@ -88,7 +88,7 @@ func Test_Router_DomainObject1(t *testing.T) { } func Test_Router_DomainObject2(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Domain("localhost, local").BindObject("/object", new(DomainObject), "Show, Info") s.SetPort(p) @@ -139,7 +139,7 @@ func Test_Router_DomainObject2(t *testing.T) { } func Test_Router_DomainObjectMethod(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Domain("localhost, local").BindObjectMethod("/object-info", new(DomainObject), "Info") s.SetPort(p) diff --git a/net/ghttp/ghttp_unit_router_exit_test.go b/net/ghttp/ghttp_unit_router_exit_test.go index 81fd7a9a7..d12dc9946 100644 --- a/net/ghttp/ghttp_unit_router_exit_test.go +++ b/net/ghttp/ghttp_unit_router_exit_test.go @@ -17,7 +17,7 @@ import ( ) func Test_Router_Exit(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHookHandlerByMap("/*", map[string]ghttp.HandlerFunc{ ghttp.HOOK_BEFORE_SERVE: func(r *ghttp.Request) { r.Response.Write("1") }, @@ -46,7 +46,7 @@ func Test_Router_Exit(t *testing.T) { } func Test_Router_ExitHook(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/priority/show", func(r *ghttp.Request) { r.Response.Write("show") @@ -84,7 +84,7 @@ func Test_Router_ExitHook(t *testing.T) { } func Test_Router_ExitAll(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/priority/show", func(r *ghttp.Request) { r.Response.Write("show") diff --git a/net/ghttp/ghttp_unit_router_group_group_test.go b/net/ghttp/ghttp_unit_router_group_group_test.go index d2c5890a6..23545dae5 100644 --- a/net/ghttp/ghttp_unit_router_group_group_test.go +++ b/net/ghttp/ghttp_unit_router_group_group_test.go @@ -17,7 +17,7 @@ import ( ) func Test_Router_Group_Group(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Group("/api.v2", func(group *ghttp.RouterGroup) { group.Middleware(func(r *ghttp.Request) { diff --git a/net/ghttp/ghttp_unit_router_group_hook_test.go b/net/ghttp/ghttp_unit_router_group_hook_test.go index 21c3c5a10..99e8a2e14 100644 --- a/net/ghttp/ghttp_unit_router_group_hook_test.go +++ b/net/ghttp/ghttp_unit_router_group_hook_test.go @@ -17,7 +17,7 @@ import ( ) func Test_Router_Group_Hook1(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) group := s.Group("/api") group.GET("/handler", func(r *ghttp.Request) { @@ -46,7 +46,7 @@ func Test_Router_Group_Hook1(t *testing.T) { } func Test_Router_Group_Hook2(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) g := s.Group("/api") g.GET("/handler", func(r *ghttp.Request) { @@ -76,7 +76,7 @@ func Test_Router_Group_Hook2(t *testing.T) { } func Test_Router_Group_Hook3(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.Group("/api").Bind([]g.Slice{ {"ALL", "handler", func(r *ghttp.Request) { diff --git a/net/ghttp/ghttp_unit_router_group_rest_test.go b/net/ghttp/ghttp_unit_router_group_rest_test.go index dcb0eef41..82ae9bfcf 100644 --- a/net/ghttp/ghttp_unit_router_group_rest_test.go +++ b/net/ghttp/ghttp_unit_router_group_rest_test.go @@ -98,7 +98,7 @@ func (o *GroupObjRest) Head(r *ghttp.Request) { } func Test_Router_GroupRest(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) g := s.Group("/api") ctl := new(GroupCtlRest) diff --git a/net/ghttp/ghttp_unit_router_group_test.go b/net/ghttp/ghttp_unit_router_group_test.go index 46ffd4f9d..a25017210 100644 --- a/net/ghttp/ghttp_unit_router_group_test.go +++ b/net/ghttp/ghttp_unit_router_group_test.go @@ -71,7 +71,7 @@ func Handler(r *ghttp.Request) { } func Test_Router_GroupBasic1(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) obj := new(GroupObject) ctl := new(GroupController) @@ -118,7 +118,7 @@ func Test_Router_GroupBasic1(t *testing.T) { } func Test_Router_GroupBasic2(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) obj := new(GroupObject) ctl := new(GroupController) @@ -160,7 +160,7 @@ func Test_Router_GroupBasic2(t *testing.T) { } func Test_Router_GroupBuildInVar(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) obj := new(GroupObject) ctl := new(GroupController) @@ -192,7 +192,7 @@ func Test_Router_GroupBuildInVar(t *testing.T) { } func Test_Router_Group_Mthods(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) obj := new(GroupObject) ctl := new(GroupController) diff --git a/net/ghttp/ghttp_unit_router_hook_test.go b/net/ghttp/ghttp_unit_router_hook_test.go index a36fd7b98..317a4dc77 100644 --- a/net/ghttp/ghttp_unit_router_hook_test.go +++ b/net/ghttp/ghttp_unit_router_hook_test.go @@ -17,7 +17,7 @@ import ( ) func Test_Router_Hook_Basic(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHookHandlerByMap("/*", map[string]ghttp.HandlerFunc{ ghttp.HOOK_BEFORE_SERVE: func(r *ghttp.Request) { r.Response.Write("1") }, @@ -44,7 +44,7 @@ func Test_Router_Hook_Basic(t *testing.T) { } func Test_Router_Hook_Fuzzy_Router(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) i := 1000 pattern1 := "/:name/info" @@ -88,7 +88,7 @@ func Test_Router_Hook_Fuzzy_Router(t *testing.T) { } func Test_Router_Hook_Priority(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/priority/show", func(r *ghttp.Request) { r.Response.Write("show") @@ -127,7 +127,7 @@ func Test_Router_Hook_Priority(t *testing.T) { } func Test_Router_Hook_Multi(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/multi-hook", func(r *ghttp.Request) { r.Response.Write("show") diff --git a/net/ghttp/ghttp_unit_router_names_test.go b/net/ghttp/ghttp_unit_router_names_test.go index 5216b12fe..54a68b37c 100644 --- a/net/ghttp/ghttp_unit_router_names_test.go +++ b/net/ghttp/ghttp_unit_router_names_test.go @@ -23,7 +23,7 @@ func (o *NamesObject) ShowName(r *ghttp.Request) { } func Test_NameToUri_FullName(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.SetNameToUriType(ghttp.URI_TYPE_FULLNAME) s.BindObject("/{.struct}/{.method}", new(NamesObject)) @@ -44,7 +44,7 @@ func Test_NameToUri_FullName(t *testing.T) { } func Test_NameToUri_AllLower(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.SetNameToUriType(ghttp.URI_TYPE_ALLLOWER) s.BindObject("/{.struct}/{.method}", new(NamesObject)) @@ -65,7 +65,7 @@ func Test_NameToUri_AllLower(t *testing.T) { } func Test_NameToUri_Camel(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.SetNameToUriType(ghttp.URI_TYPE_CAMEL) s.BindObject("/{.struct}/{.method}", new(NamesObject)) @@ -86,7 +86,7 @@ func Test_NameToUri_Camel(t *testing.T) { } func Test_NameToUri_Default(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.SetNameToUriType(ghttp.URI_TYPE_DEFAULT) s.BindObject("/{.struct}/{.method}", new(NamesObject)) diff --git a/net/ghttp/ghttp_unit_router_object_rest1_test.go b/net/ghttp/ghttp_unit_router_object_rest1_test.go index 506e41021..8788b8147 100644 --- a/net/ghttp/ghttp_unit_router_object_rest1_test.go +++ b/net/ghttp/ghttp_unit_router_object_rest1_test.go @@ -55,7 +55,7 @@ func (o *ObjectRest) Head(r *ghttp.Request) { } func Test_Router_ObjectRest(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindObjectRest("/", new(ObjectRest)) s.BindObjectRest("/{.struct}/{.method}", new(ObjectRest)) diff --git a/net/ghttp/ghttp_unit_router_object_rest2_test.go b/net/ghttp/ghttp_unit_router_object_rest2_test.go index 08f6b4861..22c1e0499 100644 --- a/net/ghttp/ghttp_unit_router_object_rest2_test.go +++ b/net/ghttp/ghttp_unit_router_object_rest2_test.go @@ -43,7 +43,7 @@ func (o *ObjectRest2) Delete(r *ghttp.Request) { } func Test_Router_ObjectRest_Id(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindObjectRest("/object/:id", new(ObjectRest2)) s.SetPort(p) diff --git a/net/ghttp/ghttp_unit_router_object_test.go b/net/ghttp/ghttp_unit_router_object_test.go index ef18e7934..5d0562fed 100644 --- a/net/ghttp/ghttp_unit_router_object_test.go +++ b/net/ghttp/ghttp_unit_router_object_test.go @@ -39,7 +39,7 @@ func (o *Object) Info(r *ghttp.Request) { } func Test_Router_Object1(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindObject("/", new(Object)) s.BindObject("/{.struct}/{.method}", new(Object)) @@ -70,7 +70,7 @@ func Test_Router_Object1(t *testing.T) { } func Test_Router_Object2(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindObject("/object", new(Object), "Show, Info") s.SetPort(p) @@ -96,7 +96,7 @@ func Test_Router_Object2(t *testing.T) { } func Test_Router_ObjectMethod(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindObjectMethod("/object-info", new(Object), "Info") s.SetPort(p) diff --git a/net/ghttp/ghttp_unit_session_test.go b/net/ghttp/ghttp_unit_session_test.go index 894d1f59e..c6e3dce4b 100644 --- a/net/ghttp/ghttp_unit_session_test.go +++ b/net/ghttp/ghttp_unit_session_test.go @@ -17,7 +17,7 @@ import ( ) func Test_Session_Cookie(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/set", func(r *ghttp.Request) { r.Session.Set(r.GetString("k"), r.GetString("v")) @@ -64,7 +64,7 @@ func Test_Session_Cookie(t *testing.T) { } func Test_Session_Header(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/set", func(r *ghttp.Request) { r.Session.Set(r.GetString("k"), r.GetString("v")) @@ -115,7 +115,7 @@ func Test_Session_Header(t *testing.T) { func Test_Session_StorageFile(t *testing.T) { sessionId := "" - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/set", func(r *ghttp.Request) { r.Session.Set(r.GetString("k"), r.GetString("v")) diff --git a/net/ghttp/ghttp_unit_static_test.go b/net/ghttp/ghttp_unit_static_test.go index f9ae39e87..d2ab5d720 100644 --- a/net/ghttp/ghttp_unit_static_test.go +++ b/net/ghttp/ghttp_unit_static_test.go @@ -25,7 +25,7 @@ import ( func Test_Static_ServerRoot(t *testing.T) { // SetServerRoot with absolute path gtest.C(t, func(t *gtest.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) path := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p) defer gfile.Remove(path) @@ -44,7 +44,7 @@ func Test_Static_ServerRoot(t *testing.T) { // SetServerRoot with relative path gtest.C(t, func(t *gtest.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) path := fmt.Sprintf(`static/test/%d`, p) defer gfile.Remove(path) @@ -64,7 +64,7 @@ func Test_Static_ServerRoot(t *testing.T) { func Test_Static_ServerRoot_Security(t *testing.T) { gtest.C(t, func(t *gtest.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.SetServerRoot(gdebug.TestDataPath("static1")) s.SetPort(p) @@ -85,7 +85,7 @@ func Test_Static_ServerRoot_Security(t *testing.T) { func Test_Static_Folder_Forbidden(t *testing.T) { gtest.C(t, func(t *gtest.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) path := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p) defer gfile.Remove(path) @@ -106,7 +106,7 @@ func Test_Static_Folder_Forbidden(t *testing.T) { func Test_Static_IndexFolder(t *testing.T) { gtest.C(t, func(t *gtest.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) path := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p) defer gfile.Remove(path) @@ -129,7 +129,7 @@ func Test_Static_IndexFolder(t *testing.T) { func Test_Static_IndexFiles1(t *testing.T) { gtest.C(t, func(t *gtest.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) path := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p) defer gfile.Remove(path) @@ -151,7 +151,7 @@ func Test_Static_IndexFiles1(t *testing.T) { func Test_Static_IndexFiles2(t *testing.T) { gtest.C(t, func(t *gtest.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) path := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p) defer gfile.Remove(path) @@ -173,7 +173,7 @@ func Test_Static_IndexFiles2(t *testing.T) { func Test_Static_AddSearchPath1(t *testing.T) { gtest.C(t, func(t *gtest.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) path1 := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p) path2 := fmt.Sprintf(`%s/ghttp/static/test/%d/%d`, gfile.TempDir(), p, p) @@ -196,7 +196,7 @@ func Test_Static_AddSearchPath1(t *testing.T) { func Test_Static_AddSearchPath2(t *testing.T) { gtest.C(t, func(t *gtest.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) path1 := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p) path2 := fmt.Sprintf(`%s/ghttp/static/test/%d/%d`, gfile.TempDir(), p, p) @@ -220,7 +220,7 @@ func Test_Static_AddSearchPath2(t *testing.T) { func Test_Static_AddStaticPath(t *testing.T) { gtest.C(t, func(t *gtest.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) path1 := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p) path2 := fmt.Sprintf(`%s/ghttp/static/test/%d/%d`, gfile.TempDir(), p, p) @@ -245,7 +245,7 @@ func Test_Static_AddStaticPath(t *testing.T) { func Test_Static_AddStaticPath_Priority(t *testing.T) { gtest.C(t, func(t *gtest.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) path1 := fmt.Sprintf(`%s/ghttp/static/test/%d/test`, gfile.TempDir(), p) path2 := fmt.Sprintf(`%s/ghttp/static/test/%d/%d/test`, gfile.TempDir(), p, p) @@ -270,7 +270,7 @@ func Test_Static_AddStaticPath_Priority(t *testing.T) { func Test_Static_Rewrite(t *testing.T) { gtest.C(t, func(t *gtest.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) path := fmt.Sprintf(`%s/ghttp/static/test/%d`, gfile.TempDir(), p) defer gfile.Remove(path) diff --git a/net/ghttp/ghttp_unit_template_test.go b/net/ghttp/ghttp_unit_template_test.go index 661867c42..d18889d0e 100644 --- a/net/ghttp/ghttp_unit_template_test.go +++ b/net/ghttp/ghttp_unit_template_test.go @@ -24,7 +24,7 @@ import ( func Test_Template_Basic(t *testing.T) { gtest.C(t, func(t *gtest.T) { v := gview.New(gdebug.TestDataPath("template", "basic")) - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.SetView(v) s.BindHandler("/", func(r *ghttp.Request) { @@ -50,7 +50,7 @@ func Test_Template_Encode(t *testing.T) { gtest.C(t, func(t *gtest.T) { v := gview.New(gdebug.TestDataPath("template", "basic")) v.SetAutoEncode(true) - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.SetView(v) s.BindHandler("/", func(r *ghttp.Request) { @@ -75,7 +75,7 @@ func Test_Template_Encode(t *testing.T) { func Test_Template_Layout1(t *testing.T) { gtest.C(t, func(t *gtest.T) { v := gview.New(gdebug.TestDataPath("template", "layout1")) - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.SetView(v) s.BindHandler("/layout", func(r *ghttp.Request) { @@ -105,7 +105,7 @@ func Test_Template_Layout1(t *testing.T) { func Test_Template_Layout2(t *testing.T) { gtest.C(t, func(t *gtest.T) { v := gview.New(gdebug.TestDataPath("template", "layout2")) - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.SetView(v) s.BindHandler("/main1", func(r *ghttp.Request) { @@ -144,7 +144,7 @@ func Test_Template_XSS(t *testing.T) { v := gview.New() v.SetAutoEncode(true) c := "
" - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.SetView(v) s.BindHandler("/", func(r *ghttp.Request) { diff --git a/net/ghttp/ghttp_unit_websocket_test.go b/net/ghttp/ghttp_unit_websocket_test.go index 31c0059a5..7fd1ecea1 100644 --- a/net/ghttp/ghttp_unit_websocket_test.go +++ b/net/ghttp/ghttp_unit_websocket_test.go @@ -19,7 +19,7 @@ import ( ) func Test_WebSocket(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := g.Server(p) s.BindHandler("/ws", func(r *ghttp.Request) { ws, err := r.WebSocket() diff --git a/net/gtcp/gtcp_unit_pkg_test.go b/net/gtcp/gtcp_unit_pkg_test.go index 2498ad08f..89687b800 100644 --- a/net/gtcp/gtcp_unit_pkg_test.go +++ b/net/gtcp/gtcp_unit_pkg_test.go @@ -16,7 +16,7 @@ import ( ) func Test_Package_Basic(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := gtcp.NewServer(fmt.Sprintf(`:%d`, p), func(conn *gtcp.Conn) { defer conn.Close() for { @@ -96,7 +96,7 @@ func Test_Package_Basic(t *testing.T) { } func Test_Package_Timeout(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := gtcp.NewServer(fmt.Sprintf(`:%d`, p), func(conn *gtcp.Conn) { defer conn.Close() for { @@ -132,7 +132,7 @@ func Test_Package_Timeout(t *testing.T) { } func Test_Package_Option(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := gtcp.NewServer(fmt.Sprintf(`:%d`, p), func(conn *gtcp.Conn) { defer conn.Close() option := gtcp.PkgOption{HeaderSize: 1} diff --git a/net/gtcp/gtcp_unit_pool_pkg_test.go b/net/gtcp/gtcp_unit_pool_pkg_test.go index d8e517d46..49e7fa407 100644 --- a/net/gtcp/gtcp_unit_pool_pkg_test.go +++ b/net/gtcp/gtcp_unit_pool_pkg_test.go @@ -16,7 +16,7 @@ import ( ) func Test_Pool_Package_Basic(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := gtcp.NewServer(fmt.Sprintf(`:%d`, p), func(conn *gtcp.Conn) { defer conn.Close() for { @@ -96,7 +96,7 @@ func Test_Pool_Package_Basic(t *testing.T) { } func Test_Pool_Package_Timeout(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := gtcp.NewServer(fmt.Sprintf(`:%d`, p), func(conn *gtcp.Conn) { defer conn.Close() for { @@ -132,7 +132,7 @@ func Test_Pool_Package_Timeout(t *testing.T) { } func Test_Pool_Package_Option(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := gtcp.NewServer(fmt.Sprintf(`:%d`, p), func(conn *gtcp.Conn) { defer conn.Close() option := gtcp.PkgOption{HeaderSize: 1} diff --git a/net/gtcp/gtcp_unit_pool_test.go b/net/gtcp/gtcp_unit_pool_test.go index d38967b73..dbd8cf051 100644 --- a/net/gtcp/gtcp_unit_pool_test.go +++ b/net/gtcp/gtcp_unit_pool_test.go @@ -15,7 +15,7 @@ import ( ) func Test_Pool_Basic1(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := gtcp.NewServer(fmt.Sprintf(`:%d`, p), func(conn *gtcp.Conn) { defer conn.Close() for { @@ -42,7 +42,7 @@ func Test_Pool_Basic1(t *testing.T) { } func Test_Pool_Basic2(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := gtcp.NewServer(fmt.Sprintf(`:%d`, p), func(conn *gtcp.Conn) { conn.Close() }) diff --git a/net/gudp/gudp_unit_basic_test.go b/net/gudp/gudp_unit_basic_test.go index 343d74c4a..fbe3c26bd 100644 --- a/net/gudp/gudp_unit_basic_test.go +++ b/net/gudp/gudp_unit_basic_test.go @@ -17,7 +17,7 @@ import ( ) func Test_Basic(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := gudp.NewServer(fmt.Sprintf("127.0.0.1:%d", p), func(conn *gudp.Conn) { defer conn.Close() for { @@ -75,7 +75,7 @@ func Test_Basic(t *testing.T) { // If the read buffer size is less than the sent package size, // the rest data would be dropped. func Test_Buffer(t *testing.T) { - p := ports.PopRand() + p, _ := ports.PopRand() s := gudp.NewServer(fmt.Sprintf("127.0.0.1:%d", p), func(conn *gudp.Conn) { defer conn.Close() for {