Skip to content

Instantly share code, notes, and snippets.

@bsiegert
Created February 5, 2023 13:01
Show Gist options
  • Save bsiegert/eb94f435e7f3782ea0d53797fc1d82a8 to your computer and use it in GitHub Desktop.
Save bsiegert/eb94f435e7f3782ea0d53797fc1d82a8 to your computer and use it in GitHub Desktop.
Go and Lua Hello World
module github.com/bsiegert/luatest
go 1.19
require github.com/Shopify/go-lua v0.0.0-20221004153744-91867de107cf // indirect
github.com/Shopify/go-lua v0.0.0-20221004153744-91867de107cf h1:VSUCKpFV0AfYGslgQSRdBI9HCVp1TCXJmScWD0VXL5g=
github.com/Shopify/go-lua v0.0.0-20221004153744-91867de107cf/go.mod h1:UCCi6u6YA8oXfJ15vEMiMGIaWWfLiOacinBPHxLXtEU=
package main
import lua "github.com/Shopify/go-lua"
func main() {
l := lua.NewState()
lua.OpenLibraries(l)
l.Global("print")
l.PushString("Hello World!\n")
l.Call(1, 0)
}
@shutongy
Copy link

Quick question, if I call DoString on the lua state, how can I retrieve the value of that lua code snippet? It seems the documentation is really lacking in go-lua.

Thanks in advance!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment