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: inconsistently aligns values in struct/proto literal #3965

Closed
griesemer opened this issue Aug 16, 2012 · 2 comments
Closed

go/printer: inconsistently aligns values in struct/proto literal #3965

griesemer opened this issue Aug 16, 2012 · 2 comments
Milestone

Comments

@griesemer
Copy link
Contributor

gofmt -w x.go

with x.go:

package p

// aligned
var _ = T1{
    a:                    x,
    b:                    y,
    cccccccccccccccccccc: z,
}

// not aligned
var _ = T2{
    a: x,
    b: y,
    ccccccccccccccccccccc: z,
}

// aligned
var a = T3{
    aaaaaaaaaaaaaaaaaaaa: x,
    b:                    y,
    c:                    z,
}

// still aligned
var a = T4{
    aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa: x,
    b:                                       y,
    c:                                       z,
}

gofmt aligns "similarly sized" composite literal elements; it breaks the
grouping when an internal threshold is reached. This works fine for T1, T2, and T3. But
the algorithm is not working for T4.
@rsc
Copy link
Contributor

rsc commented Sep 12, 2012

Comment 1:

Labels changed: added go1.1maybe.

@griesemer
Copy link
Contributor Author

Comment 3:

This issue was closed by revision 1f6fba2.

Status changed to Fixed.

@griesemer griesemer self-assigned this Oct 5, 2012
@rsc rsc added this to the Go1.1 milestone Apr 14, 2015
@rsc rsc removed the go1.1maybe label Apr 14, 2015
@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

3 participants