mirror of
https://github.com/MHSanaei/3x-ui.git
synced 2026-09-25 03:06:45 +08:00
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.
This commit is contained in:
@@ -4,6 +4,7 @@ package sys
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"bufio"
|
"bufio"
|
||||||
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"os"
|
"os"
|
||||||
@@ -93,7 +94,7 @@ func CPUPercentRaw() (float64, error) {
|
|||||||
|
|
||||||
rd := bufio.NewReader(f)
|
rd := bufio.NewReader(f)
|
||||||
line, err := rd.ReadString('\n')
|
line, err := rd.ReadString('\n')
|
||||||
if err != nil && err != io.EOF {
|
if err != nil && !errors.Is(err, io.EOF) {
|
||||||
return 0, err
|
return 0, err
|
||||||
}
|
}
|
||||||
// Expect: cpu user nice system idle iowait irq softirq steal guest guest_nice
|
// Expect: cpu user nice system idle iowait irq softirq steal guest guest_nice
|
||||||
|
|||||||
Reference in New Issue
Block a user