x/time/rate: add rate.Sometimes, which runs a function occasionally.

Modeled after sync.Once; intended to provide simple throttling
akin to the C++ log functions LOG_FIRST_N, LOG_EVERY_N, and
LOG_EVERY_N_SEC.

Originally authored by sameer@golang.org.

Fixes golang/go#54237

Change-Id: I7c6266cc780eb6dad30d310485de492f790dbcdb
Reviewed-on: https://go-review.googlesource.com/c/time/+/421915
Reviewed-by: Sameer Ajmani <sameer@golang.org>
2 files changed
tree: e0da087f5d32beb707b05eb72c591963aa1380cb
  1. rate/
  2. CONTRIBUTING.md
  3. go.mod
  4. LICENSE
  5. PATENTS
  6. README.md
README.md

Go Time

Go Reference

This repository provides supplementary Go time packages.

Download/Install

The easiest way to install is to run go get -u golang.org/x/time. You can also manually git clone the repository to $GOPATH/src/golang.org/x/time.

Report Issues / Send Patches

This repository uses Gerrit for code changes. To learn how to submit changes to this repository, see https://golang.org/doc/contribute.html.

The main issue tracker for the time repository is located at https://github.com/golang/go/issues. Prefix your issue with “x/time:” in the subject line, so it is easy to find.