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

26 lines
450 B

преди 4 години
  1. package strings
  2. import (
  3. lua "github.com/yuin/gopher-lua"
  4. )
  5. func PreLoadGo(L *lua.LState) {
  6. L.PreloadModule("strings", 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. "split": Split,
  16. "trim": Trim,
  17. "trim_prefix": TrimPrefix,
  18. "trim_suffix": TrimSuffix,
  19. "has_prefix": HasPrefix,
  20. "has_suffix": HasSuffix,
  21. "contains": Contains,
  22. }