internal

package
v0.18.0 Latest Latest
Warning

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

Go to latest
Published: Apr 20, 2024 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrTypeMismatch    = errors.New("type mismatch")
	ErrUnsupportedType = owl.ErrUnsupportedType
)

Functions

func DecodeTime

func DecodeTime(value string) (time.Time, error)

DecodeTime parses data bytes as time.Time in UTC timezone. Supported formats of the data bytes are: 1. RFC3339Nano string, e.g. "2006-01-02T15:04:05-07:00". 2. Date string, e.g. "2006-01-02". 3. Unix timestamp, e.g. "1136239445", "1136239445.8", "1136239445.812738".

func DecodeUnixtime added in v0.15.0

func DecodeUnixtime(value string) (time.Time, error)

value must be valid unix timestamp, matches reUnixtime.

func DereferencedType added in v0.18.0

func DereferencedType(v any) reflect.Type

DereferencedType returns the underlying type of a pointer.

func IsNil added in v0.15.0

func IsNil(value reflect.Value) bool

func PanicOnError added in v0.15.0

func PanicOnError(err error)

func Pointerize added in v0.15.0

func Pointerize[T any](v T) *T

func TypeOf added in v0.15.0

func TypeOf[T any]() reflect.Type

TypeOf returns the reflect.Type of a given type. e.g. TypeOf[int]() returns reflect.TypeOf(0)

func UnsupportedType added in v0.15.0

func UnsupportedType(rt reflect.Type) error

Types

type AnyStringableAdaptor added in v0.15.0

type AnyStringableAdaptor func(any) (Stringable, error)

func NewAnyStringableAdaptor added in v0.15.0

func NewAnyStringableAdaptor[T any](adapt StringableAdaptor[T]) AnyStringableAdaptor

type Bool added in v0.15.0

type Bool bool

func (*Bool) FromString added in v0.15.0

func (bv *Bool) FromString(s string) error

func (Bool) ToString added in v0.15.0

func (bv Bool) ToString() (string, error)

type ByteSlice added in v0.15.0

type ByteSlice []byte

ByteSlice is a wrapper of []byte to implement Stringable. NOTE: we're using base64.StdEncoding here, not base64.URLEncoding.

func (*ByteSlice) FromString added in v0.15.0

func (bs *ByteSlice) FromString(s string) error

func (ByteSlice) ToString added in v0.15.0

func (bs ByteSlice) ToString() (string, error)

type Complex128 added in v0.15.0

type Complex128 complex128

func (*Complex128) FromString added in v0.15.0

func (cv *Complex128) FromString(s string) error

func (Complex128) ToString added in v0.15.0

func (cv Complex128) ToString() (string, error)

type Complex64 added in v0.15.0

type Complex64 complex64

func (*Complex64) FromString added in v0.15.0

func (cv *Complex64) FromString(s string) error

func (Complex64) ToString added in v0.15.0

func (cv Complex64) ToString() (string, error)

type Float32 added in v0.15.0

type Float32 float32

func (*Float32) FromString added in v0.15.0

func (fv *Float32) FromString(s string) error

func (Float32) ToString added in v0.15.0

func (fv Float32) ToString() (string, error)

type Float64 added in v0.15.0

type Float64 float64

func (*Float64) FromString added in v0.15.0

func (fv *Float64) FromString(s string) error

func (Float64) ToString added in v0.15.0

func (fv Float64) ToString() (string, error)

type Int added in v0.15.0

type Int int

func (*Int) FromString added in v0.15.0

func (iv *Int) FromString(s string) error

func (Int) ToString added in v0.15.0

func (iv Int) ToString() (string, error)

type Int16 added in v0.15.0

type Int16 int16

func (*Int16) FromString added in v0.15.0

func (iv *Int16) FromString(s string) error

func (Int16) ToString added in v0.15.0

func (iv Int16) ToString() (string, error)

type Int32 added in v0.15.0

type Int32 int32

func (*Int32) FromString added in v0.15.0

func (iv *Int32) FromString(s string) error

func (Int32) ToString added in v0.15.0

func (iv Int32) ToString() (string, error)

type Int64 added in v0.15.0

type Int64 int64

func (*Int64) FromString added in v0.15.0

func (iv *Int64) FromString(s string) error

func (Int64) ToString added in v0.15.0

func (iv Int64) ToString() (string, error)

type Int8 added in v0.15.0

type Int8 int8

func (*Int8) FromString added in v0.15.0

func (iv *Int8) FromString(s string) error

func (Int8) ToString added in v0.15.0

func (iv Int8) ToString() (string, error)

type String added in v0.15.0

type String string

func (*String) FromString added in v0.15.0

func (sv *String) FromString(s string) error

func (String) ToString added in v0.15.0

func (sv String) ToString() (string, error)

type StringMarshaler added in v0.15.0

type StringMarshaler interface {
	ToString() (string, error)
}

type StringUnmarshaler added in v0.15.0

type StringUnmarshaler interface {
	FromString(string) error
}

type Stringable added in v0.15.0

type Stringable interface {
	StringMarshaler
	StringUnmarshaler
}

func NewStringable added in v0.15.0

func NewStringable(rv reflect.Value) (Stringable, error)

NewStringable returns a Stringable from the given reflect.Value. We assume that the given reflect.Value is a non-nil pointer to a value. It will panic if the given reflect.Value is not a pointer.

type StringableAdaptor added in v0.15.0

type StringableAdaptor[T any] func(*T) (Stringable, error)

type Time added in v0.15.0

type Time time.Time

func (*Time) FromString added in v0.15.0

func (tv *Time) FromString(s string) error

func (Time) ToString added in v0.15.0

func (tv Time) ToString() (string, error)

type Uint added in v0.15.0

type Uint uint

func (*Uint) FromString added in v0.15.0

func (uv *Uint) FromString(s string) error

func (Uint) ToString added in v0.15.0

func (uv Uint) ToString() (string, error)

type Uint16 added in v0.15.0

type Uint16 uint16

func (*Uint16) FromString added in v0.15.0

func (uv *Uint16) FromString(s string) error

func (Uint16) ToString added in v0.15.0

func (uv Uint16) ToString() (string, error)

type Uint32 added in v0.15.0

type Uint32 uint32

func (*Uint32) FromString added in v0.15.0

func (uv *Uint32) FromString(s string) error

func (Uint32) ToString added in v0.15.0

func (uv Uint32) ToString() (string, error)

type Uint64 added in v0.15.0

type Uint64 uint64

func (*Uint64) FromString added in v0.15.0

func (uv *Uint64) FromString(s string) error

func (Uint64) ToString added in v0.15.0

func (uv Uint64) ToString() (string, error)

type Uint8 added in v0.15.0

type Uint8 uint8

func (*Uint8) FromString added in v0.15.0

func (uv *Uint8) FromString(s string) error

func (Uint8) ToString added in v0.15.0

func (uv Uint8) ToString() (string, error)

Jump to

Keyboard shortcuts

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