gtrsconvert

package
v0.6.1 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2024 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnsupportedFieldType = errors.New("unsupported field type")

Functions

func MapToStruct

func MapToStruct(st any, data map[string]any) error

mapToStruct tries to convert a map to a struct.

func StructToMap

func StructToMap(st any) (map[string]any, error)

structToMap convert a struct to a map.

Types

type AsciiTime

type AsciiTime time.Time

func (AsciiTime) MarshalBinary

func (m AsciiTime) MarshalBinary() (text []byte, err error)

func (*AsciiTime) Time

func (m *AsciiTime) Time() time.Time

func (*AsciiTime) UnmarshalBinary

func (m *AsciiTime) UnmarshalBinary(text []byte) error

type ConvertibleFrom

type ConvertibleFrom interface {
	FromMap(map[string]any) error
}

ConvertibleFrom is implemented by types that can load themselves from a map.

type ConvertibleTo

type ConvertibleTo interface {
	ToMap() (map[string]any, error)
}

ConvertibleTo is implemented by types that can convert themselves to a map.

type FieldParseError

type FieldParseError struct {
	Field string
	Value any
	Err   error
}

FieldParseError is returned by the default parser if data for a field is present: - but its not assignable - or the field is of an unsupported type

func (FieldParseError) Error

func (fpe FieldParseError) Error() string

func (FieldParseError) Unwrap

func (fpe FieldParseError) Unwrap() error

type Metadata

type Metadata map[string]any

func (Metadata) MarshalBinary

func (m Metadata) MarshalBinary() (text []byte, err error)

func (*Metadata) UnmarshalBinary

func (m *Metadata) UnmarshalBinary(text []byte) error

type SerializeError

type SerializeError struct {
	Field string
	Value any
	Err   error
}

func (SerializeError) Error

func (se SerializeError) Error() string

func (SerializeError) Unwrap

func (se SerializeError) Unwrap() error

Jump to

Keyboard shortcuts

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