Documentation
¶
Index ¶
- Constants
- Variables
- func Assign(dst, src any) (ok bool)
- func AssignBuf(dst, src any, buf AccumulativeBuffer) (ok bool)
- func AssignToBool(dst, src any, _ AccumulativeBuffer) (ok bool)
- func AssignToBytes(dst, src any, buf AccumulativeBuffer) (ok bool)
- func AssignToFloat(dst, src any, _ AccumulativeBuffer) (ok bool)
- func AssignToInt(dst, src any, _ AccumulativeBuffer) (ok bool)
- func AssignToStr(dst, src any, buf AccumulativeBuffer) (ok bool)
- func AssignToUint(dst, src any, _ AccumulativeBuffer) (ok bool)
- func Bufferize(buf, p []byte) ([]byte, []byte)
- func BufferizeString(buf []byte, s string) ([]byte, string)
- func DEQMustCheck(path string, options *DEQOptions) bool
- func EqualFloat32(a, b float32, opts *DEQOptions) bool
- func EqualFloat64(a, b float64, opts *DEQOptions) bool
- func RegisterAssignFn(fn AssignFn)
- func RegisterInspector(name string, ins Inspector)
- func RegisterStrToXFn(typ, snippet string, imports []string)
- func StrConvSnippet(s, typn, typu, _var string) (string, []string, error)
- type AccumulativeBuffer
- type AssignFn
- type BaseInspector
- func (i BaseInspector) Capacity(_ any, _ *int, _ ...string) error
- func (i BaseInspector) Compare(_ any, _ Op, _ string, _ *bool, _ ...string) error
- func (i BaseInspector) Copy(_ any) (dst any, err error)
- func (i BaseInspector) CopyTo(_, _ any, _ AccumulativeBuffer) error
- func (i BaseInspector) DeepEqual(l, r any) bool
- func (i BaseInspector) DeepEqualWithOptions(_, _ any, _ *DEQOptions) bool
- func (i BaseInspector) Get(_ any, _ ...string) (any, error)
- func (i BaseInspector) GetTo(_ any, _ *any, _ ...string) error
- func (i BaseInspector) Length(_ any, _ *int, _ ...string) error
- func (i BaseInspector) Loop(_ any, _ Iterator, _ *[]byte, _ ...string) error
- func (i BaseInspector) Reset(_ any) error
- func (i BaseInspector) Set(_, _ any, _ ...string) error
- func (i BaseInspector) SetWithBuffer(_, _ any, _ AccumulativeBuffer, _ ...string) error
- func (i BaseInspector) TypeName() string
- func (i BaseInspector) Unmarshal(_ []byte, _ Encoding) (any, error)
- type ByteBuffer
- type ByteStringWriter
- type Compiler
- type Config
- type DEQOptions
- type Encoding
- type Inspector
- type Iterator
- type Logger
- type LoopCtl
- type Op
- type ReflectInspector
- func (i ReflectInspector) Capacity(_ any, _ *int, _ ...string) error
- func (i ReflectInspector) Compare(_ any, _ Op, _ string, _ *bool, _ ...string) error
- func (i ReflectInspector) Copy(x any) (any, error)
- func (i ReflectInspector) CopyTo(_, _ any, _ AccumulativeBuffer) error
- func (i ReflectInspector) DeepEqual(l, r any) bool
- func (i ReflectInspector) DeepEqualWithOptions(l, r any, _ *DEQOptions) bool
- func (i ReflectInspector) Get(src any, path ...string) (any, error)
- func (i ReflectInspector) GetTo(src any, buf *any, path ...string) error
- func (i ReflectInspector) Length(_ any, _ *int, _ ...string) error
- func (i ReflectInspector) Loop(_ any, _ Iterator, _ *[]byte, _ ...string) (err error)
- func (i ReflectInspector) Reset(_ any) error
- func (i ReflectInspector) Set(_, _ any, _ ...string) error
- func (i ReflectInspector) SetWithBuffer(_, _ any, _ AccumulativeBuffer, _ ...string) error
- func (i ReflectInspector) TypeName() string
- func (i ReflectInspector) Unmarshal(p []byte, typ Encoding) (any, error)
- type StaticInspector
- func (i StaticInspector) Capacity(x any, result *int, _ ...string) error
- func (i StaticInspector) Compare(src any, cond Op, right string, result *bool, _ ...string) error
- func (i StaticInspector) Copy(x any) (dst any, err error)
- func (i StaticInspector) CopyTo(src, dst any, buf AccumulativeBuffer) error
- func (i StaticInspector) DeepEqual(l, r any) bool
- func (i StaticInspector) DeepEqualWithOptions(l, r any, _ *DEQOptions) bool
- func (i StaticInspector) Get(src any, _ ...string) (any, error)
- func (i StaticInspector) GetTo(src any, buf *any, _ ...string) error
- func (i StaticInspector) Length(x any, result *int, _ ...string) error
- func (i StaticInspector) Loop(_ any, _ Iterator, _ *[]byte, _ ...string) error
- func (i StaticInspector) Reset(x any) error
- func (i StaticInspector) Set(_, _ any, _ ...string) error
- func (i StaticInspector) SetWithBuffer(_, _ any, _ AccumulativeBuffer, _ ...string) error
- func (i StaticInspector) TypeName() string
- func (i StaticInspector) Unmarshal(p []byte, typ Encoding) (any, error)
- type StrConv
- type StringAnyMapInspector
- func (i StringAnyMapInspector) Capacity(x any, result *int, path ...string) error
- func (i StringAnyMapInspector) Compare(src any, cond Op, right string, result *bool, path ...string) (err error)
- func (i StringAnyMapInspector) Copy(x any) (dst any, err error)
- func (i StringAnyMapInspector) CopyTo(src, dst any, buf AccumulativeBuffer) (err error)
- func (i StringAnyMapInspector) DeepEqual(l, r any) bool
- func (i StringAnyMapInspector) DeepEqualWithOptions(l, r any, opts *DEQOptions) bool
- func (i StringAnyMapInspector) Get(src any, path ...string) (any, error)
- func (i StringAnyMapInspector) GetTo(src any, buf *any, path ...string) error
- func (i StringAnyMapInspector) Length(x any, result *int, path ...string) error
- func (i StringAnyMapInspector) Loop(src any, it Iterator, buf *[]byte, path ...string) error
- func (i StringAnyMapInspector) Reset(x any) error
- func (i StringAnyMapInspector) Set(dst, value any, path ...string) error
- func (i StringAnyMapInspector) SetWithBuffer(dst, value any, buf AccumulativeBuffer, path ...string) (err error)
- func (i StringAnyMapInspector) TypeName() string
- func (i StringAnyMapInspector) Unmarshal(p []byte, typ Encoding) (any, error)
- type StringsInspector
- func (i StringsInspector) Capacity(src any, result *int, path ...string) error
- func (i StringsInspector) Compare(src any, cond Op, right string, result *bool, path ...string) error
- func (i StringsInspector) Copy(x any) (any, error)
- func (i StringsInspector) CopyTo(src, dst any, buf AccumulativeBuffer) error
- func (i StringsInspector) DeepEqual(l, r any) bool
- func (i StringsInspector) DeepEqualWithOptions(l, r any, _ *DEQOptions) bool
- func (i StringsInspector) Get(src any, path ...string) (any, error)
- func (i StringsInspector) GetTo(src any, buf *any, path ...string) error
- func (i StringsInspector) Length(src any, result *int, path ...string) error
- func (i StringsInspector) Loop(src any, l Iterator, buf *[]byte, path ...string) error
- func (i StringsInspector) Reset(x any) error
- func (i StringsInspector) Set(dst, value any, path ...string) error
- func (i StringsInspector) SetWithBuffer(dst, value any, buf AccumulativeBuffer, path ...string) error
- func (i StringsInspector) TypeName() string
- func (i StringsInspector) Unmarshal(p []byte, typ Encoding) (any, error)
- type Target
Constants ¶
const FloatPrecision = 1e-3
const Nil = "nil"
Variables ¶
var ( ErrNoConfig = errors.New("no config provided") ErrUnknownTarget = errors.New("unknown target provided") ErrUnknownInspector = errors.New("unknown inspector") ErrNoGOPATH = errors.New("no GOPATH variable found") ErrDstNotExists = errors.New("destination directory doesn't exists") ErrUnknownEncodingType = errors.New("unknown encoding type") ErrUnsupportedType = errors.New("unsupported type") ErrMustPointerType = errors.New("variable must have pointer type") ErrNotImplement = errors.New("not implemented") )
var (
ErrNoConvFunc = errors.New("convert function doesn't exists")
)
Functions ¶
func AssignBuf ¶
func AssignBuf(dst, src any, buf AccumulativeBuffer) (ok bool)
AssignBuf is a generic buffered assign function.
Walks other registered assign callbacks and try to execute each of them. Stops when current callback return true.
func AssignToBool ¶
func AssignToBool(dst, src any, _ AccumulativeBuffer) (ok bool)
AssignToBool assign(converts) source to bool destination.
func AssignToBytes ¶
func AssignToBytes(dst, src any, buf AccumulativeBuffer) (ok bool)
AssignToBytes assigns(converts) source to bytes destination.
func AssignToFloat ¶
func AssignToFloat(dst, src any, _ AccumulativeBuffer) (ok bool)
AssignToFloat assigns(converts) source to float destination.
func AssignToInt ¶
func AssignToInt(dst, src any, _ AccumulativeBuffer) (ok bool)
AssignToInt assigns(converts) source to int destination.
func AssignToStr ¶
func AssignToStr(dst, src any, buf AccumulativeBuffer) (ok bool)
AssignToStr assigns(converts) source to string destination.
func AssignToUint ¶
func AssignToUint(dst, src any, _ AccumulativeBuffer) (ok bool)
AssignToUint assigns(converts) source to unsigned int destination.
func Bufferize ¶
Bufferize appends p to the buffer and returns both pointers to buffer and buffered data.
func BufferizeString ¶
BufferizeString appends s to the buffer and returns both pointers to buffer and buffered data.
func DEQMustCheck ¶
func DEQMustCheck(path string, options *DEQOptions) bool
DEQMustCheck makes a decision must field (by given path) checks or not during DeepEqual().
func EqualFloat32 ¶
func EqualFloat32(a, b float32, opts *DEQOptions) bool
func EqualFloat64 ¶
func EqualFloat64(a, b float64, opts *DEQOptions) bool
func RegisterAssignFn ¶
func RegisterAssignFn(fn AssignFn)
RegisterAssignFn registers new assign function to the registry.
func RegisterInspector ¶
RegisterInspector saves inspector to the registry.
func RegisterStrToXFn ¶ added in v1.4.2
RegisterStrToXFn registers new snippet.
Types ¶
type AccumulativeBuffer ¶
type AccumulativeBuffer interface { // AcquireBytes returns more space to use. AcquireBytes() []byte // ReleaseBytes returns space to the buffer. ReleaseBytes([]byte) // Bufferize makes a copy of p to buffer and returns pointer to copy. Bufferize(p []byte) []byte // BufferizeString makes a copy of s to buffer and returns pointer to copy. BufferizeString(s string) string // Reset all accumulated data. Reset() }
AccumulativeBuffer describes buffer that accumulates bytes data. Collects data during inspector functions work.
type AssignFn ¶
type AssignFn func(dst, src any, buf AccumulativeBuffer) bool
AssignFn describes signature of assign function.
Assigns src to dst with dynamic typecasting. Returns true if typecasting success, false otherwise.
type BaseInspector ¶
type BaseInspector struct{}
BaseInspector describes base struct.
func (BaseInspector) Capacity ¶ added in v1.4.5
func (i BaseInspector) Capacity(_ any, _ *int, _ ...string) error
func (BaseInspector) CopyTo ¶ added in v1.4.5
func (i BaseInspector) CopyTo(_, _ any, _ AccumulativeBuffer) error
func (BaseInspector) DeepEqual ¶ added in v1.4.5
func (i BaseInspector) DeepEqual(l, r any) bool
func (BaseInspector) DeepEqualWithOptions ¶ added in v1.4.5
func (i BaseInspector) DeepEqualWithOptions(_, _ any, _ *DEQOptions) bool
func (BaseInspector) Get ¶ added in v1.4.5
func (i BaseInspector) Get(_ any, _ ...string) (any, error)
func (BaseInspector) GetTo ¶ added in v1.4.5
func (i BaseInspector) GetTo(_ any, _ *any, _ ...string) error
func (BaseInspector) Length ¶ added in v1.4.5
func (i BaseInspector) Length(_ any, _ *int, _ ...string) error
func (BaseInspector) Reset ¶ added in v1.4.5
func (i BaseInspector) Reset(_ any) error
func (BaseInspector) SetWithBuffer ¶ added in v1.4.5
func (i BaseInspector) SetWithBuffer(_, _ any, _ AccumulativeBuffer, _ ...string) error
func (BaseInspector) TypeName ¶ added in v1.4.5
func (i BaseInspector) TypeName() string
type ByteBuffer ¶
type ByteBuffer struct {
// contains filtered or unexported fields
}
func NewByteBuffer ¶
func NewByteBuffer(size int) *ByteBuffer
func (*ByteBuffer) AcquireBytes ¶
func (b *ByteBuffer) AcquireBytes() []byte
func (*ByteBuffer) Bufferize ¶ added in v1.4.2
func (b *ByteBuffer) Bufferize(p []byte) []byte
func (*ByteBuffer) BufferizeString ¶ added in v1.4.2
func (b *ByteBuffer) BufferizeString(s string) string
func (*ByteBuffer) ReleaseBytes ¶
func (b *ByteBuffer) ReleaseBytes(p []byte)
func (*ByteBuffer) Reset ¶
func (b *ByteBuffer) Reset()
type ByteStringWriter ¶
type ByteStringWriter interface { Write(p []byte) (n int, err error) WriteByte(c byte) error WriteString(s string) (n int, err error) Bytes() []byte String() string Reset() }
ByteStringWriter is an extended writer interface.
type Compiler ¶
type Compiler struct {
// contains filtered or unexported fields
}
func NewCompiler ¶
type Config ¶ added in v1.4.3
type Config struct { // Target points to source for parsing (package, directory or file). Target Target // Package indicates source directory relatives to GOPATH (or modules) directory. Package string // Directory indicates source directory contains go files. Directory string // File indicates path to Go file. File string // Destination directory path. Destination string // Package to import inspector code. // Required for directory or file targets. Import string // Registry of blacklisted types. BlackList map[string]struct{} // Flag denies destination directory cleaning. NoClean bool // Flag denies compiling inspectors to separate files. // Reserved, still not works. NoSplit bool // Flag if destination equals source. InPlace bool // Continue even if error occurred. Force bool // Path to build debug data in XML format. XML string // Output buffer. Buf ByteStringWriter // Logger of debug messages. Logger Logger }
type DEQOptions ¶
type DEQOptions struct { // Float fields comparison precision. Precision float64 // List of fields to exclude from check. Exclude map[string]struct{} // Limit fields to check. Filter map[string]struct{} }
DEQOptions describes DeepEqual options.
type Inspector ¶
type Inspector interface { // TypeName returns name of underlying type. TypeName() string // Get returns value from src according path. Get(src any, path ...string) (any, error) // GetTo writes value from src to buf according path. GetTo(src any, buf *any, path ...string) error // Set sets value to dst according path. Set(dst, value any, path ...string) error // SetWithBuffer is a buffered version of Set(). SetWithBuffer(dst, value any, buf AccumulativeBuffer, path ...string) error // Compare applies condition cond to value in src by path and right. // Result will set to result buffer. Compare(src any, cond Op, right string, result *bool, path ...string) error // Loop iterates in src value taking by path using iterator iter. Loop(src any, iter Iterator, buf *[]byte, path ...string) error // DeepEqual compares l and r. DeepEqual(l, r any) bool // DeepEqualWithOptions compares l and r corresponding options. DeepEqualWithOptions(l, r any, options *DEQOptions) bool // Unmarshal parses encoded data according encoding type. Unmarshal(p []byte, typ Encoding) (any, error) // Copy makes a copy of x. Copy(x any) (any, error) // CopyTo makes a copy of src to dst using buffer. CopyTo(src, dst any, buf AccumulativeBuffer) error // Length puts length of field value by path in src to the buffer. Length(src any, result *int, path ...string) error // Capacity puts capacity of field value by path in src to the buffer. Capacity(src any, result *int, path ...string) error // Reset resets x. Reset(x any) error }
Inspector signature.
func GetInspector ¶
GetInspector returns inspector from the registry.
type Iterator ¶ added in v1.4.2
type Iterator interface { // RequireKey checks set key requirement. RequireKey() bool // SetKey sets the key value and inspector to hidden context. SetKey(val any, ins Inspector) // SetVal sets the value and inspector to context. SetVal(val any, ins Inspector) // Iterate performs the iteration. Iterate() LoopCtl }
Iterator signature.
type ReflectInspector ¶
type ReflectInspector struct {
BaseInspector
}
func (ReflectInspector) Capacity ¶ added in v1.4.2
func (i ReflectInspector) Capacity(_ any, _ *int, _ ...string) error
func (ReflectInspector) CopyTo ¶
func (i ReflectInspector) CopyTo(_, _ any, _ AccumulativeBuffer) error
func (ReflectInspector) DeepEqual ¶
func (i ReflectInspector) DeepEqual(l, r any) bool
func (ReflectInspector) DeepEqualWithOptions ¶
func (i ReflectInspector) DeepEqualWithOptions(l, r any, _ *DEQOptions) bool
func (ReflectInspector) GetTo ¶
func (i ReflectInspector) GetTo(src any, buf *any, path ...string) error
func (ReflectInspector) Length ¶ added in v1.4.2
func (i ReflectInspector) Length(_ any, _ *int, _ ...string) error
func (ReflectInspector) Reset ¶
func (i ReflectInspector) Reset(_ any) error
func (ReflectInspector) SetWithBuffer ¶ added in v1.4.2
func (i ReflectInspector) SetWithBuffer(_, _ any, _ AccumulativeBuffer, _ ...string) error
func (ReflectInspector) TypeName ¶
func (i ReflectInspector) TypeName() string
type StaticInspector ¶
type StaticInspector struct {
BaseInspector
}
func (StaticInspector) Capacity ¶ added in v1.4.2
func (i StaticInspector) Capacity(x any, result *int, _ ...string) error
func (StaticInspector) CopyTo ¶
func (i StaticInspector) CopyTo(src, dst any, buf AccumulativeBuffer) error
func (StaticInspector) DeepEqual ¶
func (i StaticInspector) DeepEqual(l, r any) bool
func (StaticInspector) DeepEqualWithOptions ¶
func (i StaticInspector) DeepEqualWithOptions(l, r any, _ *DEQOptions) bool
func (StaticInspector) Length ¶ added in v1.4.2
func (i StaticInspector) Length(x any, result *int, _ ...string) error
func (StaticInspector) Reset ¶
func (i StaticInspector) Reset(x any) error
func (StaticInspector) SetWithBuffer ¶ added in v1.4.2
func (i StaticInspector) SetWithBuffer(_, _ any, _ AccumulativeBuffer, _ ...string) error
func (StaticInspector) TypeName ¶
func (i StaticInspector) TypeName() string
type StringAnyMapInspector ¶ added in v1.4.4
type StringAnyMapInspector struct {
BaseInspector
}
func (StringAnyMapInspector) Capacity ¶ added in v1.4.4
func (i StringAnyMapInspector) Capacity(x any, result *int, path ...string) error
func (StringAnyMapInspector) Copy ¶ added in v1.4.4
func (i StringAnyMapInspector) Copy(x any) (dst any, err error)
func (StringAnyMapInspector) CopyTo ¶ added in v1.4.4
func (i StringAnyMapInspector) CopyTo(src, dst any, buf AccumulativeBuffer) (err error)
func (StringAnyMapInspector) DeepEqual ¶ added in v1.4.4
func (i StringAnyMapInspector) DeepEqual(l, r any) bool
func (StringAnyMapInspector) DeepEqualWithOptions ¶ added in v1.4.4
func (i StringAnyMapInspector) DeepEqualWithOptions(l, r any, opts *DEQOptions) bool
func (StringAnyMapInspector) Get ¶ added in v1.4.4
func (i StringAnyMapInspector) Get(src any, path ...string) (any, error)
func (StringAnyMapInspector) GetTo ¶ added in v1.4.4
func (i StringAnyMapInspector) GetTo(src any, buf *any, path ...string) error
func (StringAnyMapInspector) Length ¶ added in v1.4.4
func (i StringAnyMapInspector) Length(x any, result *int, path ...string) error
func (StringAnyMapInspector) Reset ¶ added in v1.4.4
func (i StringAnyMapInspector) Reset(x any) error
func (StringAnyMapInspector) Set ¶ added in v1.4.4
func (i StringAnyMapInspector) Set(dst, value any, path ...string) error
func (StringAnyMapInspector) SetWithBuffer ¶ added in v1.4.4
func (i StringAnyMapInspector) SetWithBuffer(dst, value any, buf AccumulativeBuffer, path ...string) (err error)
func (StringAnyMapInspector) TypeName ¶ added in v1.4.4
func (i StringAnyMapInspector) TypeName() string
type StringsInspector ¶ added in v1.4.2
type StringsInspector struct{}
StringsInspector is a built-in inspector for []string/[][]byte types.
func (StringsInspector) Capacity ¶ added in v1.4.2
func (i StringsInspector) Capacity(src any, result *int, path ...string) error
func (StringsInspector) CopyTo ¶ added in v1.4.2
func (i StringsInspector) CopyTo(src, dst any, buf AccumulativeBuffer) error
func (StringsInspector) DeepEqual ¶ added in v1.4.2
func (i StringsInspector) DeepEqual(l, r any) bool
func (StringsInspector) DeepEqualWithOptions ¶ added in v1.4.2
func (i StringsInspector) DeepEqualWithOptions(l, r any, _ *DEQOptions) bool
func (StringsInspector) Get ¶ added in v1.4.2
func (i StringsInspector) Get(src any, path ...string) (any, error)
func (StringsInspector) GetTo ¶ added in v1.4.2
func (i StringsInspector) GetTo(src any, buf *any, path ...string) error
func (StringsInspector) Length ¶ added in v1.4.2
func (i StringsInspector) Length(src any, result *int, path ...string) error
func (StringsInspector) Reset ¶ added in v1.4.2
func (i StringsInspector) Reset(x any) error
func (StringsInspector) Set ¶ added in v1.4.2
func (i StringsInspector) Set(dst, value any, path ...string) error
func (StringsInspector) SetWithBuffer ¶ added in v1.4.2
func (i StringsInspector) SetWithBuffer(dst, value any, buf AccumulativeBuffer, path ...string) error
func (StringsInspector) TypeName ¶ added in v1.4.2
func (i StringsInspector) TypeName() string