From 67c374d2e81ed69fbce5c1735d5795ac8b4ab79f Mon Sep 17 00:00:00 2001 From: Adrien Waksberg Date: Wed, 26 Jun 2019 21:48:13 +0200 Subject: [PATCH] feat: add a comment for all functions --- CHANGELOG.md | 6 +++++- proc.go | 4 ++++ swapus.go | 1 + 3 files changed, 10 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cdf8cc4..30374ff 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/proc.go b/proc.go index f91e4eb..9988944 100644 --- a/proc.go +++ b/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 { diff --git a/swapus.go b/swapus.go index 8c994c9..d647f24 100644 --- a/swapus.go +++ b/swapus.go @@ -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")