Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
B
beego
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
go
beego
Commits
3f4d750d
Commit
3f4d750d
authored
May 20, 2014
by
astaxie
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
utils: improve the file grep
parent
9f01aeed
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
3 deletions
+9
-3
file.go
utils/file.go
+9
-3
No files found.
utils/file.go
View file @
3f4d750d
...
@@ -64,24 +64,30 @@ func GrepFile(patten string, filename string) (lines []string, err error) {
...
@@ -64,24 +64,30 @@ func GrepFile(patten string, filename string) (lines []string, err error) {
lines
=
make
([]
string
,
0
)
lines
=
make
([]
string
,
0
)
reader
:=
bufio
.
NewReader
(
fd
)
reader
:=
bufio
.
NewReader
(
fd
)
prefix
:=
""
prefix
:=
""
isLongLine
:=
false
for
{
for
{
byteLine
,
isPrefix
,
er
:=
reader
.
ReadLine
()
byteLine
,
isPrefix
,
er
:=
reader
.
ReadLine
()
if
er
!=
nil
&&
er
!=
io
.
EOF
{
if
er
!=
nil
&&
er
!=
io
.
EOF
{
return
nil
,
er
return
nil
,
er
}
}
if
er
==
io
.
EOF
{
break
}
line
:=
string
(
byteLine
)
line
:=
string
(
byteLine
)
if
isPrefix
{
if
isPrefix
{
prefix
+=
line
prefix
+=
line
continue
continue
}
else
{
isLongLine
=
true
}
}
line
=
prefix
+
line
line
=
prefix
+
line
if
isLongLine
{
prefix
=
""
}
if
re
.
MatchString
(
line
)
{
if
re
.
MatchString
(
line
)
{
lines
=
append
(
lines
,
line
)
lines
=
append
(
lines
,
line
)
}
}
if
er
==
io
.
EOF
{
break
}
}
}
return
lines
,
nil
return
lines
,
nil
}
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment