From: spf13 Date: Tue, 4 Nov 2014 05:26:56 +0000 (-0500) Subject: Adding ReaderTo and ToReader helper functions X-Git-Tag: v0.13~349 X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=dcea0fa5;p=brevno-suite%2Fhugo Adding ReaderTo and ToReader helper functions --- diff --git a/helpers/general.go b/helpers/general.go index f68908d9..bfac5bea 100644 --- a/helpers/general.go +++ b/helpers/general.go @@ -64,6 +64,20 @@ func ReaderToBytes(lines io.Reader) []byte { return b.Bytes() } +func ReaderToString(lines io.Reader) string { + b := new(bytes.Buffer) + b.ReadFrom(lines) + return b.String() +} + +func StringToReader(in string) io.Reader { + return strings.NewReader(in) +} + +func BytesToReader(in []byte) io.Reader { + return bytes.NewReader(in) +} + // sliceToLower goes through the source slice and lowers all values. func SliceToLower(s []string) []string { if s == nil {