From bcb1531ea10d57fa1033a24c023b0b91083eb674 Mon Sep 17 00:00:00 2001 From: Pulkit Kathuria Date: Wed, 20 Nov 2024 14:28:11 +0900 Subject: [PATCH] lint: print -> shouldPrint --- gobrew.go | 6 +++--- helpers.go | 24 ++++++++++++------------ 2 files changed, 15 insertions(+), 15 deletions(-) diff --git a/gobrew.go b/gobrew.go index 99b7e78..6a92407 100644 --- a/gobrew.go +++ b/gobrew.go @@ -275,8 +275,8 @@ func (gb *GoBrew) ListVersions() { } // ListRemoteVersions that are installed by dir ls -func (gb *GoBrew) ListRemoteVersions(print bool) map[string][]string { - if print { +func (gb *GoBrew) ListRemoteVersions(shouldPrint bool) map[string][]string { + if shouldPrint { color.Infoln("==> [Info] Fetching remote versions") } tags := gb.getGolangVersions() @@ -284,7 +284,7 @@ func (gb *GoBrew) ListRemoteVersions(print bool) map[string][]string { var versions []string versions = append(versions, tags...) - return gb.getGroupedVersion(versions, print) + return gb.getGroupedVersion(versions, shouldPrint) } // CurrentVersion get current version from symb link diff --git a/helpers.go b/helpers.go index 4cf23d7..d47ba79 100644 --- a/helpers.go +++ b/helpers.go @@ -41,7 +41,7 @@ func (gb *GoBrew) getArch() string { return runtime.GOOS + "-" + runtime.GOARCH } -func (gb *GoBrew) getGroupedVersion(versions []string, print bool) map[string][]string { +func (gb *GoBrew) getGroupedVersion(versions []string, shouldPrint bool) map[string][]string { groupedVersions := make(map[string][]string) for _, version := range versions { parts := strings.Split(version, ".") @@ -88,15 +88,15 @@ func (gb *GoBrew) getGroupedVersion(versions []string, print bool) map[string][] lookupKey = versionParts[0] + "." + versionParts[1] // On match 1.0.0, print 1. On match 2.0.0 print 2 if reTopVersion.MatchString(strKey) { - if print { + if shouldPrint { color.Infop(versionParts[0]) } - gb.print("\t", print) + gb.print("\t", shouldPrint) } else { - if print { + if shouldPrint { color.Successp(lookupKey) } - gb.print("\t", print) + gb.print("\t", shouldPrint) } groupedVersionsSemantic := make([]*semver.Version, 0) @@ -112,29 +112,29 @@ func (gb *GoBrew) getGroupedVersion(versions []string, print bool) map[string][] maxPerLine++ if maxPerLine == 6 { maxPerLine = 0 - gb.print("\n\t", print) + gb.print("\n\t", shouldPrint) } - gb.print(gvSemantic.String()+" ", print) + gb.print(gvSemantic.String()+" ", shouldPrint) } maxPerLine = 0 - gb.print("\n\t", print) + gb.print("\n\t", shouldPrint) // print rc and beta versions in the end for _, rcVersion := range groupedVersions[lookupKey] { r := regexp.MustCompile("beta.*|rc.*") matches := r.FindAllString(rcVersion, -1) if len(matches) == 1 { - gb.print(rcVersion+" ", print) + gb.print(rcVersion+" ", shouldPrint) maxPerLine++ if maxPerLine == 6 { maxPerLine = 0 - gb.print("\n\t", print) + gb.print("\n\t", shouldPrint) } } } - gb.print("\n", print) - gb.print("\n", print) + gb.print("\n", shouldPrint) + gb.print("\n", shouldPrint) } return groupedVersions }