From d5795681d431b6685423b043f94fcef632bf27b1 Mon Sep 17 00:00:00 2001 From: "Guillaume J. Charmes" Date: Tue, 1 Apr 2014 15:46:52 -0700 Subject: [PATCH] Update Version to not use string anymore Docker-DCO-1.1-Signed-off-by: Guillaume J. Charmes (github: creack) --- version/version.go | 14 +++++++------- version/version_test.go | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/version/version.go b/version/version.go index 3721d64..5ff9d2e 100644 --- a/version/version.go +++ b/version/version.go @@ -7,10 +7,10 @@ import ( type Version string -func (me Version) compareTo(other string) int { +func (me Version) compareTo(other Version) int { var ( meTab = strings.Split(string(me), ".") - otherTab = strings.Split(other, ".") + otherTab = strings.Split(string(other), ".") ) for i, s := range meTab { var meInt, otherInt int @@ -31,22 +31,22 @@ func (me Version) compareTo(other string) int { return 0 } -func (me Version) LessThan(other string) bool { +func (me Version) LessThan(other Version) bool { return me.compareTo(other) == -1 } -func (me Version) LessThanOrEqualTo(other string) bool { +func (me Version) LessThanOrEqualTo(other Version) bool { return me.compareTo(other) <= 0 } -func (me Version) GreaterThan(other string) bool { +func (me Version) GreaterThan(other Version) bool { return me.compareTo(other) == 1 } -func (me Version) GreaterThanOrEqualTo(other string) bool { +func (me Version) GreaterThanOrEqualTo(other Version) bool { return me.compareTo(other) >= 0 } -func (me Version) Equal(other string) bool { +func (me Version) Equal(other Version) bool { return me.compareTo(other) == 0 } diff --git a/version/version_test.go b/version/version_test.go index 4bebd0c..27c0536 100644 --- a/version/version_test.go +++ b/version/version_test.go @@ -5,7 +5,7 @@ import ( ) func assertVersion(t *testing.T, a, b string, result int) { - if r := Version(a).compareTo(b); r != result { + if r := Version(a).compareTo(Version(b)); r != result { t.Fatalf("Unexpected version comparison result. Found %d, expected %d", r, result) } }