Need help with gopher-luar?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

layeh
161 Stars 39 Forks Mozilla Public License 2.0 196 Commits 0 Opened issues

Description

simplifies data passing to and from gopher-lua

Services available

!
?

Need anything else?

Contributors list

# 22,906
Go
oauth2
oauth2-...
golang
194 commits
# 671,483
python-...
Raspber...
Shell
CSS
2 commits

gopher-luar GoDoc

gopher-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

}

License

MPL 2.0

Author

Tim Cooper ([email protected])

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.