From a245a19d0221e374d195084e99aef33a06e5ef3c Mon Sep 17 00:00:00 2001 From: Makis Maropoulos Date: Sat, 18 Jun 2016 01:14:57 +0300 Subject: [PATCH] gofmt --- graceful/graceful.go | 2 +- middleware/cors/cors.go | 2 +- tests/httperror_test.go | 36 +++++++++++++++---------------- tests/route_test.go | 48 ++++++++++++++++++++--------------------- 4 files changed, 44 insertions(+), 44 deletions(-) diff --git a/graceful/graceful.go b/graceful/graceful.go index 1c60ecce..c338f225 100644 --- a/graceful/graceful.go +++ b/graceful/graceful.go @@ -238,7 +238,7 @@ func (srv *Server) interruptChan() chan os.Signal { } func (srv *Server) handleInterrupt(interrupt chan os.Signal, quitting chan struct{}, listener net.Listener) { - for _ = range interrupt { + for range interrupt { if srv.Interrupted { srv.log("already shutting down") continue diff --git a/middleware/cors/cors.go b/middleware/cors/cors.go index d06a25a5..f2efa1b6 100644 --- a/middleware/cors/cors.go +++ b/middleware/cors/cors.go @@ -176,7 +176,7 @@ func New(options Options) *Cors { break } else if i := strings.IndexByte(origin, '*'); i >= 0 { // Split the origin in two: start and end string without the * - w := wildcard{origin[0:i], origin[i+1 : len(origin)]} + w := wildcard{origin[0:i], origin[i+1:]} c.allowedWOrigins = append(c.allowedWOrigins, w) } else { c.allowedOrigins = append(c.allowedOrigins, origin) diff --git a/tests/httperror_test.go b/tests/httperror_test.go index b9a82daa..c9f62dbe 100644 --- a/tests/httperror_test.go +++ b/tests/httperror_test.go @@ -13,25 +13,25 @@ var internalServerMessage = "Iris custom message for 500 internal server error" var routesCustomErrors = []route{ // NOT FOUND CUSTOM ERRORS - not registed - route{"GET", "/test_get_nofound_custom", "/test_get_nofound_custom", notFoundMessage, 404, false, nil, nil}, - route{"POST", "/test_post_nofound_custom", "/test_post_nofound_custom", notFoundMessage, 404, false, nil, nil}, - route{"PUT", "/test_put_nofound_custom", "/test_put_nofound_custom", notFoundMessage, 404, false, nil, nil}, - route{"DELETE", "/test_delete_nofound_custom", "/test_delete_nofound_custom", notFoundMessage, 404, false, nil, nil}, - route{"HEAD", "/test_head_nofound_custom", "/test_head_nofound_custom", notFoundMessage, 404, false, nil, nil}, - route{"OPTIONS", "/test_options_nofound_custom", "/test_options_nofound_custom", notFoundMessage, 404, false, nil, nil}, - route{"CONNECT", "/test_connect_nofound_custom", "/test_connect_nofound_custom", notFoundMessage, 404, false, nil, nil}, - route{"PATCH", "/test_patch_nofound_custom", "/test_patch_nofound_custom", notFoundMessage, 404, false, nil, nil}, - route{"TRACE", "/test_trace_nofound_custom", "/test_trace_nofound_custom", notFoundMessage, 404, false, nil, nil}, + {"GET", "/test_get_nofound_custom", "/test_get_nofound_custom", notFoundMessage, 404, false, nil, nil}, + {"POST", "/test_post_nofound_custom", "/test_post_nofound_custom", notFoundMessage, 404, false, nil, nil}, + {"PUT", "/test_put_nofound_custom", "/test_put_nofound_custom", notFoundMessage, 404, false, nil, nil}, + {"DELETE", "/test_delete_nofound_custom", "/test_delete_nofound_custom", notFoundMessage, 404, false, nil, nil}, + {"HEAD", "/test_head_nofound_custom", "/test_head_nofound_custom", notFoundMessage, 404, false, nil, nil}, + {"OPTIONS", "/test_options_nofound_custom", "/test_options_nofound_custom", notFoundMessage, 404, false, nil, nil}, + {"CONNECT", "/test_connect_nofound_custom", "/test_connect_nofound_custom", notFoundMessage, 404, false, nil, nil}, + {"PATCH", "/test_patch_nofound_custom", "/test_patch_nofound_custom", notFoundMessage, 404, false, nil, nil}, + {"TRACE", "/test_trace_nofound_custom", "/test_trace_nofound_custom", notFoundMessage, 404, false, nil, nil}, // SERVER INTERNAL ERROR 500 PANIC CUSTOM ERRORS - registed - route{"GET", "/test_get_panic_custom", "/test_get_panic_custom", internalServerMessage, 500, true, nil, nil}, - route{"POST", "/test_post_panic_custom", "/test_post_panic_custom", internalServerMessage, 500, true, nil, nil}, - route{"PUT", "/test_put_panic_custom", "/test_put_panic_custom", internalServerMessage, 500, true, nil, nil}, - route{"DELETE", "/test_delete_panic_custom", "/test_delete_panic_custom", internalServerMessage, 500, true, nil, nil}, - route{"HEAD", "/test_head_panic_custom", "/test_head_panic_custom", internalServerMessage, 500, true, nil, nil}, - route{"OPTIONS", "/test_options_panic_custom", "/test_options_panic_custom", internalServerMessage, 500, true, nil, nil}, - route{"CONNECT", "/test_connect_panic_custom", "/test_connect_panic_custom", internalServerMessage, 500, true, nil, nil}, - route{"PATCH", "/test_patch_panic_custom", "/test_patch_panic_custom", internalServerMessage, 500, true, nil, nil}, - route{"TRACE", "/test_trace_panic_custom", "/test_trace_panic_custom", internalServerMessage, 500, true, nil, nil}, + {"GET", "/test_get_panic_custom", "/test_get_panic_custom", internalServerMessage, 500, true, nil, nil}, + {"POST", "/test_post_panic_custom", "/test_post_panic_custom", internalServerMessage, 500, true, nil, nil}, + {"PUT", "/test_put_panic_custom", "/test_put_panic_custom", internalServerMessage, 500, true, nil, nil}, + {"DELETE", "/test_delete_panic_custom", "/test_delete_panic_custom", internalServerMessage, 500, true, nil, nil}, + {"HEAD", "/test_head_panic_custom", "/test_head_panic_custom", internalServerMessage, 500, true, nil, nil}, + {"OPTIONS", "/test_options_panic_custom", "/test_options_panic_custom", internalServerMessage, 500, true, nil, nil}, + {"CONNECT", "/test_connect_panic_custom", "/test_connect_panic_custom", internalServerMessage, 500, true, nil, nil}, + {"PATCH", "/test_patch_panic_custom", "/test_patch_panic_custom", internalServerMessage, 500, true, nil, nil}, + {"TRACE", "/test_trace_panic_custom", "/test_trace_panic_custom", internalServerMessage, 500, true, nil, nil}, } func TestCustomErrors(t *testing.T) { diff --git a/tests/route_test.go b/tests/route_test.go index 02a2ebfe..b04017cc 100644 --- a/tests/route_test.go +++ b/tests/route_test.go @@ -27,33 +27,33 @@ type route struct { var routes = []route{ // FOUND - registed - route{"GET", "/test_get", "/test_get", "hello, get!", 200, true, nil, nil}, - route{"POST", "/test_post", "/test_post", "hello, post!", 200, true, nil, nil}, - route{"PUT", "/test_put", "/test_put", "hello, put!", 200, true, nil, nil}, - route{"DELETE", "/test_delete", "/test_delete", "hello, delete!", 200, true, nil, nil}, - route{"HEAD", "/test_head", "/test_head", "hello, head!", 200, true, nil, nil}, - route{"OPTIONS", "/test_options", "/test_options", "hello, options!", 200, true, nil, nil}, - route{"CONNECT", "/test_connect", "/test_connect", "hello, connect!", 200, true, nil, nil}, - route{"PATCH", "/test_patch", "/test_patch", "hello, patch!", 200, true, nil, nil}, - route{"TRACE", "/test_trace", "/test_trace", "hello, trace!", 200, true, nil, nil}, + {"GET", "/test_get", "/test_get", "hello, get!", 200, true, nil, nil}, + {"POST", "/test_post", "/test_post", "hello, post!", 200, true, nil, nil}, + {"PUT", "/test_put", "/test_put", "hello, put!", 200, true, nil, nil}, + {"DELETE", "/test_delete", "/test_delete", "hello, delete!", 200, true, nil, nil}, + {"HEAD", "/test_head", "/test_head", "hello, head!", 200, true, nil, nil}, + {"OPTIONS", "/test_options", "/test_options", "hello, options!", 200, true, nil, nil}, + {"CONNECT", "/test_connect", "/test_connect", "hello, connect!", 200, true, nil, nil}, + {"PATCH", "/test_patch", "/test_patch", "hello, patch!", 200, true, nil, nil}, + {"TRACE", "/test_trace", "/test_trace", "hello, trace!", 200, true, nil, nil}, // NOT FOUND - not registed - route{"GET", "/test_get_nofound", "/test_get_nofound", "Not Found", 404, false, nil, nil}, - route{"POST", "/test_post_nofound", "/test_post_nofound", "Not Found", 404, false, nil, nil}, - route{"PUT", "/test_put_nofound", "/test_put_nofound", "Not Found", 404, false, nil, nil}, - route{"DELETE", "/test_delete_nofound", "/test_delete_nofound", "Not Found", 404, false, nil, nil}, - route{"HEAD", "/test_head_nofound", "/test_head_nofound", "Not Found", 404, false, nil, nil}, - route{"OPTIONS", "/test_options_nofound", "/test_options_nofound", "Not Found", 404, false, nil, nil}, - route{"CONNECT", "/test_connect_nofound", "/test_connect_nofound", "Not Found", 404, false, nil, nil}, - route{"PATCH", "/test_patch_nofound", "/test_patch_nofound", "Not Found", 404, false, nil, nil}, - route{"TRACE", "/test_trace_nofound", "/test_trace_nofound", "Not Found", 404, false, nil, nil}, + {"GET", "/test_get_nofound", "/test_get_nofound", "Not Found", 404, false, nil, nil}, + {"POST", "/test_post_nofound", "/test_post_nofound", "Not Found", 404, false, nil, nil}, + {"PUT", "/test_put_nofound", "/test_put_nofound", "Not Found", 404, false, nil, nil}, + {"DELETE", "/test_delete_nofound", "/test_delete_nofound", "Not Found", 404, false, nil, nil}, + {"HEAD", "/test_head_nofound", "/test_head_nofound", "Not Found", 404, false, nil, nil}, + {"OPTIONS", "/test_options_nofound", "/test_options_nofound", "Not Found", 404, false, nil, nil}, + {"CONNECT", "/test_connect_nofound", "/test_connect_nofound", "Not Found", 404, false, nil, nil}, + {"PATCH", "/test_patch_nofound", "/test_patch_nofound", "Not Found", 404, false, nil, nil}, + {"TRACE", "/test_trace_nofound", "/test_trace_nofound", "Not Found", 404, false, nil, nil}, // Parameters - route{"GET", "/test_get_parameter1/:name", "/test_get_parameter1/iris", "name=iris", 200, true, []param{param{"name", "iris"}}, nil}, - route{"GET", "/test_get_parameter2/:name/details/:something", "/test_get_parameter2/iris/details/anything", "name=iris,something=anything", 200, true, []param{param{"name", "iris"}, param{"something", "anything"}}, nil}, - route{"GET", "/test_get_parameter2/:name/details/:something/*else", "/test_get_parameter2/iris/details/anything/elsehere", "name=iris,something=anything,else=/elsehere", 200, true, []param{param{"name", "iris"}, param{"something", "anything"}, param{"else", "elsehere"}}, nil}, + {"GET", "/test_get_parameter1/:name", "/test_get_parameter1/iris", "name=iris", 200, true, []param{{"name", "iris"}}, nil}, + {"GET", "/test_get_parameter2/:name/details/:something", "/test_get_parameter2/iris/details/anything", "name=iris,something=anything", 200, true, []param{{"name", "iris"}, {"something", "anything"}}, nil}, + {"GET", "/test_get_parameter2/:name/details/:something/*else", "/test_get_parameter2/iris/details/anything/elsehere", "name=iris,something=anything,else=/elsehere", 200, true, []param{{"name", "iris"}, {"something", "anything"}, {"else", "elsehere"}}, nil}, // URL Parameters - route{"GET", "/test_get_urlparameter1/first", "/test_get_urlparameter1/first?name=irisurl", "name=irisurl", 200, true, nil, []param{param{"name", "irisurl"}}}, - route{"GET", "/test_get_urlparameter2/second", "/test_get_urlparameter2/second?name=irisurl&something=anything", "name=irisurl,something=anything", 200, true, nil, []param{param{"name", "irisurl"}, param{"something", "anything"}}}, - route{"GET", "/test_get_urlparameter2/first/second/third", "/test_get_urlparameter2/first/second/third?name=irisurl&something=anything&else=elsehere", "name=irisurl,something=anything,else=elsehere", 200, true, nil, []param{param{"name", "irisurl"}, param{"something", "anything"}, param{"else", "elsehere"}}}, + {"GET", "/test_get_urlparameter1/first", "/test_get_urlparameter1/first?name=irisurl", "name=irisurl", 200, true, nil, []param{{"name", "irisurl"}}}, + {"GET", "/test_get_urlparameter2/second", "/test_get_urlparameter2/second?name=irisurl&something=anything", "name=irisurl,something=anything", 200, true, nil, []param{{"name", "irisurl"}, {"something", "anything"}}}, + {"GET", "/test_get_urlparameter2/first/second/third", "/test_get_urlparameter2/first/second/third?name=irisurl&something=anything&else=elsehere", "name=irisurl,something=anything,else=elsehere", 200, true, nil, []param{{"name", "irisurl"}, {"something", "anything"}, {"else", "elsehere"}}}, } func TestRouter(t *testing.T) {