I have a go program that inspects a large repository, selects some packages of interest, and then generates a new main.go file that has:
import(
_ (package of interest here)
_ (another package of interest here)
...
)
func main() {...}
The main is interested in some values these packages set in their init
method.
However some of these packages have (...)/internal/(...) paths and so I get use of internal package not allowed
when trying to run the generated main.go.
Is there some compiler / linker / other flag that disables the internal
path check?
An import of a path containing the element “internal” disallowed if the importing code is outside the tree rooted at the parent of the “internal” directory. There is no mechanism for exceptions. In particular, by design, there is no ACL mechanism for allowing a whitelist of other packages to use an internal package.
Proposal for the rule
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With