Skip to content

Commit 986bc2c

Browse files
committed
refactor(plugin): move PluginObjKey to base package for consistency
This change centralizes the PluginObjKey constant in the base package to avoid duplication and ensure consistency across the codebase. The LuaPluginObjKey constant was removed from the plugin package as it is no longer needed.
1 parent b7f295f commit 986bc2c

2 files changed

Lines changed: 5 additions & 8 deletions

File tree

internal/base/world.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,8 @@ var (
2020
)
2121

2222
const (
23-
OsType = "OS_TYPE"
24-
ArchType = "ARCH_TYPE"
25-
Runtime = "RUNTIME"
23+
PluginObjKey = "PLUGIN"
24+
OsType = "OS_TYPE"
25+
ArchType = "ARCH_TYPE"
26+
Runtime = "RUNTIME"
2627
)

internal/plugin/luai/plugin.go

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,6 @@ import (
1515
lua "github.com/yuin/gopher-lua"
1616
)
1717

18-
const (
19-
LuaPluginObjKey = "PLUGIN"
20-
)
21-
2218
type LuaPlugin struct {
2319
vm *LuaVM
2420
pluginObj *lua.LTable
@@ -230,7 +226,7 @@ func CreateLuaPlugin(pluginDirPath string, config *config.Config, runtimeVersion
230226
}
231227

232228
vm.Instance.SetGlobal(base.Runtime, r)
233-
pluginObj := vm.Instance.GetGlobal(LuaPluginObjKey)
229+
pluginObj := vm.Instance.GetGlobal(base.PluginObjKey)
234230
if pluginObj.Type() == lua.LTNil {
235231
return nil, fmt.Errorf("plugin object not found")
236232
}

0 commit comments

Comments
 (0)