1
0
mirror of https://github.com/jesseduffield/lazygit.git synced 2025-08-09 09:22:48 +03:00
This commit is contained in:
Jesse Duffield
2021-05-30 15:22:04 +10:00
parent bc044c64b2
commit 258eedb38c
15 changed files with 802 additions and 680 deletions

25
pkg/utils/io.go Normal file
View File

@@ -0,0 +1,25 @@
package utils
import (
"bufio"
"os"
)
func ForEachLineInFile(path string, f func(string, int)) error {
file, err := os.Open(path)
if err != nil {
return err
}
defer file.Close()
reader := bufio.NewReader(file)
for i := 0; true; i++ {
line, err := reader.ReadString('\n')
if err != nil {
break
}
f(line, i)
}
return nil
}