Home > Article > Backend Development > Will "go mod tidy" automatically upgrade the go version in go.mod?
Previously this project was using go 1.20
in go.mod
. I have upgraded my go version to 1.21.0
on my local Linux machine.
When I ran go mod tidy
for the project, it automatically upgraded go.mod
to use go 1.21.0
.
If this is expected behavior, is there a way to disable this behavior, aka. When running go mod tidy
, won't the go version in go.mod
be automatically updated? Because others may not have upgraded locally yet.
The go mod tidy
command (currently) does not change only based on the local toolchain version go.mod## The
go directive in #. It is set up based on dependencies and does not require tracking patch versions.
go1.21, then your module
requires go1.21, forcing
go tools Update the
go.mod directives in
go.mod accordingly. There is no use having your module declare a version prior to
go1.21 when building the module actually requires
go1.21.
The above is the detailed content of Will "go mod tidy" automatically upgrade the go version in go.mod?. For more information, please follow other related articles on the PHP Chinese website!