-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/gofmt: inconsistent blank line after package statement #30741
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
This looks like a clear bug in |
Maybe not so clear. This affects other declarations too. E.g., the following is considered "gofmt"ed in Go 1.12: package main // comment
import "archive/tar" // comment
var _ = tar.TypeReg // comment
type x struct{} // comment
const y = 0 // comment
func main() {} // comment
func (x) m() bool { return true } // comment /cc @griesemer |
Yes, I'd consider this a bug. There should be a blank line between the package clause and declarations, and between different kinds of declarations. There shouldn't be a difference just because there's a comment. |
this looks like a duplicate of #22631 |
It is, thanks for pointing that out @jamdagni86. Closing this as duplicate of #22631. |
Using Go1.12
Consider the following two snippets:
and
The former formats as:
while the latter formats as:
The latter does not have a blank line injected when a trailing comment on the package statement exists.
This seems to be the root problem of #26290, which was not addressed in the right place, in my opinion.
The text was updated successfully, but these errors were encountered: