Refactoring: move code to new package

390 views
Skip to first unread message

Zippoxer

unread,
Feb 7, 2016, 3:13:36 PM2/7/16
to golang-nuts
I was careless about project organization before and now I'm paying for it.

It's an old project and I put everything in the main package.

The names are long and confusing and (supposed to be-) isolated modules are sharing their private types and values.

I'd like to move some pieces of the code to new packages. The moved code has references and I would have to rename to include the new package name (like <moved_type> to <new_package.moved_type>.)

I tried gorename, but as soon as I move code to a new package and old references become undeclared errors, gorename refuses to refactor because of those errors.

Is there any tool that allows this kind of renaming?

Konstantin Kulikov

unread,
Feb 8, 2016, 7:08:48 AM2/8/16
to Zippoxer, golang-nuts

--
You received this message because you are subscribed to the Google Groups "golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Sam Whited

unread,
Feb 8, 2016, 7:02:56 PM2/8/16
to Zippoxer, golang-nuts
On Sun, Feb 7, 2016 at 7:09 AM, Zippoxer <zipp...@gmail.com> wrote:
> Is there any tool that allows this kind of renaming?

At the risk of sounding snarky: Why not just use a mix of grep and sed?

Sometimes the simplest tools are the best tools.

Best,
Sam


--
Sam Whited
pub 4096R/54083AE104EA7AD3
https://blog.samwhited.com

Zippoxer

unread,
Feb 9, 2016, 2:23:23 PM2/9/16
to golang-nuts, zipp...@gmail.com
Confidence I guess. I'm afraid I might damage my code. The words I'd need to replace are also used inside strings :\
Reply all
Reply to author
Forward
0 new messages