Skip to content

Commit

Permalink
lint: print -> shouldPrint
Browse files Browse the repository at this point in the history
  • Loading branch information
kevincobain2000 committed Nov 20, 2024
1 parent 8bc4e2d commit bcb1531
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 15 deletions.
6 changes: 3 additions & 3 deletions gobrew.go
Original file line number Diff line number Diff line change
Expand Up @@ -275,16 +275,16 @@ 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()

var versions []string
versions = append(versions, tags...)

return gb.getGroupedVersion(versions, print)
return gb.getGroupedVersion(versions, shouldPrint)
}

// CurrentVersion get current version from symb link
Expand Down
24 changes: 12 additions & 12 deletions helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -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, ".")
Expand Down Expand Up @@ -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)
Expand All @@ -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
}
Expand Down

0 comments on commit bcb1531

Please sign in to comment.