github.com/wangyougui/gf/v2@v2.6.5/os/gcron/gcron_z_example_1_test.go (about)

     1  // Copyright GoFrame Author(https://goframe.org). All Rights Reserved.
     2  //
     3  // This Source Code Form is subject to the terms of the MIT License.
     4  // If a copy of the MIT was not distributed with this file,
     5  // You can obtain one at https://github.com/wangyougui/gf.
     6  
     7  package gcron_test
     8  
     9  import (
    10  	"context"
    11  	"time"
    12  
    13  	"github.com/wangyougui/gf/v2/os/gcron"
    14  	"github.com/wangyougui/gf/v2/os/glog"
    15  )
    16  
    17  func ExampleCronAddSingleton() {
    18  	gcron.AddSingleton(ctx, "* * * * * *", func(ctx context.Context) {
    19  		glog.Print(context.TODO(), "doing")
    20  		time.Sleep(2 * time.Second)
    21  	})
    22  	select {}
    23  }