Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (go version)?
go version go1.9.2 darwin/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (go env)?
GOARCH="amd64"
GOHOSTARCH="amd64"
GOHOSTOS="darwin"
GOOS="darwin"
What did you do?
- Created a file named
a.go with the following contents:
package foo // import "example.org/foo"
import "fmt"
var ErrWhatever = fmt.Errorf("whatever")
- Ran
gofmt a.go. The output was:
package foo // import "example.org/foo"
import "fmt"
var ErrWhatever = fmt.Errorf("whatever")
What did you expect to see?
Expected the gofmt output to have a newline between the package and the import lines; i.e. like so:
package foo // import "example.org/foo"
import "fmt"
var ErrWhatever = fmt.Errorf("whatever")
What did you see instead?
The gofmt output did not have a newline between the package and the import lines.
If the import comment // import "example.org/foo" isn't present in the file, then the newline is produced. It looks like gofmt's behavior is different when an import comment exists, but that shouldn't be the case.
Please answer these questions before submitting your issue. Thanks!
What version of Go are you using (
go version)?go version go1.9.2 darwin/amd64
Does this issue reproduce with the latest release?
yes
What operating system and processor architecture are you using (
go env)?What did you do?
a.gowith the following contents:gofmt a.go. The output was:What did you expect to see?
Expected the
gofmtoutput to have a newline between the package and the import lines; i.e. like so:What did you see instead?
The
gofmtoutput did not have a newline between the package and the import lines.If the import comment
// import "example.org/foo"isn't present in the file, then the newline is produced. It looks likegofmt's behavior is different when an import comment exists, but that shouldn't be the case.