Merge pull request #132 from muesli/gocritic-fixes

Simplified code a bit
This commit is contained in:
Dawid Dziurla 2019-07-19 11:08:04 +02:00 committed by GitHub
commit 0c82a7089c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 7 additions and 11 deletions

View file

@ -225,20 +225,16 @@ func (c *Container) PlotGraph(spec config.GraphConfig, width int) (string, error
if spec.MinType == "" {
if i == 0 {
min = floatValue
} else {
if floatValue < min {
min = floatValue
}
} else if floatValue < min {
min = floatValue
}
}
if spec.MaxType == "" {
if i == 0 {
max = floatValue
} else {
if floatValue > max {
max = floatValue
}
} else if floatValue > max {
max = floatValue
}
}

View file

@ -9,7 +9,7 @@ import (
func (gui *Gui) GetColor(keys []string) gocui.Attribute {
var attribute gocui.Attribute
for _, key := range keys {
attribute = attribute | utils.GetGocuiAttribute(key)
attribute |= utils.GetGocuiAttribute(key)
}
return attribute
}

View file

@ -227,7 +227,7 @@ func FormatBinaryBytes(b int) string {
units := []string{"B", "kiB", "MiB", "GiB", "TiB", "PiB", "EiB", "ZiB", "YiB"}
for _, unit := range units {
if n > math.Pow(2, 10) {
n = n / math.Pow(2, 10)
n /= math.Pow(2, 10)
} else {
val := fmt.Sprintf("%.2f%s", n, unit)
if val == "0.00B" {
@ -244,7 +244,7 @@ func FormatDecimalBytes(b int) string {
units := []string{"B", "kB", "MB", "GB", "TB", "PB", "EB", "ZB", "YB"}
for _, unit := range units {
if n > math.Pow(10, 3) {
n = n / math.Pow(10, 3)
n /= math.Pow(10, 3)
} else {
val := fmt.Sprintf("%.2f%s", n, unit)
if val == "0.00B" {