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: empty line between two closing } #3627

Closed
griesemer opened this issue May 15, 2012 · 2 comments
Closed

go/printer: empty line between two closing } #3627

griesemer opened this issue May 15, 2012 · 2 comments

Comments

@griesemer
Copy link
Contributor

func foo() {
    if true {
    }
              <--- yuck
}

Consider fixing this when printing code.
@griesemer
Copy link
Contributor Author

Comment 1:

Originally reported by Albert Strasheim (3/15/2012).

@griesemer
Copy link
Contributor Author

Comment 2:

I am going to close this again. Rationale:
While it wouldn't be too hard to fix this, it is not clear that it is the right thing to
do: In general, gofmt respects extra newlines (up to a max. of one at this point), so
removing it here would mean changing that rule. We have code in the library of the form:
if some_condition {
      alot-of-code-here
} else {
      alot-of-code-here
}
where the extra empty lines around the inner code blocks are intentional to make the
overall structure more visible. Doing a good formatting job here would mean to either a)
recognize this case and not eliminate the empty lines, or b) recognize this case and
eliminate the empty lines before and after (context-sensitive). This kind of
larger-scale context sensitive formatting is non-trivial in the current implementation
of gofmt and generally not done.

Status changed to WorkingAsIntended.

@griesemer griesemer self-assigned this May 15, 2012
@golang golang locked and limited conversation to collaborators Jun 24, 2016
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants