cmd/gofmt: fix error on partial Go code ending with line comment.

Fix issue by always appending newline after user input, before
the closing curly bracket. The adjust func is modified to remove
this new newline.

Add test case (it fails before CL, passes after).

Fixes issue 8411.

LGTM=gri
R=golang-codereviews, bradfitz, josharian, gri
CC=golang-codereviews
https://codereview.appspot.com/124700043

Committer: Robert Griesemer <gri@golang.org>
runtime: please vet
The current code is correct, but vet does not understand it:
asm_amd64.s:963: [amd64] invalid MOVL of ret+0(FP); int64 is 8-byte value
asm_amd64.s:964: [amd64] invalid offset ret+4(FP); expected ret+0(FP)

LGTM=minux
R=golang-codereviews, minux
CC=golang-codereviews
https://codereview.appspot.com/125200044