-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy path02_do_string_2.go
More file actions
40 lines (35 loc) · 1009 Bytes
/
Copy path02_do_string_2.go
File metadata and controls
40 lines (35 loc) · 1009 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
// Seriál "Programovací jazyk Go"
// https://www.root.cz/serialy/programovaci-jazyk-go/
//
// Dvacátá sedmá část
// Skriptovací jazyk Lua v aplikacích naprogramovaných v Go
// https://www.root.cz/clanky/skriptovaci-jazyk-lua-v-aplikacich-naprogramovanych-v-go/
//
// Repositář:
// https://github.com/tisnik/go-root/
//
// Seznam demonstračních příkladů z dvacáté sedmé části:
// https://github.com/tisnik/go-root/blob/master/article_27/README.md
//
// Demonstrační příklad číslo 2:
// Poslání skriptu v řetězci do Lua VM.
//
// Dokumentace ve stylu "literate programming":
// https://tisnik.github.io/go-root/article_27/02_do_string_2.html
package main
import (
"github.com/yuin/gopher-lua"
"log"
)
func main() {
luaVM := lua.NewState()
log.Println("Lua VM has been initialized")
defer func() {
luaVM.Close()
log.Println("Lua VM has been closed")
}()
err := luaVM.DoString(`print("Hello from Lua!")`)
if err != nil {
log.Fatal(err)
}
}