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: Inconsistent alignment of struct field values #7819

Closed
gopherbot opened this issue Apr 18, 2014 · 1 comment
Closed

cmd/gofmt: Inconsistent alignment of struct field values #7819

gopherbot opened this issue Apr 18, 2014 · 1 comment

Comments

@gopherbot
Copy link

by waters@google.com:

What does 'go version' print?

1.2, and using version from playground.

What steps reproduce the problem?

http://play.golang.org/p/tXDIgmPIky

What happened?

{
    Field:                     value,
    LongerField:               value,
    EspeciallyEvenLongerField: value,
    Field: value,
},

What should have happened instead?

{
    Field:                     value,
    LongerField:               value,
    EspeciallyEvenLongerField: value,
    Field:                     value,
},

Please provide any additional information below.

There appears to be logic in gofmt which avoids aligning long field values, but this is
inconsistent when a field is short after a long one.  See play link for other examples.
@griesemer
Copy link
Contributor

Comment 1:

This is not a bug. The code in gofmt aligns types of fields that belong to a "group" of
fields. A group of fields is terminated if the length ratio between the previous and the
next field declaration goes over a certain threshold.

Status changed to WorkingAsIntended.

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