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: should handle function parameter indentation properly #11423
Instead of this:
It should do this:
And yes, I know with this toy example I could just put all the arguments on one line. But sometimes when using external type names which can be rather long, it is unavoidable.
Generally, indentation is done with tabs only. One could use two tabs in your suggestion but that seems odd (only place where indentation is changed in steps larger than 1). Using spaces is after a tab is unprecedented in gofmt.
Sorry if my use of space in my examples was confusing ... that was merely trying to control how the result would show, since tabs don't always show up the same in different editors/browsers/etc. I understand indentation is done with tabs only. I was not suggesting using spaces instead. I was just suggesting that function parameters to be indented more than the function body. Why do you think that seems odd? I believe this is very standard practice for most programming languages. Examples:
I'm aware it's standard practice elsewhere. It's also standard practice to never indent with tabs - or in other words: "standard practice elsewhere" is not a compelling argument...
The formatting suggestion I offered does work and avoids the irregularity here - think of the parameter list as opening a scope: indeed, the parameters are part of the function's body scope, which is "temporarily opened", and then closed again (hence the outdent) for the result type, and the opened again (indent for body). It's very regular. It also works for named results, and it scales:
By scaling I mean for instance:
Leaving closed for now.