8 ms·
> It only syncs go.mod with what is already being used by the build process If dependencies are incomplete, Go will fail to compile and tell you to run go mod
by mxey 4mo ago
> It only syncs go.mod with what is already being used by the build process
If dependencies are incomplete, Go will fail to compile and tell you to run go mod tidy to fix it.
- kbolino 4mo agoIndeed, I ran two tests (missing indirect dependency, stale indirect dependency version) and it refused to compile both. Either what I said was never true, or it was only true for earlier versions of the `go` command. Nevertheless, adjusted accordingly, I believe the following statement is true: `go mod tidy` doesn't change versions in go.mod unless it needs to, to satisfy the other dependencies listed in go.mod, or to fill in a missing dependency for an import in code. It would be nice if there were a flag to turn off the latter behavior, though.
- mxey 4mo agoYes, initially modules used to modify the file automatically which is why I have -mod=readonly in some old pipelines. I think the “new” way is much better. I still run tidy in pipelines to check but that’s only for cleanup.