Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/gohugoio/hugo.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbep <bjorn.erik.pedersen@gmail.com>2015-03-12 22:50:44 +0300
committerbep <bjorn.erik.pedersen@gmail.com>2015-03-12 22:50:44 +0300
commitb190ad0ff9626f383945e137e66c0ae213f2c112 (patch)
tree26a6dbacd993faedc3f5faec96ad15311d33c1a4 /helpers
parentf8a840a14c9ad2ffa0120e9540be0a250409bfd3 (diff)
source: add some test cases for File
Diffstat (limited to 'helpers')
-rw-r--r--helpers/general.go6
1 files changed, 6 insertions, 0 deletions
diff --git a/helpers/general.go b/helpers/general.go
index e0fe99b6f..a0aa20c78 100644
--- a/helpers/general.go
+++ b/helpers/general.go
@@ -75,6 +75,9 @@ func GuessType(in string) string {
// ReaderToBytes takes an io.Reader argument, reads from it
// and returns bytes.
func ReaderToBytes(lines io.Reader) []byte {
+ if lines == nil {
+ return []byte{}
+ }
b := bp.GetBuffer()
defer bp.PutBuffer(b)
@@ -87,6 +90,9 @@ func ReaderToBytes(lines io.Reader) []byte {
// ReaderToString is the same as ReaderToBytes, but returns a string.
func ReaderToString(lines io.Reader) string {
+ if lines == nil {
+ return ""
+ }
b := bp.GetBuffer()
defer bp.PutBuffer(b)
b.ReadFrom(lines)