Go Tutorial: Packages & Modules
Stop reinventing the wheel. Use Go's rich standard library and the entire open-source ecosystem.
You are not alone
Every program you have written so far has used at least one package: `fmt`. You imported it, called its functions, and moved on.
But Go ships with hundreds of packages covering everything from string manipulation to cryptography, HTTP servers to JSON encoding. And beyond the standard library, thousands of open-source packages are one `go get` away.
Understanding packages and modules is what takes you from writing scripts to building real software.
Twelve steps.
What you'll learn in this Go packages & modules tutorial
This interactive Go tutorial has 9 hands-on exercises. Estimated time: 22 minutes.
- What is a package — Every Go file starts with `package`. Think of it as the file's team jersey — it tells Go which group this file belongs t…
- Searching and transforming book titles — The `strings` package handles almost every text operation a librarian needs.
- ahha — library statistics with math — The `math` package helps you calculate library stats — average pages, shelf space, membership growth.
- Managing due dates with time — The `time` package handles everything a librarian needs: due dates, borrowing periods, and overdue calculations.
- Exported vs unexported — In Go, whether a function or type is public or private is decided by a single rule:
- What is a module and using third-party packages — A module is a collection of Go packages with a shared identity and version — like a library's catalog system with multip…
- Import aliases — You can give an imported package an alias:
- Blank import — Sometimes you import a package purely for its side effects — it registers something when it loads, but you never call it…
- Build a library catalog tool — No starter code. Build a small library catalog tool using `strings`, `fmt`, and `math`:
Go Packages & Modules concepts covered
- You are not alone