Commit 14e9f482 authored by Daniel Martí's avatar Daniel Martí Committed by Ian Lance Taylor

cmd/cover: don't ignore os.Create error

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/33278Reviewed-by: default avatarIan Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
parent d7c0de98
......@@ -64,9 +64,12 @@ func htmlOutput(profile, outfile string) error {
} 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
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment