For my current project I am implementing a code (separate package) to be part of binary which (this package) can also be imported by other projects (binaries) as if it was a library. The reason why such package is not a part of shared library is that it's functionality is tied tightly with the mentioned project.
The problem is this package provides an interface with two implementations
- one with direct access to underlying database which should only be used within the current project
- another with HTTP request to be imported in other projects (HTTP requests going to current project)
My question is: is there a mechanism in Go how to prevent certain part of package or it's sub-package from being imported by another projects?
It's mostly just an aesthetic issue since the DB-accessing implementation won't work at all (throwing errors) when used outside of current project.