Skip to content

Commit 0d45f64

Browse files
authored
Merge pull request #4 from huttotw/feature/check-types-before-less-than
check types before comparing gt or gte
2 parents 985e60c + 238d98f commit 0d45f64

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

comparators.go

+10
Original file line numberDiff line numberDiff line change
@@ -114,11 +114,21 @@ func lessThanEqual(a, b interface{}) bool {
114114

115115
// greaterThan will return true if a > b
116116
func greaterThan(a, b interface{}) bool {
117+
// We need to check the types here because, lessThanEqual will
118+
// return false if the types do not match.
119+
if reflect.TypeOf(a) != reflect.TypeOf(b) {
120+
return false
121+
}
117122
return !lessThanEqual(a, b)
118123
}
119124

120125
// greaterThanEqual will return true if a >= b
121126
func greaterThanEqual(a, b interface{}) bool {
127+
// We need to check the types here because, lessThan will
128+
// return false if the types do not match.
129+
if reflect.TypeOf(a) != reflect.TypeOf(b) {
130+
return false
131+
}
122132
return !lessThan(a, b)
123133
}
124134

0 commit comments

Comments
 (0)