duration

package
v0.0.0-...-292ea0a Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2025 License: MIT Imports: 5 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseDuration

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

ParseDuration parses a duration string. A duration string is a possibly signed sequence of decimal numbers, each with optional fraction and a unit suffix, such as "300ms", "-1.5h" or "2h45m". Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h", "d", "w", "y".

Types

type DurationOption

type DurationOption time.Duration

DurationOption is a type for parsing a duration string passed through a config file or by other means into a time.Duration. It implements the json.Unmarshaler and yaml.Unmarshaler interfaces. It also implements marshaler interfaces, but that output is not well readable by humans.

func (DurationOption) Duration

func (do DurationOption) Duration() time.Duration

Duration returns the time.Duration

func (DurationOption) MarshalJSON

func (do DurationOption) MarshalJSON() (b []byte, err error)

MarshalJSON implements the json.Marshaler interface

func (DurationOption) MarshalYAML

func (do DurationOption) MarshalYAML() (interface{}, error)

MarshalYAML implements the yaml.Marshaler interface

func (*DurationOption) UnmarshalJSON

func (do *DurationOption) UnmarshalJSON(bytes []byte) error

UnmarshalJSON implements the json.Unmarshaler interface

func (*DurationOption) UnmarshalYAML

func (do *DurationOption) UnmarshalYAML(n *yaml.Node) error

UnmarshalYAML implements the yaml.Unmarshaler interface

Jump to

Keyboard shortcuts

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