You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Discovered this case by accident. It looks a bit unexpected to me. Whether it can be considered as a bug or not is obviously up to you. I don't write code like that, so it's not a critical issue for me, but I thought it's worth reporting.
In case you didn't notice the problem. Braces of the one-line function are weirdly aligned with the comment on the next line. Or if the first function is longer than the second one, comment section will be weirdly aligned with braces.
The text was updated successfully, but these errors were encountered:
bradfitz
changed the title
gofmt: Unexpected formatting with one line functions/methods.
cmd/gofmt: Unexpected formatting with one line functions/methods.
Mar 14, 2017
The vtab controls the column layout. We want one here because if we have multiple one-line functions w/o empty lines between them, we want the function bodies to align (at least that's what they are doing now).
The assumption was that there would be an empty line before and after any multi-line function, and then the issue you're seeing doesn't occur. (That's also the work-around in this case).
What version of Go are you using (
go version
)?go version go1.8 linux/amd64
What operating system and processor architecture are you using (
go env
)?Doesn't matter.
What did you do?
gofmt the following code:
What did you expect to see?
What did you see instead?
Discovered this case by accident. It looks a bit unexpected to me. Whether it can be considered as a bug or not is obviously up to you. I don't write code like that, so it's not a critical issue for me, but I thought it's worth reporting.
In case you didn't notice the problem. Braces of the one-line function are weirdly aligned with the comment on the next line. Or if the first function is longer than the second one, comment section will be weirdly aligned with braces.
The text was updated successfully, but these errors were encountered: