decoder

package
v0.1.3 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2023 License: GPL-3.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrNotPointerToStruct = errors.New("val must be a pointer to a struct")

Functions

This section is empty.

Types

type Decoder

type Decoder struct {
	Runner *interp.Runner
	// Enable distro overrides (true by default)
	Overrides bool
	// Enable using like distros for overrides
	LikeDistros bool
	// contains filtered or unexported fields
}

Decoder provides methods for decoding variable values

func New

func New(info *distro.OSRelease, runner *interp.Runner) *Decoder

New creates a new variable decoder

func (*Decoder) DecodeVar

func (d *Decoder) DecodeVar(name string, val any) error

DecodeVar decodes a variable to val using reflection. Structs should use the "sh" struct tag.

func (*Decoder) DecodeVars

func (d *Decoder) DecodeVars(val any) error

DecodeVars decodes all variables to val using reflection. Structs should use the "sh" struct tag.

func (*Decoder) GetFunc

func (d *Decoder) GetFunc(name string) (ScriptFunc, bool)

GetFunc returns a function corresponding to a bash function with the given name

type InvalidTypeError

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

func (InvalidTypeError) Error

func (ite InvalidTypeError) Error() string

type ScriptFunc

type ScriptFunc func(ctx context.Context, opts ...interp.RunnerOption) error

type VarNotFoundError

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

func (VarNotFoundError) Error

func (nfe VarNotFoundError) Error() string

Jump to

Keyboard shortcuts

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