gf/g/os/gcron/gcron_z_example_1_test.go

22 lines
518 B
Go
Raw Normal View History

// Copyright 2019 gf Author(https://github.com/gogf/gf). All Rights Reserved.
2019-01-16 22:59:26 +08:00
//
// 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://github.com/gogf/gf.
2019-01-16 22:59:26 +08:00
package gcron_test
import (
2019-06-19 09:06:52 +08:00
"github.com/gogf/gf/g/os/gcron"
"github.com/gogf/gf/g/os/glog"
"time"
2019-01-16 22:59:26 +08:00
)
func ExampleCron_AddSingleton() {
2019-06-19 09:06:52 +08:00
gcron.AddSingleton("* * * * * *", func() {
glog.Println("doing")
time.Sleep(2 * time.Second)
})
select {}
2019-01-16 22:59:26 +08:00
}