Skip to content

Commit 70fa4e8

Browse files
Feature/welcome - nothing major, just icons (#213)
* feat: welcome messages has icons * feat: unignore * feat: unwanted comment * ci: WARN The linter 'exportloopref' is deprecated (since v1.60.2) due to: Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar. * ci: WARN The linter 'exportloopref' is deprecated (since v1.60.2) due to: Since Go1.22 (loopvar) this linter is no longer relevant. Replaced by copyloopvar. * lint: print -> shouldPrint * lint: 🤔 * lint: 🤔 * docs: CHANGE LOG
1 parent 007a5f6 commit 70fa4e8

File tree

5 files changed

+56
-56
lines changed

5 files changed

+56
-56
lines changed

.golangci.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ linters:
1212
- staticcheck
1313
- dupl
1414
- errorlint
15-
- exportloopref
15+
- copyloopvar
1616
- goconst
1717
- gocritic
1818
- gocyclo

README.md

Lines changed: 22 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -357,27 +357,28 @@ export GOPATH="$HOME/.gobrew/current/go"
357357

358358
# MAJOR CHANGE LOG
359359

360-
- v1.2.0 - Added rc|beta versions, appended at the end of list
361-
- v1.5.0 - Mac M1 support
362-
- v1.5.5 - arm|M1|darwin support added
363-
- v1.5.8 - Show download progress and use Go's compression instead of tar command
364-
- v1.6.0 - Added support for @latest and @dev-latest and progress bar for download
365-
- v1.6.2 - Using goreleaser #35 by @juev
366-
- v1.6.3 - Added latest and dev-latest
367-
- v1.6.4 - Github action publish
368-
- v1.6.7 - Fixes rate limit issue
369-
- v1.7.4 - Added 2 new options `gobrew version` and `gobrew prune`
370-
- v1.7.5 - Fixes strange output on `gobrew use latest`
371-
- v1.7.8 - Windows support, self-update fixes
372-
- v1.7.9 - Windows fix ups and bash-completions
373-
- v1.8.0 - Windows support, including actions
374-
- v1.8.4 - Light background terminal support
375-
- v1.8.6 - Fixes where 1.20.0 was detected as 1.20
376-
- v1.9.0 - v1.8.6 ~ v1.9.0, updates colors packages, fixes UT issues for Github status codes
377-
- v1.9.4 - `gobrew` interactive
378-
- v1.9.8 - bug fix where 1.21 is not detected as 1.21.0
379-
- v1.10.10 - `ls-remote` is blazing fast, cached.
380-
- v1.10.11 - Optional options for cache and ttl.
360+
- **v1.2.0** - Added rc|beta versions, appended at the end of list
361+
- **v1.5.0** - Mac M1 support
362+
- **v1.5.5** - arm|M1|darwin support added
363+
- **v1.5.8** - Show download progress and use Go's compression instead of tar command
364+
- **v1.6.0** - Added support for @latest and @dev-latest and progress bar for download
365+
- **v1.6.2** - Using goreleaser #35 by @juev
366+
- **v1.6.3** - Added latest and dev-latest
367+
- **v1.6.4** - Github action publish
368+
- **v1.6.7** - Fixes rate limit issue
369+
- **v1.7.4** - Added 2 new options `gobrew version` and `gobrew prune`
370+
- **v1.7.5** - Fixes strange output on `gobrew use latest`
371+
- **v1.7.8** - Windows support, self-update fixes
372+
- **v1.7.9** - Windows fix ups and bash-completions
373+
- **v1.8.0** - Windows support, including actions
374+
- **v1.8.4** - Light background terminal support
375+
- **v1.8.6** - Fixes where 1.20.0 was detected as 1.20
376+
- **v1.9.0** - v1.8.6 ~ v1.9.0, updates colors packages, fixes UT issues for Github status codes
377+
- **v1.9.4** - `gobrew` interactive
378+
- **v1.9.8** - bug fix where 1.21 is not detected as 1.21.0
379+
- **v1.10.10** - `ls-remote` is blazing fast, cached.
380+
- **v1.10.11** - Optional options for cache and ttl.
381+
- **v1.10.12** - Icons on `gobrew` and install command.
381382

382383

383384
# DEVELOPMENT NOTES

gobrew.go

Lines changed: 19 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -114,31 +114,33 @@ func (gb *GoBrew) Interactive(ask bool) {
114114
fmt.Println()
115115

116116
if currentVersion == NoneVersion {
117-
color.Warnln("GO Installed Version", ".......", currentVersion)
117+
color.Warnln("🚨 Installed Version", ".......", currentVersion, "⚠️")
118118
} else {
119119
var labels []string
120120
if modVersion != NoneVersion && currentMajorVersion != modVersion {
121-
labels = append(labels, "not same as go.mod")
121+
labels = append(labels, "🔄 not same as go.mod")
122122
}
123123
if currentVersion != latestVersion {
124-
labels = append(labels, "not latest")
124+
labels = append(labels, "⬆️ not latest")
125125
}
126126
label := ""
127127
if len(labels) > 0 {
128-
label = "(" + strings.Join(labels, ", ") + ")"
129128
label = " " + color.FgRed.Render(label)
130129
}
131-
color.Successln("GO Installed Version", ".......", currentVersion+label)
130+
if currentVersion != latestVersion {
131+
color.Successln("✅ Installed Version", ".......", currentVersion+label, "\t🌟", latestVersion, "available")
132+
} else {
133+
color.Successln("✅ Installed Version", ".......", currentVersion+label, "\t🎉", "on latest")
134+
}
132135
}
133136

134137
if modVersion != NoneVersion && latestMajorVersion != modVersion {
135-
label := " " + color.FgYellow.Render("(not latest)")
136-
color.Successln("GO go.mod Version", " .......", modVersion+label)
138+
label := " " + color.FgYellow.Render("\t⚠️ not latest")
139+
color.Successln("📄 go.mod Version", " .......", modVersion+label)
137140
} else {
138-
color.Successln("GO go.mod Version", " .......", modVersion)
141+
color.Successln("📄 go.mod Version", " .......", modVersion)
139142
}
140143

141-
color.Successln("GO Latest Version", " .......", latestVersion)
142144
fmt.Println()
143145

144146
if currentVersion == NoneVersion {
@@ -154,10 +156,11 @@ func (gb *GoBrew) Interactive(ask bool) {
154156
}
155157

156158
if modVersion != NoneVersion && currentMajorVersion != modVersion {
157-
color.Warnf("GO Installed Version (%s) and go.mod Version (%s) are different.\n", currentMajorVersion, modVersion)
159+
color.Warnf("⚠️ GO Installed Version (%s) and go.mod Version (%s) are different.\n", currentMajorVersion, modVersion)
160+
fmt.Println(" Please consider updating your go.mod file")
158161
c := true
159162
if ask {
160-
c = askForConfirmation("Do you want to use GO version same as go.mod version (" + modVersion + "@latest)?")
163+
c = askForConfirmation("🤔 Do you want to use GO version same as go.mod version (" + modVersion + "@latest)?")
161164
}
162165
if c {
163166
gb.Use(modVersion + "@latest")
@@ -166,10 +169,10 @@ func (gb *GoBrew) Interactive(ask bool) {
166169
}
167170

168171
if currentVersion != latestVersion {
169-
color.Warnf("GO Installed Version (%s) and GO Latest Version (%s) are different.\n", currentVersion, latestVersion)
172+
color.Warnf("⚠️ GO Installed Version (%s) and GO Latest Version (%s) are different.\n", currentVersion, latestVersion)
170173
c := true
171174
if ask {
172-
c = askForConfirmation("Do you want to update GO to latest version (" + latestVersion + ")?")
175+
c = askForConfirmation("🤔 Do you want to update GO to latest version (" + latestVersion + ")?")
173176
}
174177
if c {
175178
gb.Use(latestVersion)
@@ -272,16 +275,16 @@ func (gb *GoBrew) ListVersions() {
272275
}
273276

274277
// ListRemoteVersions that are installed by dir ls
275-
func (gb *GoBrew) ListRemoteVersions(print bool) map[string][]string {
276-
if print {
278+
func (gb *GoBrew) ListRemoteVersions(shouldPrint bool) map[string][]string {
279+
if shouldPrint {
277280
color.Infoln("==> [Info] Fetching remote versions")
278281
}
279282
tags := gb.getGolangVersions()
280283

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

284-
return gb.getGroupedVersion(versions, print)
287+
return gb.getGroupedVersion(versions, shouldPrint)
285288
}
286289

287290
// CurrentVersion get current version from symb link

helpers.go

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func (gb *GoBrew) getArch() string {
4141
return runtime.GOOS + "-" + runtime.GOARCH
4242
}
4343

44-
func (gb *GoBrew) getGroupedVersion(versions []string, print bool) map[string][]string {
44+
func (gb *GoBrew) getGroupedVersion(versions []string, shouldPrint bool) map[string][]string {
4545
groupedVersions := make(map[string][]string)
4646
for _, version := range versions {
4747
parts := strings.Split(version, ".")
@@ -88,15 +88,15 @@ func (gb *GoBrew) getGroupedVersion(versions []string, print bool) map[string][]
8888
lookupKey = versionParts[0] + "." + versionParts[1]
8989
// On match 1.0.0, print 1. On match 2.0.0 print 2
9090
if reTopVersion.MatchString(strKey) {
91-
if print {
91+
if shouldPrint {
9292
color.Infop(versionParts[0])
9393
}
94-
gb.print("\t", print)
94+
gb.print("\t", shouldPrint)
9595
} else {
96-
if print {
96+
if shouldPrint {
9797
color.Successp(lookupKey)
9898
}
99-
gb.print("\t", print)
99+
gb.print("\t", shouldPrint)
100100
}
101101

102102
groupedVersionsSemantic := make([]*semver.Version, 0)
@@ -112,29 +112,29 @@ func (gb *GoBrew) getGroupedVersion(versions []string, print bool) map[string][]
112112
maxPerLine++
113113
if maxPerLine == 6 {
114114
maxPerLine = 0
115-
gb.print("\n\t", print)
115+
gb.print("\n\t", shouldPrint)
116116
}
117-
gb.print(gvSemantic.String()+" ", print)
117+
gb.print(gvSemantic.String()+" ", shouldPrint)
118118
}
119119

120120
maxPerLine = 0
121-
gb.print("\n\t", print)
121+
gb.print("\n\t", shouldPrint)
122122

123123
// print rc and beta versions in the end
124124
for _, rcVersion := range groupedVersions[lookupKey] {
125125
r := regexp.MustCompile("beta.*|rc.*")
126126
matches := r.FindAllString(rcVersion, -1)
127127
if len(matches) == 1 {
128-
gb.print(rcVersion+" ", print)
128+
gb.print(rcVersion+" ", shouldPrint)
129129
maxPerLine++
130130
if maxPerLine == 6 {
131131
maxPerLine = 0
132-
gb.print("\n\t", print)
132+
gb.print("\n\t", shouldPrint)
133133
}
134134
}
135135
}
136-
gb.print("\n", print)
137-
gb.print("\n", print)
136+
gb.print("\n", shouldPrint)
137+
gb.print("\n", shouldPrint)
138138
}
139139
return groupedVersions
140140
}
@@ -503,8 +503,8 @@ func askForConfirmation(s string) bool {
503503
reader := bufio.NewReader(os.Stdin)
504504

505505
for {
506-
fmt.Printf("%s ", s)
507-
color.Successf("[y/n]: ")
506+
color.Successf(s) // nolint:govet
507+
fmt.Print(" [y/n]: ")
508508

509509
response, err := reader.ReadString('\n')
510510
if err != nil {

helpers_test.go

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ func TestJudgeVersion(t *testing.T) {
5858
// },
5959
}
6060
for _, test := range tests {
61-
test := test
6261
t.Run(test.version, func(t *testing.T) {
6362
t.Parallel()
6463
ts := httptest.NewServer(http.FileServer(http.Dir("testdata")))
@@ -140,7 +139,6 @@ func TestExtractMajorVersion(t *testing.T) {
140139
},
141140
}
142141
for _, tt := range tests {
143-
tt := tt
144142
t.Run(tt.name, func(t *testing.T) {
145143
t.Parallel()
146144
if got := extractMajorVersion(tt.args.version); got != tt.want {
@@ -180,7 +178,6 @@ func TestGoBrew_extract(t *testing.T) {
180178
},
181179
}
182180
for _, tt := range tests {
183-
tt := tt
184181
t.Run(tt.name, func(t *testing.T) {
185182
t.Parallel()
186183
ts := httptest.NewServer(http.FileServer(http.Dir("testdata")))
@@ -213,7 +210,6 @@ func Test_doRequest(t *testing.T) {
213210
},
214211
}
215212
for _, tt := range tests {
216-
tt := tt
217213
t.Run(tt.name, func(t *testing.T) {
218214
t.Parallel()
219215
ts := httptest.NewServer(http.FileServer(http.Dir("testdata")))

0 commit comments

Comments
 (0)