Skip to content

Commit

Permalink
chore: add os name to platform files, remove find func in rules
Browse files Browse the repository at this point in the history
  • Loading branch information
mworzala committed Sep 16, 2023
1 parent d5d37d0 commit 5a62b1c
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 17 deletions.
15 changes: 1 addition & 14 deletions internal/pkg/game/rule/rule.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ func NewEvaluator(features ...string) *Evaluator {
}

return &Evaluator{
os: determineOS(),
os: platform.Name,
arch: determineArch(),
version: determineVersion(),
features: featureMap,
Expand Down Expand Up @@ -114,19 +114,6 @@ func (e *Evaluator) evalSingle(rule *Rule) Action {
return action
}

func determineOS() string {
switch runtime.GOOS {
case "darwin":
return "osx"
case "linux":
return "linux"
case "windows":
return "windows"
default:
panic(fmt.Sprintf("unsupported os/arch: %s/%s", runtime.GOOS, runtime.GOARCH))
}
}

func determineArch() string {
switch runtime.GOARCH {
case "amd64":
Expand Down
5 changes: 4 additions & 1 deletion internal/pkg/platform/platform_darwin.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

package platform

const ClasspathSeparator = ":"
const (
Name = "osx"
ClasspathSeparator = ":"
)

func GetVersion() (string, error) {
return "unknown", nil
Expand Down
5 changes: 4 additions & 1 deletion internal/pkg/platform/platform_linux.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,10 @@

package platform

const ClasspathSeparator = ":"
const (
Name = "linux"
ClasspathSeparator = ":"
)

func GetVersion() (string, error) {
return "unknown", nil
Expand Down
5 changes: 4 additions & 1 deletion internal/pkg/platform/platform_windows.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ package platform

import "golang.org/x/sys/windows/registry"

const ClasspathSeparator = ";"
const (
Name = "windows"
ClasspathSeparator = ";"
)

func GetVersion() (string, error) {
const NTCurrentVersionKey = `SOFTWARE\Microsoft\Windows NT\CurrentVersion`
Expand Down

0 comments on commit 5a62b1c

Please sign in to comment.