added build tags to files
This commit is contained in:
1 parent
71e4f1294e
commit
ea50417715
4 files changed
+14
-16
No files matched your search
@@ -1,3 +1,5 @@
|
||||
//go:build linux
|
||||
|
||||
package system_check
|
||||
|
||||
import (
|
||||
@@ -47,3 +49,7 @@ func getLinuxRamInfo() (MemoryInformation, error) {
|
||||
AvailableMemory: AvailMemory,
|
||||
}, nil
|
||||
}
|
||||
|
||||
func GetRamInformation() (MemoryInformation, error) {
|
||||
return getLinuxRamInfo()
|
||||
}
|
||||
@@ -1,10 +1,5 @@
|
||||
package system_check
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
type MemoryInformation struct {
|
||||
/*
|
||||
* The total amount of memory the system has available
|
||||
@@ -19,14 +14,3 @@ type MemoryInformation struct {
|
||||
func (memInfo MemoryInformation) GetUsedMemory() uint64 {
|
||||
return memInfo.SystemMemory - memInfo.AvailableMemory
|
||||
}
|
||||
|
||||
func GetRamInformation() (MemoryInformation, error) {
|
||||
switch runtime.GOOS {
|
||||
case "windows":
|
||||
return getWinRamInfo(getWindowsTools().ProcGlobalMemoryStatusEx), nil
|
||||
case "linux":
|
||||
return getLinuxRamInfo()
|
||||
default:
|
||||
return MemoryInformation{}, fmt.Errorf("Unsupported OS: \"%s\"", runtime.GOOS)
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,5 @@
|
||||
//go:build windows
|
||||
|
||||
package system_check
|
||||
|
||||
import (
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
//go:build windows
|
||||
|
||||
package system_check
|
||||
|
||||
import (
|
||||
@@ -42,3 +44,7 @@ func getWinRamInfo(procGlobalMemoryStatusEx *windows.LazyProc) MemoryInformation
|
||||
AvailableMemory: mem.ullAvailPhys,
|
||||
}
|
||||
}
|
||||
|
||||
func GetRamInformation() (MemoryInformation, error) {
|
||||
return getWinRamInfo(getWindowsTools().ProcGlobalMemoryStatusEx), nil
|
||||
}
|
||||
Reference in new issue
Block a user