func GoLua(L *lua.State) int { go func() { LT := L.NewThread() L.PushValue(1) lua.XMove(L, LT, 1) res := LT.Resume(0) for res != 0 { if res == 2 { emsg := LT.ToString(-1) RaiseError(LT, emsg) } ch, t := valueOfProxy(LT, -2) if LT.ToBoolean(-1) { // send on a channel val := luaToGoValue(LT, t.Elem(), -3) ch.Send(val) res = LT.Resume(0) } else { // receive on a channel val, ok := ch.Recv() GoToLua(LT, t.Elem(), val, false) LT.PushBoolean(ok) res = LT.Resume(2) } } }() return 0 }