Help us shape the future of Go! Take the 2026 Go Developer Survey

cooldown

package
v1.20.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package cooldown enforces a minimum delay between destructive operations on a per-profile basis, protecting against runaway automation.

Default delay is 10 seconds. Per-profile overrides are read from the config (destructive-cooldown field on the Profile struct). Setting the value to 0 disables the cooldown for that profile. Passing noInput=true always skips the cooldown regardless of config, so CI/CD pipelines are never affected.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Enforce

func Enforce(profileName string, noInput bool, configured *time.Duration) error

Enforce checks whether a cooldown period has elapsed since the last destructive operation for profileName. If not, it sleeps for the remaining duration, printing a message to stderr.

Rules:

  • noInput=true → always returns nil immediately (CI/CD bypass)
  • configured != nil && *configured == 0 → returns nil (explicitly disabled)
  • configured == nil → uses defaultCooldown (10s)
  • otherwise → uses *configured

func Record

func Record(profileName string)

Record saves the current time as the last destructive operation timestamp for profileName. Errors are silently ignored — a failed record just means the next operation won't benefit from the cooldown gap.

Types

This section is empty.

Jump to

Keyboard shortcuts

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