Skip to content

d0x7/go-interval-notation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go Interval Notation

This library is used to parse interval notations (e.g. [v1.2,] or [v1,v3)) for versions in Go. The following format of versions are supported:

  • 1
  • 1.2
  • 1.2.3
  • SemanticVersioning
  • Addtionally every version prefixed with a 'v'.

For actually parsing the version and comparing them, it's using SemVer from @Masterminds

Usage

First use go get to import the package:

go get github.com/d0x7/go-interval-notation

Afterwards you can use like this:

package main

import "github.com/d0x7/go-interval-notation"

func main() {
  interval_notation.InRange("[v1,v2]", "v1.5.3") // == true
  interval_notation.InRange("[v1,v2]", "v2.5.3") // == false
}

License

MIT © 2023 Dorian Heinrichs