Documentation ¶
Overview ¶
Package internal contains types and utilities that are not part of the public API, and may change without notice. It should be only imported by the custom Starlark modules under starlet/lib folders, and not by the Starlet main package to avoid cyclic import.
Index ¶
- Constants
- func ExecModuleWithErrorTest(t *testing.T, name string, loader ModuleLoadFunc, script string, ...) (starlark.StringDict, error)
- func GetBytesMD5(data []byte) string
- func GetStringMD5(data string) string
- func HereDoc(raw string) string
- func HereDocf(raw string, args ...interface{}) string
- type FloatOrInt
- type ModuleLoadFunc
- type NumericValue
- type StringOrBytes
- type ThreadLoadFunc
Constants ¶
const StarletVersion = "v0.0.6"
StarletVersion is the current version of Starlet.
Variables ¶
This section is empty.
Functions ¶
func ExecModuleWithErrorTest ¶
func ExecModuleWithErrorTest(t *testing.T, name string, loader ModuleLoadFunc, script string, wantErr string, predecl starlark.StringDict) (starlark.StringDict, error)
ExecModuleWithErrorTest executes a Starlark script with a module loader and compares the error with the expected error.
func GetBytesMD5 ¶ added in v0.0.10
GetBytesMD5 returns the MD5 hash of the given data as a hex string.
func GetStringMD5 ¶ added in v0.0.10
GetStringMD5 returns the MD5 hash of the given string as a hex string.
Types ¶
type FloatOrInt ¶
type FloatOrInt float64
FloatOrInt is an Unpacker that converts a Starlark int or float to Go's float64.
func (FloatOrInt) GoFloat ¶ added in v0.0.16
func (p FloatOrInt) GoFloat() float64
GoFloat returns the Go float64 representation of the FloatOrInt.
func (FloatOrInt) GoInt ¶ added in v0.0.16
func (p FloatOrInt) GoInt() int
GoInt returns the Go int representation of the FloatOrInt.
type ModuleLoadFunc ¶
type ModuleLoadFunc func() (starlark.StringDict, error)
ModuleLoadFunc is a function that loads a Starlark module and returns the module's string dict.
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) 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.
func (StringOrBytes) GoBytes ¶ added in v0.0.11
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.
type ThreadLoadFunc ¶
ThreadLoadFunc is a function that loads a Starlark module by name, usually used by the Starlark thread.
func NewAssertLoader ¶
func NewAssertLoader(moduleName string, loader ModuleLoadFunc) ThreadLoadFunc
NewAssertLoader creates a Starlark thread loader that loads a module by name or asserts.star for testing.