Documentation
¶
Overview ¶
autogenerated: DO NOT EDIT
net covers the types in net.
time covers the package 'time'.
Index ¶
- func Bool(s string) (b bool, err error)
- func Complex128(s string) (c complex128, err error)
- func Duration(s string) (time.Duration, error)
- func Float64(s string) (x float64, err error)
- func FromBinary[T any, PT interface{ ... }](b []byte) (T, error)
- func FromJSONString[T any](s string) (t T, err error)
- func FromText[T any, PT interface{ ... }](s string) (T, error)
- func FromTextBytes[T any, PT interface{ ... }](b []byte) (T, error)
- func HSet[K comparable](parse func(string) (K, error), raw string) (set.HSet[K], error)
- func IP(s string) (net.IP, error)
- func IPv4(s string) (net.IP, error)
- func Int(s string) (int, error)
- func Int16(s string) (int16, error)
- func Int16Base(s string, base int) (int16, error)
- func Int32(s string) (int32, error)
- func Int32Base(s string, base int) (int32, error)
- func Int64(s string) (int64, error)
- func Int64Base(s string, base int) (int64, error)
- func Int8(s string) (int8, error)
- func Int8Base(s string, base int) (int8, error)
- func IntBase(s string, base int) (int, error)
- func KeyVal[K any, V any](kv string, sep byte, parseKey func(string) (K, error), ...) (k K, v V, err error)
- func MAC(s string) (net.HardwareAddr, error)
- func Map[K comparable, V any](parseK func(rawKey string) (K, error), parseV func(rawVal string) (V, error), ...) (map[K]V, error)
- func MapFunc[K comparable, V any](parseK func(string) (K, error), parseV func(string) (V, error)) func(s string) (map[K]V, error)
- func Port(s string) (uint16, error)
- func Slice[T any](parse func(s string) (T, error), s string) (a []T, err error)
- func SliceFunc[T any](parse func(s string) (T, error)) func(string) ([]T, error)
- func TimeRFC3339(s string) (time.Time, error)
- func Trace(s string) (trace.Trace, error)
- func TraceNode(s string) (*trace.Node, error)
- func UUID(s string) (uuid.UUID, error)
- func Uint(s string) (uint, error)
- func Uint16(s string) (uint16, error)
- func Uint16Base(s string, base int) (uint16, error)
- func Uint32(s string) (uint32, error)
- func Uint32Base(s string, base int) (uint32, error)
- func Uint64(s string) (uint64, error)
- func Uint64Base(s string, base int) (uint64, error)
- func Uint8(s string) (uint8, error)
- func Uint8Base(s string, base int) (uint8, error)
- func UintBase(s string, base int) (uint, error)
- type Error
- type MapError
- type SliceError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Bool ¶
Bool wraps strconv.ParseBool. It accepts 1, t, T, TRUE, true, True, 0, f, F, FALSE, false, False. Any other value returns an error.
func Complex128 ¶
func Complex128(s string) (c complex128, err error)
Complex128 wraps strconv.ParseComplex(s, 128)
func Duration ¶
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".
func FromBinary ¶
func FromBinary[T any, PT interface { *T encoding.BinaryUnmarshaler }](b []byte, ) (T, error)
FromBinary parses an encoding.BinaryUnmarshaler from a []byte by using its UnmarshalBytes() method.
func FromJSONString ¶
FromJSON attempts to unmarshal s to a *T using json.Unmarshal([]byte(s), &t)
func FromText ¶
func FromText[T any, PT interface { *T encoding.TextUnmarshaler }](s string, ) (T, error)
FromTextBytes parses an encoding.TextUnmarshaler from a []byte by using its UnmarshalText() method.
func FromTextBytes ¶
func FromTextBytes[T any, PT interface { *T encoding.TextUnmarshaler }](b []byte, ) (T, error)
FromTextBytes parses an encoding.TextUnmarshaler from a []byte by using its UnmarshalText() method.
func HSet ¶
HSet parses text as a series of keys separated by whitespace and/or commas. The rules are identical to Slice[K]. Duplicate keys are NOT an error.
func IP ¶
// wrapper for net.ParseIP
IP parses the string as a net.IP. The following forms are OK:
IPv4 dotted decimal ("192.0.2.1") IPv4-mapped IPv6 ("::ffff:192.0.2.1") IPv6 ("2001:db8::68")
func IPv4 ¶
IPv4 parses the string as an IPv4. The following forms are OK:
IPv4 dotted decimal ("192.0.2.1") IPv4-mapped IPv6 ("::ffff:192.0.2.1")
func Int ¶
Int is equivalent to strconv.ParseInt(s, 0, 0), but gives more informative error messages.
func Int16 ¶ added in v0.1.2
Int16 is equivalent to strconv.ParseInt(s, 0, 16), but gives more informative error messages.
func Int16Base ¶ added in v0.1.2
Int16Base is equivalent to strconv.ParseInt(s, base, 16), but gives more informative error messages.
func Int32 ¶ added in v0.1.2
Int32 is equivalent to strconv.ParseInt(s, 0, 32), but gives more informative error messages.
func Int32Base ¶ added in v0.1.2
Int32Base is equivalent to strconv.ParseInt(s, base, 32), but gives more informative error messages.
func Int64 ¶ added in v0.1.2
Int64 is equivalent to strconv.ParseInt(s, 0, 64), but gives more informative error messages.
func Int64Base ¶ added in v0.1.2
Int64Base is equivalent to strconv.ParseInt(s, base, 64), but gives more informative error messages.
func Int8 ¶ added in v0.1.2
Int8 is equivalent to strconv.ParseInt(s, 0, 8), but gives more informative error messages.
func Int8Base ¶ added in v0.1.2
Int8Base is equivalent to strconv.ParseInt(s, base, 8), but gives more informative error messages.
func IntBase ¶
IntBase is equivalent to strconv.ParseInt(s, base, 0), but gives more informative error messages.
func KeyVal ¶
func KeyVal[K any, V any]( kv string, sep byte, parseKey func(string) (K, error), parseVal func(string) (V, error), ) (k K, v V, err error)
KeyVal parses a 'sep'-separated key-value pair k<SEP>v by calling fk on k and fv on v. eg, KeyVal(`"expires":10m", ':', strconv.Unquote, ParseDuration) should return ("expires", 10*time.Minute, nil) You probably don't want to use this directly unless you're implementing parsing of a data-structure directly.
func MAC ¶
func MAC(s string) (net.HardwareAddr, error)
// wrapper for net.ParseMAC
MAC parses the string as a net.HardwareAddr ParseMAC parses s as an IEEE 802 MAC-48, EUI-48, EUI-64, or a 20-octet IP over InfiniBand link-layer address using one of the following formats:
00:00:5e:00:53:01 02:00:5e:10:00:00:00:01 00:00:00:00:fe:80:00:00:00:00:00:00:02:00:5e:10:00:00:00:01 00-00-5e-00-53-01 02-00-5e-10-00-00-00-01 00-00-00-00-fe-80-00-00-00-00-00-00-02-00-5e-10-00-00-00-01 0000.5e00.5301 0200.5e10.0000.0001 0000.0000.fe80.0000.0000.0000.0200.5e10.0000.0001
func Map ¶
func Map[K comparable, V any]( parseK func(rawKey string) (K, error), parseV func(rawVal string) (V, error), raw string, ) (map[K]V, error)
Map parses a string in the form "{k0:v0, k1:v1}" by calling parseK on the keys and parseV on the vals. The map must have unique keys: duplicate fields are an error. Non-nil errors are of type *MapError.
func MapFunc ¶
func MapFunc[K comparable, V any]( parseK func(string) (K, error), parseV func(string) (V, error), ) func(s string) (map[K]V, error)
MapFunc(parseK, parseV) creates a closure f such that f(s) = Map(parseK, parseV, s)
func Slice ¶
Slice parses text as a series of values separated by commas (and optional whitespace), optionally enclosed in a [] or {}. An error will be of type *ParseError[T].
func TimeRFC3339 ¶
TimeRFC3339 is as time.Parse(time.RFC3339, s).
func UUID ¶
UUID decodes s into a UUID or returns an error. The following forms are OK:
xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx // standard urn:uuid:xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx // also standard {xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx} // microsoft xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx. // raw hex
This is just a wrapper for uuid.Parse.
func Uint ¶
Uint is equivalent to strconv.ParseUint(s, 0, 0), but gives more informative error messages.
func Uint16 ¶ added in v0.1.2
Uint16 is equivalent to strconv.ParseUint(s, 0, 16), but gives more informative error messages.
func Uint16Base ¶ added in v0.1.2
Uint16Base is equivalent to strconv.ParseUint(s, base, 16), but gives more informative error messages.
func Uint32 ¶ added in v0.1.2
Uint32 is equivalent to strconv.ParseUint(s, 0, 32), but gives more informative error messages.
func Uint32Base ¶ added in v0.1.2
Uint32Base is equivalent to strconv.ParseUint(s, base, 32), but gives more informative error messages.
func Uint64 ¶ added in v0.1.2
Uint64 is equivalent to strconv.ParseUint(s, 0, 64), but gives more informative error messages.
func Uint64Base ¶ added in v0.1.2
Uint64Base is equivalent to strconv.ParseUint(s, base, 64), but gives more informative error messages.
func Uint8 ¶ added in v0.1.2
Uint8 is equivalent to strconv.ParseUint(s, 0, 8), but gives more informative error messages.
Types ¶
type MapError ¶
type MapError[K comparable, V any] struct { // The text that failed parsing. Raw string // Underlying error that caused the failure. Returned by Unwrap(). Err error // Index of the comma-separated item where parsing failed, if any. I int // Number of elements N int // The item at index I, in the form key:value Sub string }
MapError is returned from a failed call to Slice(parseK, parseV, s). It will Unwrap() to the error of parse(), if any.
type SliceError ¶
type SliceError[T any] struct { // The text that failed parsing. Raw string // Underlying error that caused the failure. Returned by Unwrap(). Err error // Index of the comma-separated item where parsing failed, if any. I int // The item at index I. Sub string }
SliceError is returned from a failed call to Slice(parse, s). It will Unwrap() to the error of parse(), if any.
func (*SliceError[T]) Error ¶
func (err *SliceError[T]) Error() string
Unwrap() returns the underlying error that caused the parsing failure.
func (*SliceError[T]) Unwrap ¶
func (err *SliceError[T]) Unwrap() error
Unwrap() returns the underlying error that caused the parsing failure.