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

go/printer: unexpected handling of indented comment #12822

griesemer opened this Issue Oct 2, 2015 · 1 comment


None yet
2 participants
Copy link

griesemer commented Oct 2, 2015

The comment was indented one extra tab stop beyond where it should be by gofmt.

  • Deleting one of the tabs and running gofmt again results in the proper alignment.
  • Removing the statement below the comment and re-formatting will remove the extra tab stop.
  • Changing the statement above the comment so the "func" line is on the same line as the assignment causes the extra tab to be removed as well.

Also unexpected, and the reason the bug was noticed: gofmt converts two spaces into two tabs here, which causes an unfortunate interaction with xxx (when not in tab mode) and probably other editors -- if you attempt to remove the extra indent and then re-run gofmt, you may be led to believe it's impossible to get the comment to line up as desired/expected.

package p

func f() {
    a =
        func(T1) T2 {
            return q

        // Comment
    b =
        func(T1) T2 {
            return q

@griesemer griesemer self-assigned this Oct 2, 2015

@rsc rsc changed the title cmd/gofmt: unexpected handling of indented comment go/printer: unexpected handling of indented comment Oct 23, 2015

@rsc rsc added this to the Go1.6 milestone Oct 23, 2015


This comment has been minimized.

Copy link

rsc commented Nov 30, 2015

Too late for Go 1.6.

@rsc rsc modified the milestones: Unplanned, Go1.6 Nov 30, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.