luacfg

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: May 28, 2019 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Example
package main

import (
	"bytes"
	"fmt"

	"storj.io/storj/cmd/statreceiver/luacfg"
)

func main() {
	scope := luacfg.NewScope()

	err := scope.RegisterVal("print", fmt.Println)
	if err != nil {
		panic(err)
	}

	err = scope.Run(bytes.NewBufferString(`print "hello"`))
	if err != nil {
		panic(err)
	}

}
Output:

hello

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Scope

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

Scope represents a collection of values registered in a Lua namespace.

func NewScope

func NewScope() *Scope

NewScope creates an empty Scope.

func (*Scope) RegisterType

func (scope *Scope) RegisterType(name string, example interface{}) error

RegisterType allows you to add a Lua function that creates new values of the given type to the scope.

func (*Scope) RegisterVal

func (scope *Scope) RegisterVal(name string, value interface{}) error

RegisterVal adds the Go value 'value', including Go functions, to the Lua scope.

func (*Scope) Run

func (scope *Scope) Run(in io.Reader) error

Run runs the Lua source represented by in

Jump to

Keyboard shortcuts

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