Hi all,
I have a use-case which I'm not sure I'll be able to tackle using current tooling but just to be sure, I'm asking here.
I have a package which originally looked like:
/
/go.mod
/package_name
/other_packages...
there are no go files at the root of the module, and the code that is "meant" to be used (understand "exposed") is located in /package_name. The /other_packages are in fact internal ones.
I'm currently refactoring this all to:
- put all go files that constitute the package we want to expose at the root of the module
- add an internal/ folder to handle not-exposed features and helpers
- other changes like performance, more idiomatic go...
The problem I have is that we need to be compatible with current code using the /package_name during the process. So what I originally came up with is:
/
/go.mod // for the module and main package
/package_name // for compat, wired into new package
/package_name/go.mod // with a single dependency -> the root of the module
/internal/
/internal/other_packages
/go files for the correctly exposed new version of the package
I was in the optic of updating the go.mod in /package_name regularly to see if my refactoring was not breaking anything. But now `go mod` has a problem: it finds the package /package_name in two different places:
- one in /package_name/go.mod - the one that's being kept for compatibility
- one in /, the root, which has a sub-package /package_name
It feels like the problem is having two distinct go.mod, one in a subfolder of the root of the module, but I have difficulties wrapping my head around all that... If anyone has a clue what I should do, or what I'm doing wrong, I'll be happy to take it!
Thanks!