-
-
Notifications
You must be signed in to change notification settings - Fork 250
/
helpers.go
43 lines (37 loc) · 791 Bytes
/
helpers.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
package processor
import (
"time"
)
// Returns the current time as a millisecond timestamp
func makeTimestampMilli() int64 {
return time.Now().UnixNano() / int64(time.Millisecond)
}
// Returns the current time as a nanosecond timestamp as some things
// are far too fast to measure using nanoseconds
func makeTimestampNano() int64 {
return time.Now().UnixNano()
}
func min(a, b int) int {
if a < b {
return a
}
return b
}
func max(a, b int) int {
if a > b {
return a
}
return b
}
// Takes a slice of bytes and returns a unique slice of bytes
func uniqueByte(slice []byte) []byte {
keys := make(map[byte]bool)
list := []byte{}
for _, entry := range slice {
if _, value := keys[entry]; !value {
keys[entry] = true
list = append(list, entry)
}
}
return list
}