1
0
mirror of https://github.com/astaxie/beego.git synced 2025-06-12 12:50:40 +00:00

beego:1.2.0

This commit is contained in:
astaxie
2014-05-20 15:53:41 +08:00
parent b45f0b9bf6
commit 03080b3ef2
3 changed files with 26 additions and 30 deletions

View File

@ -64,24 +64,30 @@ func GrepFile(patten string, filename string) (lines []string, err error) {
lines = make([]string, 0)
reader := bufio.NewReader(fd)
prefix := ""
isLongLine := false
for {
byteLine, isPrefix, er := reader.ReadLine()
if er != nil && er != io.EOF {
return nil, er
}
if er == io.EOF {
break
}
line := string(byteLine)
if isPrefix {
prefix += line
continue
} else {
isLongLine = true
}
line = prefix + line
if isLongLine {
prefix = ""
}
if re.MatchString(line) {
lines = append(lines, line)
}
if er == io.EOF {
break
}
}
return lines, nil
}