filinvadim / wall-clock-ticker

Golang wall clocks ticker

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

golang-action status

wall-clock-ticker

Golang wall clock ticker is a Go library that provides a ticker which ticks according to wall clock.

Installation

go get -u github.com/filinvadim/wall-clock-ticker

Usage

Using Golang wall clock ticker is very much like time.NewTicker with the addition of an accuracy and start time.

The following creates a ticker which ticks on the minute according the hosts wall clock with an accuracy of plus or minus one second.

package main

import (
	"fmt"
	"time"

	wct "github.com/filinvadim/wall-clock-ticker"
)

func main() {
	// ticks every 59th minute of every hour
	t := wct.NewWCTicker(time.Minute*59, time.Second)
	for tick := range t.C {
		// Process tick
		fmt.Println("tick:", tick)
	}
}

License

Golang wall clock ticker is available under the BSD 2-Clause License.

About

Golang wall clocks ticker

License:BSD 2-Clause "Simplified" License


Languages

Language:Go 100.0%