如何禁用“不允许使用内部软件包"? [英] How to disable "use of internal package not allowed"
问题描述
我有一个go程序,该程序检查大型存储库,选择一些感兴趣的包,然后生成一个新的main.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() {...}
主要对这些软件包在其init
方法中设置的某些值感兴趣.
The main is interested in some values these packages set in their init
method.
但是其中一些软件包具有(...)/internal/(...)路径,因此在尝试运行生成的main.go时得到use of internal package not allowed
.
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.
是否存在一些禁用internal
路径检查的编译器/链接器/其他标志?
Is there some compiler / linker / other flag that disables the internal
path check?
推荐答案
如果导入代码位于以内部"目录的父级为根的树之外,则不允许导入包含内部"元素的路径.没有例外机制.特别是,根据设计,没有允许其他包的白名单使用内部包的ACL机制.
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.
这篇关于如何禁用“不允许使用内部软件包"?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!