Global Variable of type Lua Table
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Aptitud para principiantes
- 22/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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
}
- Lenguaje dominante
- Go
- Estrellas
- 3.5k
- Forks
- 217
- Métricas de merge de PR
- Sin PR fusionados en 30 d
Preparar el entorno
Este proyecto no incluye contenedor de desarrollo, Dockerfile ni guía de contribución, así que la configuración corre por tu cuenta: empieza por su README y consulta nuestra guía para la primera contribución para los pasos generales.
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de Shopify/go-lua
-
Numeric modulo fast path disagrees with Lua 5.2 and the library fallback for negative operandsPosiblemente ocupada @efegokdemir la tomó hace 35 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
-
io.write discards spaces after trailing numbersPosiblemente ocupada @flynn-eye la tomó hace 25 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
-
enhancement
Dificultad 2/5 1-3 horas Aptitud para principiantes 70/100
-
State.close leaves closed upvalues in the open list, so calls get slower without boundPosiblemente ocupada @efegokdemir la tomó hace 17 días. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 25/100
-
Dificultad 4/5 3-5 días Aptitud para principiantes 25/100
Todos los issues de Shopify/go-lua
Issues similares
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 82/100
limitlessprojects/Go-Hybrid#4764 ·
Los mantenedores suelen responder en 1 día
-
[bug]: lint fails on main, generated CLI docs out of datePosiblemente ocupada @bupd la tomó hoy. Abiertobug documentation
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
goharbor/harbor-cli#1180 ·
Los mantenedores suelen responder en 1 día
-
crane: mutate --env adds duplicate PATH on Windows images when key case differsPosiblemente ocupada @aad1tyaaaaa la tomó hoy. Abierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
google/go-containerregistry#2523 ·
Los mantenedores suelen responder en 4 días
-
bosh_io_stemcell_type: regular does not work for noble and resolute as it adds -go_agent as suffixAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
cloudfoundry/bosh-deployment-resource#138 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 68/100