Add some documentation to pkg/system

Partially addresses #11581

Signed-off-by: Ankush Agarwal <ankushagarwal11@gmail.com>
This commit is contained in:
Ankush Agarwal 2015-03-31 01:03:31 -07:00
parent dce6f8ba76
commit eea8abd59e
10 changed files with 24 additions and 2 deletions

View file

@ -15,8 +15,8 @@ var (
ErrMalformed = errors.New("malformed file")
)
// Retrieve memory statistics of the host system and parse them into a MemInfo
// type.
// ReadMemInfo retrieves memory statistics of the host system and returns a
// MemInfo type.
func ReadMemInfo() (*MemInfo, error) {
file, err := os.Open("/proc/meminfo")
if err != nil {
@ -26,6 +26,10 @@ func ReadMemInfo() (*MemInfo, error) {
return parseMemInfo(file)
}
// parseMemInfo parses the /proc/meminfo file into
// a MemInfo object given a io.Reader to the file.
//
// Throws error if there are problems reading from the file
func parseMemInfo(reader io.Reader) (*MemInfo, error) {
meminfo := &MemInfo{}
scanner := bufio.NewScanner(reader)