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: pattern for struct initialization with arbitrary number of fields #4431

Closed
jmhodges opened this issue Nov 24, 2012 · 6 comments
Closed

Comments

@jmhodges
Copy link
Contributor

Given the code:

     msg1 := &msg{foo: bar, baz: quux}
     msg2 := &msg{foo: bar}

There's no (documented?) gofmt pattern that will match both. Instead, you apply two
different ones:

    gofmt -r '&msg{a} -> &anotherMsg{a}' -w *.go
    gofmt -r '&msg{a, c} -> &anotherMsg{a, c}' -w *.go

If it's doable, it would nice to have one.
@griesemer
Copy link
Contributor

Comment 1:

Owner changed to @griesemer.

@rsc
Copy link
Contributor

rsc commented Dec 9, 2012

Comment 2:

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

@rsc
Copy link
Contributor

rsc commented Dec 9, 2012

Comment 3:

Status changed to Accepted.

@rsc
Copy link
Contributor

rsc commented Dec 9, 2012

Comment 4:

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

@robpike
Copy link
Contributor

robpike commented Mar 7, 2013

Comment 5:

Labels changed: removed go1.1maybe.

@griesemer
Copy link
Contributor

Comment 6:

This is going beyond the pattern-matching abilities currently present. Also, there's an
easy work-around per your own suggestion. Will not fix.

Status changed to Unfortunate.

@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

5 participants