Go Mod Tidy¶
Usage¶
Output of go help mod tidy, formatted:
Tidy makes sure go.mod matches the source code in the module.
It adds any missing modules necessary to build the current module's packages and dependencies, and it removes unused modules that don't provide any relevant packages.
It also adds any missing entries to go.sum and removes any unnecessary ones.
-
The
-vflag causestidyto print information about removed modules to standard error. -
The
-eflag causestidyto attempt to continue regardless of errors encountered while loading packages. -
The
-goflag causes tidy to update the'go'directive in thego.modfile to the given version, which may change which module dependencies are retained as explicit requirements in thego.modfile.
(Go versions 1.17 and higher retain more requirements in order to support lazy module loading.)
-
The
-compatflag preserves any additional checksums needed for the'go'command (from the indicated major Go release) to successfully load the module graph.- This also causes
tidyto error out if that version of the'go'command would load any imported package from a different module version.
- This also causes
By default, tidy acts as if the -compat flag were set to the
version prior to the one indicated by the 'go' directive in the go.mod
file.
- The
-xflag causes tidy to print the commands download executes.