stardecoder

package module
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2021 License: MPL-2.0 Imports: 3 Imported by: 0

README

Starlark Value Decoder

GoDoc

Recursively decodes Starlark values into Go values.

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. There is one exception, Starlark functions or lambda expressions will be returned back unchanged to its Go equivalent: *starlark.Function

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{}{}
Function → *starlark.Function

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