在go中使用lua示例, 基于gopher-lua!
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

21 lines
301 B

4 years ago
  1. package json
  2. import (
  3. lua "github.com/yuin/gopher-lua"
  4. )
  5. func PreloadGo(L *lua.LState) {
  6. L.PreloadModule("json", Loader)
  7. }
  8. func Loader(L *lua.LState) int {
  9. t := L.NewTable()
  10. L.SetFuncs(t, api)
  11. L.Push(t)
  12. return 1
  13. }
  14. var api = map[string]lua.LGFunction{
  15. "decode": Decode,
  16. "encode": Encode,
  17. }