-
Notifications
You must be signed in to change notification settings - Fork 0
/
condtion.go
53 lines (47 loc) · 1 KB
/
condtion.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
package costtime
import "time"
// CondGTE 创建cost>=t时间输出日志的条件
func CondGTE(t time.Duration) ConditionFunc {
return func(cost time.Duration) bool {
if cost >= t {
return true
}
return false
}
}
// CondGT 创建cost>t时间输出日志的条件
func CondGT(t time.Duration) ConditionFunc {
return func(cost time.Duration) bool {
if cost > t {
return true
}
return false
}
}
// CondLTE 创建cost<=t时间输出日志的条件
func CondLTE(t time.Duration) ConditionFunc {
return func(cost time.Duration) bool {
if cost >= t {
return true
}
return false
}
}
// CondLT 创建cost<t时间输出日志的条件
func CondLT(t time.Duration) ConditionFunc {
return func(cost time.Duration) bool {
if cost < t {
return true
}
return false
}
}
// CondRange 创建t1<=cost<=t2时间输出日志的条件
func CondRange(t1, t2 time.Duration) ConditionFunc {
return func(cost time.Duration) bool {
if t1 <= cost && cost <= t2 {
return true
}
return false
}
}