英文:
Are unexported identifier package public in Golang?
问题
正如主题所说,Golang中的未导出标识符package public
吗?我阅读了规范,但没有找到相关内容。编译器似乎将未导出的函数名称视为文件私有而不是包公共。
英文:
As the subject says, are unexported identifiers package public
in Golang?
I read the spec but can't find anything. The compiler seems to treat unexported function names as file private (and not package public).
答案1
得分: 1
所有顶级常量、类型、变量和函数都具有包范围。这包括这些种类的未导出标识符。具体的规范语言如下所示:
在顶级(任何函数之外)声明的常量、类型、变量或函数(但不包括方法)所表示的标识符的作用域是包块。
导入的包名是唯一具有文件范围的实体。
英文:
All top level constants, types variables and functions have package scope. This includes unexported identifiers of these kinds. The exact language from the specification is:
> The scope of an identifier denoting a constant, type, variable, or
> function (but not method) declared at top level (outside any function)
> is the package block.
Imported package names are the only entity with file scope.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论