-
Notifications
You must be signed in to change notification settings - Fork 18k
x/tools/cmd/{gomvpkg, gorename}: change scope is too large #10917
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
Comments
There is a related issue #10907.
I think a proper solution is to prepare a new GOPATH just for
gomvpkg/gorename with only the repository you're interested
in.
|
Thanks for pointing out the other issue. If preparing a new GOPATH what you need to do each time, then it seems to me The problem is that if you scope the changes, and then later encounter |
Hi Rog, can you clarify a few things for me? You say you never want to rename within all the packages that refer to the renamed symbol, because you do not necessarily have commit rights to them. Does that mean you are intentionally breaking certain packages? Similarly, when you say you might not have all the packages that use the renamed symbol in your GOPATH, is this another case of intentional breakage? The notion of repository isn't very well defined in 'go build'. Do you mean the directories immediately beneath GOPATH/src? It should be straightforward to add flags that allow the user to express the disposition of each package, perhaps using a glob or regexp. There are several dispositions of possible interest: Let me think about it for a bit. |
Movement on this would be cool. This is still a big bummer and one of the reasons why I can't reliably use or recommend gorename to other folks. |
When I try to run So, there should be a way to tell rename function to look within the current project, and not have it ensure that the entire |
Totally agree with @manishrjain |
Yes, gorename has never worked reliably for me and is always very slow. I wonder if this comes from some different philosophy. Like many others here, I set As another commenter noted, maybe this comes down to the fact that at Google you're blessed because you have a pristine monorepo which is always perfectly maintained and has people thinking carefully how to organize it, and not doing things like putting the Go sources so that they would appear in your GOPATH. Or maybe you have software which sets your GOPATH for you. I don't really know. I can only assume you don't spend your days setting your GOPATH. My monorepo is My As a user trying to rename a single symbol in a small package I'm developing inside my monorepo For the experience of most Go devs to be smooth, gorename should probably default to not trying to change everything everywhere and be scoped unless they ask for it. I could see an argument though that this should be the default of any UX which wraps gorename rather than gorename's problem itself. But in any case I'd love to see this "just work" for people who don't spend their time thinking much about GOPATH. |
The only thing I ever want from gorename is to change things in exactly one package, ie. one directory. |
Just an idea - what if we used the presence of a vendor directory in the project as an indicator that gorename should not look outside the project? The assumption would be that a project that vendors some dependencies vendors all dependencies, and depends on nothing else in the #GOPATH. |
FYI: Our team is currently working to build a foundation for analysis tools such as gorename that allows them to work equally well in workspaces laid out using the conventions of 'go build', Bazel, and Google's internal build system, at which point we'll have more available effort (and incentive) to improve the usability of the tools for everyone. |
#16427 is related to the reason why I want to restrict where |
I like gorename integrated in vim-go, but I desperately need a way to limit it's scope to exactly one package. That's what I ever want. I even consider it silently messing with other repositories a dangerous bug, TBH. Currently gorename works no more for me in vim-go since I have the
I realize this is probably a vim-go bug rather that gorename's, but if I could limit gorename's scope to only the package I'm editing the bug will probably not show up at all. |
It's probably not vim-go. gorename doesnt work for me anymore even after waiting the 1-2 minutes it takes for it to go throgh my ~/src. A couple of GCC source trees are examples where gorename fails hard enough to refuse a rename to even go through. |
+1 on all the experiences. For now, you are better off using find and replace — which is tedious. There really needs to be an option to say |
I today tried to fork and rip off the repair-whole-world functionality from What about crowdfunding someone to do the fork? I'd happily participate with, say some tens of €. If there would be like at least a dozen of us I guess the thing can possibly happen. Thougths? cc @dominikh |
@cznic — I think it sounds like a great idea. (I did a similar fork recently, where I just commented out the global renaming part Create a funding page and let the fundraising begin? :) On a more general note, it would be really cool to have a fund where such efforts/ideas for static analysis and refactoring tools could be continuously funded. That should have the potential to attract corporate sponsors too. |
Just a bit of information on my own plans: in 2018, I want to implement something akin to After this database is in place, I'll port tools like guru and gorename to make use of it, which should result in significant speed improvements. As for funding, there isn't a pool of funding for multiple devs, but there is my own Patreon to support specifically my tools. |
Nice. Wrt speed improvements, those are welcome, but much more important for me is that the tool never silently mutates other packages. (vim-go reports only the total number of renames, IIRC). Something like
Yup, that's why I have CC'd you ;-) |
Any movement on this ? Just came across the same issue, where I ended up using https://github.com/prateek/gorename fork which pretty much does the job. |
Here is a package that achieves the expected behavior, perhaps it is useful as an example of how to limit gorename's scope? https://github.com/amitbet/gorename For the time being I will remove gorename from my path and add this as a functional replacement. |
closing as obsoleted by #69360 |
These commands go through the entire GOPATH changing anything
that refers to the moved package or renamed symbol.
I see that this would work well in the Google "one big repository" world,
but is never what I want, as the GOPATH is filled with thousands
of packages in different repositories which I do not necessarily have commit
rights to.
Moreover, it's not really sufficient, as I might not have
all the packages that use the renamed symbol in my import path.
I'd find gorename much more useful if it could rename within one
repository only (possibly with an flag to cause it to error if anything
in $GOPATH refers to the renamed symbol), and there was
a way to update a package that imports another package that
has already had a symbol renamed (i.e. it is currently
broken, but renaming the symbol will fix it).
Instead of gomvpkg, I would find a copy-package utility more useful,
with the scope strictly limited to the package itself, although
govers covers most of my needs here.
Submitting this as an issue because I'd really like to find these tools useful
but I have never encountered as situation where I was able to use them,
even though I'm refactoring and renaming all the time.
The text was updated successfully, but these errors were encountered: