Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

attempt to index trim 'local' (a nil value) #21

Open
hjf1223 opened this issue Feb 14, 2016 · 1 comment
Open

attempt to index trim 'local' (a nil value) #21

hjf1223 opened this issue Feb 14, 2016 · 1 comment

Comments

@hjf1223
Copy link

hjf1223 commented Feb 14, 2016

Hi

I try to use goluago library, but I got the error:

runtime error: scripts/gointeroperate.lua:3: attempt to index trim 'local' (a nil value)

The lua script is:

require("goluago/strings")

strings.trim("loll ")

Invoking the script like this:

package main

import (
    "gitlab.meitu.com/pl_storage/atlas/atlas-devops/data"
    "github.com/Shopify/go-lua"
    "github.com/Shopify/goluago"
    "fmt"
)

type LuaProcessor struct {
    L      *lua.State
    Script string
}

// script: the lua script file name
func NewLuaProcessor(script string) *LuaProcessor {
    l := lua.NewState()
    lua.OpenLibraries(l)
    goluago.Open(l)

    return &LuaProcessor{L:l, Script:script}
}
func (processor *LuaProcessor) Process(taskIndex int, record data.Record) (size int32, err error) {
    if err := lua.DoFile(processor.L, processor.Script); err != nil {
        fmt.Print(err)
    }
    return 0, nil
}

func ExampleLuaProcessor_GoInteroperate()  {
    processor := NewLuaProcessor("scripts/gointeroperate.lua")

    processor.Process(1, nil)

    //Output:Hello World from Lua file!
}

Any helps? thanks.

@hjf1223
Copy link
Author

hjf1223 commented Feb 15, 2016

I have tried on go 1.5 and 1.4.2, both don't work.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant