encoding/htmlindex: Fix generated code not being gofmted.

When generating "tables.go", the last line was written without a newline.

This happened due two factors. First, the code generation simply ommited
writing that newline. Fixed that so it writes it, for consistency.

Second, the gen.WriteGoFile func is responsible for applying gofmt on
its input. However, it writes the package declaration separately and
does not supply that to format.Source. That causes format.Source to
preserve the whitespace before and after the given input. Instead,
it's better to provide the complete Go source code to format.Source
so that it ensures the entire file is compatible with gofmt formatting.
Fixed gen.WriteGoFile to always gofmt the entire source.

Change-Id: Ica2074eb1aa27e2143496699c9f2f40930700994
Reviewed-on: https://go-review.googlesource.com/10702
Reviewed-by: Nigel Tao <nigeltao@golang.org>
4 files changed