Compare compares v with other version, and tells if v is equal, less, or greater than other. It interprets nil as &version{major: 0, minor: 0, patch: 0}
(other *version)
| 74 | // Compare compares v with other version, and tells if v is equal, less, or greater than other. |
| 75 | // It interprets nil as &version{major: 0, minor: 0, patch: 0} |
| 76 | func (v *version) Compare(other *version) versionComparisonResult { |
| 77 | if v == nil { |
| 78 | v = zeroVersion |
| 79 | } |
| 80 | if other == nil { |
| 81 | other = zeroVersion |
| 82 | } |
| 83 | |
| 84 | switch { |
| 85 | case v.major > other.major: |
| 86 | return greater |
| 87 | case v.major < other.major: |
| 88 | return less |
| 89 | case v.minor > other.minor: |
| 90 | return greater |
| 91 | case v.minor < other.minor: |
| 92 | return less |
| 93 | case v.patch > other.patch: |
| 94 | return greater |
| 95 | case v.patch < other.patch: |
| 96 | return less |
| 97 | } |
| 98 | |
| 99 | return equal |
| 100 | } |
| 101 | |
| 102 | // change represents the action that needs to be taken during upgrade as a result of some breaking |
| 103 | // change |
no outgoing calls