Package
A package is a programming-language namespace and organizational unit that groups related code and may define import, compilation, or access boundaries.
The Well-Grounded Python Developer: How the pros use Python and Flask
A Python package is an importable directory that organizes related Python modules and subpackages.
- How it is used
- Organizes related modules into meaningful namespaces and supports restructuring a growing Flask application.
- How deep it goes
- Shows directory creation, `__init__.py` import behavior, nested packages, and an application-factory refactor without exploring package-loading internals.
- Examples
- Uses a `utilities/strings.py` refactor and a Flask application layout with an `app` package and `myblog.py`.
- What you can do after
- Build it from scratch by adding `__init__.py` to a directory, then use package imports to organize modules or a Flask app.
Read how The Well-Grounded Python Developer: How the pros use Python and Flask explains package →
Go in Action, Second Edition
A package is a Go compilation and namespace unit that groups related declarations and controls their visibility across source files.
- How it is used
- Organizes related Go declarations and sets visibility boundaries within applications and modules.
- How deep it goes
- Explains declarations, exported identifiers, executable entry points, import cycles, and layout conventions without prescribing one application structure.
- Examples
- Uses `package main`, `fmt.Println`, conventional project directories, and a multimodule RSS reader.
- What you can do after
- Build it from scratch by choosing package boundaries, exposing needed identifiers, and avoiding import cycles.
Learn Go with Pocket-Sized Projects
A Go package is a collection of related source files in one directory that share a package name and provide a scope for declarations.
- How it is used
- Organizes Go applications and libraries while controlling which declarations other packages can use.
- How deep it goes
- Defines package structure, naming, visibility, and API stability, but does not descend into compiler internals.
- Examples
- Demonstrates main.go, fmt, pocketlog, gordle, and genericcache through runnable code and project trees.
- What you can do after
- Build packages with deliberate names, directory layouts, exported APIs, and runnable entry points.
Read how Learn Go with Pocket-Sized Projects explains package →
100 Go Mistakes and How to Avoid Them
A package is a Go unit of source organization and compilation that groups related declarations and controls dependencies between code units.
- How it is used
- Organizes related Go code into dependency and visibility boundaries that make projects easier to navigate and maintain.
- How deep it goes
- Works through directory relationships, naming and granularity trade-offs, API refactoring, and external tests; does not develop a fixed project template.
- Examples
- Contrasts net directory nesting, util versus stringset calls, and a counter_test file that checks an exported API.
- What you can do after
- Practice/perform package organization by grouping cohesive code, choosing expressive names, and using external tests to check exported behavior.
Read how 100 Go Mistakes and How to Avoid Them explains package →
Go in Practice, Second Edition
A Go package is a compilable unit of related Go source files whose exported identifiers are referenced through the package name.
- How it is used
- Organizes dependencies and lets Go code reference standard-library or external functionality through package-qualified names.
- How deep it goes
- Explains imports, naming, grouping, external paths, and formatting conventions through standard-library and external examples.
- Examples
- Uses fmt.Println, grouped fmt/net/http imports, an external golang.org/x/net/html path, and go get ./....
- What you can do after
- Apply it via Go imports to call standard-library and external package functionality from a program.
Go by Example
A Go package is a collection of Go source files that provides a namespace and compilation unit.
- How it is used
- Organizes executable programs, reusable logic, HTTP handlers, and standard-library functionality into named compilation units.
- How deep it goes
- Defines packages through runnable programs and service boundaries, then stops short of detailed compilation mechanics.
- Examples
- Uses a hello-world executable, a link-shortening REST service, and a standard-library HTTP server.
- What you can do after
- Build it from scratch by declaring, running, organizing, and naming Go packages for programs and services.
Python Workout, Second Edition
A package is a Python namespace that organizes related modules and subpackages, typically represented by a directory.
- How it is used
- Organizes related modules so larger Python projects remain shorter, reusable, and maintainable.
- How deep it goes
- Defines directory-based packages and demonstrates alternative module import paths without descending into package internals.
- Examples
- Uses mypackage with first.py, second.py, and third.py, plus a menu.py packaging exercise.
- What you can do after
- Build packages from related modules and import those modules with short or qualified names.
Related concepts
- encoding/jsonincludes · encoding/json is Go’s standard-library package for encoding Go values as JSON and decoding JSON into Go values.
- go modulepart of · A Go module is a versioned collection of related Go packages defined by a go.mod file and managed as a unit for dependency resolution and builds.
- import statementused by · An import statement is a source-code declaration that makes names or definitions from another module, package, or namespace available in the current scope.
- init functionhas part · An init function is a special Go package-level function that runs automatically during package initialization before ordinary program execution.
- classhas part · A class is a programming-language construct that defines a type’s structure or behavior and provides a basis for creating or representing objects.
- Kotlinused by · Kotlin is a statically typed general-purpose programming language that targets the JVM and other platforms and interoperates with Java.
These guides are generated from the text of Manning books by Manning's knowledge graph and link to the sections they draw on. The full books are available on liveBook and at manning.com.






