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: non-idempotent empty struct formatting #4504

Closed
kylelemons opened this issue Dec 7, 2012 · 13 comments
Closed

cmd/gofmt: non-idempotent empty struct formatting #4504

kylelemons opened this issue Dec 7, 2012 · 13 comments
Milestone

Comments

@kylelemons
Copy link
Contributor

Steps to reproduce:
1. http://play.golang.org/p/GzwSKNPZch
2. Click format
2. Click format

Inside a var() block:
var (
  short = X{
  }
  someLongVarName = 1
)

when formatted it becomes
var (
    short = X{}
    someLongVarName = 1
)

which, upon second formatting, becomes
var (
    short           = X{}
    someLongVarName = 1
)
@rsc
Copy link
Contributor

rsc commented Dec 9, 2012

Comment 1:

Labels changed: added priority-later, removed priority-triage.

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Dec 10, 2012

Comment 2:

Labels changed: added size-l.

@rsc
Copy link
Contributor

rsc commented Mar 11, 2013

Comment 3:

Unfortunate, but I think it's too late to be tweaking gofmt.

Labels changed: added go1.2, removed go1.1.

@griesemer
Copy link
Contributor

Comment 4:

Owner changed to @griesemer.

@vdobler
Copy link
Contributor

vdobler commented Jul 4, 2013

Comment 5:

While not idempotent it converges to a fixed point in just
two iterations.  Is this something to bother about?

@minux
Copy link
Member

minux commented Jul 4, 2013

Comment 6:

if we don't fix this issue, how many times should you run gofmt on your source code?
i believe you have to run at least 2 times (and in this case, 3) to be sure.
please consider this (imo, common) scenario:
developer has a gofmt hook at save time.
the SCM has a pre-commit hook that checks gofmt won't change the source.
the developer writes http://play.golang.org/p/GzwSKNPZch, then save, gofmt
runs, format it to the first revision.
however, when he tries to commit the file, gofmt will transform the file to the
2nd revision (the fixed point), and SCM will reject this commit.

@rsc
Copy link
Contributor

rsc commented Sep 9, 2013

Comment 7:

Labels changed: added go1.3, removed go1.2.

@gopherbot
Copy link

Comment 8 by leterip:

Just adding a note that this issue affects not just structs:
http://play.golang.org/p/3hGexMROmB

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 9:

Labels changed: added release-go1.3.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 10:

Labels changed: removed go1.3.

@rsc
Copy link
Contributor

rsc commented Dec 4, 2013

Comment 11:

Labels changed: added repo-main.

@griesemer
Copy link
Contributor

Comment 12:

Pending fix: https://golang.org/cl/69260045

Status changed to Started.

@griesemer
Copy link
Contributor

Comment 13:

This issue was closed by revision 28cc8aa.

Status changed to Fixed.

@rsc rsc added this to the Go1.3 milestone Apr 14, 2015
@rsc rsc removed the release-go1.3 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

6 participants