Skip to content

strict version check constraint bug (or expected?) #242

@Diliz

Description

@Diliz

Hello!

I actually saw that the version constraint sometimes does not work as expected, as you can see here: https://go.dev/play/p/u1nq3v1-SiS

I got the following versions:

"1.0.0",
"1.0.0-beta.2"
"1.0.0-beta.1"
"1.0.0-alpha.2"
"1.0.0-alpha.1"
"1.0.0+toto.1"

here is a usable snippet:

	versions := []string{
		"1.0.0",
		"1.0.0-beta.2",
		"1.0.0-beta.1",
		"1.0.0-alpha.2",
		"1.0.0-alpha.1",
		"1.0.0+toto.1",
	}
	c, _ := semver.NewConstraint("= 1.0.0")
	for _, vs := range versions {
		v, _ := semver.NewVersion(vs)
		fmt.Println(v, c.Check(v))
	}

What I got:

1.0.0 true
1.0.0-beta.2 false
1.0.0-beta.1 false
1.0.0-alpha.2 false
1.0.0-alpha.1 false
1.0.0+toto.1 true

What I was expecting:

1.0.0 true
1.0.0-beta.2 false
1.0.0-beta.1 false
1.0.0-alpha.2 false
1.0.0-alpha.1 false
1.0.0+toto.1 false

If this was the expected behaviour:

  • how do I set a constraint that will work to have only the 1.0.0 matching here?
  • If not possible to match only 1.0.0 here, can we have a == constraint so that a really precise version could be set here?

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions