Created
September 27, 2022 10:22
-
-
Save betandr/f4066c4da7807e180d2eb9c82614e38a to your computer and use it in GitHub Desktop.
Semver
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"flag" | |
"fmt" | |
"github.com/Masterminds/semver/v3" | |
) | |
var vFlag = flag.String("version", "0.1", "version to check") | |
func main() { | |
flag.Parse() | |
c, err := semver.NewConstraint(">= 0.1") | |
if err != nil { | |
fmt.Println("constraint not parseable") | |
} | |
v, err := semver.NewVersion(*vFlag) | |
if err != nil { | |
fmt.Println("version not parseable") | |
} | |
valid, _ := c.Validate(v) | |
if !valid { | |
fmt.Println("not valid") | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment