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", load) } func load(L *lua.LState) int { t := L.NewTable() L.SetFuncs(t, api) L.Push(t) return 1 }