generic

package
v5.0.0-...-03972fd Latest Latest
Warning

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

Go to latest
Published: Jan 20, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	DateFormat     = "2006-01-02"
	TimeFormat     = "15:04:05"
	DateTimeFormat = "2006-01-02 15:04:05"
)

Variables

View Source
var ErrNoMatch = errors.New("no rows")

Functions

func CloneValue

func CloneValue(src interface{}) interface{}

func CloneValueTo

func CloneValueTo(dst interface{}, src interface{})

Deep copy value Usage^

type data struct {
	a string
	b string
	c []string
}
src := &data{
 "works1",
 "works2",
  []string{"a", "b"},
}
var dst data
CloneValueTo(&dst, src)
src.c = append(src.c, "c")
fmt.Println(src)
fmt.Println(dst)

So you can pass any type at run time as long as you're sure that source and destin are both of the same type, (and destin is a pointer to that type).

func CoalesceFloat32

func CoalesceFloat32(values ...float32) float32

func CoalesceFloat64

func CoalesceFloat64(values ...float64) float64

func CoalesceInt

func CoalesceInt(values ...int) int

func CoalesceInt16

func CoalesceInt16(values ...int16) int16

func CoalesceInt32

func CoalesceInt32(values ...int32) int32

func CoalesceInt64

func CoalesceInt64(values ...int64) int64

func CoalesceInt8

func CoalesceInt8(values ...int8) int8

func CoalesceString

func CoalesceString(values ...string) string

func CoalesceUint

func CoalesceUint(values ...uint) uint

func CoalesceUint16

func CoalesceUint16(values ...uint16) uint16

func CoalesceUint32

func CoalesceUint32(values ...uint32) uint32

func CoalesceUint64

func CoalesceUint64(values ...uint64) uint64

func CoalesceUint8

func CoalesceUint8(values ...uint8) uint8

func ConvertAssign

func ConvertAssign(dest, src interface{}) error

func ConvertToBoolean

func ConvertToBoolean(val interface{}) (res bool, valid bool)

func ConvertToFloat32

func ConvertToFloat32(val interface{}) (res float32, valid bool)

func ConvertToFloat64

func ConvertToFloat64(val interface{}) (res float64, valid bool)

func ConvertToInt

func ConvertToInt(val interface{}) (res int, valid bool)

func ConvertToInt16

func ConvertToInt16(val interface{}) (res int16, valid bool)

func ConvertToInt32

func ConvertToInt32(val interface{}) (res int32, valid bool)

func ConvertToInt64

func ConvertToInt64(val interface{}) (res int64, valid bool)

func ConvertToInt8

func ConvertToInt8(val interface{}) (res int8, valid bool)

func ConvertToString

func ConvertToString(val interface{}) (res string, valid bool)

func ConvertToTime

func ConvertToTime(val interface{}) (res time.Time, valid bool)

func ConvertToUint

func ConvertToUint(val interface{}) (res uint, valid bool)

func ConvertToUint16

func ConvertToUint16(val interface{}) (res uint16, valid bool)

func ConvertToUint32

func ConvertToUint32(val interface{}) (res uint32, valid bool)

func ConvertToUint64

func ConvertToUint64(val interface{}) (res uint64, valid bool)

func ConvertToUint8

func ConvertToUint8(val interface{}) (res uint8, valid bool)

func ImplodeInt

func ImplodeInt(list []int, delim string) string

func ImplodeInt16

func ImplodeInt16(list []int16, delim string) string

func ImplodeInt32

func ImplodeInt32(list []int32, delim string) string

func ImplodeInt64

func ImplodeInt64(list []int64, delim string) string

func ImplodeInt8

func ImplodeInt8(list []int8, delim string) string

func ImplodeUint

func ImplodeUint(list []uint, delim string) string

func ImplodeUint16

func ImplodeUint16(list []uint16, delim string) string

func ImplodeUint32

func ImplodeUint32(list []uint32, delim string) string

func ImplodeUint64

func ImplodeUint64(list []uint64, delim string) string

func ImplodeUint8

func ImplodeUint8(list []uint8, delim string) string

func IsEmpty

func IsEmpty(value interface{}) bool

func IsEqualMaps

func IsEqualMaps(a, b map[string]interface{}) bool

func MakePointerTo

func MakePointerTo(obj interface{}) interface{}

func ResetFields

func ResetFields(rec interface{}, fields []string)

Types

type Getter

type Getter interface {
	Get(ctx context.Context, key string, defValue interface{}) (interface{}, error)
}

type GetterFunc

type GetterFunc func(ctx context.Context, key string, defValue interface{}) (interface{}, error)

func (GetterFunc) Get

func (fn GetterFunc) Get(ctx context.Context, key string, defValue interface{}) (interface{}, error)

type GetterSetter

type GetterSetter interface {
	Getter
	Setter
}

type Parameters

type Parameters interface {
	ReaderWriter
	JSON() string
}

type Params

type Params map[string]interface{}

List of various named parameters

func (Params) Get

func (params Params) Get(ctx context.Context, key string, defValue interface{}) (interface{}, error)

func (Params) GetBoolean

func (params Params) GetBoolean(ctx context.Context, key string, defValue bool) (bool, error)

func (Params) GetFloat32

func (params Params) GetFloat32(ctx context.Context, key string, defValue float32) (float32, error)

func (Params) GetFloat64

func (params Params) GetFloat64(ctx context.Context, key string, defValue float64) (float64, error)

func (Params) GetInt

func (params Params) GetInt(ctx context.Context, key string, defValue int) (int, error)

func (Params) GetInt16

func (params Params) GetInt16(ctx context.Context, key string, defValue int16) (int16, error)

func (Params) GetInt32

func (params Params) GetInt32(ctx context.Context, key string, defValue int32) (int32, error)

func (Params) GetInt64

func (params Params) GetInt64(ctx context.Context, key string, defValue int64) (int64, error)

func (Params) GetInt8

func (params Params) GetInt8(ctx context.Context, key string, defValue int8) (int8, error)

func (Params) GetString

func (params Params) GetString(ctx context.Context, key string, defValue string) (string, error)

func (Params) GetTime

func (params Params) GetTime(ctx context.Context, key string, defValue time.Time) (time.Time, error)

func (Params) GetUint

func (params Params) GetUint(ctx context.Context, key string, defValue uint) (uint, error)

func (Params) GetUint16

func (params Params) GetUint16(ctx context.Context, key string, defValue uint16) (uint16, error)

func (Params) GetUint32

func (params Params) GetUint32(ctx context.Context, key string, defValue uint32) (uint32, error)

func (Params) GetUint64

func (params Params) GetUint64(ctx context.Context, key string, defValue uint64) (uint64, error)

func (Params) GetUint8

func (params Params) GetUint8(ctx context.Context, key string, defValue uint8) (uint8, error)

func (Params) JSON

func (params Params) JSON() string

func (Params) Set

func (params Params) Set(ctx context.Context, key string, value interface{}) error

func (Params) SetBoolean

func (params Params) SetBoolean(ctx context.Context, key string, value bool) error

func (Params) SetFloat32

func (params Params) SetFloat32(ctx context.Context, key string, value float32) error

func (Params) SetFloat64

func (params Params) SetFloat64(ctx context.Context, key string, value float64) error

func (Params) SetInt

func (params Params) SetInt(ctx context.Context, key string, value int) error

func (Params) SetInt16

func (params Params) SetInt16(ctx context.Context, key string, value int16) error

func (Params) SetInt32

func (params Params) SetInt32(ctx context.Context, key string, value int32) error

func (Params) SetInt64

func (params Params) SetInt64(ctx context.Context, key string, value int64) error

func (Params) SetInt8

func (params Params) SetInt8(ctx context.Context, key string, value int8) error

func (Params) SetString

func (params Params) SetString(ctx context.Context, key string, value string) error

func (Params) SetTime

func (params Params) SetTime(ctx context.Context, key string, value time.Time) error

func (Params) SetUint

func (params Params) SetUint(ctx context.Context, key string, value uint) error

func (Params) SetUint16

func (params Params) SetUint16(ctx context.Context, key string, value uint16) error

func (Params) SetUint32

func (params Params) SetUint32(ctx context.Context, key string, value uint32) error

func (Params) SetUint64

func (params Params) SetUint64(ctx context.Context, key string, value uint64) error

func (Params) SetUint8

func (params Params) SetUint8(ctx context.Context, key string, value uint8) error

type RawBytes

type RawBytes []byte

type Reader

type Reader interface {
	Get(ctx context.Context, key string, defValue interface{}) (interface{}, error)

	GetInt(ctx context.Context, key string, defValue int) (int, error)
	GetInt8(ctx context.Context, key string, defValue int8) (int8, error)
	GetInt16(ctx context.Context, key string, defValue int16) (int16, error)
	GetInt32(ctx context.Context, key string, defValue int32) (int32, error)
	GetInt64(ctx context.Context, key string, defValue int64) (int64, error)

	GetUint(ctx context.Context, key string, defValue uint) (uint, error)
	GetUint8(ctx context.Context, key string, defValue uint8) (uint8, error)
	GetUint16(ctx context.Context, key string, defValue uint16) (uint16, error)
	GetUint32(ctx context.Context, key string, defValue uint32) (uint32, error)
	GetUint64(ctx context.Context, key string, defValue uint64) (uint64, error)

	GetFloat32(ctx context.Context, key string, defValue float32) (float32, error)
	GetFloat64(ctx context.Context, key string, defValue float64) (float64, error)

	GetString(ctx context.Context, key string, defValue string) (string, error)
	GetBoolean(ctx context.Context, key string, defValue bool) (bool, error)
	GetTime(ctx context.Context, key string, defValue time.Time) (time.Time, error)
}

func NewReader

func NewReader(getter Getter) Reader

type ReaderWriter

type ReaderWriter interface {
	Reader
	Writer
}

func NewReaderWriter

func NewReaderWriter(manager GetterSetter) ReaderWriter

type Scanner

type Scanner interface {
	Scan(src interface{}) error
}

Data scanner (see standard package database/sql)

type Serializer

type Serializer interface {
	Serialize(src interface{}) (string, error)
	Unserialize(src string, dst interface{}) error
}

func NewSerializer

func NewSerializer() Serializer

type Setter

type Setter interface {
	Set(ctx context.Context, key string, value interface{}) error
}

type Writer

type Writer interface {
	Set(ctx context.Context, key string, value interface{}) error

	SetInt(ctx context.Context, key string, value int) error
	SetInt8(ctx context.Context, key string, value int8) error
	SetInt16(ctx context.Context, key string, value int16) error
	SetInt32(ctx context.Context, key string, value int32) error
	SetInt64(ctx context.Context, key string, value int64) error

	SetUint(ctx context.Context, key string, value uint) error
	SetUint8(ctx context.Context, key string, value uint8) error
	SetUint16(ctx context.Context, key string, value uint16) error
	SetUint32(ctx context.Context, key string, value uint32) error
	SetUint64(ctx context.Context, key string, value uint64) error

	SetFloat32(ctx context.Context, key string, value float32) error
	SetFloat64(ctx context.Context, key string, value float64) error

	SetString(ctx context.Context, key string, value string) error
	SetBoolean(ctx context.Context, key string, value bool) error
	SetTime(ctx context.Context, key string, value time.Time) error
}

func NewWriter

func NewWriter(setter Setter) Writer

Jump to

Keyboard shortcuts

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