mirror of
https://github.com/lima-vm/lima.git
synced 2026-10-28 11:44:35 +08:00
Fix new lint findings from golangci-lint 2.15.0
errcheck v1.30.0 reports a bare receive from an error channel as an unchecked error. Each receive it flagged waits for a process or server to exit after Lima has stopped or killed it, so the error adds nothing; discard it with "_ = <-ch". But staticcheck's S1005 flags "_ = <-ch" as an unnecessary blank assignment, so each spelling of the discard fails one of the two linters. Disable S1005. It also flags blank identifiers in range loops, such as "for _ = range", but gofmt's simplify step and revive's range rule still catch those. Signed-off-by: Jan Dubois <jan.dubois@suse.com>
This commit is contained in:
1 parent
b79e16b94b
commit
00c49d5cee
4 files changed
+9
-8
No files matched your search
@@ -135,6 +135,7 @@ linters:
|
||||
- -ST1001 # duplicates revive.dot-imports
|
||||
- -ST1022
|
||||
- -SA4023 # workaround for timing out https://github.com/golangci/golangci-lint/issues/6732
|
||||
- -S1005 # flags "_ = <-errCh", which errcheck requires https://github.com/dominikh/go-tools/issues/1844
|
||||
usestdlibvars:
|
||||
http-method: false
|
||||
time-date-month: true
|
||||
|
||||
Vendored
+3
-3
@@ -112,7 +112,7 @@ func Serve(ctx context.Context, driver driver.Driver) {
|
||||
case <-sigs:
|
||||
logger.Info("Received shutdown signal, stopping server...")
|
||||
server.GracefulStop()
|
||||
<-serveErr
|
||||
_ = <-serveErr
|
||||
case err := <-serveErr:
|
||||
if err != nil && !errors.Is(err, grpc.ErrServerStopped) {
|
||||
logger.Errorf("Failed to serve: %v", err)
|
||||
@@ -251,7 +251,7 @@ func Start(ctx context.Context, extDriver *registry.ExternalDriver, instName str
|
||||
if err := cmd.Process.Kill(); err != nil {
|
||||
driverLogger.Errorf("Failed to kill external driver process after client creation failure: %v", err)
|
||||
}
|
||||
<-procExit
|
||||
_ = <-procExit
|
||||
return fmt.Errorf("failed to create driver client: %w", err)
|
||||
}
|
||||
driverLogger.Debugf("External driver %s started successfully", extDriver.Name)
|
||||
@@ -266,7 +266,7 @@ func Start(ctx context.Context, extDriver *registry.ExternalDriver, instName str
|
||||
if err := cmd.Process.Kill(); err != nil {
|
||||
driverLogger.Errorf("Failed to kill external driver process after socket wait timeout: %v", err)
|
||||
}
|
||||
<-procExit
|
||||
_ = <-procExit
|
||||
return errors.New("timed out waiting for external driver to create socket file")
|
||||
}
|
||||
}
|
||||
|
||||
@@ -173,14 +173,14 @@ func (l *LimaKrunkitDriver) Stop(_ context.Context) error {
|
||||
|
||||
timeout := time.After(30 * time.Second)
|
||||
select {
|
||||
case <-l.krunkitWaitCh:
|
||||
case _ = <-l.krunkitWaitCh:
|
||||
return nil
|
||||
case <-timeout:
|
||||
if err := l.krunkitCmd.Process.Kill(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
<-l.krunkitWaitCh
|
||||
_ = <-l.krunkitWaitCh
|
||||
return nil
|
||||
}
|
||||
}
|
||||
|
||||
@@ -331,7 +331,7 @@ func waitForDaemon(ctx context.Context, cmd *exec.Cmd, pidFile string, timeout t
|
||||
ready, err := pidFileWritten(pidFile)
|
||||
if err != nil {
|
||||
_ = cmd.Process.Kill()
|
||||
<-waitCh
|
||||
_ = <-waitCh
|
||||
return err
|
||||
}
|
||||
if ready {
|
||||
@@ -340,7 +340,7 @@ func waitForDaemon(ctx context.Context, cmd *exec.Cmd, pidFile string, timeout t
|
||||
select {
|
||||
case <-ctx.Done():
|
||||
_ = cmd.Process.Kill()
|
||||
<-waitCh
|
||||
_ = <-waitCh
|
||||
return ctx.Err()
|
||||
case waitErr := <-waitCh:
|
||||
// Process exited. If it managed to write the PID file first, treat as success;
|
||||
@@ -358,7 +358,7 @@ func waitForDaemon(ctx context.Context, cmd *exec.Cmd, pidFile string, timeout t
|
||||
return &daemonExitedError{err: waitErr}
|
||||
case <-timer.C:
|
||||
_ = cmd.Process.Kill()
|
||||
<-waitCh
|
||||
_ = <-waitCh
|
||||
return &daemonStuckError{timeout: timeout}
|
||||
case <-ticker.C:
|
||||
// re-check the PID file on the next loop iteration
|
||||
|
||||
Reference in new issue
Block a user