times

package
v1.0.6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 21, 2023 License: MIT Imports: 4 Imported by: 3

Documentation

Overview

Package times 时间相关.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Between added in v1.0.6

func Between(ctx context.Context, start, stop int, yield func(context.Context))

Between 时间范围内执行,超出时间终止.

func Hour

func Hour(yield func()) func() bool

Hour 整点运行,返回取消方法.

Example
package main

import (
	"time"

	"github.com/xuender/kit/logs"
	"github.com/xuender/kit/times"
)

func main() {
	logs.I.Println("start")

	cancel := times.Hour(func() {
		logs.I.Println("run")
	})

	go func() {
		time.Sleep(time.Second)
		cancel()
		logs.I.Println("stop")
	}()

	logs.I.Println("sleep")
	time.Sleep(2 * time.Second)
	logs.I.Println("end")

}
Output:

func InScope added in v1.0.6

func InScope(start, stop int) bool

InScope 返回是否在时间范围内. nolint: cyclop

func Sleep added in v1.0.6

func Sleep(stop int) time.Duration

Sleep 计算睡眠时间.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL