Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to disable "use of internal package not allowed"

Tags:

go

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?

like image 375
Javier Zunzunegui Avatar asked Dec 09 '16 12:12

Javier Zunzunegui


1 Answers

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

like image 138
I159 Avatar answered Nov 16 '22 07:11

I159