chromeworker/proxyserver/uidcompare.go

41 lines
605 B
Go
Raw Permalink Normal View History

2020-11-18 11:49:46 +00:00
package main
// CompareTaskID 任务id比较
func CompareTaskID(k1, k2 interface{}) int {
s1 := k2.(string)
s2 := k1.(string)
switch {
case len(s1) > len(s2):
for i := 0; i < len(s2); i++ {
if s1[i] != s2[i] {
if s1[i] > s2[i] {
return 1
}
return -1
}
}
return 1
case len(s1) < len(s2):
for i := 0; i < len(s1); i++ {
if s1[i] != s2[i] {
if s1[i] > s2[i] {
return 1
}
return -1
}
}
return -1
default:
for i := 0; i < len(s1); i++ {
if s1[i] != s2[i] {
if s1[i] > s2[i] {
return 1
}
return -1
}
}
return 0
}
}