Skip to content

Commit

Permalink
chore: smplified code
Browse files Browse the repository at this point in the history
  • Loading branch information
aooohan committed Mar 25, 2024
1 parent 02dec8e commit f8de0c2
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 59 deletions.
4 changes: 0 additions & 4 deletions internal/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -48,8 +48,6 @@ type Manager struct {
openSdks map[string]*Sdk
EnvManager env.Manager
Record env.Record
osType util.OSType
archType util.ArchType
Config *config.Config
}

Expand Down Expand Up @@ -472,8 +470,6 @@ func newSdkManager(record env.Record, meta *PathMeta) *Manager {
EnvManager: envManger,
Record: record,
openSdks: make(map[string]*Sdk),
osType: util.GetOSType(),
archType: util.GetArchType(),
Config: c,
}
return manager
Expand Down
4 changes: 2 additions & 2 deletions internal/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -337,8 +337,8 @@ func NewLuaPlugin(content, path string, manager *Manager) (*LuaPlugin, error) {

// !!!! Must be set after loading the script to prevent overwriting!
// set OS_TYPE and ARCH_TYPE
vm.Instance.SetGlobal(OsType, lua.LString(manager.osType))
vm.Instance.SetGlobal(ArchType, lua.LString(manager.archType))
vm.Instance.SetGlobal(OsType, lua.LString(util.GetOSType()))
vm.Instance.SetGlobal(ArchType, lua.LString(util.GetArchType()))

pluginObj := vm.Instance.GetGlobal(LuaPluginObjKey)
if pluginObj.Type() == lua.LTNil {
Expand Down
40 changes: 0 additions & 40 deletions internal/util/os.go

This file was deleted.

21 changes: 8 additions & 13 deletions internal/util/arch.go → internal/util/runtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,15 @@ package util

import "runtime"

type ArchType string

const (
AMD64 ArchType = "amd64"
ARM64 ArchType = "arm64"
type (
OSType string
ArchType string
)

func GetOSType() OSType {
return OSType(runtime.GOOS)
}

func GetArchType() ArchType {
switch runtime.GOARCH {
case "amd64":
return AMD64
case "arm64":
return ARM64
default:
return ArchType(runtime.GOARCH)
}
return ArchType(runtime.GOARCH)
}

0 comments on commit f8de0c2

Please sign in to comment.