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: extend column alignment to include assignments and declarations #23495

Open
savaki opened this issue Jan 21, 2018 · 7 comments
Open
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Milestone

Comments

@savaki
Copy link

savaki commented Jan 21, 2018

Please answer these questions before submitting your issue. Thanks!

What version of Go are you using (go version)?

Should apply to any version of go.

Does this issue reproduce with the latest release?

Yep. It's a formatting enhancement.

What operating system and processor architecture are you using (go env)?

Should happen in any environment.

What did you do?

Type the following and run it through gofmt:

  a.b.c = 123
  a.d = "def"
  a.e.f.g = 456
  h, i = 7, 8

  j := 123
  k.l := "def"
  k.m.n.o := 456
  p, q := 7, 8

  var r = "abc"
  var t, u = 1, 2
  var v int = 3

and nothing would change with the formatting

What did you expect to see?

I would like to see are the same rules gofmt currently applies to structs and maps to be more uniformly applied. Specifically to sequential assignments, sequential declarations with := and sequential declaration withs =.

So I'd like to see:

  a.b.c   = 123
  a.d     = "def"
  a.e.f.g = 456
  h, i    = 7, 8

  j       := 123
  k.l     := "def"
  k.m.n.o := 456
  p, q    := 7, 8

  var r     = "abc"
  var t, u  = 1, 2
  var v int = 3

What did you see instead?

Saw the original code.

@bradfitz bradfitz added this to the Unplanned milestone Jan 21, 2018
@bradfitz
Copy link
Contributor

gofmt isn't soliciting change requests at this time, but I'll keep this open on the back burner ("Unplanned") in any case. Maybe @griesemer will consider a batch of them at some point in the future.

@josharian
Copy link
Contributor

Note that inside a factored var block, this already happens:

var (
	r        = "abc"
	t, u     = 1, 2
	v    int = 3
)

Note also that the formatting here differs slightly from your suggested formatting--u and int do not vertically overlap.

@griesemer griesemer self-assigned this Jan 21, 2018
@golang golang deleted a comment from sylr Mar 21, 2018
@andybons andybons added the NeedsFix The path to resolution is known, but the work has not been done. label Mar 21, 2018
@sylr
Copy link

sylr commented Apr 12, 2018

This would be really nice to have.

PS: I've just realized that I've already commented on this issue: bradfitz deleted a comment from sylr 22 days ago. @bradfitz would you be kind enough to tell me why you removed my comment.

@dlsniper
Copy link
Contributor

dlsniper commented Apr 13, 2018

@sylr, +1's are useless comments. Your comment provided no value for the issue and it was removed, per https://github.com/golang/go/wiki/NoMeToo

@bradfitz
Copy link
Contributor

Well, "useless" and "no value" might be a little harsh, but yes: we enforce our NoMeToo policy to make bug threads more readable.

@sylr
Copy link

sylr commented Apr 13, 2018

Fair enough.

However, due to a less than perfect Github issue search engine, you can't list the issues you have subscribed to and commenting is, to my knowledge, the only way to be able to search for issues you have interest for at a later time.

In the case of this particular issue which I don't have meaningful things to add, commenting "+1" or "This would be really nice to have." was, besides hoping to increase traction on this issue, mainly intended for me to be able to look for it in the search engine.

But I do understand if everyone does it it becomes unbearable.

@sylr
Copy link

sylr commented Dec 12, 2018

Could this be planned for go2 ?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
NeedsFix The path to resolution is known, but the work has not been done.
Projects
None yet
Development

No branches or pull requests

7 participants