Join GitHub today
GitHub is home to over 40 million developers working together to host and review code, manage projects, and build software together.
Sign upcmd/gofmt: does not remove empty line right after open brace #28691
Comments
This comment has been minimized.
This comment has been minimized.
I don't know gofmt removes the blank line in one case but not the other. I really don't feel strongly either way, except that changing gofmt output at this point is kind of a pain since it causes perfectly fine existing code to suddenly fail gofmt checks. Leaving for @griesemer . |
This comment has been minimized.
This comment has been minimized.
Duplicate of #6996. |
Sign up for free
to subscribe to this conversation on GitHub.
Already have an account?
Sign in.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
In all code examples and documentation in go, there is no empty line right after open brace in start of a function, or a loop, or similar.
Gofmt seems to not enforce this, though, and there are members of my team that insist that if gofmt isn't changing it, then it's official stance of go language, since it does remove it in struct declaration.
I'm opening this issue to seek clarification and if there's any official stance from @ianlancetaylor on empty lines after opening brace, and, hopefully, add enforcing of that into gofmt, since it already does that to structs.
For example here
gofmt
will remove the first empty line:But here
gofmt
will not:More examples that can be gofmt'ed are at this link -- https://play.golang.org/p/FkD7WAOU-uL
What did you expect to see?
Empty lines after opening brace removed, as it's being done with struct definitions.
What did you see instead?
Only struct definition gets empty line removed after opening brace.