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
Hi, I realize there's been some talk of making gofumpt take care of breaking long lines, but that's not gone anywhere, I don't think. I'd like to ask about something related, but a different approach.
Inspired by formatters for Zig and by Black (for Python), I'd like to suggest including some logic that would latch onto a presence/absence of a trailing comma in a param/arg/field list to break a def or decl automatically. I think we have nothing like this on the fmt level now except for Golines which (according to my colleagues, at least) takes away too much control from our code formatting. So here's how that would work:
If you write one of the above, say a func sig, pre-save, this way (mind the trailing comma):
Would you consider adding this kind of a feature? I am sold on it, frankly -- it gives you control over the line length, but also lets you easily break lines down and bring them back together quickly with the assistance of the fmtr.
All the best!
The text was updated successfully, but these errors were encountered:
I just came here to suggest this exact behavior - it's also how ruff works in Python, underlining that it's an established pattern, and has saved me a lot of tedious work that can usually not be automated. Since trailing commas are currently removed, they won't be present in formatted code, so this would not be a breaking change, and same for the other way around.
Hi, I realize there's been some talk of making gofumpt take care of breaking long lines, but that's not gone anywhere, I don't think. I'd like to ask about something related, but a different approach.
Inspired by formatters for Zig and by Black (for Python), I'd like to suggest including some logic that would latch onto a presence/absence of a trailing comma in a param/arg/field list to break a def or decl automatically. I think we have nothing like this on the fmt level now except for
Golines
which (according to my colleagues, at least) takes away too much control from our code formatting. So here's how that would work:If you write one of the above, say a func sig, pre-save, this way (mind the trailing comma):
and then hit save (or just fmt), then if gets broken down into:
But if you omit the trailing comma to begin with and then save/fmt, it does not get broken down.
Analogously, if you have a def etc that's split into several lines like so (mind the trailing comma now removed, we are pre-save/fmt):
and now you hit save/fmt, the lines get joined into a single-line (notably, trailing comma now missing post-join as well):
Would you consider adding this kind of a feature? I am sold on it, frankly -- it gives you control over the line length, but also lets you easily break lines down and bring them back together quickly with the assistance of the fmtr.
All the best!
The text was updated successfully, but these errors were encountered: