Skip to content

Commit 0416f5e

Browse files
committed
Fix lint: upgrade to first version that supports go1.21
https://github.com/golangci/golangci-lint/releases/tag/v1.54.0
1 parent ba83ab9 commit 0416f5e

File tree

10 files changed

+18
-20
lines changed

10 files changed

+18
-20
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ endif
3333
GOOS ?= $(shell go env GOOS)
3434
GOARCH ?= $(shell go env GOARCH)
3535
INSTALL_LOCATION:=$(shell go env GOPATH)/bin
36-
GOLANGCI_LINT_VERSION ?= 1.51.2
36+
GOLANGCI_LINT_VERSION ?= 1.54.0
3737
GOSEC_VERSION ?= 2.13.1
3838

3939
REGISTRY ?= gcr.io/$(shell gcloud config get-value project)

cmd/server/app/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ func (p *Proxy) runAgentServer(o *options.ProxyRunOptions, server *server.ProxyS
393393
return nil
394394
}
395395

396-
func (p *Proxy) runAdminServer(o *options.ProxyRunOptions, server *server.ProxyServer) error {
396+
func (p *Proxy) runAdminServer(o *options.ProxyRunOptions, _ *server.ProxyServer) error {
397397
muxHandler := http.NewServeMux()
398398
muxHandler.Handle("/metrics", promhttp.Handler())
399399
if o.EnableProfiling {

cmd/test-server/main.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -143,15 +143,15 @@ func SetupSignalHandler() (stopCh <-chan struct{}) {
143143
return stop
144144
}
145145

146-
func returnSuccess(w http.ResponseWriter, req *http.Request) {
146+
func returnSuccess(w http.ResponseWriter, _ *http.Request) {
147147
fmt.Fprintf(w, "<!DOCTYPE html>\n<html>\n <head>\n <title>Success</title>\n </head>\n <body>\n <p>The success test page!</p>\n </body>\n</html>")
148148
}
149149

150-
func returnError(w http.ResponseWriter, req *http.Request) {
150+
func returnError(w http.ResponseWriter, _ *http.Request) {
151151
http.Error(w, http.StatusText(http.StatusInternalServerError), http.StatusInternalServerError)
152152
}
153153

154-
func closeNoResponse(w http.ResponseWriter, req *http.Request) {
154+
func closeNoResponse(w http.ResponseWriter, _ *http.Request) {
155155
hj, ok := w.(http.Hijacker)
156156
if !ok {
157157
http.Error(w, "webserver doesn't support hijacking", http.StatusInternalServerError)

pkg/server/backend_manager.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"fmt"
2222
"io"
2323
"math/rand"
24+
"slices"
2425
"strings"
2526
"sync"
2627
"time"
@@ -278,12 +279,7 @@ func NewDefaultBackendStorage(idTypes []header.IdentifierType) *DefaultBackendSt
278279
}
279280

280281
func containIDType(idTypes []header.IdentifierType, idType header.IdentifierType) bool {
281-
for _, it := range idTypes {
282-
if it == idType {
283-
return true
284-
}
285-
}
286-
return false
282+
return slices.Contains(idTypes, idType)
287283
}
288284

289285
// addBackend adds a backend.

pkg/server/default_route_backend_manager.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ func NewDefaultRouteBackendManager() *DefaultRouteBackendManager {
3636
}
3737

3838
// Backend tries to get a backend that advertises default route, with random selection.
39-
func (dibm *DefaultRouteBackendManager) Backend(ctx context.Context) (Backend, error) {
39+
func (dibm *DefaultRouteBackendManager) Backend(_ context.Context) (Backend, error) {
4040
return dibm.GetRandomBackend()
4141
}
4242

tests/agent_disconnect_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ func clientRequest(c *http.Client, addr string) ([]byte, error) {
173173
return data, nil
174174
}
175175

176-
func createGrpcTunnelClient(ctx context.Context, proxyAddr, addr string) (*http.Client, error) {
176+
func createGrpcTunnelClient(ctx context.Context, proxyAddr, _ string) (*http.Client, error) {
177177
tunnel, err := createSingleUseGrpcTunnel(ctx, proxyAddr)
178178
if err != nil {
179179
return nil, err
@@ -189,7 +189,7 @@ func createGrpcTunnelClient(ctx context.Context, proxyAddr, addr string) (*http.
189189
return c, nil
190190
}
191191

192-
func createHTTPConnectClient(ctx context.Context, proxyAddr, addr string) (*http.Client, error) {
192+
func createHTTPConnectClient(_ context.Context, proxyAddr, addr string) (*http.Client, error) {
193193
conn, err := net.Dial("unix", proxyAddr)
194194
if err != nil {
195195
return nil, err

tests/framework/agent.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,7 @@ func (a *externalAgent) waitForLiveness() error {
208208
}
209209

210210
func agentOptions(t testing.TB, opts AgentOpts) (*agentopts.GrpcProxyAgentOptions, error) {
211+
t.Helper()
211212
o := agentopts.NewGrpcProxyAgentOptions()
212213

213214
host, port, err := net.SplitHostPort(opts.ServerAddr)

tests/framework/proxy_server.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ func (ps *inProcessProxyServer) Metrics() metricstest.ServerTester {
136136
}
137137

138138
func serverOptions(t testing.TB, opts ProxyServerOpts) (*serveropts.ProxyRunOptions, error) {
139+
t.Helper()
139140
o := serveropts.NewProxyRunOptions()
140141

141142
o.ServerCount = uint(opts.ServerCount)

tests/ha_proxy_server_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ type tcpLB struct {
3737
backends []string
3838
}
3939

40-
func copy(wc io.WriteCloser, r io.Reader) {
40+
func ioCopy(wc io.WriteCloser, r io.Reader) {
4141
defer wc.Close()
4242
io.Copy(wc, r)
4343
}
@@ -48,8 +48,8 @@ func (lb *tcpLB) handleConnection(in net.Conn, backend string) {
4848
lb.t.Log(err)
4949
return
5050
}
51-
go copy(out, in)
52-
go copy(in, out)
51+
go ioCopy(out, in)
52+
go ioCopy(in, out)
5353
}
5454

5555
func (lb *tcpLB) serve(stopCh chan struct{}) string {

tests/proxy_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ func newSizedServer(length, chunks int) *testServer {
7676
}
7777
}
7878

79-
func (s *testServer) ServeHTTP(w http.ResponseWriter, req *http.Request) {
79+
func (s *testServer) ServeHTTP(w http.ResponseWriter, _ *http.Request) {
8080
for i := 0; i < s.chunks; i++ {
8181
w.Write(s.echo)
8282
}
@@ -94,7 +94,7 @@ func newWaitingServer() *waitingServer {
9494
}
9595
}
9696

97-
func (s *waitingServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
97+
func (s *waitingServer) ServeHTTP(w http.ResponseWriter, _ *http.Request) {
9898
close(s.requestReceivedCh)
9999
<-s.respondCh // Wait for permission to respond.
100100
w.Write([]byte("hello"))
@@ -114,7 +114,7 @@ func newDelayedServer() *delayedServer {
114114

115115
var _ = newDelayedServer() // Suppress unused lint error.
116116

117-
func (s *delayedServer) ServeHTTP(w http.ResponseWriter, r *http.Request) {
117+
func (s *delayedServer) ServeHTTP(w http.ResponseWriter, _ *http.Request) {
118118
delay := time.Duration(rand.Int63n(int64(s.maxWait-s.minWait))) + s.minWait /* #nosec G404 */
119119
time.Sleep(delay)
120120
w.Write([]byte("hello"))

0 commit comments

Comments
 (0)