2023-07-23 08:30:27 +02:00
|
|
|
package internal
|
|
|
|
|
2023-11-07 09:45:11 +01:00
|
|
|
import "runtime"
|
|
|
|
|
2023-07-23 08:30:27 +02:00
|
|
|
type TargetOS uint8
|
|
|
|
|
|
|
|
const (
|
|
|
|
TargetOSLinux TargetOS = iota
|
|
|
|
TargetOSWindows
|
|
|
|
TargetOSMacOS
|
|
|
|
)
|
2023-11-07 09:45:11 +01:00
|
|
|
|
|
|
|
func (t TargetOS) String() string {
|
|
|
|
switch t {
|
|
|
|
case TargetOSLinux:
|
|
|
|
return "linux"
|
|
|
|
case TargetOSWindows:
|
|
|
|
return "windows"
|
|
|
|
case TargetOSMacOS:
|
|
|
|
return "macos"
|
|
|
|
}
|
|
|
|
return ""
|
|
|
|
}
|
|
|
|
|
|
|
|
func NewTargetOSFromRuntime(GOOSRuntime string) TargetOS {
|
|
|
|
switch GOOSRuntime {
|
|
|
|
case "linux":
|
|
|
|
return TargetOSLinux
|
|
|
|
case "windows":
|
|
|
|
return TargetOSWindows
|
|
|
|
case "darwin":
|
|
|
|
return TargetOSMacOS
|
|
|
|
}
|
|
|
|
return TargetOSLinux
|
|
|
|
}
|
|
|
|
|
|
|
|
func CurrentTargetOS() TargetOS {
|
|
|
|
return NewTargetOSFromRuntime(runtime.GOOS)
|
|
|
|
}
|