在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.

24 regels
371 B

4 jaren geleden
  1. package time
  2. import (
  3. lua "github.com/yuin/gopher-lua"
  4. )
  5. func PreLoadGo(L *lua.LState) {
  6. L.PreloadModule("time", 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. "unix": Unix,
  16. "unix_nano": UnixNano,
  17. "sleep": Sleep,
  18. "parse": Parse,
  19. "format": Format,
  20. }