↳
In-reply-to
»
Dang it! I ran into import cycles with shared test utilities again. :-( Either I have to copy this function to set up an in-memory test storage across packages or I have to put it in the storage package itself and guard it with a build tag that is only used in tests (otherwise I end up with this function in my production binary as well). I don't like any of the alternatives. :-(
⤋ Read More
re reading so NewRAMStorage(…)
is just something that setups your storage and initial data.. that can probably live with storage/sqlite
. The point is the storage
package does not import the implementations of storage.Storage
It just defines the contract for things that use that interface. Now storage/sqlite
CAN import storage
and not have a circle dep.
It kinda works in reverse for import directions. usually you have your root package that imports things from deeper in the directory structures.. but for the case of interfaces it reverses where the deeper can import from parents but parents cannot import from children.
- app < storage
< storage/sqlite
< controller < storage
< storage/sqlite
- sqlite < storage
- storage X storage/sqlite