package stat import ( "bufio" "io" "strings" ) type LoadAvg struct { Min1, Min5, Min15 string } func (loadavg LoadAvg) Command() string { return "cat /proc/loadavg" } func (loadavg LoadAvg) Parse(r io.Reader) (*LoadAvg, error) { var ( scanner = bufio.NewScanner(r) ) load := LoadAvg{} for scanner.Scan() { line := scanner.Text() parts := strings.Fields(line) load.Min1 = parts[0] load.Min5 = parts[1] load.Min15 = parts[2] } return &load, scanner.Err() }