configutil

package
v2.1.0 Latest Latest
Warning

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

Go to latest
Published: May 20, 2022 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ParseBoolEnv

func ParseBoolEnv(envKey string, defaultValue bool) (bool, error)

ParseBoolEnv gets the value of the environment variable envKey and, if set, parses it as a boolean. If the environment variable is unset, defaultValue is returned.

func ParseDuration

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

ParseDuration parses s as a duration, accepting a subset of the syntax supported by time.ParseDuration.

Valid time units are "ms", "s", "m".

func ParseDurationEnv

func ParseDurationEnv(envKey string, defaultDuration time.Duration) (time.Duration, error)

ParseDurationEnv gets the value of the environment variable envKey and, if set, parses it as a duration. If the environment variable is unset, defaultDuration is returned.

func ParseDurationEnvOptions

func ParseDurationEnvOptions(envKey string, defaultDuration time.Duration, opts DurationOptions) (time.Duration, error)

ParseDurationEnvOptions gets the value of the environment variable envKey and, if set, parses it as a duration. If the environment variable is unset, defaultDuration is returned.

func ParseDurationOptions

func ParseDurationOptions(s string, opts DurationOptions) (time.Duration, error)

ParseDurationOptions parses s as a duration, accepting a subset of the syntax supported by time.ParseDuration. It allows a DurationOptions to be passed to specify the minimum time.Duration unit allowed.

Valid time units are "us", "ms", "s", "m".

func ParseList

func ParseList(s, sep string) []string

ParseList parses s as a list of strings, separated by sep, and with whitespace trimmed from the list items, omitting empty items.

func ParseListEnv

func ParseListEnv(envKey, sep string, defaultValue []string) []string

ParseListEnv gets the value of the environment variable envKey and, if set, parses it as a list separated by sep. If the environment variable is unset, defaultValue is returned.

func ParseWildcardPattern

func ParseWildcardPattern(p string) *wildcard.Matcher

ParseWildcardPattern parses p as a wildcard pattern, returning a wildcard.Matcher.

Patterns support the "*" wildcard, which will match zero or more characters. A prefix of (?-i) treats the pattern case-sensitively, while a prefix of (?i) treats the pattern case-insensitively (the default). All other characters in the pattern are matched exactly.

func ParseWildcardPatterns

func ParseWildcardPatterns(s string) wildcard.Matchers

ParseWildcardPatterns parses s as a comma-separated list of wildcard patterns, and returns wildcard.Matchers for each.

Patterns support the "*" wildcard, which will match zero or more characters. A prefix of (?-i) treats the pattern case-sensitively, while a prefix of (?i) treats the pattern case-insensitively (the default). All other characters in the pattern are matched exactly.

func ParseWildcardPatternsEnv

func ParseWildcardPatternsEnv(envKey string, defaultValue wildcard.Matchers) wildcard.Matchers

ParseWildcardPatternsEnv gets the value of the environment variable envKey and, if set, parses it as a list of wildcard patterns. If the environment variable is unset, defaultValue is returned.

Types

type DurationOptions

type DurationOptions struct {
	MinimumDurationUnit time.Duration
}

DurationOptions can be used to specify the minimum accepted duration unit for ParseDurationOptions.

type Size

type Size int64

Size represents a size in bytes.

const (
	Byte  Size = 1
	KByte Size = 1024
	MByte Size = 1024 * 1024
	GByte Size = 1024 * 1024 * 1024
)

Common power-of-two sizes.

func ParseSize

func ParseSize(s string) (Size, error)

ParseSize parses s as a size, in bytes.

Valid size units are "b", "kb", "mb", "gb".

func ParseSizeEnv

func ParseSizeEnv(envKey string, defaultSize Size) (Size, error)

ParseSizeEnv gets the value of the environment variable envKey and, if set, parses it as a size. If the environment variable is unset, defaultSize is returned.

func (Size) Bytes

func (s Size) Bytes() int64

Bytes returns s as a number of bytes.

func (Size) String

func (s Size) String() string

String returns s in its most compact string representation.

Jump to

Keyboard shortcuts

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