// 执行lua脚本 func (L *State) Dofile(fname string) (ok bool) { fn := C.CString(fname) defer C.free(unsafe.Pointer(fn)) if C.luaL_loadfile(L.s, fn) == 0 { return C.lua_pcall(L.s, 0, C.LUA_MULTRET, 0) == 0 } return false }
// luaL_loadfile func (L *State) LoadFile(filename string) int { Cfilename := C.CString(filename) defer C.free(unsafe.Pointer(Cfilename)) return int(C.luaL_loadfile(L.s, Cfilename)) }
// Loadfile Loads a file as a Lua chunk. This function uses lua_load to load // the chunk in the file named filename. The first line in the file is ignored // if it starts with a # // // As lua_load, this function only loads the chunk; it does not run it. // // http://www.lua.org/manual/5.1/manual.html#luaL_loadfile func (this *State) Loadfile(filename string) error { cs := C.CString(filename) defer C.free(unsafe.Pointer(cs)) return this.geterror(int(C.luaL_loadfile(this.luastate, cs))) }
// Loads the specified file as a Lua chunk. The first line in the file is // ignored if it starts with '#'. // // This function only loads the chunk; it does not run it. func (s *State) Loadfile(filename string) error { cs := C.CString(filename) defer C.free(unsafe.Pointer(cs)) r := int(C.luaL_loadfile(s.l, cs)) return numtoerror(r) }
func (L *State) LoadFile(filename string) int { return int(C.luaL_loadfile(L.s, C.CString(filename))) }