Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

go1.21: go.mod:3: invalid go version '1.21.0': must match format 1.23 #129

Closed
ialidzhikov opened this issue Sep 1, 2023 · 9 comments
Closed

Comments

@ialidzhikov
Copy link

With go1.21 the module version has to be in format X.Y.Z. See golang/go#62278 and dependabot/dependabot-core#7895.

Trying to use 1.21.0 as module version

module github.com/foo/bar

go 1.21.0

fails with:

go.mod:3: invalid go version '1.21.0': must match format 1.23
@ialidzhikov
Copy link
Author

/cc @incu6us

@incu6us
Copy link
Owner

incu6us commented Sep 7, 2023

@ialidzhikov try to use v3.4.4. And reopen the issue in case of a problem

@incu6us incu6us closed this as completed Sep 7, 2023
@ialidzhikov
Copy link
Author

ialidzhikov commented Sep 7, 2023

I see that v3.4.4 includes #133. which only bumps the go version for the project.

The issue report is about the cases when you run goimports-reviser against a module with go version directive in format X.Y.Z. For example

module github.com/foo/bar

go 1.21.0

goimports-reviser still fails with:

go.mod:3: invalid go version '1.21.0': must match format 1.23

Usage of goimports-reviser:

<Usage text is omitted>

Let me know if you need more detailed steps to reproduce.


And reopen the issue in case of a problem

When a maintainer closes an issue, the reporter cannot open it. Can you please reopen it?

@incu6us incu6us reopened this Sep 7, 2023
@incu6us
Copy link
Owner

incu6us commented Sep 8, 2023

As I see in the official documentation(https://go.dev/doc/modules/gomod-ref#module-syntax) the version must have format like X.Y.
image

Mentioned error message telling you that you are using wrong format(...must match format 1.23). So, in your case the string should be go 1.21

@ialidzhikov
Copy link
Author

See https://go.dev/doc/toolchain#version:

Before Go 1.21, the initial release of a Go toolchain was version 1.N, not 1.N.0, so for N < 21, the ordering is adjusted to place 1.N after the release candidates.

You can also check all the comments in golang/go#62278. My understanding is that with go1.21 the expect format is go X.Y.Z and go X.Y refers to a development version of the X.Y version. So, goimports-reviser has to definitely support the go X.Y.Z format.

incu6us added a commit that referenced this issue Sep 8, 2023
@incu6us
Copy link
Owner

incu6us commented Sep 8, 2023

fixed with new version v3.4.5:

image

@ialidzhikov
Copy link
Author

Thank you @incu6us !

[email protected] resolves the issue.

ialidzhikov added a commit to ialidzhikov/gardener that referenced this issue Sep 8, 2023
ialidzhikov added a commit to ialidzhikov/gardener-extension-registry-cache that referenced this issue Sep 8, 2023
gardener-prow bot pushed a commit to gardener/gardener that referenced this issue Sep 8, 2023
nickytd pushed a commit to nickytd/gardener that referenced this issue Sep 11, 2023
gardener-prow bot pushed a commit to gardener/gardener-extension-registry-cache that referenced this issue Sep 15, 2023
* Use `1.21.0` instead of `1.21` as module version

* Update goimports-reviser

from v3.4.1 to v3.4.5

[email protected] contains a fix for incu6us/goimports-reviser#129.
gardener-ci-robot pushed a commit to gardener-ci-robot/gardener that referenced this issue Sep 18, 2023
ialidzhikov added a commit to ialidzhikov/gardener that referenced this issue Sep 18, 2023
ialidzhikov added a commit to ialidzhikov/gardener that referenced this issue Sep 18, 2023
gardener-prow bot pushed a commit to gardener/gardener that referenced this issue Sep 18, 2023
from v3.4.1 to v3.4.5

[email protected] contains a fix for incu6us/goimports-reviser#129.

Co-authored-by: ialidzhikov <[email protected]>
gardener-prow bot pushed a commit to gardener/gardener that referenced this issue Sep 18, 2023
gardener-prow bot pushed a commit to gardener/gardener that referenced this issue Sep 18, 2023
@2048Nemo
Copy link

I'm also having this issue, but I regenerated a go.mod file via go mod init XXXX , the original go.mod file was generated in vscode, but I ran into problems opening it in goland

@incu6us
Copy link
Owner

incu6us commented Sep 21, 2023

@2048Nemo update the tool to the latest version

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants