-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/gofmt: inconsistent spaces around bitwise & #12720
Comments
Working as intended. gofmt uses spaces around binary expressions to express binding strength. Depending on nesting level, spaces are removed. |
@griesemer I did look for duplicates although, I guess, I only checked open issues (will look better next time). All but #11497 are closed for the reasons of emphasizing the precedence in otherwise complex expressions. Do we have to highlight in this example I read the long comment for
Is I am sorry, but in my opinion this error report is different from other closed reports. I could not find the answer from |
@RomanSaveljev "(arr, i & maxKeys)" is not a single expression. But the point is that "i & maxKeys" if standing "alone", including standing alone inside ()'s, gets the space around the '&', and otherwise it won't. Which is why we get
to show some examples. That is, an expression inside a parameter list (== a list of expressions) is treated similarly to an expression inside larger expression (e.g., "a list of terms in a sum" as in a + b + c where each a, b, c is "inside"). |
gofmt formats this file differently than it used to, and results in what at first seems like an odd inconsistency. Apparently this is by design (see [this][1] and [this][2]), and due to nesting level. [1]: golang/go#11497 [2]: golang/go#12720
Go version:
go version go1.5.1 linux/amd64
What I did: used gofmt on my source code
What I expected: have spaces around bitwise
&
everywhereWhat I saw: in one occasion there was no spaces around the operator
I have put "before" and "after" code into a gist, so from the diff you can easily see the changes applied by gofmt
The text was updated successfully, but these errors were encountered: