go mod tidy vs download

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