Documentation ¶
Index ¶
- Constants
- Variables
- func CleanupTimer(timer *time.Timer)
- func CopyPtr[T any](t *T) *T
- func CreateArrayContext(ctx context.Context, numItems int, curItem int) context.Context
- func DeepCopy[T Copyable](copyable Copyable) T
- func DeepCopySlice[I any, O any](in []I) (out []O)
- func DeepCopySliceWithConverter[I any, O any](in []I, converter func(I) O) (out []O)
- func Dump(data []byte, highlights ...int) string
- func DumpAnything(anything any, options ...func(*BoxOptions)) string
- func DumpFixedWidth(data []byte, desiredCharWidth int, highlights ...int) string
- func DuplicateIP(ip net.IP) net.IP
- func GenerateId(localLog zerolog.Logger, numBytes int) string
- func GetCurItemFromContext(ctx context.Context) int
- func GetIPAddresses(localLog zerolog.Logger, ctx context.Context, netInterface net.Interface, ...) (foundIps chan net.IP, err error)
- func GetLastItemFromContext(ctx context.Context) bool
- func GetNumItemsFromContext(ctx context.Context) int
- func GetSubgroupMatches(r *regexp.Regexp, query string) map[string]string
- func IncrementIP(ip net.IP) net.IP
- func InlineIf[T any](test bool, a func() T, b func() T) T
- func IsNil(v interface{}) bool
- func PlcValueUint8ListToByteArray(value values.PlcValue) []byte
- func RandomString(length int) string
- func StrToBool(str string) (bool, error)
- func StrToInt32(str string) (int32, error)
- func StrToString(s string) (string, error)
- func StrToUint16(str string) (uint16, error)
- func StrToUint32(str string) (uint32, error)
- func StrToUint8(str string) (uint8, error)
- func ToPtr[T any](v T) *T
- func WithAsciiBoxBoxSet(boxSet BoxSet) func(*BoxOptions)
- func WithAsciiBoxCharWidth(charWidth int) func(*BoxOptions)
- func WithAsciiBoxFooter(footer string) func(*BoxOptions)
- func WithAsciiBoxHeader(header string) func(*BoxOptions)
- func WithAsciiBoxName(name string) func(*BoxOptions)
- func WithAsciiBoxOptions(boxOptions BoxOptions) func(*BoxOptions)
- func WithAsciiBoxWriterDefaultBoxSet(boxSet BoxSet) func(*asciiBoxWriter)
- func WithAsciiBoxWriterDefaultColoredBoxes(nameColor, headerColor, footerColor *color.Color) func(*asciiBoxWriter)
- func WithAsciiBoxWriterDisableColoredBoxes() func(*asciiBoxWriter)
- func WithWriteBufferBoxBasedMergeSingleBoxes() func(*boxedWriteBuffer)
- func WithWriteBufferBoxBasedOmitEmptyBoxes() func(*boxedWriteBuffer)
- func WithWriteBufferBoxBasedPrintPosLengthFooter() func(*boxedWriteBuffer)
- type AlternateStringer
- type AsciiBox
- func (m AsciiBox) ChangeBoxFooter(newFooter string) AsciiBox
- func (m AsciiBox) ChangeBoxHeader(newHeader string) AsciiBox
- func (m AsciiBox) ChangeBoxName(newName string) AsciiBox
- func (m AsciiBox) GetBoxName() string
- func (m AsciiBox) Height() int
- func (m AsciiBox) IsEmpty() bool
- func (m AsciiBox) Lines() []string
- func (m AsciiBox) String() string
- func (m AsciiBox) Width() int
- type AsciiBoxWriter
- type AsciiBoxer
- type BoxOptions
- type BoxSet
- type BufferCommons
- func (b BufferCommons) ExtractAdditionalStringRepresentation(readerWriterArgs ...WithReaderWriterArgs) string
- func (b BufferCommons) ExtractEncoding(readerWriterArgs ...WithReaderWriterArgs) string
- func (b BufferCommons) IsToBeRenderedAsList(readerWriterArgs ...WithReaderWriterArgs) bool
- func (b BufferCommons) SanitizeLogicalName(logicalName string) string
- type ByteOrderAware
- type Copyable
- type CustomOption
- type ErrorIdentify
- type LengthAware
- type MultiError
- type ParseAssertError
- type ParseValidationError
- type PlcValuedeprecated
- type PositionAware
- type ReadBuffer
- type ReadBufferByteBased
- type ReadBufferByteBasedOptions
- type Serializable
- type Stack
- type TimeoutError
- type WithReaderArgs
- type WithReaderWriterArgs
- func UpcastReaderArgs(args ...WithReaderArgs) []WithReaderWriterArgs
- func UpcastWriterArgs(args ...WithWriterArgs) []WithReaderWriterArgs
- func WithAdditionalStringRepresentation(stringRepresentation string) WithReaderWriterArgs
- func WithEncoding(encoding string) WithReaderWriterArgs
- func WithRenderAsList(renderAsList bool) WithReaderWriterArgs
- type WithWriterArgs
- type WriteBuffer
- type WriteBufferBoxBased
- type WriteBufferByteBased
- type WriteBufferByteBasedOptions
- type WriteBufferJsonBased
- type WriteBufferXmlBased
Constants ¶
const DefaultWidth = 46 // 10 bytes per line on a []byte < 999
DefaultWidth defaults to a default screen dumps size
Variables ¶
var ANSI_PATTERN = regexp.MustCompile("[\u001b\u009b][\\[()#;?]*(?:[0-9]{1,4}(?:;[0-9]{0,4})*)?[0-9A-ORZcf-nqry=><]")
ANSI_PATTERN source: https://github.com/chalk/ansi-regex/blob/main/index.js#L3
var AsciiBoxLogger zerolog.Logger
var AsciiBoxWriterDefault = NewAsciiBoxWriter()
var AsciiBoxWriterLight = NewAsciiBoxWriter(WithAsciiBoxWriterDefaultBoxSet(DefaultLightBoxSet()))
var DebugAsciiBox bool
DebugAsciiBox set to true to get debug messages
var DebugHex bool
DebugHex set to true to get debug messages
Functions ¶
func CleanupTimer ¶
CleanupTimer stops a timer and purges anything left in the channel
and is safe to call even if the channel has already been received
func CreateArrayContext ¶
CreateArrayContext creates a new context, which contains information on the size and the current position in the array.
func DeepCopySlice ¶
DeepCopySlice copies as slice into a new one. Note: if slice contains pointer use DeepCopySliceWithConverter in combination with ToPtr
func DeepCopySliceWithConverter ¶
DeepCopySliceWithConverter copies as slice into a new one using converter for transformation
func DumpAnything ¶
func DumpAnything(anything any, options ...func(*BoxOptions)) string
DumpAnything dumps anything as hex
func DumpFixedWidth ¶
DumpFixedWidth dumps hex as hex string. The minimum width of string returned is 18 up to supplied charWidth
func GetCurItemFromContext ¶
GetCurItemFromContext helper to get access to the curItem value stored in the context.
func GetIPAddresses ¶
func GetLastItemFromContext ¶
GetLastItemFromContext helper to get access to the lastItem value which is calculated from data stored in the context.
func GetNumItemsFromContext ¶
GetNumItemsFromContext helper to get access to the numItems value stored in the context.
func RandomString ¶
RandomString returns a random string using the alphabet
func StrToInt32 ¶
func StrToString ¶
func StrToUint16 ¶
func StrToUint32 ¶
func StrToUint8 ¶
func WithAsciiBoxBoxSet ¶
func WithAsciiBoxBoxSet(boxSet BoxSet) func(*BoxOptions)
func WithAsciiBoxCharWidth ¶
func WithAsciiBoxCharWidth(charWidth int) func(*BoxOptions)
func WithAsciiBoxFooter ¶
func WithAsciiBoxFooter(footer string) func(*BoxOptions)
func WithAsciiBoxHeader ¶
func WithAsciiBoxHeader(header string) func(*BoxOptions)
func WithAsciiBoxName ¶
func WithAsciiBoxName(name string) func(*BoxOptions)
func WithAsciiBoxOptions ¶
func WithAsciiBoxOptions(boxOptions BoxOptions) func(*BoxOptions)
func WithAsciiBoxWriterDefaultBoxSet ¶
func WithAsciiBoxWriterDefaultBoxSet(boxSet BoxSet) func(*asciiBoxWriter)
func WithAsciiBoxWriterDisableColoredBoxes ¶
func WithAsciiBoxWriterDisableColoredBoxes() func(*asciiBoxWriter)
func WithWriteBufferBoxBasedMergeSingleBoxes ¶
func WithWriteBufferBoxBasedMergeSingleBoxes() func(*boxedWriteBuffer)
func WithWriteBufferBoxBasedOmitEmptyBoxes ¶
func WithWriteBufferBoxBasedOmitEmptyBoxes() func(*boxedWriteBuffer)
func WithWriteBufferBoxBasedPrintPosLengthFooter ¶
func WithWriteBufferBoxBasedPrintPosLengthFooter() func(*boxedWriteBuffer)
Types ¶
type AlternateStringer ¶
AlternateStringer can be implemented by stuff using the generator to give an alternate fmt.Stringer representation
type AsciiBox ¶
type AsciiBox struct {
// contains filtered or unexported fields
}
AsciiBox is a string surrounded by an ascii border (and an optional name)
func BoxAnything ¶
func BoxAnything(anything any, options ...func(*BoxOptions)) AsciiBox
func BoxedDump ¶
func BoxedDump(data []byte, options ...func(*BoxOptions)) AsciiBox
BoxedDump dumps a 56+2 char wide hex string
func BoxedDumpAnything ¶
func BoxedDumpAnything(anything any, options ...func(*BoxOptions)) AsciiBox
BoxedDumpAnything dumps anything as hex into a beautiful box
func (AsciiBox) ChangeBoxFooter ¶
func (AsciiBox) ChangeBoxHeader ¶
func (AsciiBox) ChangeBoxName ¶
func (AsciiBox) GetBoxName ¶
type AsciiBoxWriter ¶
type AsciiBoxWriter interface { BoxBox(box AsciiBox, options ...func(*BoxOptions)) AsciiBox BoxString(data string, options ...func(*BoxOptions)) AsciiBox AlignBoxes(asciiBoxes []AsciiBox, desiredWith int, options ...func(*BoxOptions)) AsciiBox BoxSideBySide(box1 AsciiBox, box2 AsciiBox, options ...func(*BoxOptions)) AsciiBox BoxBelowBox(box1 AsciiBox, box2 AsciiBox, options ...func(*BoxOptions)) AsciiBox }
func NewAsciiBoxWriter ¶
func NewAsciiBoxWriter(opts ...func(writer *asciiBoxWriter)) AsciiBoxWriter
type AsciiBoxer ¶
type AsciiBoxer interface { // Box with options Box(...func(*BoxOptions)) AsciiBox }
AsciiBoxer is used to render something in a box
type BoxOptions ¶
type BoxSet ¶
type BoxSet struct { UpperLeftCorner string UpperRightCorner string HorizontalLine string VerticalLine string LowerLeftCorner string LowerRightCorner string }
func DefaultBoxSet ¶
func DefaultBoxSet() BoxSet
func DefaultLightBoxSet ¶
func DefaultLightBoxSet() BoxSet
type BufferCommons ¶
type BufferCommons struct { }
func (BufferCommons) ExtractAdditionalStringRepresentation ¶
func (b BufferCommons) ExtractAdditionalStringRepresentation(readerWriterArgs ...WithReaderWriterArgs) string
func (BufferCommons) ExtractEncoding ¶
func (b BufferCommons) ExtractEncoding(readerWriterArgs ...WithReaderWriterArgs) string
func (BufferCommons) IsToBeRenderedAsList ¶
func (b BufferCommons) IsToBeRenderedAsList(readerWriterArgs ...WithReaderWriterArgs) bool
func (BufferCommons) SanitizeLogicalName ¶
func (b BufferCommons) SanitizeLogicalName(logicalName string) string
type ByteOrderAware ¶
type CustomOption ¶
type CustomOption struct {
// contains filtered or unexported fields
}
CustomOption can be used for transporting custom readerWriterArgs. Use NewCustomOption to create one.
func NewCustomOption ¶
func NewCustomOption() CustomOption
type ErrorIdentify ¶
ErrorIdentify is an interface defining the inline interface defined in errors.Is(err, target error) bool (wrap.go)
type LengthAware ¶
type MultiError ¶
type MultiError struct { // MainError denotes the error which summarize the error MainError error // Errors are the child errors Errors []error }
MultiError is a Wrapper for multiple Errors
func (*MultiError) Append ¶
func (m *MultiError) Append(err error)
func (*MultiError) DeepCopy ¶
func (m *MultiError) DeepCopy() any
func (*MultiError) Error ¶
func (m *MultiError) Error() string
func (*MultiError) Is ¶
func (m *MultiError) Is(target error) bool
type ParseAssertError ¶
func (ParseAssertError) Error ¶
func (e ParseAssertError) Error() string
func (ParseAssertError) Is ¶
func (e ParseAssertError) Is(target error) bool
type ParseValidationError ¶
type ParseValidationError struct {
Message string
}
func (ParseValidationError) Error ¶
func (e ParseValidationError) Error() string
func (ParseValidationError) Is ¶
func (e ParseValidationError) Is(target error) bool
type PositionAware ¶
type PositionAware interface { // GetPos return the current byte position GetPos() uint16 }
type ReadBuffer ¶
type ReadBuffer interface { PositionAware ByteOrderAware // Reset sets the position to the supplied byte position Reset(pos uint16) // HasMore returns true if there are bitLength bits available HasMore(bitLength uint8) bool // PullContext signals that we expect now a context with the supplied logical name PullContext(logicalName string, readerArgs ...WithReaderArgs) error ReadBit(logicalName string, readerArgs ...WithReaderArgs) (bool, error) ReadByte(logicalName string, readerArgs ...WithReaderArgs) (byte, error) ReadByteArray(logicalName string, numberOfBytes int, readerArgs ...WithReaderArgs) ([]byte, error) ReadUint8(logicalName string, bitLength uint8, readerArgs ...WithReaderArgs) (uint8, error) ReadUint16(logicalName string, bitLength uint8, readerArgs ...WithReaderArgs) (uint16, error) ReadUint32(logicalName string, bitLength uint8, readerArgs ...WithReaderArgs) (uint32, error) ReadUint64(logicalName string, bitLength uint8, readerArgs ...WithReaderArgs) (uint64, error) ReadInt8(logicalName string, bitLength uint8, readerArgs ...WithReaderArgs) (int8, error) ReadInt16(logicalName string, bitLength uint8, readerArgs ...WithReaderArgs) (int16, error) ReadInt32(logicalName string, bitLength uint8, readerArgs ...WithReaderArgs) (int32, error) ReadInt64(logicalName string, bitLength uint8, readerArgs ...WithReaderArgs) (int64, error) ReadBigInt(logicalName string, bitLength uint64, readerArgs ...WithReaderArgs) (*big.Int, error) ReadFloat32(logicalName string, bitLength uint8, readerArgs ...WithReaderArgs) (float32, error) ReadFloat64(logicalName string, bitLength uint8, readerArgs ...WithReaderArgs) (float64, error) ReadBigFloat(logicalName string, bitLength uint8, readerArgs ...WithReaderArgs) (*big.Float, error) ReadString(logicalName string, bitLength uint32, readerArgs ...WithReaderArgs) (string, error) // CloseContext signals that we expect the end of the context with the supplied logical name CloseContext(logicalName string, readerArgs ...WithReaderArgs) error }
func NewJsonReadBuffer ¶
func NewJsonReadBuffer(reader io.Reader) ReadBuffer
NewJsonReadBuffer return as ReadBuffer which doesn't validate attributes and lists
func NewStrictJsonReadBuffer ¶
func NewStrictJsonReadBuffer(reader io.Reader, validateAttr bool) ReadBuffer
NewStrictJsonReadBuffer return as ReadBuffer which does validate attributes on the setting
func NewStrictXmlReadBuffer ¶
func NewStrictXmlReadBuffer(reader io.Reader, validateAttr bool, validateList bool) ReadBuffer
NewStrictXmlReadBuffer return as ReadBuffer which does validate attributes and lists depending on the setting
func NewXmlReadBuffer ¶
func NewXmlReadBuffer(reader io.Reader) ReadBuffer
NewXmlReadBuffer return as ReadBuffer which doesn't validate attributes and lists
type ReadBufferByteBased ¶
type ReadBufferByteBased interface { ReadBuffer GetBytes() []byte GetTotalBytes() uint64 PeekByte(offset byte) byte }
func NewReadBufferByteBased ¶
func NewReadBufferByteBased(data []byte, options ...ReadBufferByteBasedOptions) ReadBufferByteBased
type ReadBufferByteBasedOptions ¶
type ReadBufferByteBasedOptions = func(b *byteReadBuffer)
func WithByteOrderForReadBufferByteBased ¶
func WithByteOrderForReadBufferByteBased(byteOrder binary.ByteOrder) ReadBufferByteBasedOptions
type Serializable ¶
type TimeoutError ¶
type TimeoutError struct {
// contains filtered or unexported fields
}
func NewTimeoutError ¶
func NewTimeoutError(timeout time.Duration) TimeoutError
func (TimeoutError) Error ¶
func (t TimeoutError) Error() string
func (TimeoutError) Is ¶
func (t TimeoutError) Is(target error) bool
type WithReaderArgs ¶
type WithReaderArgs interface {
// contains filtered or unexported methods
}
WithReaderArgs is a marker interface for reader args supplied by the builders
type WithReaderWriterArgs ¶
type WithReaderWriterArgs interface { WithReaderArgs WithWriterArgs }
WithReaderWriterArgs is a marker interface for reader args supplied by the builders
func UpcastReaderArgs ¶
func UpcastReaderArgs(args ...WithReaderArgs) []WithReaderWriterArgs
func UpcastWriterArgs ¶
func UpcastWriterArgs(args ...WithWriterArgs) []WithReaderWriterArgs
func WithAdditionalStringRepresentation ¶
func WithAdditionalStringRepresentation(stringRepresentation string) WithReaderWriterArgs
WithAdditionalStringRepresentation can be used by e.g. enums to supply an additional string representation
func WithEncoding ¶
func WithEncoding(encoding string) WithReaderWriterArgs
WithEncoding specifies an encoding
func WithRenderAsList ¶
func WithRenderAsList(renderAsList bool) WithReaderWriterArgs
WithRenderAsList indicates that an element can be rendered as list
type WithWriterArgs ¶
type WithWriterArgs interface {
// contains filtered or unexported methods
}
WithWriterArgs is a marker interface for writer args supplied by the builders like WithAdditionalStringRepresentation
type WriteBuffer ¶
type WriteBuffer interface { PositionAware ByteOrderAware // PushContext signals opening context with the supplied logical name PushContext(logicalName string, writerArgs ...WithWriterArgs) error WriteBit(logicalName string, value bool, writerArgs ...WithWriterArgs) error WriteByte(logicalName string, value byte, writerArgs ...WithWriterArgs) error WriteByteArray(logicalName string, data []byte, writerArgs ...WithWriterArgs) error WriteUint8(logicalName string, bitLength uint8, value uint8, writerArgs ...WithWriterArgs) error WriteUint16(logicalName string, bitLength uint8, value uint16, writerArgs ...WithWriterArgs) error WriteUint32(logicalName string, bitLength uint8, value uint32, writerArgs ...WithWriterArgs) error WriteUint64(logicalName string, bitLength uint8, value uint64, writerArgs ...WithWriterArgs) error WriteInt8(logicalName string, bitLength uint8, value int8, writerArgs ...WithWriterArgs) error WriteInt16(logicalName string, bitLength uint8, value int16, writerArgs ...WithWriterArgs) error WriteInt32(logicalName string, bitLength uint8, value int32, writerArgs ...WithWriterArgs) error WriteInt64(logicalName string, bitLength uint8, value int64, writerArgs ...WithWriterArgs) error WriteBigInt(logicalName string, bitLength uint8, value *big.Int, writerArgs ...WithWriterArgs) error WriteFloat32(logicalName string, bitLength uint8, value float32, writerArgs ...WithWriterArgs) error WriteFloat64(logicalName string, bitLength uint8, value float64, writerArgs ...WithWriterArgs) error WriteBigFloat(logicalName string, bitLength uint8, value *big.Float, writerArgs ...WithWriterArgs) error WriteString(logicalName string, bitLength uint32, value string, writerArgs ...WithWriterArgs) error WriteVirtual(ctx context.Context, logicalName string, value any, writerArgs ...WithWriterArgs) error WriteSerializable(ctx context.Context, serializable Serializable) error // PopContext signals work done with the context with the supplied logical name PopContext(logicalName string, writerArgs ...WithWriterArgs) error }
type WriteBufferBoxBased ¶
type WriteBufferBoxBased interface { WriteBuffer GetBox() AsciiBox }
func NewWriteBufferBoxBased ¶
func NewWriteBufferBoxBased(opts ...func(buffer *boxedWriteBuffer)) WriteBufferBoxBased
type WriteBufferByteBased ¶
type WriteBufferByteBased interface { WriteBuffer GetPos() uint16 GetBytes() []byte GetTotalBytes() uint64 }
func NewWriteBufferByteBased ¶
func NewWriteBufferByteBased(options ...WriteBufferByteBasedOptions) WriteBufferByteBased
type WriteBufferByteBasedOptions ¶
type WriteBufferByteBasedOptions = func(b *byteWriteBuffer)
func WithByteOrderForByteBasedBuffer ¶
func WithByteOrderForByteBasedBuffer(byteOrder binary.ByteOrder) WriteBufferByteBasedOptions
func WithCustomBufferForByteBasedBuffer ¶
func WithCustomBufferForByteBasedBuffer(buffer *bytes.Buffer) WriteBufferByteBasedOptions
func WithInitialSizeForByteBasedBuffer ¶
func WithInitialSizeForByteBasedBuffer(length int) WriteBufferByteBasedOptions
type WriteBufferJsonBased ¶
type WriteBufferJsonBased interface { WriteBuffer GetJsonString() (string, error) }
func NewJsonWriteBuffer ¶
func NewJsonWriteBuffer() WriteBufferJsonBased
func NewJsonWriteBufferWithOptions ¶
func NewJsonWriteBufferWithOptions(renderAttr bool) WriteBufferJsonBased
type WriteBufferXmlBased ¶
type WriteBufferXmlBased interface { WriteBuffer GetXmlString() string }
func NewConfiguredXmlWriteBuffer ¶
func NewConfiguredXmlWriteBuffer(renderLists bool, renderAttr bool) WriteBufferXmlBased
NewConfiguredXmlWriteBuffer returns a WriteBufferXmlBased which renders configured information into xml
func NewXmlWriteBuffer ¶
func NewXmlWriteBuffer() WriteBufferXmlBased
NewXmlWriteBuffer returns a WriteBufferXmlBased which renders all information into xml
Source Files ¶
- ArrayContext.go
- Buffer.go
- ByteOrderAware.go
- CastUtils.go
- Copyable.go
- Errors.go
- IdGenerator.go
- LengthAware.go
- Net.go
- PositionAware.go
- ReadBuffer.go
- ReadBufferByteBased.go
- ReadBufferJsonBased.go
- ReadBufferXmlBased.go
- Regexp.go
- Serializable.go
- StringUtils.go
- WriteBuffer.go
- WriteBufferBoxBased.go
- WriteBufferByteBased.go
- WriteBufferJsonBased.go
- WriteBufferXmlBased.go
- asciiBox.go
- bufferCommons.go
- common.go
- dumpUtils.go
- hex.go
- mock_requirements.go
- options.go