syncthing/cmd/syncthing/upgrade_common.go

34 lines
634 B
Go
Raw Normal View History

2014-07-14 10:45:29 +02:00
package main
import (
"bytes"
"strconv"
"strings"
)
type githubRelease struct {
Tag string `json:"tag_name"`
Prerelease bool `json:"prerelease"`
Assets []githubAsset `json:"assets"`
2014-07-14 10:45:29 +02:00
}
type githubAsset struct {
URL string `json:"url"`
Name string `json:"name"`
}
func compareVersions(a, b string) int {
return bytes.Compare(versionParts(a), versionParts(b))
}
func versionParts(v string) []byte {
parts := strings.Split(v, "-")
fields := strings.Split(parts[0], ".")
res := make([]byte, len(fields))
for i, s := range fields {
v, _ := strconv.Atoi(s)
res[i] = byte(v)
}
return res
}