feat: add a comment for all functions
This commit is contained in:
parent
f6497a7bb7
commit
67c374d2e8
3 changed files with 10 additions and 1 deletions
|
@ -7,9 +7,13 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
|
|||
|
||||
## Unreleased
|
||||
|
||||
### Added
|
||||
|
||||
- A comment for all functions
|
||||
|
||||
### Removed
|
||||
|
||||
- duplicate array interval
|
||||
- Duplicate array interval
|
||||
|
||||
## v1.0.0 - 2019-06-25
|
||||
|
||||
|
|
4
proc.go
4
proc.go
|
@ -24,12 +24,14 @@ import (
|
|||
"strconv"
|
||||
)
|
||||
|
||||
// Proc is a struct with process information
|
||||
type Proc struct {
|
||||
Pid int
|
||||
CmdLine string
|
||||
Swap int
|
||||
}
|
||||
|
||||
// NewProc initialize a new Proc struct
|
||||
func NewProc(pid int) *Proc {
|
||||
proc := new(Proc)
|
||||
proc.Pid = pid
|
||||
|
@ -39,6 +41,7 @@ func NewProc(pid int) *Proc {
|
|||
return proc
|
||||
}
|
||||
|
||||
// CmdLine return the command line for a process
|
||||
func CmdLine(pid int) string {
|
||||
data, err := ioutil.ReadFile("/proc/" + strconv.Itoa(pid) + "/cmdline")
|
||||
if err != nil {
|
||||
|
@ -49,6 +52,7 @@ func CmdLine(pid int) string {
|
|||
return cmdline
|
||||
}
|
||||
|
||||
// Swap return the swap usage for a process
|
||||
func Swap(pid int) int {
|
||||
data, err := ioutil.ReadFile("/proc/" + strconv.Itoa(pid) + "/status")
|
||||
if err != nil {
|
||||
|
|
|
@ -26,6 +26,7 @@ import (
|
|||
"path/filepath"
|
||||
)
|
||||
|
||||
// Variable setted by option
|
||||
var (
|
||||
LIMIT = flag.Int("limit", 20, "limit the number of processes to print")
|
||||
REVERSE = flag.Bool("reverse", false, "reverse the list of processes to print")
|
||||
|
|
Loading…
Add table
Reference in a new issue