feat: add a comment for all functions

This commit is contained in:
Adrien Waksberg 2019-06-26 21:48:13 +02:00
parent f6497a7bb7
commit 67c374d2e8
3 changed files with 10 additions and 1 deletions

View file

@ -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

View file

@ -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 {

View file

@ -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")