stardecoder

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2020 License: MPL-2.0 Imports: 3 Imported by: 0

README

Starlark Value Decoder

GoDoc

Recursively decodes Starlark values into an equivalent shaped Go value made up of only primitive types.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decode

func Decode(v starlark.Value) (g interface{}, err error)

Decode recursively decodes the starlark value v into an equivalent shaped Go value g, made up of only primitive types.

The following are the conversions made from Starlark types to Go types:

None   → nil
Bool   → bool
Int    → int
Float  → float64
String → string
List   → []interface{}
Tuple  → []interface{}
Dict   → map[interface{}]interface{}{}

func DecodeKWargs

func DecodeKWargs(kwargs []starlark.Tuple, g interface{}) error

DecodeKWargs decodes Starlark keyword arguments into the value pointed by g. If g is a struct, it uses its fields names by default to find the arguments and do the mapping. The struct field name can be redefined through struct tags prefixed with "starlark". Example:

type Repo struct {
	SourceFile string `starlark:"file"`
}

Types

This section is empty.

Jump to

Keyboard shortcuts

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