英文:
Implicit private function import?
问题
main.go是如何使用buildIndexMapping函数的呢?
这个函数没有大写字母开头,所以它如何在包内公开访问,而且还没有显式导入mapping.go?
main.go: https://github.com/blevesearch/beer-search/blob/721fab2198a52d919133df08058fde8043bab365/main.go#L55
mapping.go: https://github.com/blevesearch/beer-search/blob/721fab2198a52d919133df08058fde8043bab365/mapping.go#L19
英文:
How is main.go able to use buildIndexMapping?
The function is not uppercased so how is it publicly accessible within the package and that too without an explicit import of mapping.go?
main.go: https://github.com/blevesearch/beer-search/blob/721fab2198a52d919133df08058fde8043bab365/main.go#L55
mapping.go: https://github.com/blevesearch/beer-search/blob/721fab2198a52d919133df08058fde8043bab365/mapping.go#L19
答案1
得分: 2
两者都在同一个包中。在Go语言中,你导入的是包,而不是文件,因此私有函数是可用的。
英文:
Both are in the same package. In Go you import packages, not files, thus the private function is available.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。


评论