Documentation ¶
Index ¶
- Variables
- func AppendError(base error, err error) error
- func Autotype(in interface{}) interface{}
- func ConvertCustomType(in interface{}) (interface{}, error)
- func ConvertHexToInteger(in interface{}) (int64, error)
- func ConvertTo(toType ConvertType, inI interface{}) (interface{}, error)
- func ConvertToBool(in interface{}) (bool, error)
- func ConvertToBytes(in interface{}) ([]byte, error)
- func ConvertToFloat(in interface{}) (float64, error)
- func ConvertToInteger(in interface{}) (int64, error)
- func ConvertToString(in interface{}) (string, error)
- func ConvertToTime(in interface{}) (time.Time, error)
- func DetectTimeFormat(in string) string
- func GenericMarshalJSON(in interface{}, extraData ...map[string]interface{}) ([]byte, error)
- func IsBoolean(inI interface{}) bool
- func IsBooleanFalse(inI interface{}) bool
- func IsBooleanTrue(inI interface{}) bool
- func IsFloat(in interface{}) bool
- func IsHexadecimal(in interface{}) bool
- func IsInteger(in interface{}) bool
- func IsKind(in interface{}, kinds ...reflect.Kind) bool
- func IsNumeric(in interface{}) bool
- func IsTime(inI interface{}) bool
- func IsZero(value interface{}) bool
- func ParseDuration(in string) (time.Duration, error)
- func RegisterTypeHandler(handler TypeConvertFunc, types ...string)
- func ResolveValue(in interface{}) interface{}
- func SliceEach(slice interface{}, iterFn IterationFunc, preserve ...reflect.Kind) error
- func ToString(in interface{}) (string, error)
- type ConvertType
- type IterationFunc
- type TimedReadCloser
- func (self *TimedReadCloser) BytesRead() int64
- func (self *TimedReadCloser) Close() (err error)
- func (self *TimedReadCloser) CloseDuration() time.Duration
- func (self *TimedReadCloser) Duration() time.Duration
- func (self *TimedReadCloser) LastReadAt() time.Time
- func (self *TimedReadCloser) Read(b []byte) (int, error)
- func (self *TimedReadCloser) ReadDuration() time.Duration
- func (self *TimedReadCloser) Reset()
- func (self *TimedReadCloser) SetReadCloser(rc io.ReadCloser)
- func (self *TimedReadCloser) SinceLastRead() time.Duration
- func (self *TimedReadCloser) StartedAt() time.Time
- type TypeConvertFunc
Constants ¶
This section is empty.
Variables ¶
var BooleanFalseValues = []string{`false`, `no`, `off`}
var BooleanTrueValues = []string{`true`, `yes`, `on`}
var CompoundTypes = []reflect.Kind{ reflect.Invalid, reflect.Complex64, reflect.Complex128, reflect.Array, reflect.Chan, reflect.Func, reflect.Interface, reflect.Map, reflect.Ptr, reflect.Slice, reflect.Struct, }
var EachChanMaxItems = 1048576
var NilStrings = []string{`null`, `NULL`, `<nil>`, `nil`, `Nil`, `None`, `undefined`, ``}
var PassthroughType = errors.New(`passthrough`)
var ReferenceTime time.Time = time.Date(2006, 1, 2, 15, 4, 5, 0, time.FixedZone("MST", -7*60*60))
var Stop = fmt.Errorf("stop iterating")
var TimeFormats = []string{ time.RFC3339, time.RFC3339Nano, time.ANSIC, time.UnixDate, time.RubyDate, time.RFC850, time.RFC822, time.RFC822Z, time.RFC1123, time.RFC1123Z, time.Kitchen, `2006-01-02 15:04:05.000000000`, `2006-01-02 15:04:05.000000`, `2006-01-02 15:04:05.000`, `2006-01-02 15:04:05 -0700 MST`, `2006-01-02 15:04:05Z07:00`, `2006-01-02 15:04:05`, `2006-01-02 15:04`, `2006-01-02`, `2006-01-02T15:04:05.000000000`, `2006-01-02T15:04:05.000000`, `2006-01-02T15:04:05.000`, `2006-01-02T15:04:05 -0700 MST`, `2006-01-02T15:04:05Z07:00`, `2006-01-02T15:04:05`, `2006-01-02T15:04`, }
Functions ¶
func AppendError ¶
Appends on error to another, allowing for operations that return multiple errors to remain compatible within a single-valued context.
func ConvertCustomType ¶
func ConvertCustomType(in interface{}) (interface{}, error)
Returns the given value, converted according to any handlers set via RegisterTypeHandler.
func ConvertHexToInteger ¶
func ConvertTo ¶
func ConvertTo(toType ConvertType, inI interface{}) (interface{}, error)
func ConvertToBool ¶
func ConvertToBytes ¶
func ConvertToFloat ¶
func ConvertToInteger ¶
func ConvertToString ¶
func ConvertToTime ¶
func DetectTimeFormat ¶
func GenericMarshalJSON ¶
func IsBooleanFalse ¶
func IsBooleanFalse(inI interface{}) bool
func IsBooleanTrue ¶
func IsBooleanTrue(inI interface{}) bool
func IsHexadecimal ¶
func IsHexadecimal(in interface{}) bool
func IsKind ¶
Dectect whether the concrete underlying value of the given input is one or more Kinds of value.
func IsZero ¶
func IsZero(value interface{}) bool
Returns whether the given value represents the underlying type's zero value
func RegisterTypeHandler ¶
func RegisterTypeHandler(handler TypeConvertFunc, types ...string)
Register's a handler used for converting one type to another. Type are checked in the following manner: The input value's reflect.Type String() value is matched, falling back to its reflect.Kind String() value, finally checking for a special "*" value that matches any type. If the handler function returns nil, its value replaces the input value. If the special error type PassthroughType is returned, the original value is returned unmodified.
func ResolveValue ¶
func ResolveValue(in interface{}) interface{}
Types ¶
type ConvertType ¶
type ConvertType int
const ( Invalid ConvertType = iota Bytes String Float Integer Time Boolean Nil UserDefined )
func Detect ¶
func Detect(in interface{}) (ConvertType, interface{})
func DetectConvertType ¶
func DetectConvertType(in interface{}) ConvertType
func (ConvertType) IsSupersetOf ¶
func (self ConvertType) IsSupersetOf(other ConvertType) bool
func (ConvertType) String ¶
func (self ConvertType) String() string
type IterationFunc ¶
type TimedReadCloser ¶
type TimedReadCloser struct {
// contains filtered or unexported fields
}
A TimedReadCloser wraps an io.ReadCloser, keeping track of how long actually reading from and closing the ReadCloser took, as well as how many bytes were read.
Measurement starts from the first call to Read(), and ends when Close() is called.
func NewTimedReadCloser ¶
func NewTimedReadCloser(rc io.ReadCloser) *TimedReadCloser
func (*TimedReadCloser) BytesRead ¶
func (self *TimedReadCloser) BytesRead() int64
func (*TimedReadCloser) Close ¶
func (self *TimedReadCloser) Close() (err error)
func (*TimedReadCloser) CloseDuration ¶
func (self *TimedReadCloser) CloseDuration() time.Duration
func (*TimedReadCloser) Duration ¶
func (self *TimedReadCloser) Duration() time.Duration
func (*TimedReadCloser) LastReadAt ¶
func (self *TimedReadCloser) LastReadAt() time.Time
Return the time of the last call to Read()
func (*TimedReadCloser) ReadDuration ¶
func (self *TimedReadCloser) ReadDuration() time.Duration
Return a running duration of how long reading has been happening. Updated on every call to Read().
func (*TimedReadCloser) Reset ¶
func (self *TimedReadCloser) Reset()
Reset the internal counters to zero. Useful after calling SetReadCloser().
func (*TimedReadCloser) SetReadCloser ¶
func (self *TimedReadCloser) SetReadCloser(rc io.ReadCloser)
Set the underlying io.ReadCloser. Does not call Reset(), so multiple ReadClosers can be cumulitively tracked.
func (*TimedReadCloser) SinceLastRead ¶
func (self *TimedReadCloser) SinceLastRead() time.Duration
Return the duration of time since the last Read() occurred.
func (*TimedReadCloser) StartedAt ¶
func (self *TimedReadCloser) StartedAt() time.Time
Return the time of the first call to Read().
type TypeConvertFunc ¶
type TypeConvertFunc func(in interface{}) (interface{}, error)