mirror of https://github.com/ledisdb/ledisdb.git
22 lines
427 B
Go
22 lines
427 B
Go
|
package json
|
||
|
|
||
|
import (
|
||
|
"github.com/yuin/gopher-lua"
|
||
|
)
|
||
|
|
||
|
// Preload adds json to the given Lua state's package.preload table. After it
|
||
|
// has been preloaded, it can be loaded using require:
|
||
|
//
|
||
|
// local json = require("json")
|
||
|
func Preload(L *lua.LState) {
|
||
|
L.PreloadModule("json", Loader)
|
||
|
}
|
||
|
|
||
|
// Loader is the module loader function.
|
||
|
func Loader(L *lua.LState) int {
|
||
|
t := L.NewTable()
|
||
|
L.SetFuncs(t, api)
|
||
|
L.Push(t)
|
||
|
return 1
|
||
|
}
|