Running "go mod tidy" automatically changes "go 1.23" to "go 1.23.0"

372 views
Skip to first unread message

Benjamin Wang

unread,
Jan 15, 2025, 12:49:19 PM1/15/25
to golang-nuts
Hello,

We set both go and toolchain in go.mod file, see below. But when executing "go mod tidy" command, it automatically changes "go 1.23" to "go 1.23.0". The local go version is 1.23.4 (darwin/arm64). see.  https://github.com/etcd-io/etcd-operator/blob/7e8cf49ea8fef6f108084fb55cb437887dc71c3a/tools/mod/go.mod#L3-L5

go 1.23

toolchain go1.23.4

When I execute "go mod tidy" under another project (etcd) on the same machine with exactly the same go version, it doesn't automatically make the same change, see https://github.com/etcd-io/etcd/blob/ce4b4e533d037d8247843cefe2ba4c69cd109097/go.mod#L3-L5

Could anyone please explain the reason for the different behaviour? 

Regards,
Benjamin

Jason Phillips

unread,
Jan 15, 2025, 7:27:37 PM1/15/25
to golang-nuts
Since Go 1.21, the go directive in go.mod must be greater than or equal to the go directive for all dependencies.

Almost certainly, in the first case there's a dependency that specifies 1.23.0 and in the second case all dependencies are 1.23 or older.


Jason

Benjamin Wang

unread,
Jan 16, 2025, 5:06:47 AM1/16/25
to golang-nuts
Thank you for the clarification. 

Indeed confirmed that some dependencies "k8s.io/*" specify "go 1.23.0" in their go.mod files.

Regards,
Benjamin

Reply all
Reply to author
Forward
0 new messages