Permalink
Browse files

If cmd outputs to a file, close it.

  • Loading branch information...
1 parent 3edef80 commit 4a5e8abce36462f89d92d28bd69b54c7845db818 James Tunnicliffe committed Aug 20, 2015
Showing with 4 additions and 1 deletion.
  1. +4 −1 output.go
View
@@ -156,9 +156,12 @@ func (c *Output) Write(ctx *Context, value interface{}) (err error) {
target = ctx.Stdout
} else {
path := ctx.AbsPath(c.outPath)
- if target, err = os.Create(path); err != nil {
+ var f *os.File
+ if f, err = os.Create(path); err != nil {
return
}
+ defer f.Close()
+ target = f
}
bytes, err := c.formatter.format(value)
if err != nil {

0 comments on commit 4a5e8ab

Please sign in to comment.