|
|
@ -4,6 +4,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
package utils
|
|
|
|
package utils
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import "time"
|
|
|
|
|
|
|
|
|
|
|
|
// Comparator will make type assertion (see IntComparator for example),
|
|
|
|
// Comparator will make type assertion (see IntComparator for example),
|
|
|
|
// which will panic if a or b are not of the asserted type.
|
|
|
|
// which will panic if a or b are not of the asserted type.
|
|
|
|
//
|
|
|
|
//
|
|
|
@ -51,6 +53,21 @@ func IntComparator(a, b interface{}) int {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// TimeComparator provides a basic comparison on time.Time
|
|
|
|
|
|
|
|
func TimeComparator(a, b interface{}) int {
|
|
|
|
|
|
|
|
aAsserted := a.(time.Time)
|
|
|
|
|
|
|
|
bAsserted := b.(time.Time)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch {
|
|
|
|
|
|
|
|
case aAsserted.After(bAsserted) :
|
|
|
|
|
|
|
|
return 1
|
|
|
|
|
|
|
|
case aAsserted.Before(bAsserted):
|
|
|
|
|
|
|
|
return -1
|
|
|
|
|
|
|
|
default:
|
|
|
|
|
|
|
|
return 0
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Int8Comparator provides a basic comparison on int8
|
|
|
|
// Int8Comparator provides a basic comparison on int8
|
|
|
|
func Int8Comparator(a, b interface{}) int {
|
|
|
|
func Int8Comparator(a, b interface{}) int {
|
|
|
|
aAsserted := a.(int8)
|
|
|
|
aAsserted := a.(int8)
|
|
|
|