Documentation
¶
Overview ¶
Package types provides wrappers for Starlark types that can be unpacked by the Unpack helper functions to interpret call arguments.
Index ¶
- Variables
- type FloatOrInt
- type Nullable
- type NullableBool
- type NullableBytes
- type NullableCallable
- type NullableDict
- type NullableFloat
- type NullableInt
- type NullableIterable
- type NullableList
- type NullableSet
- type NullableString
- type NullableStringOrBytes
- type NullableTuple
- type NumericValue
- type StringOrBytes
Constants ¶
This section is empty.
Variables ¶
var ( // NewNullableInt creates and returns a new NullableInt with the given default value. NewNullableInt = func(dv starlark.Int) *NullableInt { return NewNullable[starlark.Int](dv) } // NewNullableFloat creates and returns a new NullableFloat with the given default value. NewNullableFloat = func(dv starlark.Float) *NullableFloat { return NewNullable[starlark.Float](dv) } // NewNullableBool creates and returns a new NullableBool with the given default value. NewNullableBool = func(dv starlark.Bool) *NullableBool { return NewNullable[starlark.Bool](dv) } // NewNullableString creates and returns a new NullableString with the given default value. NewNullableString = func(dv starlark.String) *NullableString { return NewNullable[starlark.String](dv) } // NewNullableBytes creates and returns a new NullableBytes with the given default value. NewNullableBytes = func(dv starlark.Bytes) *NullableBytes { return NewNullable[starlark.Bytes](dv) } // NewNullableList creates and returns a new NullableList with the given default value. NewNullableList = func(dv *starlark.List) *NullableList { return NewNullable[*starlark.List](dv) } // NewNullableTuple creates and returns a new NullableTuple with the given default value. NewNullableTuple = func(dv starlark.Tuple) *NullableTuple { return NewNullable[starlark.Tuple](dv) } // NewNullableSet creates and returns a new NullableSet with the given default value. NewNullableSet = func(dv *starlark.Set) *NullableSet { return NewNullable[*starlark.Set](dv) } // NewNullableDict creates and returns a new NullableDict with the given default value. NewNullableDict = func(dv *starlark.Dict) *NullableDict { return NewNullable[*starlark.Dict](dv) } // NewNullableIterable creates and returns a new NullableIterable with the given default value. NewNullableIterable = func(dv starlark.Iterable) *NullableIterable { return NewNullable[starlark.Iterable](dv) } // NewNullableCallable creates and returns a new NullableCallable with the given default value. NewNullableCallable = func(dv starlark.Callable) *NullableCallable { return NewNullable[starlark.Callable](dv) } )
Functions ¶
This section is empty.
Types ¶
type FloatOrInt ¶
type FloatOrInt float64
FloatOrInt is an Unpacker that converts a Starlark int or float to Go's float64. There is no constructor for this type because it is a simple type alias of float64.
func (FloatOrInt) GoFloat ¶
func (p FloatOrInt) GoFloat() float64
GoFloat returns the Go float64 representation of the FloatOrInt.
func (FloatOrInt) GoInt ¶
func (p FloatOrInt) GoInt() int
GoInt returns the Go int representation of the FloatOrInt.
type Nullable ¶
Nullable is an Unpacker that converts a Starlark None or T to Go's starlark.Value.
func NewNullable ¶
NewNullable creates and returns a new Nullable with the given default value.
type NullableBool ¶
NullableBool is an Unpacker that converts a Starlark None or Bool.
type NullableBytes ¶
NullableBytes is an Unpacker that converts a Starlark None or Bytes.
type NullableCallable ¶
NullableCallable is an Unpacker that converts a Starlark None or Callable.
type NullableDict ¶
NullableDict is an Unpacker that converts a Starlark None or Dict.
type NullableFloat ¶
NullableFloat is an Unpacker that converts a Starlark None or Float.
type NullableInt ¶
NullableInt is an Unpacker that converts a Starlark None or Int.
type NullableIterable ¶
NullableIterable is an Unpacker that converts a Starlark None or Iterable.
type NullableList ¶
NullableList is an Unpacker that converts a Starlark None or List.
type NullableSet ¶
NullableSet is an Unpacker that converts a Starlark None or Set.
type NullableString ¶
NullableString is an Unpacker that converts a Starlark None or String.
type NullableStringOrBytes ¶
type NullableStringOrBytes struct {
// contains filtered or unexported fields
}
NullableStringOrBytes is an Unpacker that converts a Starlark None or string to Go's string.
func NewNullableStringOrBytes ¶
func NewNullableStringOrBytes(s string) *NullableStringOrBytes
NewNullableStringOrBytes creates and returns a new NullableStringOrBytes.
func (*NullableStringOrBytes) GoString ¶
func (p *NullableStringOrBytes) GoString() string
GoString returns the Go string representation of the NullableStringOrBytes, if the underlying value is nil, it returns an empty string.
func (*NullableStringOrBytes) IsNull ¶
func (p *NullableStringOrBytes) IsNull() bool
IsNull returns true if the underlying value is nil.
func (*NullableStringOrBytes) IsNullOrEmpty ¶
func (p *NullableStringOrBytes) IsNullOrEmpty() bool
IsNullOrEmpty returns true if the underlying value is nil or an empty string.
type NullableTuple ¶
NullableTuple is an Unpacker that converts a Starlark None or Tuple.
type NumericValue ¶
type NumericValue struct {
// contains filtered or unexported fields
}
NumericValue holds a Starlark numeric value and tracks its type. It can represent an integer or a float, and it prefers integers over floats.
func NewNumericValue ¶
func NewNumericValue() *NumericValue
NewNumericValue creates and returns a new NumericValue.
func (*NumericValue) Add ¶
func (n *NumericValue) Add(value starlark.Value) error
Add takes a Starlark Value and adds it to the NumericValue. It returns an error if the given value is neither an int nor a float.
func (*NumericValue) AsFloat ¶
func (n *NumericValue) AsFloat() float64
AsFloat returns the float representation of the NumericValue.
func (*NumericValue) Unpack ¶
func (n *NumericValue) Unpack(v starlark.Value) error
Unpack implements Unpacker.
func (*NumericValue) Value ¶
func (n *NumericValue) Value() starlark.Value
Value returns the Starlark Value representation of the NumericValue.
type StringOrBytes ¶
type StringOrBytes string
StringOrBytes is an Unpacker that converts a Starlark string or bytes to Go's string. It works because Go Starlark strings and bytes are both represented as Go strings. There is no constructor for this type because it is a simple type alias of string.
func (StringOrBytes) GoBytes ¶
func (p StringOrBytes) GoBytes() []byte
GoBytes returns the Go byte slice representation of the StringOrBytes.
func (StringOrBytes) GoString ¶
func (p StringOrBytes) GoString() string
GoString returns the Go string representation of the StringOrBytes.
func (StringOrBytes) StarlarkString ¶
func (p StringOrBytes) StarlarkString() starlark.String
StarlarkString returns the Starlark string representation of the StringOrBytes.