Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cmd/gofmt: incorrect alignment on two returned functions #22521

Closed
leonklingele opened this issue Nov 1, 2017 · 1 comment
Closed

cmd/gofmt: incorrect alignment on two returned functions #22521

leonklingele opened this issue Nov 1, 2017 · 1 comment
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone

Comments

@leonklingele
Copy link
Contributor

If a function returns two or more functions, go fmt misaligns them as follows:

func makeFuncs() (func(), func()) {
	return func() {
			// a
		}, func() {
			// b
		}
}

I'd expect the code to be aligned as such:

func makeFuncs() (func(), func()) {
	return func() {
		// a
	}, func() {
		// b
	}
}

See this playground snippet.

@ianlancetaylor ianlancetaylor changed the title cmd/go: fmt: incorrect alignment on two returned functions cmd/gofmt: incorrect alignment on two returned functions Nov 1, 2017
@ianlancetaylor ianlancetaylor added this to the Unplanned milestone Nov 1, 2017
@ianlancetaylor ianlancetaylor added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Nov 1, 2017
@griesemer
Copy link
Contributor

This working as intended. If you returned a longer expression (https://play.golang.org/p/XeOqTapb6g) you wouldn't want the expression operands aligned with the return either. That's exactly what happens here.

@golang golang locked and limited conversation to collaborators Nov 1, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Projects
None yet
Development

No branches or pull requests

4 participants