Masterminds / semver

Work with Semantic Versions in Go

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

`Checking Version Constraints` is unpredictable while patch is missing in version string

pkbhowmick opened this issue · comments

When I was trying to validate version 14.1.1-debian against constraints 14.1.1-alpine, it was giving error like 14.1.1-debian is not equal to 14.1.1-alpine which is expected.

But when I was trying version 14.1-debian against constraints 14.1-alpine, it was considered as valid version which is not expected to me.

semver version: v3.1.1

For reproducing the error, I have given my go code below:

package main

import (
	"fmt"
	"github.com/Masterminds/semver/v3"
	"log"
)

func main() {
	c, err := semver.NewConstraint("14.1-alpine")
	if err != nil {
		log.Fatalln(err)
	}

	v, err := semver.NewVersion("14.1-debian")
	if err != nil {
		log.Fatalln(err)
	}

	valid, errs := c.Validate(v)
	if len(errs) > 0 {
		log.Fatalln(errs)
	}
	fmt.Println(valid)
}

Output:

 true