mirror of
https://github.com/bcicen/ctop.git
synced 2024-08-30 18:23:19 +00:00
Merge pull request #168 from CodeLingoBot/rewrite
Fix function comments based on best practices from Effective Go
This commit is contained in:
commit
0479d42e31
@ -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
|
||||
}
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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 {
|
||||
|
@ -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()
|
||||
}
|
||||
|
@ -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 {
|
||||
|
@ -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
|
||||
|
@ -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 {
|
||||
|
Loading…
Reference in New Issue
Block a user