How to disable "use of internal package not allowed"
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.
Related videos on Youtube

Javier Zunzunegui
Updated on July 09, 2022Comments
-
Javier Zunzunegui 11 months
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?-
Volker over 6 yearsNo there is not. You'll either have to invoke the compiler "by hand" (
go tool compile
) ore move these packages. -
Kaedys over 6 yearsGenerally, if they are in an
/internal/
subdirectory, that means you're either using a library from before vendoring was added (Go 1.5/1.6), or you're not supposed to use those packages. -
I159 over 6 yearsPossible duplicate of Internal packages in Go
-