parser

package
v0.0.0-...-e06565c Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2025 License: Apache-2.0 Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LengthPrefixedChunking

func LengthPrefixedChunking(
	reader io.Reader,
	magicNumber byte,
	maxChunkSize uint32,
	processor func([]byte) error,
) error

We uses following format: All data is stored in little endian format

| Field         | Size     | Description                     |
|---------------|----------|---------------------------------|
| Magic Number  | 1 byte   | Magic number identifier         |
| Reserved      | 1 byte   | Reserved field                  |
| Header Length | 2 bytes  | Header length (usually 0xa)    |
| Data Length   | 4 bytes  | Length of the data              |
| Reserved      | 6 bytes  | Reserved fields                 |
| Data          | Variable | Actual data content             |

| Reserved Fields | Header   | Data     |
|-----------------|----------|----------|
| 4 bytes total   | Variable | Variable |

NOTE: this function is not thread safe

func LineBasedChunking

func LineBasedChunking(reader io.Reader, maxChunkSize int, processor func([]byte) error) error

func Map

func Map[From any, To any](f func(From) To, arr []From) []To

func MapToStruct

func MapToStruct[T any](m map[string]any) (*T, error)

func MarshalCBOR

func MarshalCBOR[T any](v T) ([]byte, error)

func MarshalGob

func MarshalGob(v any) ([]byte, error)

func MarshalJson

func MarshalJson[T any](data T) string

func MarshalJsonBytes

func MarshalJsonBytes[T any](data T) []byte

func MarshalPluginID

func MarshalPluginID(author string, name string, version string) string

func MarshalYaml

func MarshalYaml[T any](data T) string

func MarshalYamlBytes

func MarshalYamlBytes[T any](data T) []byte

func ParserCommaSeparatedValues

func ParserCommaSeparatedValues[T any](data []byte) (T, error)

ParserCommaSeparatedValues parses the comma separated values and returns a map of key-value pairs examples: data: a=1,b=2

T: type struct {
	A int `comma:"a"`
	B string `comma:"b"`
}

return:
T{A: 1, B: "2"}

func SnakeToCamel

func SnakeToCamel(s string) string

func StructToMap

func StructToMap(data any) map[string]any

func ToPtr

func ToPtr[T any](value T) *T

func UnmarshalCBOR

func UnmarshalCBOR[T any](data []byte) (T, error)

func UnmarshalGob

func UnmarshalGob[T any](data []byte) (T, error)

func UnmarshalJson

func UnmarshalJson[T any](text string) (T, error)

func UnmarshalJson2Map

func UnmarshalJson2Map(json string) (map[string]any, error)

func UnmarshalJsonBytes

func UnmarshalJsonBytes[T any](data []byte) (T, error)

func UnmarshalJsonBytes2Map

func UnmarshalJsonBytes2Map(data []byte) (map[string]any, error)

func UnmarshalJsonBytes2Slice

func UnmarshalJsonBytes2Slice[T any](data []byte) ([]T, error)

func UnmarshalYaml

func UnmarshalYaml[T any](text string, validator ...validator.Validate) (T, error)

func UnmarshalYaml2Map

func UnmarshalYaml2Map(yaml []byte) (map[string]any, error)

func UnmarshalYamlBytes

func UnmarshalYamlBytes[T any](data []byte, validator ...validator.Validate) (T, error)

Types

This section is empty.

Jump to

Keyboard shortcuts

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