Status of IO Library

Offen
#49 1 Kommentar 0 Reaktionen 0 zugewiesene Personen Auf GitHub ansehen

Dieses Issue hat noch niemand übernommen.

Bewertung

Schwierigkeit
3/5
Geschätzter Aufwand
Ein halber Tag
Anfängerfreundlichkeit
25/100
Issue-Typ
Bug
Klarheit
Größtenteils klar
Aktivitätsstatus
Veraltet
Tech-Stack
go, lua
Bereich
compilers

Rechercherichtung

Start by reproducing the report: run the Go program from the issue with a lines.txt file and compare its output against C Lua. The problem is in the io library, where io.lines returns nil immediately. Trace how the library opens the file and advances its line reader, since the payload names no specific file. Done means io.lines yields each line of the file in the same way C Lua does, and the reproduction prints the contents.

Vom Indexierungsmodell aus dem Issue-Text verfasst.

Beschreibung

The IO library seems to be implemented, but I can't get it to work correctly. This is my Go code:

package main

import "github.com/Shopify/go-lua"
import "os"

func main() {
        l := lua.NewState()
        lua.OpenLibraries(l)
        if err := lua.DoFile(l, os.Args[1]); err != nil {
                panic(err)
        }
}

And this is the contents of my Lua file:

for line in io.lines("lines.txt") do
  print(line)
end

When run with C-Lua it correctly reads in the file and prints it back out, however, with go-lua it just outputs nothing. Upon closer inspection I discovered that io.lines always returns nil, indicating EOF. Am I doing something wrong or is the io library just not ready (yet)?

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

  1. Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
  2. Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
  3. Forken Sie das Repository und arbeiten Sie in einem Branch.
  4. Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.

Mehr aus Shopify/go-lua

Alle Issues in Shopify/go-lua

Ähnliche Issues

Weitere Issues zu Go

Neue Issues direkt in Ihr Postfach

Eine kurze Übersicht über anfängerfreundliche GitHub-Issues.