Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
cmd/gofmt: align function parameter types on subsequent lines #33507
Signatures of functions taking a lot of parameters are quickly exceeding a readable line length (80-120 characters).
To make this more readable one can put each parameter on an individual line like so:
In contrast to most other forms e.g. imports, structs, variable and constant declarations gofmt does not align this form. I propose that this form should be recognised by gofmt and parameter names and parameter types be appropriately aligned.
The objective of this proposal is to increase readability and make formatting rules more consistent.
Also for type parameters and multiple returns
func httpHandlerFunc( type T constraints.Comparable, U constraints.Ordered, ) ( logger *log.Logger, db *sql.DB, imgCache map[string]io.Reader, w http.ResponseWriter, r *http.Request, ) ( f func(w http.ResponseWriter, r *http.Request), err error, )
Sorry, but gofmt is pretty much frozen at this point. Thanks for the issue.
As the syntax for contracts evolves and becomes more concrete, I would reopen a proposal specific to that, but we're still too early to be talking about code formatting since we don't know what the final syntax is.