在线时间:8:00-16:00
迪恩网络APP
随时随地掌握行业动态
扫描二维码
关注迪恩网络微信公众号
开源软件名称(OpenSource Name):layeh/gopher-luar开源软件地址(OpenSource Url):https://github.com/layeh/gopher-luar开源编程语言(OpenSource Language):Go 100.0%开源软件介绍(OpenSource Introduction):gopher-luargopher-luar simplifies data passing to and from gopher-lua. Example usage: package luar_test
import (
"fmt"
"github.com/yuin/gopher-lua"
"layeh.com/gopher-luar"
)
type User struct {
Name string
token string
}
func (u *User) SetToken(t string) {
u.token = t
}
func (u *User) Token() string {
return u.token
}
const script = `
print("Hello from Lua, " .. u.Name .. "!")
u:SetToken("12345")
`
func Example_basic() {
L := lua.NewState()
defer L.Close()
u := &User{
Name: "Tim",
}
L.SetGlobal("u", luar.New(L, u))
if err := L.DoString(script); err != nil {
panic(err)
}
fmt.Println("Lua set your token to:", u.Token())
// Output:
// Hello from Lua, Tim!
// Lua set your token to: 12345
} LicenseMPL 2.0 AuthorTim Cooper ([email protected]) |
2023-10-27
2022-08-15
2022-08-17
2022-09-23
2022-08-13
请发表评论