skeleton for testing purposes
This commit is contained in:
1 parent
8076b30e3f
commit
71e4f1294e
11 files changed
+273
No files matched your search
@@ -0,0 +1,32 @@
|
||||
package system_check
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
)
|
||||
|
||||
type MemoryInformation struct {
|
||||
/*
|
||||
* The total amount of memory the system has available
|
||||
*/
|
||||
SystemMemory uint64
|
||||
/*
|
||||
* How much memory is currently unused
|
||||
*/
|
||||
AvailableMemory uint64
|
||||
}
|
||||
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user