This repository has been archived on 2015-04-29. You can view files and clone it, but cannot push or open issues or pull requests.
jsh/process.go
Ian Adam Naval e0166b98a9 Made package more go-getable.
Based on how the Revel project is organized.
2014-09-04 01:26:15 -04:00

39 lines
823 B
Go

/* File for Process-related structs and methods */
package jsh
import (
"errors"
)
// Process is a struct for marshalling into JSON output for the ps utility.
type Process struct {
User string
Pid string
PercentCpu string
PercentMem string
Vsz string
Rss string
Tty string
Stat string
Start string
Time string
Command string
}
// NewProcess
func NewProcess(args []string) (procPtr *Process, err error) {
err = nil
// 11 = number of fields in the Process struct
if len(args) != 11 {
procPtr = &Process{}
err = errors.New("Unexpected number of columns")
} else {
// TODO: figure out nicer way to do this
procPtr = &Process{
args[0], args[1], args[2], args[3], args[4], args[5],
args[6], args[7], args[8], args[9], args[10]}
}
return
}