gcron updates

This commit is contained in:
John 2019-01-16 22:59:26 +08:00
parent 36199334f0
commit cb24714faa
2 changed files with 30 additions and 5 deletions

View File

@ -0,0 +1,22 @@
// Copyright 2019 gf Author(https://gitee.com/johng/gf). All Rights Reserved.
//
// This Source Code Form is subject to the terms of the MIT License.
// If a copy of the MIT was not distributed with this file,
// You can obtain one at https://gitee.com/johng/gf.
package gcron_test
import (
"gitee.com/johng/gf/g/os/gcron"
"gitee.com/johng/gf/g/os/glog"
"time"
)
func ExampleCron_AddSingleton() {
gcron.AddSingleton("* * * * * *", func() {
glog.Println("doing")
time.Sleep(2*time.Second)
})
select { }
}

View File

@ -1,12 +1,15 @@
package main
import (
"fmt"
"gitee.com/johng/gf/g/util/grand"
"gitee.com/johng/gf/g/os/gcron"
"gitee.com/johng/gf/g/os/glog"
"time"
)
func main() {
fmt.Println(float64(10)/3)
fmt.Println(grand.Meet(1, 1))
fmt.Println(grand.MeetProb(float64(1)/2))
gcron.AddSingleton("* * * * * *", func() {
glog.Println("doing")
time.Sleep(2*time.Second)
})
select { }
}