github.com/creativeprojects/go-selfupdate@v1.2.0/release.go (about) 1 package selfupdate 2 3 import ( 4 "time" 5 6 "github.com/Masterminds/semver/v3" 7 ) 8 9 // Release represents a release asset for current OS and arch. 10 type Release struct { 11 // AssetURL is a URL to the uploaded file for the release 12 AssetURL string 13 // AssetSize represents the size of asset in bytes 14 AssetByteSize int 15 // AssetID is the ID of the asset on the source platform 16 AssetID int64 17 // ReleaseID is the ID of the release on the source platform 18 ReleaseID int64 19 // AssetName is the filename of the asset 20 AssetName string 21 // ValidationAssetID is the ID of additional validation asset on the source platform 22 ValidationAssetID int64 23 // ValidationAssetURL is the URL of additional validation asset on the source platform 24 ValidationAssetURL string 25 // ValidationChain is the list of validation assets being used (first record is ValidationAssetID). 26 ValidationChain []struct { 27 // ValidationAssetID is the ID of additional validation asset on the source platform 28 ValidationAssetID int64 29 // ValidationAssetURL is the filename of additional validation asset on the source platform 30 ValidationAssetName string 31 // ValidationAssetURL is the URL of additional validation asset on the source platform 32 ValidationAssetURL string 33 } 34 // URL is a URL to release page for browsing 35 URL string 36 // ReleaseNotes is a release notes of the release 37 ReleaseNotes string 38 // Name represents a name of the release 39 Name string 40 // PublishedAt is the time when the release was published 41 PublishedAt time.Time 42 // OS this release is for 43 OS string 44 // Arch this release is for 45 Arch string 46 // Arm 32bits version (if any). Valid values are 0 (unknown), 5, 6 or 7 47 Arm uint8 48 // Prerelease is set to true for alpha, beta or release candidates 49 Prerelease bool 50 // version is the parsed *semver.Version 51 version *semver.Version 52 repository Repository 53 } 54 55 // Version is the version string of the release 56 func (r Release) Version() string { 57 return r.version.String() 58 } 59 60 // Give access to some of the method of the internal semver 61 // so we can change the version without breaking compatibility 62 63 // Equal tests if two versions are equal to each other. 64 func (r Release) Equal(other string) bool { 65 return r.version.Equal(semver.MustParse(other)) 66 } 67 68 // LessThan tests if one version is less than another one. 69 func (r Release) LessThan(other string) bool { 70 return r.version.LessThan(semver.MustParse(other)) 71 } 72 73 // GreaterThan tests if one version is greater than another one. 74 func (r Release) GreaterThan(other string) bool { 75 return r.version.GreaterThan(semver.MustParse(other)) 76 } 77 78 // LessOrEqual tests if one version is less than or equal to another one. 79 func (r Release) LessOrEqual(other string) bool { 80 return r.version.Compare(semver.MustParse(other)) <= 0 81 } 82 83 // GreaterOrEqual tests if one version is greater than or equal to another one. 84 func (r Release) GreaterOrEqual(other string) bool { 85 return r.version.Compare(semver.MustParse(other)) >= 0 86 }