Go 语言初级教程之九[包]



Go提供了一种简单的机制来组织代码:包。每个文件开头都会声明它属于哪一个包,每个文件也可以引入它所用到的
包。任何首字母大写的名字是由包导出的,并可以被其它的包所使用。
以下是一个完整的源文件:
 

  1. package geometry
     
  2. import "math"
     
  3. /* Point is capitalized, so it is visible outside the package. */
     
  4. type Point struct {
     
  5.   /* the fields are not capitalized, so they are not visible
     
  6.      outside of the package */
     
  7.   x, y float64
     
  8. }
     

阅读全文>>

你可能感兴趣的:(Go 语言初级教程之九[包])