Difference between go mod download and go mod tidy
Asked Answered
P

1

43

What is the different between go mod download and go mod tidy?

When I run go mod tidy, if the import is not found it also downloads it.

Piecework answered 16/3, 2022 at 10:41 Comment(2)
maybe not a perfect duplicate, but it provides useful info: stackoverflow.com/questions/66356034Craggy
Basically the quote from here: The "go mod download" command is useful mainly for pre-filling the local cache or to compute the answers for a Go module proxy.Craggy
P
44

go mod download is downloading all of the modules in the dependency graph, which it can determine from reading only the go.mod files. It doesn't know which of those modules are actually needed to satisfy a build, so it doesn't pull in the checksums for those modules (because they may not be relevant).

On the other hand, go mod tidy has to walk the package graph in order to ensure that all imports are satisfied. So it knows, for a fact, without doing any extra work, that the modules it walks through are needed for a go build in some configuration.

Possessed answered 16/3, 2022 at 15:24 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.