Merge pull request #168 from CodeLingoBot/rewrite

Fix function comments based on best practices from Effective Go
This commit is contained in:
bradley 2019-03-07 09:41:02 +05:30 committed by GitHub
commit 0479d42e31
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
10 changed files with 13 additions and 13 deletions

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -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()
}

View File

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

View File

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

View File

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