1
0
mirror of https://github.com/shirou/gopsutil.git synced 2025-04-26 13:48:59 +08:00

Merge pull request #1202 from 851235550/fix-read-lines-offset-n

Fix bug for func named ReadLinesOffsetN
This commit is contained in:
shirou 2021-12-22 21:39:51 +09:00 committed by GitHub
commit 530dc58cba
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -12,6 +12,7 @@ import (
"context"
"errors"
"fmt"
"io"
"io/ioutil"
"net/url"
"os"
@ -129,6 +130,9 @@ func ReadLinesOffsetN(filename string, offset uint, n int) ([]string, error) {
for i := 0; i < n+int(offset) || n < 0; i++ {
line, err := r.ReadString('\n')
if err != nil {
if err == io.EOF && len(line) > 0 {
ret = append(ret, strings.Trim(line, "\n"))
}
break
}
if i < int(offset) {