cmdutil

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetEnv

func GetEnv(key, defaultValue string) string

GetEnv gets an environment variable or returns a default value

func GetEnvBool added in v0.14.0

func GetEnvBool(key string, defaultValue bool) bool

GetEnvBool gets a boolean environment variable or returns a default value. Recognizes "true", "1" as true and "false", "0" as false.

func GetEnvInt

func GetEnvInt(key string, defaultValue int) int

GetEnvInt gets an integer environment variable or returns a default value

func ParseDuration added in v0.15.0

func ParseDuration(s string) (time.Duration, error)

ParseDuration parses a duration string that supports days in addition to standard Go duration units.

Supported formats:

  • "90d" (days only)
  • "10d 1h 10m 100s" (multi-unit with spaces)
  • "10d1h10m100s" (multi-unit without spaces)
  • "1h30m" (standard Go format)
  • "1000s" (seconds only)

Units: d (days), h (hours), m (minutes), s (seconds)

Returns:

  • time.Duration: The parsed duration
  • error: An error if the format is invalid or the duration is negative

Examples:

ParseDuration("90d")          // 90 days
ParseDuration("10d 1h 30m")   // 10 days, 1 hour, 30 minutes
ParseDuration("1h30m")        // 1 hour, 30 minutes
ParseDuration("1000s")        // 1000 seconds

func SetupLogger

func SetupLogger(levelStr string) *slog.Logger

SetupLogger creates a structured logger with the specified level

func ValidateDuration added in v0.15.0

func ValidateDuration(s string) error

ValidateDuration validates that a duration string is valid and non-negative. Returns nil if valid, error otherwise.

Types

This section is empty.

Jump to

Keyboard shortcuts

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