Global Variable of type Lua Table
Ninguém assumiu esta issue ainda.
Avaliação
- Dificuldade
- 3/5
- Tempo estimado
- 1-2 dias
- Facilidade para iniciantes
- 22/100
Direção de pesquisa
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.
Escrita pelo modelo de indexação a partir do texto da issue.
Descrição
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
}
- Linguagem predominante
- Go
- Estrelas
- 3.5k
- Forks
- 217
- Métricas de merge de PRs
- Nenhum PR com merge em 30d
Preparar o ambiente
Este projeto não oferece contêiner de desenvolvimento, Dockerfile nem guia de contribuição, então a configuração fica por sua conta: comece pelo README e veja nosso guia da primeira contribuição para os passos gerais.
Primeiros passos
- Leia a issue inteira e depois o guia de contribuição do projeto.
- Comente na issue dizendo que vai assumir — evita que duas pessoas façam o mesmo trabalho.
- Faça um fork do repositório e trabalhe em uma branch.
- Abra um pull request que referencie o número da issue.
Mais de Shopify/go-lua
-
Numeric modulo fast path disagrees with Lua 5.2 and the library fallback for negative operandsTalvez já em andamento @efegokdemir assumiu há 35 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 76/100
-
io.write discards spaces after trailing numbersTalvez já em andamento @flynn-eye assumiu há 25 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
-
enhancement
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 70/100
-
State.close leaves closed upvalues in the open list, so calls get slower without boundTalvez já em andamento @efegokdemir assumiu há 17 dias. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 25/100
-
Dificuldade 4/5 3-5 dias Facilidade para iniciantes 25/100
Todas as issues de Shopify/go-lua
Issues semelhantes
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 82/100
limitlessprojects/Go-Hybrid#4764 ·
Mantenedores costumam responder em até 1 dia
-
[bug]: lint fails on main, generated CLI docs out of dateTalvez já em andamento @bupd assumiu hoje. Abertabug documentation
Dificuldade 1/5 Menos de uma hora Facilidade para iniciantes 85/100
goharbor/harbor-cli#1180 ·
Mantenedores costumam responder em até 1 dia
-
crane: mutate --env adds duplicate PATH on Windows images when key case differsTalvez já em andamento @aad1tyaaaaa assumiu hoje. Aberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 62/100
google/go-containerregistry#2523 ·
Mantenedores costumam responder em até 4 dias
-
bosh_io_stemcell_type: regular does not work for noble and resolute as it adds -go_agent as suffixAberta
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 66/100
cloudfoundry/bosh-deployment-resource#138 ·
Mantenedores costumam responder em até 1 dia
-
Dificuldade 2/5 1-3 horas Facilidade para iniciantes 68/100