问题描述

我有一个检查大型资源库的程序,选择一些感兴趣的包,然后生成一个新的main.go文件,该文件包含:

  import(
_(这里感兴趣的包)
_(这里另一个感兴趣的包)
...

func main ){...}
 init 
使用内部包当试图运行生成的main.go时允许


 internal 

不允许导入包含元素internal的路径如果导入代码位于以internal目录的父级为根的树之外。没有例外的机制。特别是,通过设计,没有ACL机制允许其他包的白名单使用内部包。

google.com/document/d/1e8kOo3r51b2BWtTs_1uADIA5djfXhPT36s6eHVRIvaU/editrel =nofollow noreferrer>规则提案

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
use of internal package not allowed
internal

An import of a path containing the element "internal" is 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.

这篇关于golang禁用“不允许使用内部软件包”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!