28 lines
411 B
Go
28 lines
411 B
Go
// Copyright (C) 2018 Storj Labs, Inc.
|
|
// See LICENSE for copying information.
|
|
|
|
package luacfg_test
|
|
|
|
import (
|
|
"bytes"
|
|
"fmt"
|
|
|
|
"storj.io/storj/cmd/statreceiver/luacfg"
|
|
)
|
|
|
|
func Example() {
|
|
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
|
|
}
|