Skip to content

Commit 2fb97cf

Browse files
committed
Update golangci-lint to support go version 1.23
Some linters got inactivated leading to an error when running the linter. Thus, they are now removed from the config file's enable list.
1 parent 31901d7 commit 2fb97cf

16 files changed

Lines changed: 59 additions & 28 deletions

File tree

.golangci.yml

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,10 @@ run:
44
linters:
55
disable-all: true
66
enable:
7-
- deadcode
87
- errcheck
98
- gosimple
109
- govet
1110
- ineffassign
1211
- staticcheck
13-
- structcheck
1412
- typecheck
1513
- unused
16-
- varcheck

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -273,7 +273,7 @@ output-dir:
273273

274274
.PHONY: golangci-lint
275275
golangci-lint:
276-
$(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.56.2)
276+
$(call go-get-tool,$(GOLANGCI_LINT),github.com/golangci/golangci-lint/cmd/golangci-lint@v1.62.2)
277277

278278
.PHONY: proto-compiler
279279
proto-compiler: protoc protoc-gen-go protoc-gen-go-grpc

api/v1/webhook_suite_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ var _ = BeforeSuite(func() {
134134
if err != nil {
135135
return err
136136
}
137-
conn.Close()
137+
_ = conn.Close()
138138
return nil
139139
}).Should(Succeed())
140140

cmd/frontend/internal/bird/bird.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -124,7 +124,9 @@ func (b *RoutingService) Run(ctx context.Context, monitorLogs bool) error {
124124
return
125125
}
126126
// when context is done, close File thus signalling EOF to bufio Scan()
127-
defer w.Close()
127+
defer func() {
128+
_ = w.Close()
129+
}()
128130
<-ctx.Done()
129131
b.logger.Info("Context closed, terminate log monitoring")
130132
}()

cmd/frontend/internal/bird/configure.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ func (r *routingConfig) Apply() error {
5151
if err != nil {
5252
return fmt.Errorf("create %v, err: %v", r.path, err)
5353
}
54-
defer file.Close()
54+
defer func() {
55+
_ = file.Close()
56+
}()
5557

5658
_, err = file.WriteString(r.config)
5759
if err != nil {

cmd/frontend/main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,9 @@ func main() {
113113
if err != nil {
114114
log.Fatal(logger, "Dial NSP", "error", err)
115115
}
116-
defer conn.Close()
116+
defer func() {
117+
_ = conn.Close()
118+
}()
117119

118120
// monitor status of NSP connection and adjust probe status accordingly
119121
if err := connection.Monitor(ctx, health.NSPCliSvc, conn); err != nil {
@@ -131,7 +133,9 @@ func main() {
131133
if err != nil {
132134
log.Fatal(logger, "Dial loadbalancer", "error", err)
133135
}
134-
defer lbConn.Close()
136+
defer func() {
137+
_ = lbConn.Close()
138+
}()
135139

136140
// create and start frontend service
137141
c := &feConfig.Config{

cmd/ipam/main.go

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,9 @@ func main() {
137137
if err != nil {
138138
log.Fatal(logger, "Dial NSP err", "error", err)
139139
}
140-
defer conn.Close()
140+
defer func() {
141+
_ = conn.Close()
142+
}()
141143

142144
// monitor status of NSP connection and adjust probe status accordingly
143145
if err := connection.Monitor(ctx, health.NSPCliSvc, conn); err != nil {

cmd/operator/main.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,9 @@ func setupTLSCert(socket string) error {
8787
certDir := "/tmp/k8s-webhook-server/serving-certs"
8888

8989
go func() {
90-
defer client.Close()
90+
defer func() {
91+
_ = client.Close()
92+
}()
9193
err := client.WatchX509Context(ctx, &x509Watcher{CertDir: certDir})
9294
if err != nil && status.Code(err) != codes.Canceled {
9395
log.Fatal(setupLog, "error watching X.509 context", "error", err)
@@ -132,7 +134,7 @@ func main() {
132134
"Enabling this will ensure there is only one active controller manager.")
133135

134136
if os.Getenv(common.LogLevelEnv) == "" { // trace as default value
135-
os.Setenv(common.LogLevelEnv, "trace")
137+
_ = os.Setenv(common.LogLevelEnv, "trace")
136138
}
137139

138140
ver := flag.Bool("version", false, "Print version and quit")

cmd/proxy/main.go

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -164,7 +164,9 @@ func main() {
164164
if err != nil {
165165
log.Fatal(logger, "Dialing IPAM", "error", err)
166166
}
167-
defer conn.Close()
167+
defer func() {
168+
_ = conn.Close()
169+
}()
168170

169171
// monitor status of IPAM connection and adjust probe status accordingly
170172
if err := connection.Monitor(signalCtx, health.IPAMCliSvc, conn); err != nil {
@@ -193,7 +195,9 @@ func main() {
193195
if err != nil {
194196
log.Fatal(logger, "Dialing NSP", "error", err)
195197
}
196-
defer nspConn.Close()
198+
defer func() {
199+
_ = nspConn.Close()
200+
}()
197201

198202
// monitor status of NSP connection and adjust probe status accordingly
199203
if err := connection.Monitor(signalCtx, health.NSPCliSvc, nspConn); err != nil {
@@ -234,14 +238,18 @@ func main() {
234238
cancelSignalCtx()
235239
return
236240
}
237-
defer cc.Close()
241+
defer func() {
242+
_ = cc.Close()
243+
}()
238244
monitorClient := networkservice.NewMonitorConnectionClient(cc)
239245
go nsmmonitor.ConnectionMonitor(ctx, config.Name, monitorClient)
240246

241247
// create and start NSC that connects all remote NSE belonging to the right service
242248
interfaceMonitorClient := interfacemonitor.NewClient(interfaceMonitor, p, netUtils)
243249
nsmClient := service.GetNSC(ctx, &config, nsmAPIClient, p, interfaceMonitorClient, monitorClient)
244-
defer nsmClient.Close()
250+
defer func() {
251+
_ = nsmClient.Close()
252+
}()
245253
go func() {
246254
service.StartNSC(nsmClient, config.NetworkServiceName)
247255
cancelSignalCtx() // let others with proper clean-up gracefully terminate

cmd/stateless-lb/main.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,9 @@ func main() {
178178
if err != nil {
179179
log.Fatal(logger, "Dial NSP", "error", err)
180180
}
181-
defer conn.Close()
181+
defer func() {
182+
_ = conn.Close()
183+
}()
182184

183185
// Monitor status of NSP connection and adjust probe status accordingly
184186
if err := connection.Monitor(ctx, health.NSPCliSvc, conn); err != nil {
@@ -329,7 +331,9 @@ func main() {
329331
cancel()
330332
return
331333
}
332-
defer cc.Close()
334+
defer func() {
335+
_ = cc.Close()
336+
}()
333337
// Start monitoring NSM connections the LB is part of
334338
monitorClient := networkservice.NewMonitorConnectionClient(cc)
335339
go nsmmonitor.ConnectionMonitor(ctx, config.Name, monitorClient)

0 commit comments

Comments
 (0)