cmd/gofmt: inconsistent formatting of spacing around operators #34426
Comments
I believe that this is by design, but has nothing to do with the I'll leave it open in case @griesemer has anything to add. |
This has been like this probably since the early days of gofmt. For comparison, formatting of various expressions:
I agree that there's little difference between a list of composite literal elements and parameter lists and this is an inconsistency. It's not clear that we should change it as it would cause quite a bit of churn. If we do, we may want to combine it with some more gofmt cleanups/improvements. |
Related: #11497 |
Concatenating strings in an assignment requires spaces around the |
Well here's a sloppy patch for the issue. It's enabled with a somewhat arbitrary "-o" option. Personally, I think gofmt should have a library of configurable style options and then expose each of the predefined options such that they can be mutated. For example, Attempting to dictate to the masses precisely how thine code shall be formatted is a bad practice. There's nothing wrong with standards and style guides, but not allowing for alternatives comes off as a bit dictatorial or rigid.
|
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes, tested with
format
button on https://play.golang.org/p/Ei6Hu4QqAHaWhat operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Operators inside function calls are inconsistently formatted depending if they are inside
append
or not.What did you expect to see?
What did you see instead?
The text was updated successfully, but these errors were encountered: