-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgeneral.go
43 lines (37 loc) · 820 Bytes
/
general.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 GoPlus
import (
"fmt"
"log"
"time"
)
func HandleErr(err error) {
if err != nil {
log.Fatal(err.Error())
}
}
func HandleLightErr(err error) {
if err != nil {
fmt.Println(err)
}
}
func RemoveFromSliceOrdered(slice []int, s int) []int {
return append(slice[:s], slice[s+1:]...)
}
func RemoveFromSliceUnordered(s []int, i int) []int {
s[len(s)-1], s[i] = s[i], s[len(s)-1]
return s[:len(s)-1]
}
type interval string
// StartTimeTicker ticks when exactly a minute hits or other interval. interval must be in minutes
func StartTimeTicker(outputBroadcast *Broker, interval int) {
outputBroadcast = NewBroadcast()
go outputBroadcast.Start()
for {
if time.Now().Unix()%60 == 0 {
for {
outputBroadcast.Publish(struct{}{})
time.Sleep(time.Minute * time.Duration(interval))
}
}
}
}