Source File
semver.go
Belonging Package
golang.org/x/mod/semver
package semver
func ( string) string {
, := parse()
if ! {
return ""
}
return .prerelease
}
func (, string) int {
, := parse()
, := parse()
if ! && ! {
return 0
}
if ! {
return -1
}
if ! {
return +1
}
if := compareInt(.major, .major); != 0 {
return
}
if := compareInt(.minor, .minor); != 0 {
return
}
if := compareInt(.patch, .patch); != 0 {
return
}
return comparePrerelease(.prerelease, .prerelease)
}
func (, string) string {
= Canonical()
= Canonical()
if Compare(, ) > 0 {
return
}
return
}
func ( string) ( parsed, bool) {
if == "" || [0] != 'v' {
.err = "missing v prefix"
return
}
.major, , = parseInt([1:])
if ! {
.err = "bad major version"
return
}
if == "" {
.minor = "0"
.patch = "0"
.short = ".0.0"
return
}
if [0] != '.' {
.err = "bad minor prefix"
= false
return
}
.minor, , = parseInt([1:])
if ! {
.err = "bad minor version"
return
}
if == "" {
.patch = "0"
.short = ".0"
return
}
if [0] != '.' {
.err = "bad patch prefix"
= false
return
}
.patch, , = parseInt([1:])
if ! {
.err = "bad patch version"
return
}
if len() > 0 && [0] == '-' {
.prerelease, , = parsePrerelease()
if ! {
.err = "bad prerelease"
return
}
}
if len() > 0 && [0] == '+' {
.build, , = parseBuild()
if ! {
.err = "bad build"
return
}
}
if != "" {
.err = "junk on end"
= false
return
}
= true
return
}
func ( string) (, string, bool) {
if == "" {
return
}
if [0] < '0' || '9' < [0] {
return
}
:= 1
for < len() && '0' <= [] && [] <= '9' {
++
}
if [0] == '0' && != 1 {
return
}
return [:], [:], true
}
if == "" || [0] != '-' {
return
}
:= 1
:= 1
for < len() && [] != '+' {
if !isIdentChar([]) && [] != '.' {
return
}
if [] == '.' {
if == || isBadNum([:]) {
return
}
= + 1
}
++
}
if == || isBadNum([:]) {
return
}
return [:], [:], true
}
func ( string) (, string, bool) {
if == "" || [0] != '+' {
return
}
:= 1
:= 1
for < len() {
if !isIdentChar([]) && [] != '.' {
return
}
if [] == '.' {
if == {
return
}
= + 1
}
++
}
if == {
return
}
return [:], [:], true
}
func ( byte) bool {
return 'A' <= && <= 'Z' || 'a' <= && <= 'z' || '0' <= && <= '9' || == '-'
}
func ( string) bool {
:= 0
for < len() && '0' <= [] && [] <= '9' {
++
}
return == len() && > 1 && [0] == '0'
}
func ( string) bool {
:= 0
for < len() && '0' <= [] && [] <= '9' {
++
}
return == len()
}
func (, string) int {
if == {
return 0
}
if len() < len() {
return -1
}
if len() > len() {
return +1
}
if < {
return -1
} else {
return +1
}
}
if == {
return 0
}
if == "" {
return +1
}
if == "" {
return -1
}
for != "" && != "" {
= [1:] // skip - or .
= [1:] // skip - or .
var , string
, = nextIdent()
, = nextIdent()
if != {
:= isNum()
:= isNum()
if != {
if {
return -1
} else {
return +1
}
}
if {
if len() < len() {
return -1
}
if len() > len() {
return +1
}
}
if < {
return -1
} else {
return +1
}
}
}
if == "" {
return -1
} else {
return +1
}
}
func ( string) (, string) {
:= 0
for < len() && [] != '.' {
++
}
return [:], [:]
![]() |
The pages are generated with Golds v0.3.2-preview. (GOOS=darwin GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @Go100and1 (reachable from the left QR code) to get the latest news of Golds. |