go mod tidy cleans your dependency files, while go mod download only fetches modules to the cache.
Use go mod tidy to clean your go.mod and go.sum files by adding missing dependencies and removing unused ones, while go mod download only fetches modules into the local cache without modifying your files.
go mod tidy
If you need to pre-fetch dependencies for a CI environment without changing your module files, use:
go mod download
Think of go mod tidy as a housekeeper that organizes your shopping list by adding missing items and throwing away things you don't need. go mod download is just the act of buying the items on your list and putting them in the pantry without changing the list itself. Use tidy to fix your project configuration and download to prepare your build environment.