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

Comments

@leonklingele
Copy link
Contributor

@leonklingele leonklingele commented Nov 1, 2017

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
@griesemer
Copy link
Contributor

@griesemer griesemer commented Nov 1, 2017

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.

@griesemer griesemer closed this Nov 1, 2017
@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.
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
4 participants
You can’t perform that action at this time.