helpers

package
v0.4.32 Latest Latest
Warning

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

Go to latest
Published: Feb 9, 2025 License: MIT Imports: 8 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallFunctionFromJson added in v0.2.24

func CallFunctionFromJson(f Callable, jsonArgs interface{}) ([]reflect.Value, error)

CallFunctionFromJson calls a function with arguments provided as JSON TODO(manuel, 2024-01-12) make this take a ctx

func FillStructFromKV added in v0.1.9

func FillStructFromKV(kv map[string]string, v interface{}) error

func GetFunctionParametersJsonSchema added in v0.2.24

func GetFunctionParametersJsonSchema(reflector *jsonschema.Reflector, f Callable) (*jsonschema.Schema, error)

GetFunctionParametersJsonSchema generates a JSON Schema for the arguments of the given function

func ParseKV added in v0.1.9

func ParseKV(s string) map[string]string

ParseKV transforms a simple format. Each line has a key value pair separated by :. Empty lines are ignored

Types

type Callable added in v0.2.24

type Callable interface{}

Callable is a type representing any callable function

type Nothing

type Nothing struct{}

type Result

type Result[T any] struct {
	// contains filtered or unexported fields
}

func NewErrorResult

func NewErrorResult[T any](err error) Result[T]

func NewResult

func NewResult[T any](value T, err error) Result[T]

func NewValueResult

func NewValueResult[T any](value T) Result[T]

func (Result[T]) Error added in v0.1.18

func (r Result[T]) Error() error

func (Result[T]) MarshalZerologObject added in v0.4.25

func (r Result[T]) MarshalZerologObject(e *zerolog.Event)

MarshalZerologObject implements zerolog.LogObjectMarshaler

func (Result[T]) Ok

func (r Result[T]) Ok() bool

func (Result[T]) String added in v0.4.25

func (r Result[T]) String() string

func (Result[T]) Unwrap

func (r Result[T]) Unwrap() T

func (Result[T]) Value

func (r Result[T]) Value() (T, error)

func (Result[T]) ValueOr

func (r Result[T]) ValueOr(v T) T

type ResultSlice added in v0.4.25

type ResultSlice[T any] []Result[T]

ResultSlice is a slice of Results that can be marshaled by zerolog

func ToResultSlice added in v0.4.25

func ToResultSlice[T any](results []Result[T]) ResultSlice[T]

ToResultSlice converts a slice of Results to a ResultSlice for logging

func (ResultSlice[T]) MarshalZerologArray added in v0.4.25

func (rs ResultSlice[T]) MarshalZerologArray(a *zerolog.Array)

MarshalZerologArray implements zerolog.LogArrayMarshaler

type SimplifiedJsonSchema added in v0.4.32

type SimplifiedJsonSchema struct {
	Type        string                                   `json:"type"`
	Description string                                   `json:"description,omitempty"`
	Properties  map[string]*SimplifiedJsonSchemaProperty `json:"properties"`
	Required    []string                                 `json:"required,omitempty"`
}

SimplifiedJsonSchema represents a simplified root JSON Schema

func GetSimplifiedFunctionParametersJsonSchema added in v0.4.32

func GetSimplifiedFunctionParametersJsonSchema(reflector *jsonschema.Reflector, f Callable) (*SimplifiedJsonSchema, error)

GetSimplifiedFunctionParametersJsonSchema generates a simplified JSON Schema for the arguments of the given function

type SimplifiedJsonSchemaProperty added in v0.4.32

type SimplifiedJsonSchemaProperty struct {
	Type        string                                   `json:"type"`
	Description string                                   `json:"description,omitempty"`
	Required    bool                                     `json:"-"`
	Properties  map[string]*SimplifiedJsonSchemaProperty `json:"properties,omitempty"`
	Items       *SimplifiedJsonSchemaProperty            `json:"items,omitempty"`
}

SimplifiedJsonSchemaProperty represents a simplified property in the JSON Schema

Jump to

Keyboard shortcuts

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