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: ignore wildcards in gofmt -r #7870

Closed
joeshaw opened this issue Apr 26, 2014 · 4 comments
Closed

cmd/gofmt: ignore wildcards in gofmt -r #7870

joeshaw opened this issue Apr 26, 2014 · 4 comments

Comments

@joeshaw
Copy link
Contributor

joeshaw commented Apr 26, 2014

go version go1.2.1 darwin/amd64

I love the wildcard feature of gofmt -r, but it is also idiomatic to use single
character identifiers in Go code.  This makes it difficult to perform rewrites in
certain cases.

Suppose you have a file like http://play.golang.org/p/_6CvVWgy1v and you wanted to
change only the instance of f.Write().  If you ran gofmt -d -r 'f.Write([]byte(x)) ->
f.WriteString(x)', you would write both the f.Write() and g.Write() due to f being
interpreted as a wildcard.

I have a patch which adds a -i argument to gofmt to prevent one or more identifiers from
being interpreted as a wildcard, which I'll submit shortly.
@joeshaw
Copy link
Contributor Author

joeshaw commented Apr 26, 2014

Comment 1:

https://golang.org/cl/99790043/

@gopherbot
Copy link

Comment 2:

CL https://golang.org/cl/99790043 mentions this issue.

@griesemer
Copy link
Contributor

Comment 3:

Labels changed: added release-none, repo-main.

Owner changed to @griesemer.

@rsc
Copy link
Contributor

rsc commented Jun 19, 2014

Comment 4:

gofmt -r is what it is. I don't think we should start adding new things to it.
If we need a full-blown refactoring tool, it should be somewhere else.
code.google.com/p/go.tools/cmd/eg is one promising start.

Status changed to WorkingAsIntended.

@golang golang locked and limited conversation to collaborators Jun 25, 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

4 participants