Global Variable of type Lua Table
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 3/5
- Geschätzter Aufwand
- 1-2 Tage
- Anfängerfreundlichkeit
- 22/100
Rechercherichtung
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.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
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
}
- Vorherrschende Sprache
- Go
- Sterne
- 3.5k
- Forks
- 217
- PR-Merge-Kennzahlen
- Keine gemergten PRs in 30 T.
Entwicklungsumgebung
Dieses Projekt bietet weder Dev-Container noch Dockerfile noch Beitragsleitfaden – die Einrichtung liegt bei Ihnen. Beginnen Sie mit der README; die allgemeinen Schritte stehen in unserem Leitfaden für den ersten Beitrag.
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus Shopify/go-lua
-
Numeric modulo fast path disagrees with Lua 5.2 and the library fallback for negative operandsEvtl. vergeben @efegokdemir hat das vor 35 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
-
io.write discards spaces after trailing numbersEvtl. vergeben @flynn-eye hat das vor 25 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
-
enhancement
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 70/100
-
State.close leaves closed upvalues in the open list, so calls get slower without boundEvtl. vergeben @efegokdemir hat das vor 17 Tagen übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 25/100
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 25/100
Ähnliche Issues
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 82/100
limitlessprojects/Go-Hybrid#4764 ·
Maintainer antworten meist innerhalb von 1 Tag
-
[bug]: lint fails on main, generated CLI docs out of dateEvtl. vergeben @bupd hat das heute übernommen. Offenbug documentation
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
goharbor/harbor-cli#1180 ·
Maintainer antworten meist innerhalb von 1 Tag
-
crane: mutate --env adds duplicate PATH on Windows images when key case differsEvtl. vergeben @aad1tyaaaaa hat das heute übernommen. Offen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 62/100
google/go-containerregistry#2523 ·
Maintainer antworten meist innerhalb von 4 Tagen
-
bosh_io_stemcell_type: regular does not work for noble and resolute as it adds -go_agent as suffixOffen
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 66/100
cloudfoundry/bosh-deployment-resource#138 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 68/100