pkg/sysinfo: unify ReadMemInfo implementation
Use a single exported implementation, so that we can maintain the GoDoc string in one place, and use non-exported functions for the actual implementation. Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
This commit is contained in:
parent
09ea6744fe
commit
ec878a3d89
4 changed files with 12 additions and 5 deletions
|
@ -1,5 +1,12 @@
|
|||
package sysinfo
|
||||
|
||||
// ReadMemInfo retrieves memory statistics of the host system and returns a
|
||||
// Memory type. It is only supported on Linux and Windows, and returns an
|
||||
// error on other platforms.
|
||||
func ReadMemInfo() (*Memory, error) {
|
||||
return readMemInfo()
|
||||
}
|
||||
|
||||
// Memory contains memory statistics of the host system.
|
||||
type Memory struct {
|
||||
// Total usable RAM (i.e. physical RAM minus a few reserved bits and the
|
||||
|
|
|
@ -8,9 +8,9 @@ import (
|
|||
"strings"
|
||||
)
|
||||
|
||||
// ReadMemInfo retrieves memory statistics of the host system and returns a
|
||||
// readMemInfo retrieves memory statistics of the host system and returns a
|
||||
// Memory type.
|
||||
func ReadMemInfo() (*Memory, error) {
|
||||
func readMemInfo() (*Memory, error) {
|
||||
file, err := os.Open("/proc/meminfo")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
|
|
|
@ -5,7 +5,7 @@ package sysinfo
|
|||
|
||||
import "errors"
|
||||
|
||||
// ReadMemInfo is not supported on platforms other than linux and windows.
|
||||
func ReadMemInfo() (*Memory, error) {
|
||||
// readMemInfo is not supported on platforms other than linux and windows.
|
||||
func readMemInfo() (*Memory, error) {
|
||||
return nil, errors.New("platform and architecture is not supported")
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ type memorystatusex struct {
|
|||
|
||||
// ReadMemInfo retrieves memory statistics of the host system and returns a
|
||||
// Memory type.
|
||||
func ReadMemInfo() (*Memory, error) {
|
||||
func readMemInfo() (*Memory, error) {
|
||||
msi := &memorystatusex{
|
||||
dwLength: 64,
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue