1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2024-11-24 08:52:21 +02:00

🎨 observe the error, if there is one

This commit is contained in:
Davyd McColl 2021-06-11 17:06:47 +02:00 committed by Jesse Duffield
parent aa9ef12d43
commit 31bcd632c7

View File

@ -370,12 +370,26 @@ func TailLogsNative(logFilePath string, opts *humanlog.HandlerOptions) {
}
}
func OpenAndSeek(filepath string, offset int64) (*os.File, error) {
file, err := os.Open(filepath)
if err != nil {
return nil, err
}
_, err = file.Seek(offset, 0)
if err != nil {
_ = file.Close()
return nil, err
}
return file, nil
}
func TailFrom(lastOffset int64, logFilePath string, opts *humanlog.HandlerOptions) error {
file, err := os.Open(logFilePath)
file, err := OpenAndSeek(logFilePath, lastOffset)
if err != nil {
return err
}
file.Seek(lastOffset, 0)
fileScanner := bufio.NewScanner(file)
var lines []string
for fileScanner.Scan() {