aboutsummaryrefslogtreecommitdiffstats
path: root/file.go
diff options
context:
space:
mode:
authorSantiago M. Mola <santi@mola.io>2016-11-30 17:04:29 +0100
committerMáximo Cuadros <mcuadros@gmail.com>2016-11-30 17:04:29 +0100
commit606370479fbf0e315ccffcea8d86126c4a0c9db2 (patch)
tree891383ced1a78c9bf1a77bb9c9a68e0e636c3e0a /file.go
parentef1a0579fbc6aac510313ce073d1dd8fc8a9202b (diff)
downloadgo-git-606370479fbf0e315ccffcea8d86126c4a0c9db2.tar.gz
file: return error on File.Contents() if reader fails (#150)
Diffstat (limited to 'file.go')
-rw-r--r--file.go4
1 files changed, 3 insertions, 1 deletions
diff --git a/file.go b/file.go
index c5a6d42..e735723 100644
--- a/file.go
+++ b/file.go
@@ -30,7 +30,9 @@ func (f *File) Contents() (content string, err error) {
defer checkClose(reader, &err)
buf := new(bytes.Buffer)
- buf.ReadFrom(reader)
+ if _, err := buf.ReadFrom(reader); err != nil {
+ return "", err
+ }
return buf.String(), nil
}