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
https://blog.golang.org/go-fmt-your-code says that Gofmt'd code is easier to write, read, maintain and is uncontroversial. With respect to the first example program, I disagree that gofmt achieves this.
The func A is a common artifact encountered in a codebase where one user has an editor with a pre-conceived notion that all characters are the same width and that line wrapping should be done with a hard newline at the source level. Gofmt solves this with a tab indent. I think it should instead remove the newline.
The func B is a less common but arguably more disgusting affair used upon disagreement with gofmt about the unsupported Allman brace style.
I think both of these should be addressed to make the points decorated in the blog post more accurate with the spirit of deterministic source code. There is currently easy way to de-uglyfy these functions without go/ast wizardly. Furthermore, both of these parameter lists appear this way in the godoc too. If the goal of gofmt is to make formatting deterministic and uncontroversial, I think it should be more opinionated about this.
Preemptive note: I don't think this should apply to parameter lists in general, it can be isolated to function parameters and the number of items in the list spanning a line in the source.
The text was updated successfully, but these errors were encountered:
Sorry, gofmt is not soliciting change requests on its format at this time. Gofmt made a set of choices at one point, and everybody agrees to live with them, even if everybody might take issue with different individual choices. (as Rob says: https://www.youtube.com/watch?v=PAAkCSZUG1c&t=8m43s) For Go 2, @griesemer may trawl through the issue tracker for all old gofmt style request bugs.
What did you do?
Go format this code https://play.golang.org/p/eHh2k3LPzoz
What did you expect to see?
Exhibit 1: https://play.golang.org/p/M7ax5VTbxlY
What did you see instead?
Exhibit 2: https://play.golang.org/p/eUXlvJJHzZy
Summary
https://blog.golang.org/go-fmt-your-code says that Gofmt'd code is easier to
write
,read
,maintain
and isuncontroversial
. With respect to the first example program, I disagree that gofmt achieves this.The
func A
is a common artifact encountered in a codebase where one user has an editor with a pre-conceived notion that all characters are the same width and that line wrapping should be done with a hard newline at the source level.Gofmt
solves this with a tab indent. I think it should instead remove the newline.The
func B
is a less common but arguably more disgusting affair used upon disagreement with gofmt about the unsupported Allman brace style.I think both of these should be addressed to make the points decorated in the blog post more accurate with the spirit of deterministic source code. There is currently easy way to
de-uglyfy
these functions withoutgo/ast
wizardly. Furthermore, both of these parameter lists appear this way in the godoc too. If the goal ofgofmt
is to make formatting deterministic and uncontroversial, I think it should be more opinionated about this.Preemptive note: I don't think this should apply to parameter lists in general, it can be isolated to function parameters and the number of items in the list spanning a line in the source.
The text was updated successfully, but these errors were encountered: