From f17d0f3b0719de77c642499cc819b77363d369c2 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Ville=20Skytt=C3=A4?= <ville.skytta@iki.fi>
Date: Fri, 18 Mar 2022 22:31:27 +0200
Subject: [PATCH] Fix golangci-lint 1.45.0 findings

---
 defaults.go         |  1 +
 main.go             |  3 ++-
 powerline.go        | 36 +++++++++++++++++-------------------
 segment-bzr.go      |  4 ++--
 segment-duration.go | 14 +++++++-------
 segment-fossil.go   |  4 ++--
 segment-goenv.go    |  2 +-
 7 files changed, 32 insertions(+), 32 deletions(-)

diff --git a/defaults.go b/defaults.go
index 84df1ec8..83c91ad1 100644
--- a/defaults.go
+++ b/defaults.go
@@ -1,3 +1,4 @@
+//nolint:deadcode,varcheck
 package main
 
 var defaults = Config{
diff --git a/main.go b/main.go
index b2a55001..3dce696b 100644
--- a/main.go
+++ b/main.go
@@ -25,8 +25,9 @@ const (
 	MaxUnsignedInteger = ^MinUnsignedInteger
 	// MaxInteger maximum integer
 	MaxInteger = int(MaxUnsignedInteger >> 1)
-	// MinInteger minimum integer
+	/* MinInteger minimum integer
 	MinInteger = ^MaxInteger
+	*/
 )
 
 func warn(msg string) {
diff --git a/powerline.go b/powerline.go
index d8e7485a..e0212188 100644
--- a/powerline.go
+++ b/powerline.go
@@ -31,23 +31,22 @@ type ShellInfo struct {
 }
 
 type powerline struct {
-	cfg                    Config
-	cwd                    string
-	userInfo               user.User
-	userIsAdmin            bool
-	hostname               string
-	username               string
-	theme                  Theme
-	shell                  ShellInfo
-	reset                  string
-	symbols                SymbolTemplate
-	priorities             map[string]int
-	ignoreRepos            map[string]bool
-	Segments               [][]pwl.Segment
-	curSegment             int
-	align                  alignment
-	rightPowerline         *powerline
-	appendEastAsianPadding int
+	cfg            Config
+	cwd            string
+	userInfo       user.User
+	userIsAdmin    bool
+	hostname       string
+	username       string
+	theme          Theme
+	shell          ShellInfo
+	reset          string
+	symbols        SymbolTemplate
+	priorities     map[string]int
+	ignoreRepos    map[string]bool
+	Segments       [][]pwl.Segment
+	curSegment     int
+	align          alignment
+	rightPowerline *powerline
 }
 
 type prioritizedSegments struct {
@@ -208,8 +207,7 @@ func (p *powerline) appendSegment(origin string, segment pwl.Segment) {
 	if segment.SeparatorForeground == 0 {
 		segment.SeparatorForeground = segment.Background
 	}
-	priority, _ := p.priorities[origin]
-	segment.Priority += priority
+	segment.Priority += p.priorities[origin]
 	segment.Width = segment.ComputeWidth(p.cfg.Condensed)
 	if segment.NewLine {
 		p.newRow()
diff --git a/segment-bzr.go b/segment-bzr.go
index c23a8b01..01db68ef 100644
--- a/segment-bzr.go
+++ b/segment-bzr.go
@@ -62,11 +62,11 @@ func segmentBzr(p *powerline) []pwl.Segment {
 			foreground = p.theme.RepoCleanFg
 			background = p.theme.RepoCleanBg
 
-			content = fmt.Sprintf(branch)
+			content = branch
 		}
 
 		return []pwl.Segment{{
-            Name:       "bzr",
+			Name:       "bzr",
 			Content:    content,
 			Foreground: foreground,
 			Background: background,
diff --git a/segment-duration.go b/segment-duration.go
index 2e45ce55..5695cf55 100644
--- a/segment-duration.go
+++ b/segment-duration.go
@@ -68,31 +68,31 @@ func segmentDuration(p *powerline) []pwl.Segment {
 		hrs := ns / hours
 		ns -= hrs * hours
 		mins := ns / minutes
-		content = fmt.Sprintf("%dh %dm", hrs, mins)
+		content = fmt.Sprintf("%d%c %d%c", hrs, hour, mins, minute)
 	} else if ns > minutes {
 		mins := ns / minutes
 		ns -= mins * minutes
 		secs := ns / seconds
-		content = fmt.Sprintf("%dm %ds", mins, secs)
+		content = fmt.Sprintf("%d%c %d%c", mins, minute, secs, second)
 	} else if !hasPrecision {
 		secs := ns / seconds
-		content = fmt.Sprintf("%ds", secs)
+		content = fmt.Sprintf("%d%c", secs, second)
 	} else if ns > seconds {
 		secs := ns / seconds
 		ns -= secs * seconds
 		millis := ns / milliseconds
-		content = fmt.Sprintf("%ds %dms", secs, millis)
+		content = fmt.Sprintf("%d%c %d%c%c", secs, second, millis, milli, second)
 	} else if ns > milliseconds || p.cfg.DurationLowPrecision {
 		millis := ns / milliseconds
 		ns -= millis * milliseconds
 		micros := ns / microseconds
 		if p.cfg.DurationLowPrecision {
-			content = fmt.Sprintf("%dms", millis)
+			content = fmt.Sprintf("%d%c%c", millis, milli, second)
 		} else {
-			content = fmt.Sprintf("%dms %d\u00B5s", millis, micros)
+			content = fmt.Sprintf("%d%c%c %d%c%c", millis, milli, second, micros, micro, second)
 		}
 	} else {
-		content = fmt.Sprintf("%d\u00B5s", ns/microseconds)
+		content = fmt.Sprintf("%d%c%c", ns/microseconds, micro, second)
 	}
 
 	return []pwl.Segment{{
diff --git a/segment-fossil.go b/segment-fossil.go
index ccf21239..5f038c5e 100644
--- a/segment-fossil.go
+++ b/segment-fossil.go
@@ -62,11 +62,11 @@ func segmentFossil(p *powerline) []pwl.Segment {
 			foreground = p.theme.RepoCleanFg
 			background = p.theme.RepoCleanBg
 
-			content = fmt.Sprintf(branch)
+			content = branch
 		}
 
 		return []pwl.Segment{{
-            Name:       "fossil",
+			Name:       "fossil",
 			Content:    content,
 			Foreground: foreground,
 			Background: background,
diff --git a/segment-goenv.go b/segment-goenv.go
index 5d1ee78c..21eb8737 100644
--- a/segment-goenv.go
+++ b/segment-goenv.go
@@ -78,7 +78,7 @@ func checkForGoenvOutput() (string, error) {
 }
 
 func segmentGoenv(p *powerline) []pwl.Segment {
-	global, err := checkForGoenvGlobalVersion()
+	global, _ := checkForGoenvGlobalVersion()
 
 	segment, err := checkEnvForGoenvVersion()
 	if err != nil || segment == global {