From b401e7b17e3acde4979650f0bd9aa5fb306071ff Mon Sep 17 00:00:00 2001 From: CodeLingo Bot Date: Thu, 7 Mar 2019 02:33:29 +0000 Subject: [PATCH] Fix function comments based on best practices from Effective Go Signed-off-by: CodeLingo Bot --- config/param.go | 2 +- config/switch.go | 4 ++-- connector/docker.go | 4 ++-- connector/main.go | 2 +- connector/mock.go | 2 +- connector/runc.go | 4 ++-- container/main.go | 2 +- cursor.go | 2 +- cwidgets/single/main.go | 2 +- widgets/menu/main.go | 2 +- 10 files changed, 13 insertions(+), 13 deletions(-) diff --git a/config/param.go b/config/param.go index 30dd036..23a7670 100644 --- a/config/param.go +++ b/config/param.go @@ -30,7 +30,7 @@ func Get(k string) *Param { return &Param{} // default } -// Get Param value by key +// GetVal gets Param value by key func GetVal(k string) string { return Get(k).Val } diff --git a/config/switch.go b/config/switch.go index e209d79..ab3d7e0 100644 --- a/config/switch.go +++ b/config/switch.go @@ -35,7 +35,7 @@ type Switch struct { Label string } -// Return Switch by key +// GetSwitch returns Switch by key func GetSwitch(k string) *Switch { for _, sw := range GlobalSwitches { if sw.Key == k { @@ -45,7 +45,7 @@ func GetSwitch(k string) *Switch { return &Switch{} // default } -// Return Switch value by key +// GetSwitchVal returns Switch value by key func GetSwitchVal(k string) bool { return GetSwitch(k).Val } diff --git a/connector/docker.go b/connector/docker.go index 73ea10d..d80f729 100644 --- a/connector/docker.go +++ b/connector/docker.go @@ -143,7 +143,7 @@ func (cm *Docker) Loop() { } } -// Get a single container, creating one anew if not existing +// MustGet gets a single container, creating one anew if not existing func (cm *Docker) MustGet(id string) *container.Container { c, ok := cm.Get(id) // append container struct for new containers @@ -177,7 +177,7 @@ func (cm *Docker) delByID(id string) { log.Infof("removed dead container: %s", id) } -// Return array of all containers, sorted by field +// All returns array of all containers, sorted by field func (cm *Docker) All() (containers container.Containers) { cm.lock.Lock() for _, c := range cm.containers { diff --git a/connector/main.go b/connector/main.go index 9162d77..809a501 100644 --- a/connector/main.go +++ b/connector/main.go @@ -13,7 +13,7 @@ var ( enabled = make(map[string]func() Connector) ) -// return names for all enabled connectors on the current platform +// Enabled returns names for all enabled connectors on the current platform func Enabled() (a []string) { for k, _ := range enabled { a = append(a, k) diff --git a/connector/mock.go b/connector/mock.go index bfa30d1..59fb15b 100644 --- a/connector/mock.go +++ b/connector/mock.go @@ -73,7 +73,7 @@ func (cs *Mock) Get(id string) (*container.Container, bool) { return nil, false } -// Return array of all containers, sorted by field +// All returns array of all containers, sorted by field func (cs *Mock) All() container.Containers { cs.containers.Sort() cs.containers.Filter() diff --git a/connector/runc.go b/connector/runc.go index 796e2f0..e1b7638 100644 --- a/connector/runc.go +++ b/connector/runc.go @@ -168,7 +168,7 @@ func (cm *Runc) Loop() { } } -// Get a single ctop container in the map matching libc container, creating one anew if not existing +// MustGet gets a single ctop container in the map matching libc container, creating one anew if not existing func (cm *Runc) MustGet(id string) *container.Container { c, ok := cm.Get(id) if !ok { @@ -216,7 +216,7 @@ func (cm *Runc) delByID(id string) { log.Infof("removed dead container: %s", id) } -// Return array of all containers, sorted by field +// All returns array of all containers, sorted by field func (cm *Runc) All() (containers container.Containers) { cm.lock.Lock() for _, c := range cm.containers { diff --git a/container/main.go b/container/main.go index b4bd0b3..258f9d1 100644 --- a/container/main.go +++ b/container/main.go @@ -74,7 +74,7 @@ func (c *Container) SetState(s string) { } } -// Return container log collector +// Logs returns container log collector func (c *Container) Logs() collector.LogCollector { return c.collector.Logs() } diff --git a/cursor.go b/cursor.go index aaa1ec9..1001074 100644 --- a/cursor.go +++ b/cursor.go @@ -65,7 +65,7 @@ func (gc *GridCursor) Reset() { } } -// Return current cursor index +// Idx returns current cursor index func (gc *GridCursor) Idx() int { for n, c := range gc.filtered { if c.Id == gc.selectedID { diff --git a/cwidgets/single/main.go b/cwidgets/single/main.go index 934e212..8140b53 100644 --- a/cwidgets/single/main.go +++ b/cwidgets/single/main.go @@ -70,7 +70,7 @@ func (e *Single) SetMetrics(m models.Metrics) { e.IO.Update(m.IOBytesRead, m.IOBytesWrite) } -// Return total column height +// GetHeight returns total column height func (e *Single) GetHeight() (h int) { h += e.Info.Height h += e.Net.Height diff --git a/widgets/menu/main.go b/widgets/menu/main.go index a2e6f2a..4e4e83b 100644 --- a/widgets/menu/main.go +++ b/widgets/menu/main.go @@ -42,7 +42,7 @@ func (m *Menu) AddItems(items ...Item) { m.refresh() } -// Remove menu item by value or label +// DelItem removes menu item by value or label func (m *Menu) DelItem(s string) (success bool) { for n, i := range m.items { if i.Val == s || i.Label == s {