熟悉C++、Java、C#等面向对象的编程语言的同学,在学习Go语言的过程中,经常会被访问权限所困扰,逐渐才能了解这样一个事实:
** Go语言通过identifier的首字母是否大写来决定它是否可以被其它package所访问。**
正式的Go语言规范是这么规定的:
An identifier may be exported to permit access to it from another package. An identifier is exported if both:
the first character of the identifier's name is a Unicode upper case letter (Unicode class "Lu"); and
the identifier is declared in the package block or it is a field name or method name.All other identifiers are not exported.
这个Go语言规范定义的访问权限控制方法。

