Documentation ¶
Overview ¶
Package version tokenizes a apk package version using the same algorithm as apk-tools uses.
A valid version can be described by the following EBNF specificion:
version = digits , { "." , digits } , [ letter, digits ] , { suffix } , [ revision ] ; digit = "0" | "1" | "2" | "3"| "4" | "5" | "6" | "7" | "8" | "9" ; digits = { digit } ; revision = "-r", digit, digits ; letter = "a" | "b" | "c" | "d" | "e" | "f" | "g" | "h" | "i" | "j" | "k" | "l" | "m" | "n" | "o" | "p" | "q" | "r" | "s" | "t" | "u" | "v" | "w" | "x" | "y" | "z" ; suffix = "_" , ( pre-suffix | post-suffix ) , digits ; pre-suffix = "alpha" | "beta" | "pre" | "rc" ; post-suffix = "cvc" | "svn" | "git" | "hg" | "p" ;
Example ¶
package main import ( "fmt" "gitlab.alpinelinux.org/alpine/go/version" ) func main() { v := version.Version("1.2.3-r0") nv := &v t := version.Digit var pt version.Token var q int64 for t != version.End { pt = t t, nv, q = nv.GetToken(t) if pt == version.Digit { fmt.Printf("%d\n", q) } if pt == version.RevisionDigit { fmt.Printf("r%d\n", q) } } }
Output: 1 2 3 r0
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func IsValidWithoutRevision ¶ added in v0.10.0
IsValidWithoutRevision validates the provided version without a revision component.
Example (Invalid) ¶
fmt.Println(IsValidWithoutRevision("1.2.4_5"))
Output: false
Example (Valid) ¶
fmt.Println(IsValidWithoutRevision("1.2.4_git123"))
Output: true
Types ¶
Click to show internal directories.
Click to hide internal directories.