← Go Programming learning pathGo Programming · Module 9 of 10
Packages, modules and testing
Organise code and write tests.
📖 Key ideas
- go mod init example.com/app creates go.mod.
- go get adds dependencies.
- Packages are folders; import "example.com/app/internal/db".
- Tests in *_test.go: func TestAdd(t *testing.T).
- go test ./... runs all tests; benchmarks with func BenchmarkX.
💡 Real-life example: Modules are boxes, packages are compartments, tests are quality stamps on each compartment.
go.modModule definition file
go getAdds dependencies
_test.goTest file suffix
testing.TTest handle