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
Read this lesson in your language
All lessons in this course
20 lessons- 1Hello, Go25 min
- 2Variables and Types25 min
- 3Control Flow: if and for30 min
- 4Functions30 min
- 5Slices and Maps35 min
- 6Structs and Pointers35 min
- 7Methods and Interfaces35 min
- 8Error Handling35 min
- 9Modules and Project Structure35 min
- 10Tiny CLI Capstone40 min
- 11A Tour of the Standard Library40 min
- 12Testing and Benchmarks40 min
- 13Goroutines and Channels40 min
- 14Concurrency Patterns45 min
- 15Generics35 min
- 16HTTP Servers45 min
- 17Databases with database/sql45 min
- 18Performance and Profiling40 min
- 19Design Patterns in Go40 min
- 20Deployment and Production45 min
