Hi all,

I'm developing a command that is a utility to move packages around while
keeping compatibility with softwares that import those packages. Maybe
there are commands and utilities that already do approximately the same
thing, but I'm mainly doing this to learn to use the go/ast package and
everything. Let me give you a small example:

- Let's say I have a package in my GOPATH that's named 'foo'
- In this package there is another package 'bar', but this package bar has
grown a whole lot since the beginning of the project, and might as well be
a project on its own.
- What I want is extract package 'bar' from 'foo' without having to go
through all other projects importing 'bar' to change import paths
- The process for the command is to first move package 'bar' wherever I
tell it to move it and replace anything in previously existing package
'foo/bar' with bindings, so any function's body is replaced with a call to
the function in the moved package, any type is transformed into an "alias"
of the moved package's corresponding type (TypeA = bar.TypeA), as well as
any constant or variable.

The command is not finished yet but I'm running into a certain issue I
can't find a solution to:

Whenever the command creates a binding for a given exported variable:

var (
    Anything = 5.0
)

becomes

var (
    Anything = bar.Anything
)

there's a risk that bar.Anything was originally changed during the
program's execution and according to the context. If that was the case, any
change to bar.Anything will not be applied in foo/bar.Anything, which
breaks the whole thing.

Does anyone have an idea how to programmatically make it so that any
changes applied to bar.Anything is applied to foo/bar.Anything, as if they
really did share the same memory? Of course this would need to be totally
transparent to the user of the package.

Maybe this is not possible but if you guys know anything, please tell me.

Thanks in advance!

-- 
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+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/CANgi337gucK4we2jbXHcfbh_PkuGLjzfm95ZF7-WyeBza3GQOg%40mail.gmail.com.

Reply via email to