Documentation ¶
Overview ¶
Package types defines types used in events.
Index ¶
- func Clone(v interface{}) interface{}
- func Format(v interface{}) (string, error)
- func FormatBinary(v []byte) string
- func FormatBool(v bool) string
- func FormatFloat64(v float64) string
- func FormatInteger(v int32) string
- func FormatTime(v time.Time) string
- func IsZero(v interface{}) bool
- func ParseBinary(v string) ([]byte, error)
- func ParseBool(v string) (bool, error)
- func ParseInteger(v string) (int32, error)
- func ParseTime(v string) (time.Time, error)
- func ToBinary(v interface{}) ([]byte, error)
- func ToBool(v interface{}) (bool, error)
- func ToInteger(v interface{}) (int32, error)
- func ToString(v interface{}) (string, error)
- func ToTime(v interface{}) (time.Time, error)
- func ToURL(v interface{}) (*url.URL, error)
- func Validate(v interface{}) (interface{}, error)
- type ConvertErr
- type Timestamp
- type URI
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Clone ¶
func Clone(v interface{}) interface{}
Clone v clones a CNE attribute value, which is one of the valid types:
bool, int32, string, []byte, types.URI, types.URIRef, types.Timestamp
Returns the same type Panics if the type is not valid
func Format ¶
Format returns the canonical string format of v, where v can be any type that is convertible to a CNE type.
func FormatBinary ¶
FormatBinary returns canonical string format: standard base64 encoding
func FormatBool ¶
FormatBool returns canonical string format: "true" or "false"
func FormatFloat64 ¶
FormatFloat64 returns canonical string format: decimal notation.
func FormatInteger ¶
FormatInteger returns canonical string format: decimal notation.
func FormatTime ¶
FormatTime returns canonical string format: RFC3339 with nanoseconds
func ParseBinary ¶
ParseBinary parse canonical string format: standard base64 encoding
func ParseInteger ¶
ParseInteger parse canonical string format: decimal notation.
func ToString ¶
ToString returns a string value unaltered.
This function does not perform canonical string encoding, use one of the Format functions for that.
Types ¶
type ConvertErr ¶
type ConvertErr struct { // Value being converted Value interface{} // Type of attempted conversion Type reflect.Type // contains filtered or unexported fields }
ConvertErr convert error
func (*ConvertErr) Error ¶
func (e *ConvertErr) Error() string
type Timestamp ¶
Timestamp wraps time.Time to normalize the time layout to RFC3339. It is intended to enforce compliance with the Cloud Native events spec for their definition of Timestamp. Custom marshal methods are implemented to ensure the outbound Timestamp is a string in the RFC3339 layout.
func ParseTimestamp ¶
ParseTimestamp attempts to parse the given time assuming RFC3339 layout
func (*Timestamp) MarshalJSON ¶
MarshalJSON implements a custom json marshal method used when this type is marshaled using json.Marshal.
func (*Timestamp) MarshalXML ¶
MarshalXML implements a custom xml marshal method used when this type is marshaled using xml.Marshal.
func (*Timestamp) UnmarshalJSON ¶
UnmarshalJSON implements the json unmarshal method used when this type is unmarshalled using json.Unmarshal.
func (*Timestamp) UnmarshalXML ¶
UnmarshalXML implements the xml unmarshal method used when this type is unmarshaled using xml.Unmarshal.
type URI ¶
URI is a wrapper to url.URL. It is intended to enforce compliance with the Cloud Native Events spec for their definition of URI. Custom marshal methods are implemented to ensure the outbound URI object is a flat string.
func (URI) MarshalJSON ¶
MarshalJSON implements a custom json marshal method used when this type is marshaled using json.Marshal.
func (URI) MarshalXML ¶
MarshalXML implements a custom xml marshal method used when this type is marshaled using xml.Marshal.
func (*URI) UnmarshalJSON ¶
UnmarshalJSON implements the json unmarshal method used when this type is unmarshaled using json.Unmarshal.
func (*URI) UnmarshalXML ¶
UnmarshalXML implements the xml unmarshal method used when this type is unmarshaled using xml.Unmarshal.