diff --git a/g/os/gcron/gcron_z_example_1_test.go b/g/os/gcron/gcron_z_example_1_test.go new file mode 100644 index 000000000..4f5b6db13 --- /dev/null +++ b/g/os/gcron/gcron_z_example_1_test.go @@ -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 { } +} diff --git a/geg/other/test2.go b/geg/other/test2.go index 51cba4c94..65b39b5ea 100644 --- a/geg/other/test2.go +++ b/geg/other/test2.go @@ -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 { } } \ No newline at end of file