pkg

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2019 License: Apache-2.0 Imports: 8 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAttributeBoolValue

func GetAttributeBoolValue(obj interface{}, fieldName string) (bool, error)

GetAttributeBoolValue will try to obtain member variable's bool value

func GetAttributeFloat32Value

func GetAttributeFloat32Value(obj interface{}, fieldName string) (float32, error)

GetAttributeFloat32Value will try to obtain member variable's float32 value

func GetAttributeFloat64Value

func GetAttributeFloat64Value(obj interface{}, fieldName string) (float64, error)

GetAttributeFloat64Value will try to obtain member variable's float64 value

func GetAttributeInt16Value

func GetAttributeInt16Value(obj interface{}, fieldName string) (int16, error)

GetAttributeInt16Value will try to obtain member variable's int16 value

func GetAttributeInt32Value

func GetAttributeInt32Value(obj interface{}, fieldName string) (int32, error)

GetAttributeInt32Value will try to obtain member variable's int32 value

func GetAttributeInt64Value

func GetAttributeInt64Value(obj interface{}, fieldName string) (int64, error)

GetAttributeInt64Value will try to obtain member variable's int64 value

func GetAttributeInt8Value

func GetAttributeInt8Value(obj interface{}, fieldName string) (int8, error)

GetAttributeInt8Value will try to obtain member variable's int8 value

func GetAttributeIntValue

func GetAttributeIntValue(obj interface{}, fieldName string) (int, error)

GetAttributeIntValue will try to obtain member variable's int value

func GetAttributeInterface

func GetAttributeInterface(obj interface{}, fieldName string) (interface{}, error)

GetAttributeInterface will retrieve a members variable value as usable interface.

func GetAttributeList

func GetAttributeList(obj interface{}) ([]string, error)

GetAttributeList will populate list of struct's public member variable.

func GetAttributeStringValue

func GetAttributeStringValue(obj interface{}, fieldName string) (string, error)

GetAttributeStringValue will try to obtain member variable's string value

func GetAttributeTimeValue

func GetAttributeTimeValue(obj interface{}, fieldName string) (time.Time, error)

GetAttributeTimeValue will try to obtain member variable's time.Time value

func GetAttributeType

func GetAttributeType(obj interface{}, fieldName string) (reflect.Type, error)

GetAttributeType will return the type of a specific member variable

func GetAttributeUInt16Value

func GetAttributeUInt16Value(obj interface{}, fieldName string) (uint16, error)

GetAttributeUInt16Value will try to obtain member variable's uint16 value

func GetAttributeUInt32Value

func GetAttributeUInt32Value(obj interface{}, fieldName string) (uint32, error)

GetAttributeUInt32Value will try to obtain member variable's uint32 value

func GetAttributeUInt64Value

func GetAttributeUInt64Value(obj interface{}, fieldName string) (uint64, error)

GetAttributeUInt64Value will try to obtain member variable's uint64 value

func GetAttributeUInt8Value

func GetAttributeUInt8Value(obj interface{}, fieldName string) (uint8, error)

GetAttributeUInt8Value will try to obtain member variable's uint8 value

func GetAttributeUIntValue

func GetAttributeUIntValue(obj interface{}, fieldName string) (uint, error)

GetAttributeUIntValue will try to obtain member variable's uint value

func GetAttributeValue

func GetAttributeValue(obj interface{}, fieldName string) (reflect.Value, error)

GetAttributeValue will retrieve a members variable value.

func GetBaseKind

func GetBaseKind(val reflect.Value) reflect.Kind

GetBaseKind will try to obtain base obtainable kind of a value, so we know what method to call val.Int(), val.Uint(), etc.

func GetFunctionList

func GetFunctionList(obj interface{}) ([]string, error)

GetFunctionList get list of functions in a struct instance

func GetFunctionParameterTypes

func GetFunctionParameterTypes(obj interface{}, methodName string) ([]reflect.Type, error)

GetFunctionParameterTypes get list of parameter types of specific function in a struct instance

func GetFunctionReturnTypes

func GetFunctionReturnTypes(obj interface{}, methodName string) ([]reflect.Type, error)

GetFunctionReturnTypes get list of return types of specific function in a struct instance

func InvokeFunction

func InvokeFunction(obj interface{}, methodName string, param []interface{}) ([]interface{}, error)

InvokeFunction invokes a specific function in a struct instance, using parameters array

func IsAttributeArray

func IsAttributeArray(obj interface{}, fieldName string) (bool, error)

IsAttributeArray validate if a member variable is an array or a slice.

func IsAttributeMap

func IsAttributeMap(obj interface{}, fieldName string) (bool, error)

IsAttributeMap validate if a member variable is a map.

func IsAttributeNilOrZero

func IsAttributeNilOrZero(obj interface{}, fieldName string) (bool, error)

IsAttributeNilOrZero validate if a member variable is nil or zero.

func IsStruct

func IsStruct(obj interface{}) bool

IsStruct validates if an instance is struct or pointer to struct

func IsValidField

func IsValidField(obj interface{}, fieldName string) bool

IsValidField validates if an instance struct have a field with such name

func SetAttributeBoolValue

func SetAttributeBoolValue(obj interface{}, fieldName string, newValue bool) error

SetAttributeBoolValue will try to set member variable's bool value

func SetAttributeFloat32Value

func SetAttributeFloat32Value(obj interface{}, fieldName string, newValue float32) error

SetAttributeFloat32Value will try to set member variable's float32 value

func SetAttributeFloat64Value

func SetAttributeFloat64Value(obj interface{}, fieldName string, newValue float64) error

SetAttributeFloat64Value will try to set member variable's float64 value

func SetAttributeInt16Value

func SetAttributeInt16Value(obj interface{}, fieldName string, newValue int16) error

SetAttributeInt16Value will try to set member variable's int16 value

func SetAttributeInt32Value

func SetAttributeInt32Value(obj interface{}, fieldName string, newValue int32) error

SetAttributeInt32Value will try to set member variable's int32 value

func SetAttributeInt64Value

func SetAttributeInt64Value(obj interface{}, fieldName string, newValue int64) error

SetAttributeInt64Value will try to set member variable's int64 value

func SetAttributeInt8Value

func SetAttributeInt8Value(obj interface{}, fieldName string, newValue int8) error

SetAttributeInt8Value will try to set member variable's int8 value

func SetAttributeIntValue

func SetAttributeIntValue(obj interface{}, fieldName string, newValue int) error

SetAttributeIntValue will try to set member variable's int value

func SetAttributeInterface

func SetAttributeInterface(obj interface{}, fieldName string, value interface{}) error

SetAttributeInterface will try to set a member variable value with a value from an interface

func SetAttributeStringValue

func SetAttributeStringValue(obj interface{}, fieldName string, newValue string) error

SetAttributeStringValue will try to set member variable's string value

func SetAttributeTimeValue

func SetAttributeTimeValue(obj interface{}, fieldName string, newValue time.Time) error

SetAttributeTimeValue will try to set member variable's time.Time value

func SetAttributeUInt16Value

func SetAttributeUInt16Value(obj interface{}, fieldName string, newValue uint16) error

SetAttributeUInt16Value will try to set member variable's uint16 value

func SetAttributeUInt32Value

func SetAttributeUInt32Value(obj interface{}, fieldName string, newValue uint32) error

SetAttributeUInt32Value will try to set member variable's uint32 value

func SetAttributeUInt64Value

func SetAttributeUInt64Value(obj interface{}, fieldName string, newValue uint64) error

SetAttributeUInt64Value will try to set member variable's uint64 value

func SetAttributeUInt8Value

func SetAttributeUInt8Value(obj interface{}, fieldName string, newValue uint8) error

SetAttributeUInt8Value will try to set member variable's uint8 value

func SetAttributeUIntValue

func SetAttributeUIntValue(obj interface{}, fieldName string, newValue uint) error

SetAttributeUIntValue will try to set member variable's uint value

func SetAttributeValue

func SetAttributeValue(obj interface{}, fieldName string, value reflect.Value) error

SetAttributeValue will try to set a member variable value with a new one.

func ValueAdd

func ValueAdd(a, b reflect.Value) (reflect.Value, error)

ValueAdd will try to do a mathematical addition between two values. It will return another value as the result and an error if between the two values are not compatible for Addition

func ValueDiv

func ValueDiv(a, b reflect.Value) (reflect.Value, error)

ValueDiv will try to do a mathematical division between two values. It will return another value as the result and an error if between the two values are not compatible for division

func ValueMul

func ValueMul(a, b reflect.Value) (reflect.Value, error)

ValueMul will try to do a mathematical multiplication between two values. It will return another value as the result and an error if between the two values are not compatible for multiplication

func ValueSub

func ValueSub(a, b reflect.Value) (reflect.Value, error)

ValueSub will try to do a mathematical substraction between two values. It will return another value as the result and an error if between the two values are not compatible for substraction

func ValueToInterface

func ValueToInterface(v reflect.Value) interface{}

ValueToInterface will try to obtain an interface to a speciffic value. it will detect the value's kind.

Types

type BytesResource

type BytesResource struct {
	Bytes []byte
}

BytesResource is a struct that will hold the byte array data

func (*BytesResource) Load

func (res *BytesResource) Load() ([]byte, error)

Load will load the resource into byte array.

func (*BytesResource) String

func (res *BytesResource) String() string

String will state the resource byte array.

type FileResource

type FileResource struct {
	Path  string
	Bytes []byte
}

FileResource is a struct that will hold the file path and readed data bytes.

func (*FileResource) Load

func (res *FileResource) Load() ([]byte, error)

Load will load the resource into byte array.

func (*FileResource) String

func (res *FileResource) String() string

String will state the resource file path.

type ReaderResource

type ReaderResource struct {
	Reader io.Reader
}

ReaderResource is a struct that will hold the reader instance.

func (*ReaderResource) Load

func (res *ReaderResource) Load() ([]byte, error)

Load will load the resource into byte array.

func (*ReaderResource) String

func (res *ReaderResource) String() string

String will state the resource source.

type Resource

type Resource interface {
	Load() ([]byte, error)
	String() string
}

Resource should be implemented by any resource model so it can be loaded and parsed by the grool parser.

func NewBytesResource

func NewBytesResource(bytes []byte) Resource

NewBytesResource will create a new Resource using a byte array.

func NewFileResource

func NewFileResource(path string) Resource

NewFileResource will create a new Resource using a file located in path.

func NewReaderResource

func NewReaderResource(reader io.Reader) Resource

NewReaderResource will create a new Resource using a common reader.

func NewURLResource

func NewURLResource(url string) Resource

NewURLResource will create a new Resource using a resource as located in the url

type URLResource

type URLResource struct {
	URL   string
	Bytes []byte
}

URLResource is a struct that will hold the byte array data and URL source

func (*URLResource) Load

func (res *URLResource) Load() ([]byte, error)

Load will load the resource into byte array.

func (*URLResource) String

func (res *URLResource) String() string

String will state the resource url.

Jump to

Keyboard shortcuts

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