Modules and Project Structure
Part of the Go course
Every program you have written in this course so far has lived as a single file you could run with one command. Real Go projects almost never stay that small: code gets split across many files and folders as it grows, some of that code gets shared with other programs, and some of it depends on code other people wrote and published.
You have been writing package main at the top of every file in this course without dwelling on what that word means. A package is simply a folder of .go files that all declare the same package name at the top and are compiled together as one unit, the way every file in a single room of a house serves that room's one purpose and nothing outside the room needs to know how the furniture inside it is arranged.
Want to learn Go Modules and Project Structure in a real environment?
Click below, get a fresh Linux box with Go ready to go, and work through Modules and Project Structure hands-on with an AI tutor that knows your code.
Start this lessonModules and Project StructureWhat you'll learn
- Go mod init
- Go.mod and go.sum
- Import paths
- Package vs module
- Internal/ folder
- Cmd/ layout
- Go mod tidy
