ソースを参照

fix(lint): use errors.Is for io.EOF comparison in sys_linux

The errorlint linter rejects direct error comparison with != because it
fails on wrapped errors. Compare via errors.Is(err, io.EOF) instead.
MHSanaei 11 時間 前
コミット
56b0be0b6a
1 ファイル変更2 行追加1 行削除
  1. 2 1
      internal/util/sys/sys_linux.go

+ 2 - 1
internal/util/sys/sys_linux.go

@@ -4,6 +4,7 @@ package sys
 
 import (
 	"bufio"
+	"errors"
 	"fmt"
 	"io"
 	"os"
@@ -93,7 +94,7 @@ func CPUPercentRaw() (float64, error) {
 
 	rd := bufio.NewReader(f)
 	line, err := rd.ReadString('\n')
-	if err != nil && err != io.EOF {
+	if err != nil && !errors.Is(err, io.EOF) {
 		return 0, err
 	}
 	// Expect: cpu  user nice system idle iowait irq softirq steal guest guest_nice