Global Variable of type Lua Table
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 22/100
Direzione di ricerca
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.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
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
}
- Lingua principale
- Go
- Stelle
- 3.5k
- Fork
- 217
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Preparare l'ambiente
Questo progetto non fornisce container di sviluppo, Dockerfile né guida per i contributori, quindi l'ambiente è a tuo carico: parti dal suo README e consulta la nostra guida al primo contributo per i passaggi generali.
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di Shopify/go-lua
-
Numeric modulo fast path disagrees with Lua 5.2 and the library fallback for negative operandsForse già presa @efegokdemir l’ha presa 35 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
-
io.write discards spaces after trailing numbersForse già presa @flynn-eye l’ha presa 25 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
-
enhancement
Difficoltà 2/5 1-3 ore Idoneità per principianti 70/100
-
State.close leaves closed upvalues in the open list, so calls get slower without boundForse già presa @efegokdemir l’ha presa 17 giorni fa. Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 25/100
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 25/100
Tutte le issue di Shopify/go-lua
Issue simili
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 74/100
-
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 85/100
docker/model-runner#1118 ·
I maintainer di solito rispondono entro 1 giorno
-
Screenshot missing in READMEAperta
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 82/100