bad argument #2 to '__newindex' (not a number in proper range)
Bewertung
- Schwierigkeit
- 4/5
- Geschätzter Aufwand
- 3-5 Tage
- Anfängerfreundlichkeit
- 30/100
Rechercherichtung
Reproduce with the Lua line string.format("%012d", 34567890121111) from test1.lua, first on amd64 and then cross-compiled with GOOS=linux GOARCH=arm GOARM=7, and compare the two results. The reported error is 'bad argument #2 to '__newindex' (not a number in proper range)'. Done means the value formats correctly on 32-bit ARM, or the 32-bit integer limit is documented. The issue has no maintainer reply, so the scope is unconfirmed.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
is go-lua can only run in 64bit machine?
when i run my lua script on ubuntu 64 bit, it works ok( lua test.lua), and i run my golang code using go run main.go,int works ok too,
but when i just cross compile the same golang code using GOOS=linux GOARCH=arm GOARM=7 go build main.go
error occured,
i hope to use go-lua on my 32bit arm board,
root@b503_lcd:# uname -a# ./main
Linux b503_lcd 4.1.15-2.1.0+g37e48c8 #90 SMP PREEMPT Fri Oct 26 11:41:29 CST 2018 armv7l GNU/Linux
root@b503_lcd:
test go lua...
this is CONNECT,127.0.0.15050
panic: runtime error: test.lua:34: bad argument #2 to '__newindex' (not a number in proper range)
goroutine 1 [running]:
main.main()
/mnt/hgfs/b503/gopath/src/golua/main.go:11 +0xa0
the 34 line is string.format("%012d",34567890121111)
why? is go-lua can only run in 64bit machine?
Here's my test:
package main
import "github.com/Shopify/go-lua"
import "fmt"
var arg1 = 1
var arg2 = 2
func add(x, y int) int {
fmt.Printf("this is go func add\n")
return x + y
}
var luatestGofunc0 = func(l *lua.State) int {
fmt.Printf("this is a go func-0 called by lua script!\n")
top := l.Top()
fmt.Printf("top:%d\n", top)
a0 := l.ToUserData(0)
a1 := l.ToUserData(1)
a2 := l.ToUserData(2)
fmt.Printf("ao,a1,a2=%#v,%#v,%#v\n", a0, a1, a2)
return 2
}
func main() {
fmt.Printf("hello golang,test lua script...\n")
l := lua.NewState()
l.Register("LtestGofunc0", luatestGofunc0)
l.Register("LtestGofunc1", func(l *lua.State) int {
fmt.Printf("this is a go func 1...\n")
return 0
})
lua.OpenLibraries(l)
if err := lua.DoFile(l, "test1.lua"); err != nil {
panic(err)
}
}
bellow is test1.lua:
this is a lua script demo:
ip= "127.0.0.1"
port = 5050
function CONNECT( ip,port )
print("this is CONNECT,"..ip..port)
end
function TxData( tx )
print("this is TxData,"..tx)
end
function DISCONNECT( ... )
print("this is DISCONNECT")
end
ret = CONNECT(ip,port)
MTI = 'B001' --
STI = '52' --
DBL = '0000001C' --
DATA = '' --
shanghu = string.format("%012d",34567890121111) ----------------------the 34 line
poscode = string.format("%016d",34567890112233)
samcode = '313233343536'
optcode = '3132333435363738'
DATA = shanghu..poscode..samcode..optcode
DBL = string.format("%08x",string.len(DATA)/2)
TX = MTI .. STI .. DBL .. DATA
ret,rcv = TxData(TX)
print(rcv)
MTI = 'B004'
blackver = '00000000'
DATA = blackver .. poscode
DBL = string.format("%02x",string.len(DATA)/2)
TX = MTI .. STI .. DBL .. DATA
ret,rcv = TxData(TX)
print(rcv)
DISCONNECT()
- 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