2.6 Packages and Files
Packages in Go serve the same purposes as libraries or modules
in other languages, supporting modularity, encapsulation, separate compilation,
and reuse. The source code for a package resides in one or more
.go files, usually in a directory whose name ends with the
import path; for instance, the files of the gopl.io/ch1/helloworld package are
stored in directory $GOPATH/src/gopl.io/ch1/helloworld.
Each package serves as a separate name space for its declarations.
Within the image package, for example, the identifier
Decode refers to a different function than does the same identifier
in the unicode/utf16 package.
To refer to a function from
outside its package, we must qualify the identifier to make explicit whether ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Read now
Unlock full access