Description
Using a defer func to read/modify a function's results is convenient, except that it requires that you name the results, often unnecessarily, violating the style norms as documented at https://go.dev/wiki/CodeReviewComments#named-result-parameters, adding distracting repetition.
I was complaining about this with @ianlancetaylor @griesemer et al, and me saying how I wished there was a way to reference result parameters without naming them.
It was then counter-proposed that instead of changing the language, we could just change the pkgsite/godoc text+HTML-ifier to hide the named results based on a heuristic, such as names starting with an underscore.
Concretely, the proposal is that functions like:
func ExportedFoo(x int) (_node *Node, _err error) { ... }
func ExportedBar() (_err error) { ... }
... be instead rendered in godoc (either plaintext or HTML) as:
func ExportedFoo(x int) (*Node, error) { ... }
func ExportedBar() error { ... }
The alternative is either putting up with ugly docs, or writing this boilerplate:
func ExportedFoo(x int) (*Node, error) {
return actualFoo(x)
}
func actualFoo(x int) (node *Node, err error) { ... }
Metadata
Metadata
Assignees
Type
Projects
Status