Failing to create the output file would give confusing errors such as:
cover: invalid argument
Also do out.Close() even if Execute() errored.
Fixes #17951.
Change-Id: I897e1d31f7996871c54fde7cb09614cafbf6c3fc
Reviewed-on: https://go-review.googlesource.com/33278
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
} else {
out, err = os.Create(outfile)
}
+ if err != nil {
+ return err
+ }
err = htmlTemplate.Execute(out, d)
- if err == nil {
- err = out.Close()
+ if err2 := out.Close(); err == nil {
+ err = err2
}
if err != nil {
return err