Documentation ¶
Index ¶
- Variables
- func ParseAbsoluteTime(in interface{}) (time.Time, error)
- func ParseAddrs(addrs interface{}) ([]*sockaddr.SockAddrMarshaler, error)
- func ParseBool(in interface{}) (bool, error)
- func ParseCapacityString(in interface{}) (uint64, error)
- func ParseCommaStringSlice(in interface{}) ([]string, error)
- func ParseDirectIntSlice(in interface{}) ([]int64, error)
- func ParseDurationSecond(in interface{}) (time.Duration, error)
- func ParseInt(in interface{}) (int64, error)
- func ParseIntSlice(in interface{}) ([]int64, error)
- func ParsePath(path string) (string, error)
- func ParseString(in interface{}) (string, error)
Constants ¶
This section is empty.
Variables ¶
var ErrNotAUrl = errors.New("not a url")
Functions ¶
func ParseAbsoluteTime ¶
func ParseAddrs ¶
func ParseAddrs(addrs interface{}) ([]*sockaddr.SockAddrMarshaler, error)
func ParseCapacityString ¶
ParseCapacityString parses a capacity string and returns the number of bytes it represents. Capacity strings are things like 5gib or 10MB. Supported prefixes are kb, kib, mb, mib, gb, gib, tb, tib, which are not case sensitive. If no prefix is present, the number is assumed to be in bytes already.
func ParseCommaStringSlice ¶
func ParseDirectIntSlice ¶ added in v0.1.3
func ParseDurationSecond ¶
func ParseIntSlice ¶ added in v0.1.3
ParseIntSlice is a helper function for handling upgrades of optional slices; that is, if the API accepts a type similar to <int|[]int>, nicely handle the common cases of providing only an int-ish, providing an actual slice of int-ishes, or providing a comma-separated list of numbers.
func ParsePath ¶
ParsePath parses a URL with schemes file://, env://, or any other. Depending on the scheme it will return specific types of data:
* file:// will return a string with the file's contents
* env:// will return a string with the env var's contents
* Anything else will return the string as it was
On error, we return the original string along with the error. The caller can switch on errors.Is(err, ErrNotAUrl) to understand whether it was the parsing step that errored or something else (such as a file not found). This is useful to attempt to read a non-URL string from some resource, but where the original input may simply be a valid string of that type.
func ParseString ¶
Types ¶
This section is empty.