4 ms·
At first glance, that question makes sense; however, fmt doesn't cover all code format issues. Ex from the post: > Line length > There is no fixed line length
by sethammons 4y ago
At first glance, that question makes sense; however, fmt doesn't cover all code format issues. Ex from the post:
> Line length
> There is no fixed line length for Go source code. If a line feels too long, it should be refactored instead of broken. If it is already as short as it is practical for it to be, the line should be allowed to remain long.
> Do not split a line:
> Before an indentation change (e.g., function declaration, conditional)
>To make a long string (e.g., a URL) fit into multiple shorter lines
fmt doesn't force arbitrarily short lines in lieu of readability (looking at you python + pep8; I can't recall how many lines of code were a few characters long and pep8 formatting made the multiple lines a mess to visually parse). The Google Team decided that it was important to not break up perfectly readable lines and gave guidance on how to do that.
- Beltalowda 4y agoI hate autoformatters/linters that frob with line length with a passion. I'm an 80-column kind of guy, but 81 columns can be just fine, and in some cases 90 or even 100 can be more readable than obsessively wrapping at 80 (or some other arbitrary value). There are a few (rare) cases where gofmt will wrap lines, but it mostly leaves it alone which is one of the better "features" IMHO. Many *fmt tools really got this wrong. Automated formatters are nice, but in the end there is no substitute for human eyes and common sense.
- metaltyphoon 4y agoI hate this about default rustfmt.