Global Variable of type Lua Table
Chưa có ai nhận issue này.
Đánh giá
- Độ khó
- 3/5
- Thời gian dự kiến
- 1-2 ngày
- Mức phù hợp với người mới
- 22/100
Hướng nghiên cứu
The issue shows only user code: go_exposedLuaFunction builds a table with CreateTable and SetField, and UtilOpen registers it with lua.NewLibrary. Start by checking how the library exposes setting a global value from Go, and whether the state can carry a read-only metatable. Done would mean a Go-created global table is visible to a Lua script and can be made read-only, with a test covering both. The thread has one comment and no maintainer decision, so confirm the approach before writing code.
Do mô hình lập chỉ mục viết ra từ nội dung của issue.
Mô tả
I'm sorry for bothering you guys, but I'm have hard time trying to create a global variable on go-lua of type table.
I'd not any issue to return a table from a function call (GO Lang internal func, returning a table type variable.).
But my litle tool need to create a global variable of type table with system information fields.
And it would be nice if I was able to set it as read-only. Using pure LUA, I can set a metatable, but I never did such thing using API (On this case GO code).
The part of expose a GO Lang function to LUA script and return a table as result was prety easy!
Does anybody did something like that?
For those who need return tables from GO function to Lua script, below is my code! I hope it help!
Example:
// Exposed functions table
var goFuncsTable = []lua.RegistryFunction{
{"AppEnvironment", func(l *lua.State) int { return go_exposedLuaFunction(l) } },
}
// Register functions
func UtilOpen(l *lua.State) int {
lua.NewLibrary(l, goFuncsTable)
return 1
}
// Function implementation itself
func go_exposedLuaFunction(l *lua.State) int {
l.CreateTable(0, 6)
l.PushString("1.0.0")
l.SetField(-2, "Version")
l.PushString(BuildDate)
l.SetField(-2, "BuildDate")
l.PushString(BuildTime)
l.SetField(-2, "BuildTime")
l.PushString(runtime.GOOS)
l.SetField(-2, "OS")
l.PushString(runtime.GOARCH)
l.SetField(-2, "Arch")
l.PushInteger(runtime.GOMAXPROCS(0))
l.SetField(-2, "CPUCores")
return 1 // Returning one single table
}
- Ngôn ngữ chính
- Go
- Star
- 3.5k
- Fork
- 217
- Chỉ số merge pull request
- Không có pull request nào được merge trong 30 ngày
Chuẩn bị môi trường
Dự án này không cung cấp dev container, Dockerfile hay hướng dẫn đóng góp, nên bạn cần tự thiết lập môi trường: hãy bắt đầu từ README và xem hướng dẫn đóng góp lần đầu của chúng tôi để biết các bước chung.
Bắt đầu từ đâu
- Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
- Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
- Fork repository và làm thay đổi trên một nhánh.
- Mở pull request có tham chiếu số hiệu của issue.
Issue khác của Shopify/go-lua
-
Numeric modulo fast path disagrees with Lua 5.2 and the library fallback for negative operandsCó thể đã có người làm @efegokdemir đã nhận 35 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 76/100
-
io.write discards spaces after trailing numbersCó thể đã có người làm @flynn-eye đã nhận 25 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 62/100
-
enhancement
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 70/100
-
State.close leaves closed upvalues in the open list, so calls get slower without boundCó thể đã có người làm @efegokdemir đã nhận 17 ngày trước. Đang mở
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 25/100
-
Độ khó 4/5 3-5 ngày Mức phù hợp với người mới 25/100
Tất cả issue của Shopify/go-lua
Issue tương tự
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 68/100
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 65/100
Maintainer thường phản hồi trong vòng 1 ngày
-
Độ khó 2/5 1-3 giờ Mức phù hợp với người mới 74/100
-
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 85/100
docker/model-runner#1118 ·
Maintainer thường phản hồi trong vòng 1 ngày
-
Screenshot missing in READMEĐang mở
Độ khó 1/5 Dưới một giờ Mức phù hợp với người mới 82/100