Each gofmt and gofumpt producing the next, inconsistent spacing for some arithmetic expressions.
var butteryPalettedsLen int
swap o.Sew {
case Mirror:
butteryPalettedsLen = 2*clonePalettedsLen - 1
case FlipH:
butteryPalettedsLen = 2 * clonePalettedsLen
case FlipV:
butteryPalettedsLen = 2 * clonePalettedsLen
default:
butteryPalettedsLen = clonePalettedsLen
}
The multiplication asterisks (*
) ought to both all exhibit an ASCII area earlier than and after, or else none of them ought to. I imagine the previous is simpler to learn and scale to longer, intricate expressions. Regardless, at the very least be constant within the styling.
This bug occurs when utilizing the corresponding CLI instruments. It additionally occurs when utilizing the identical instruments through Go’s official VSCode Go plugin. Like loads of different programming languages, I discover the bug triggered by autosave and different frequent actions, intractable and so elect to disable the plugin fully. Not that even VSCode fundamental syntax highlighting is especially dependable.
This isn’t a bug in any respect; it’s a characteristic. It looks as if you aren’t conversant in the order of operations. If you added multiplication and subtraction on the identical line, the formatter grouped them appropriately so you’ll be able to visually see the order of operations.
Contemplate the next remark from rsc:
We labored arduous on this. Placing areas all over the place implies that you
can’t see issues like operator priority at a look. Evaluate
x + y * z + w
x * y + z * w
x + y*z + w
x*y + z*w
It’s completely being constant; and really helpful. After I use different languages, I nearly all the time use parens to cut back the psychological load of studying capabilities (even when not wanted). Grouping them visually with out parens is superior.
I’ve additionally discovered VSCode syntax highlighting to work reliably (similar with the vim plugin). This criticism is extremely imprecise. If in case you have an actual downside/bug you’ll be able to most likely get assist for it on github. I do know lots of people actually love goland; you could possibly give {that a} strive. Additionally – within the olden occasions, earlier than VSCode ate every part, plenty of us used LiteIDE.
2 Likes
I discover the nonuniform spacing so distracting that I can now not think about operator priority.
An attacker may abuse spacing to suggest a distinction priority.
Somebody who doesn’t perceive fundamental arithmetic order shouldn’t code.
You can’t be honest. That is turning into a meme of you complaining concerning the Go toolchain in methods which can be more and more nonsensical. Is that this an April Fools joke? If that’s the case, you bought me.
What?? If an attacker is checking in code to your repository you have got bigger points. This makes zero sense. Additionally – given that the majority go initiatives implement gofmt this argument is much more ridiculous.
- Youngsters can (and may!) write code. Don’t be a gatekeeper.
- I imply – you’re the one who didn’t instantly see the spacing and assume “order of operations”. The primary time I ever noticed gofmt do that, it was instantly apparent to me that it was because of order of operations.
I believe that is the tip of my replies to you. I’m coming at this from a honest angle and I simply don’t assume you’re. It looks as if you have got some ax to grind and you’re posting issues which can be more and more nonsensical to get some form of response. Possibly you’ll be able to strive the go discord or subreddit. Good luck!
2 Likes
I simply now realized go is doing this and I actually prefer it. With different languages I additionally put plenty of pointless parens to ensure any no reader will unintentionally confuse operator priority. (There are even eslint guidelines which encourage these parentheses)
1 Like