Skip to content

filinvadim/wall-clock-ticker

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

10 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.