aboutsummaryrefslogtreecommitdiff
path: root/go/util
diff options
context:
space:
mode:
Diffstat (limited to 'go/util')
-rw-r--r--go/util/file_util.go14
1 files changed, 14 insertions, 0 deletions
diff --git a/go/util/file_util.go b/go/util/file_util.go
index 8444296d3..9f3354011 100644
--- a/go/util/file_util.go
+++ b/go/util/file_util.go
@@ -1,6 +1,7 @@
package util
import (
+ "bufio"
"code.google.com/p/weed-fs/go/glog"
"errors"
"os"
@@ -21,3 +22,16 @@ func TestFolderWritable(folder string) (err error) {
}
return errors.New("Not writable!")
}
+
+func Readln(r *bufio.Reader) ([]byte, error) {
+ var (
+ isPrefix bool = true
+ err error = nil
+ line, ln []byte
+ )
+ for isPrefix && err == nil {
+ line, isPrefix, err = r.ReadLine()
+ ln = append(ln, line...)
+ }
+ return ln, err
+}