From c14c0aada8812f5540b9e2e27ad82b91e384d228 Mon Sep 17 00:00:00 2001 From: Shulhan Date: Thu, 15 Feb 2024 02:35:41 +0700 Subject: [PATCH] all: set unused parameter to "_" --- api/telegram/bot/command_test.go | 2 +- lib/http/http_test.go | 4 ++-- lib/http/server_test.go | 8 ++++---- lib/http/sse_endpoint_test.go | 4 ++-- lib/websocket/client_test.go | 16 ++++++++-------- lib/websocket/rootroute_test.go | 2 +- lib/websocket/server_test.go | 2 +- 7 files changed, 19 insertions(+), 19 deletions(-) diff --git a/api/telegram/bot/command_test.go b/api/telegram/bot/command_test.go index b22b3336..e1d7d715 100644 --- a/api/telegram/bot/command_test.go +++ b/api/telegram/bot/command_test.go @@ -62,7 +62,7 @@ func TestCommand_validate(t *testing.T) { cmd: Command{ Command: "help", Description: "Bantuan", - Handler: func(up Update) {}, + Handler: func(_ Update) {}, }, }} diff --git a/lib/http/http_test.go b/lib/http/http_test.go index caceedf2..d846ca2e 100644 --- a/lib/http/http_test.go +++ b/lib/http/http_test.go @@ -28,7 +28,7 @@ var ( client = &http.Client{} - cbNone = func(epr *EndpointRequest) ([]byte, error) { + cbNone = func(_ *EndpointRequest) ([]byte, error) { return nil, nil } @@ -140,7 +140,7 @@ func registerEndpoints() { err = testServer.RegisterEndpoint(&Endpoint{ Path: "/download", ResponseType: ResponseTypePlain, - Call: func(epr *EndpointRequest) ([]byte, error) { + Call: func(_ *EndpointRequest) ([]byte, error) { return testDownloadBody, nil }, }) diff --git a/lib/http/server_test.go b/lib/http/server_test.go index 8a2ef81e..5a0d7ddc 100644 --- a/lib/http/server_test.go +++ b/lib/http/server_test.go @@ -182,7 +182,7 @@ func TestRegisterDelete(t *testing.T) { } } -var testEvaluator = func(req *http.Request, reqBody []byte) error { +var testEvaluator = func(req *http.Request, _ []byte) error { k := req.Form.Get("k") if len(k) == 0 { @@ -662,16 +662,16 @@ func TestServeHTTPOptions(t *testing.T) { func TestStatusError(t *testing.T) { var ( - cbError = func(epr *EndpointRequest) ([]byte, error) { + cbError = func(_ *EndpointRequest) ([]byte, error) { return nil, &liberrors.E{ Code: http.StatusLengthRequired, Message: `Length required`, } } - cbNoCode = func(epr *EndpointRequest) ([]byte, error) { + cbNoCode = func(_ *EndpointRequest) ([]byte, error) { return nil, liberrors.Internal(nil) } - cbCustomErr = func(epr *EndpointRequest) ([]byte, error) { + cbCustomErr = func(_ *EndpointRequest) ([]byte, error) { return nil, fmt.Errorf("Custom error") } diff --git a/lib/http/sse_endpoint_test.go b/lib/http/sse_endpoint_test.go index 106149b6..2f3ebbda 100644 --- a/lib/http/sse_endpoint_test.go +++ b/lib/http/sse_endpoint_test.go @@ -46,7 +46,7 @@ func testSSEEndpointEmptyCall(t *testing.T, httpd *Server) { func testSSEEndpointDuplicatePath(t *testing.T, httpd *Server) { var ep = &Endpoint{ Path: `/sse`, - Call: func(req *EndpointRequest) ([]byte, error) { return nil, nil }, + Call: func(_ *EndpointRequest) ([]byte, error) { return nil, nil }, } var err = httpd.RegisterEndpoint(ep) @@ -56,7 +56,7 @@ func testSSEEndpointDuplicatePath(t *testing.T, httpd *Server) { var sse = &SSEEndpoint{ Path: `/sse`, - Call: func(sseconn *SSEConn) {}, + Call: func(_ *SSEConn) {}, } err = httpd.RegisterSSE(sse) diff --git a/lib/websocket/client_test.go b/lib/websocket/client_test.go index 7f53daa8..ae53965a 100644 --- a/lib/websocket/client_test.go +++ b/lib/websocket/client_test.go @@ -189,7 +189,7 @@ func TestClientPing(t *testing.T) { gotFrame <- f return nil }, - handlePong: func(cl *Client, f *Frame) (err error) { + handlePong: func(_ *Client, f *Frame) (err error) { gotFrame <- f return nil }, @@ -306,13 +306,13 @@ func TestClient_send_FrameText(t *testing.T) { cl = &Client{ Endpoint: _testEndpointAuth, - handleClose: func(cl *Client, f *Frame) error { + handleClose: func(_ *Client, f *Frame) error { cl.sendClose(f.closeCode, nil) cl.Quit() gotFrame <- f return nil }, - HandleText: func(cl *Client, f *Frame) error { + HandleText: func(_ *Client, f *Frame) error { gotFrame <- f return nil }, @@ -442,7 +442,7 @@ func TestClientFragmentation(t *testing.T) { gotFrame <- f return nil }, - HandleText: func(cl *Client, f *Frame) error { + HandleText: func(_ *Client, f *Frame) error { gotFrame <- f return nil }, @@ -489,11 +489,11 @@ func TestClientFragmentation2(t *testing.T) { gotFrame = make(chan *Frame) testClient = &Client{ Endpoint: _testEndpointAuth, - handlePong: func(cl *Client, f *Frame) error { + handlePong: func(_ *Client, f *Frame) error { gotFrame <- f return nil }, - HandleText: func(cl *Client, f *Frame) error { + HandleText: func(_ *Client, f *Frame) error { gotFrame <- f return nil }, @@ -603,7 +603,7 @@ func TestClientSendBin(t *testing.T) { cl = &Client{ Endpoint: _testEndpointAuth, - HandleBin: func(cl *Client, f *Frame) error { + HandleBin: func(_ *Client, f *Frame) error { gotFrame <- f return nil }, @@ -661,7 +661,7 @@ func TestClientSendPing(t *testing.T) { gotFrame = make(chan *Frame) testClient = &Client{ Endpoint: _testEndpointAuth, - handlePong: func(cl *Client, f *Frame) error { + handlePong: func(_ *Client, f *Frame) error { gotFrame <- f return nil }, diff --git a/lib/websocket/rootroute_test.go b/lib/websocket/rootroute_test.go index 6d261631..caca340b 100644 --- a/lib/websocket/rootroute_test.go +++ b/lib/websocket/rootroute_test.go @@ -14,7 +14,7 @@ import ( ) func testRouteHandler(t *testing.T, target string) RouteHandler { - return func(ctx context.Context, req *Request) (res Response) { + return func(_ context.Context, req *Request) (res Response) { test.Assert(t, "routeHandler", target, req.Target) return } diff --git a/lib/websocket/server_test.go b/lib/websocket/server_test.go index 64a9d71d..1f8e0768 100644 --- a/lib/websocket/server_test.go +++ b/lib/websocket/server_test.go @@ -306,7 +306,7 @@ func TestServer_upgrader_nonblocking(t *testing.T) { qtext = make(chan []byte, 1) cl = &Client{ Endpoint: _testEndpointAuth, - HandleText: func(cl *Client, frame *Frame) (err error) { + HandleText: func(_ *Client, frame *Frame) (err error) { qtext <- frame.Payload() return nil },