summaryrefslogtreecommitdiffstats
path: root/client/go/util/io.go
diff options
context:
space:
mode:
Diffstat (limited to 'client/go/util/io.go')
-rw-r--r--client/go/util/io.go12
1 files changed, 10 insertions, 2 deletions
diff --git a/client/go/util/io.go b/client/go/util/io.go
index 217beb085d1..d7b849ba9a4 100644
--- a/client/go/util/io.go
+++ b/client/go/util/io.go
@@ -5,6 +5,7 @@
package util
import (
+ "bytes"
"errors"
"io"
"os"
@@ -24,8 +25,15 @@ func IsDirectory(path string) bool {
}
// Returns the content of a reader as a string
-func ReaderToString(reader io.ReadCloser) string {
+func ReaderToString(reader io.Reader) string {
buffer := new(strings.Builder)
io.Copy(buffer, reader)
return buffer.String()
-} \ No newline at end of file
+}
+
+// Returns the content of a reader as a byte array
+func ReaderToBytes(reader io.Reader) []byte {
+ buffer := new(bytes.Buffer)
+ buffer.ReadFrom(reader)
+ return buffer.Bytes()
+}