Chapter 6. Go Packages and Programs

Chapter 5, Functions in Go covered functions, the elementary level of abstraction for code organization that makes code addressable and reusable. This chapter continues up the ladder of abstraction with a discussion centered around Go packages. As will be covered in detail here, a package is a logical grouping of language elements stored in source code files that can be shared and reused, as covered in the following topics:

  • The Go package
  • Creating packages
  • Building packages
  • Package visibility
  • Importing packages
  • Package initialization
  • Creating programs
  • Remote packages

The Go package

Similar to other languages, Go source code files are grouped into compilable and sharable units known as packages. However, all Go source ...

Get Go: Design Patterns for Real-World Projects now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.