generate

package
v0.0.0-...-e537141 Latest Latest
Warning

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

Go to latest
Published: Jun 9, 2023 License: GPL-3.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNilString = fmt.Errorf("expected no nil string")

Functions

func AssumeStringer

func AssumeStringer(w io.Writer, val any) error

func FormatVal

func FormatVal(w io.Writer, c WriteInto, val any, sep []byte) error

func FormatVals

func FormatVals(w io.Writer, c WriteInto, vals []any, sep *string) error

func GetAnyTypes

func GetAnyTypes(vals []any) []reflect.Type

func TryConvert

func TryConvert(w io.Writer, val any) error

Types

type AnyFormatter

type AnyFormatter interface {
	FormatAnySlice(io.Writer, []any) error
}

type AnySliceSorter

type AnySliceSorter struct {
	TypeToIndex TypeToIndex
	Vals        []any
	Types       []reflect.Type
}

func (*AnySliceSorter) Len

func (a *AnySliceSorter) Len() int

Len is part of sort.Interface.

func (*AnySliceSorter) Less

func (a *AnySliceSorter) Less(i, j int) bool

Less is part of sort.Interface.

func (*AnySliceSorter) Swap

func (a *AnySliceSorter) Swap(i, j int)

Swap is part of sort.Interface.

type AnyToBytes

type AnyToBytes struct {
	// contains filtered or unexported fields
}

func (AnyToBytes) WriteInto

func (a AnyToBytes) WriteInto(w io.Writer, val any) error

type AnyToFormatter

type AnyToFormatter map[any]WriteInto

func (AnyToFormatter) ToWriter

func (a AnyToFormatter) ToWriter() TypeToFormatter

type AnyToString

type AnyToString map[any]string

func (AnyToString) ToWriter

func (a AnyToString) ToWriter() AnyToBytes

type Config

type Config struct {
	Root      *string
	Converter WriteInto
	Separator string
}

func (Config) BuildGenerator

func (cfg Config) BuildGenerator(order TypeOrder) (StringGenerator, error)

type Empty

type Empty struct{}

type ErrDuplicateType

type ErrDuplicateType struct {
	Type reflect.Type
}

func (*ErrDuplicateType) Error

func (err *ErrDuplicateType) Error() string

type ErrNoIndexForType

type ErrNoIndexForType struct {
	Val any
}

func (*ErrNoIndexForType) Error

func (err *ErrNoIndexForType) Error() string

type ErrNoMatch

type ErrNoMatch struct {
	Val any
}

func (*ErrNoMatch) Error

func (err *ErrNoMatch) Error() string

type ErrNoStringer

type ErrNoStringer struct {
	Type reflect.Type
}

func (*ErrNoStringer) Error

func (err *ErrNoStringer) Error() string

type ErrNotConvertable

type ErrNotConvertable struct {
	Value any
	Type  reflect.Type
}

func (*ErrNotConvertable) Error

func (err *ErrNotConvertable) Error() string

type Formattable

type Formattable interface {
	GenerateFormat(io.Writer) error
}

type Separator

type Separator struct {
	// contains filtered or unexported fields
}

func (Separator) FormatAnySlice

func (s Separator) FormatAnySlice(w io.Writer, vals []any) error

type SprintfTemplate

type SprintfTemplate string

func (SprintfTemplate) WriteInto

func (s SprintfTemplate) WriteInto(w io.Writer, val any) error

type String

type String interface {
	GenerateString(vals []any) (string, error)
}

type StringGenerator

type StringGenerator struct {
	// contains filtered or unexported fields
}

func (StringGenerator) Path

func (s StringGenerator) Path(args ...any) (string, error)

type TypeOrder

type TypeOrder interface {
	SortAnySlice([]any) error
}

type TypeSet

type TypeSet map[reflect.Type]Empty

type TypeSorter

type TypeSorter struct {
	// contains filtered or unexported fields
}

type TypeToFormatter

type TypeToFormatter map[reflect.Type]WriteInto

func (TypeToFormatter) WriteInto

func (t TypeToFormatter) WriteInto(w io.Writer, val any) error

type TypeToIndex

type TypeToIndex map[reflect.Type]int

type TypesMeta

type TypesMeta struct {
	Set         TypeSet
	TypeToIndex TypeToIndex
}

func NewTypesMeta

func NewTypesMeta(types []reflect.Type) (TypesMeta, error)

func (TypesMeta) HasAllTypes

func (tm TypesMeta) HasAllTypes(types []reflect.Type) bool

func (TypesMeta) HasType

func (tm TypesMeta) HasType(t reflect.Type) bool

func (TypesMeta) MakeSorter

func (tm TypesMeta) MakeSorter(vals []any) (AnySliceSorter, error)

func (TypesMeta) SortAnySlice

func (tm TypesMeta) SortAnySlice(vals []any) error

type WriteInto

type WriteInto func(io.Writer, any) error

func MergeWriters

func MergeWriters(writers ...WriteInto) WriteInto

Jump to

Keyboard shortcuts

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