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
I understand that gofmt will try to remove spaces between operator and operand, so that it's easier to tell the association. However, this creates weird situations when the star operator is involved with pointers. For example:
ianlancetaylor
changed the title
gofmt shouldn't remove spaces when there's pointer invovled
cmd/gofmt: don't remove spaces when combining binary and unary *
Jul 19, 2020
which is better for the multiplications, but worse for the addition as it lost its difference from the multiplications which have higher precedence. As has been pointed out above, this was discussed almost 10 years ago and we decided to leave it alone. The better solution is to introduce parentheses to increase readability when it's problematic. Also, this is not a very common situation.
What version of Go are you using (
go version
)?go1.14.4
Problem
I understand that gofmt will try to remove spaces between operator and operand, so that it's easier to tell the association. However, this creates weird situations when the star operator is involved with pointers. For example:
works as expected, but if we add a 1 in the last line:
where the 10 **p1 **p2 would be very easily confused as an exponential operator - which golang doesn't have.
The text was updated successfully, but these errors were encountered: