Skip to content

Commit 4b89e0c

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 4787c91 commit 4b89e0c

File tree

16 files changed

+59
-28
lines changed

16 files changed

+59
-28
lines changed

.golangci.yml

-3
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

+1-1
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

+1-1
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

+3-1
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

+3-1
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

+6-2
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

+3-1
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

+4-2
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

+12-4
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

+6-2
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)

cmd/tapa/main.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,9 @@ func main() {
170170
if err != nil {
171171
log.Fatal(logger, "dial to NSMgr", "error", err)
172172
}
173-
defer cc.Close()
173+
defer func() {
174+
_ = cc.Close()
175+
}()
174176
monitorClient := networkservice.NewMonitorConnectionClient(cc)
175177

176178
if err := os.RemoveAll(config.Socket); err != nil {

pkg/health/probe/probe.go

+3-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,9 @@ func (hp *HealthProbe) Request(ctx context.Context) error {
118118
if err != nil {
119119
return fmt.Errorf("failed to connect service %q, %w", hp.addr, err)
120120
}
121-
defer conn.Close()
121+
defer func() {
122+
_ = conn.Close()
123+
}()
122124

123125
rpcCtx, rpcCancel := context.WithTimeout(ctx, hp.rpcTimeout)
124126
defer rpcCancel()

pkg/ipam/storage/sqlite/sqlite_test.go

+9-3
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,9 @@ const dbFileName = "test.db"
3030

3131
func Test_Add_Get(t *testing.T) {
3232
_ = os.Remove(dbFileName)
33-
defer os.Remove(dbFileName)
33+
defer func() {
34+
_ = os.Remove(dbFileName)
35+
}()
3436

3537
store, err := sqlite.New(dbFileName)
3638
assert.Nil(t, err)
@@ -74,7 +76,9 @@ func Test_Add_Get(t *testing.T) {
7476

7577
func Test_GetChilds(t *testing.T) {
7678
_ = os.Remove(dbFileName)
77-
defer os.Remove(dbFileName)
79+
defer func() {
80+
_ = os.Remove(dbFileName)
81+
}()
7882

7983
store, err := sqlite.New(dbFileName)
8084
assert.Nil(t, err)
@@ -106,7 +110,9 @@ func Test_GetChilds(t *testing.T) {
106110

107111
func Test_Delete(t *testing.T) {
108112
_ = os.Remove(dbFileName)
109-
defer os.Remove(dbFileName)
113+
defer func() {
114+
_ = os.Remove(dbFileName)
115+
}()
110116

111117
store, err := sqlite.New(dbFileName)
112118
assert.Nil(t, err)

pkg/nsm/client.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ func (apiClient *APIClient) Delete() {
172172
apiClient.cancel()
173173
}
174174
if apiClient.GRPCClient != nil {
175-
apiClient.GRPCClient.Close()
175+
_ = apiClient.GRPCClient.Close()
176176
}
177177
}
178178

pkg/nsp/registry/sqlite/sqlite.go

+1-1
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ func (trsql *TargetRegistrySQLite) Close() error {
6060
if err != nil {
6161
return fmt.Errorf("failed to close db connection: %w", err)
6262
}
63-
sqlDB.Close()
63+
_ = sqlDB.Close()
6464
return nil
6565
}
6666

pkg/nsp/registry/sqlite/sqlite_test.go

+3-3
Original file line numberDiff line numberDiff line change
@@ -31,12 +31,12 @@ func TestTargetRegistrySQLite_Set(t *testing.T) {
3131
t.Cleanup(func() { goleak.VerifyNone(t) })
3232

3333
dbFile := "test.db"
34-
os.Remove(dbFile)
34+
_ = os.Remove(dbFile)
3535
db, err := sqlite.New(dbFile)
3636
assert.Nil(t, err)
3737
defer func() {
38-
db.Close()
39-
os.Remove(dbFile)
38+
_ = db.Close()
39+
_ = os.Remove(dbFile)
4040
}()
4141

4242
ctx := context.Background()

0 commit comments

Comments
 (0)