Shopify / go-lua

A Lua VM in Go
MIT License
3.11k stars 189 forks source link

Status of IO Library #49

Open thriqon opened 8 years ago

thriqon commented 8 years ago

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)?

ywangd commented 6 years ago

Same issue here. Can anyone please confirm this is indeed an issue? Or am I doing something obviously wrong? Thanks!