comdef

package
v0.6.15 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 6 Imported by: 5

Documentation

Overview

Package comdef provide some common type or constant definitions

Index

Constants

View Source
const (
	OpEq  = "="
	OpNeq = "!="
	OpLt  = "<"
	OpLte = "<="
	OpGt  = ">"
	OpGte = ">="
)

consts for compare operation

View Source
const (
	SingleQuote = '\''
	DoubleQuote = '"'
	SlashQuote  = '\\'

	SingleQuoteStr = "'"
	DoubleQuoteStr = `"`
	SlashQuoteStr  = "\\"
)

consts quote chars

View Source
const (
	// CommaStr const define
	CommaStr = ","
	// CommaChar define
	CommaChar = ','

	// EqualStr define
	EqualStr = "="
	// EqualChar define
	EqualChar = '='

	// ColonStr define
	ColonStr = ":"
	// ColonChar define
	ColonChar = ':'

	// SemicolonStr semicolon define
	SemicolonStr = ";"
	// SemicolonChar define
	SemicolonChar = ';'

	// PathStr define const
	PathStr = "/"
	// PathChar define
	PathChar = '/'

	// DefaultSep comma string
	DefaultSep = ","

	// SpaceChar char
	SpaceChar = ' '
	// SpaceStr string
	SpaceStr = " "

	// NewlineChar char
	NewlineChar = '\n'
	// NewlineStr string
	NewlineStr = "\n"
)
View Source
const NoIdx = -1

NoIdx invalid index or length

Variables

View Source
var ErrConvType = errors.New("convert value type error")

ErrConvType error

Functions

This section is empty.

Types

type BaseFormatter

type BaseFormatter struct {

	// Out formatted to the writer
	Out io.Writer
	// Src data(array, map, struct) for format
	Src any
	// MaxDepth limit depth for array, map data TODO
	MaxDepth int
	// Prefix string for each element
	Prefix string
	// Indent string for format each element
	Indent string
	// ClosePrefix string for last "]", "}"
	ClosePrefix string
	// contains filtered or unexported fields
}

BaseFormatter struct

func (*BaseFormatter) BsWriter

func (f *BaseFormatter) BsWriter() ByteStringWriter

BsWriter build and get

func (*BaseFormatter) Reset

func (f *BaseFormatter) Reset()

Reset after format

func (*BaseFormatter) SetOutput

func (f *BaseFormatter) SetOutput(out io.Writer)

SetOutput writer

type ByteStringWriter

type ByteStringWriter interface {
	io.Writer
	io.ByteWriter
	io.StringWriter
	fmt.Stringer
}

ByteStringWriter interface

type Compared added in v0.6.11

type Compared interface {
	Int | Uint | Float | ~string
}

Compared type. alias of constraints.SortedType

TODO: use type alias, will error on go1.18 Error: types.go:50: interface contains type constraints type Compared = SortedType

type DataFormatter

type DataFormatter interface {
	Format() string
	FormatTo(w io.Writer)
}

DataFormatter interface

type Errors added in v0.6.15

type Errors []error

Errors multi error list

func (Errors) ErrOrNil added in v0.6.15

func (es Errors) ErrOrNil() error

ErrOrNil error

func (Errors) Error added in v0.6.15

func (es Errors) Error() string

Error string

func (Errors) First added in v0.6.15

func (es Errors) First() error

First error

type Float added in v0.6.0

type Float interface {
	~float32 | ~float64
}

Float interface type

type Float64able added in v0.6.15

type Float64able interface {
	Float64() (float64, error)
}

Float64able interface

type Int added in v0.6.0

type Int interface {
	~int | ~int8 | ~int16 | ~int32 | ~int64
}

Int interface type

type Int64able added in v0.6.11

type Int64able interface {
	Int64() (int64, error)
}

Int64able interface

type IntCheckFunc added in v0.6.11

type IntCheckFunc func(val int) error

IntCheckFunc check func

type IntOrFloat added in v0.6.0

type IntOrFloat interface {
	Int | Float
}

IntOrFloat interface type. all int and float types

type Integer added in v0.6.11

type Integer interface {
	Int | Uint
}

Integer interface type. all int or uint types

type MarshalFunc

type MarshalFunc func(v any) ([]byte, error)

MarshalFunc define

type MatchFunc added in v0.6.11

type MatchFunc[T any] func(v T) bool

MatchFunc definition. implements Matcher interface

func (MatchFunc[T]) Match added in v0.6.11

func (fn MatchFunc[T]) Match(v T) bool

Match satisfies the Matcher interface

type Matcher added in v0.6.11

type Matcher[T any] interface {
	Match(s T) bool
}

Matcher interface

type SafeStringFunc added in v0.6.12

type SafeStringFunc func(v any) string

SafeStringFunc safe convert value to string

type ScalarType added in v0.6.0

type ScalarType interface {
	Int | Uint | Float | ~string | ~bool
}

ScalarType interface type.

TIP: has bool type, it cannot be ordered

contains: (x)int, float, ~string, ~bool types

type SimpleType added in v0.6.11

type SimpleType interface {
	Int | Uint | Float | ~string | ~bool
}

SimpleType interface type. alias of ScalarType

contains: (x)int, float, ~string, ~bool types

type SortedType added in v0.6.2

type SortedType interface {
	Int | Uint | Float | ~string
}

SortedType interface type. same of constraints.Ordered

it can be ordered, that supports the operators < <= >= >.

contains: (x)int, float, ~string types

type StrCheckFunc added in v0.6.11

type StrCheckFunc func(val string) error

StrCheckFunc check func

type StringHandleFunc added in v0.6.11

type StringHandleFunc func(s string) string

StringHandleFunc definition

func (StringHandleFunc) Handle added in v0.6.11

func (fn StringHandleFunc) Handle(s string) string

Handle satisfies the StringHandler interface

type StringHandler added in v0.6.11

type StringHandler interface {
	Handle(s string) string
}

StringHandler interface

type StringMatchFunc added in v0.6.10

type StringMatchFunc func(s string) bool

StringMatchFunc definition

func (StringMatchFunc) Match added in v0.6.10

func (fn StringMatchFunc) Match(s string) bool

Match satisfies the StringMatcher interface

type StringMatcher added in v0.6.10

type StringMatcher interface {
	Match(s string) bool
}

StringMatcher interface

type StringWriteStringer

type StringWriteStringer interface {
	io.StringWriter
	fmt.Stringer
}

StringWriteStringer interface

type ToStringFunc added in v0.6.12

type ToStringFunc func(v any) (string, error)

ToStringFunc try to convert value to string, return error on fail

type ToTypeFunc added in v0.6.15

type ToTypeFunc[T any] func(any) (T, error)

ToTypeFunc convert value to defined type

type Uint added in v0.6.0

type Uint interface {
	~uint | ~uint8 | ~uint16 | ~uint32 | ~uint64 | ~uintptr
}

Uint interface type

type UnmarshalFunc

type UnmarshalFunc func(bts []byte, ptr any) error

UnmarshalFunc define

type Xint added in v0.6.0

type Xint interface {
	Int | Uint
}

Xint interface type. alias of Integer

type XintOrFloat added in v0.6.0

type XintOrFloat interface {
	Int | Uint | Float
}

XintOrFloat interface type. all int, uint and float types

Jump to

Keyboard shortcuts

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