mirror of
https://github.com/shirou/gopsutil.git
synced 2025-05-08 19:29:25 +08:00
Merge pull request #1202 from 851235550/fix-read-lines-offset-n
Fix bug for func named ReadLinesOffsetN
This commit is contained in:
commit
530dc58cba
@ -12,6 +12,7 @@ import (
|
|||||||
"context"
|
"context"
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"net/url"
|
"net/url"
|
||||||
"os"
|
"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++ {
|
for i := 0; i < n+int(offset) || n < 0; i++ {
|
||||||
line, err := r.ReadString('\n')
|
line, err := r.ReadString('\n')
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
if err == io.EOF && len(line) > 0 {
|
||||||
|
ret = append(ret, strings.Trim(line, "\n"))
|
||||||
|
}
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
if i < int(offset) {
|
if i < int(offset) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user