gpt4 book ai didi

go - 未导出的标识符包在 Golang 中是否公开?

转载 作者:数据小太阳 更新时间:2023-10-29 03:35:40 27 4
gpt4 key购买 nike

正如题主所说,未导出的标识符在Golang中package public吗?我读了spec但找不到任何东西。编译器似乎将未导出的函数名称视为文件私有(private)(而不是包公共(public))。

最佳答案

所有顶级常量、类型变量和函数都具有包范围。这包括这些类型的未导出标识符。确切的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.

导入的包名称是唯一具有文件范围的实体。

关于go - 未导出的标识符包在 Golang 中是否公开?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34890480/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com