Skip to content

Commit 11b0dfd

Browse files
committed
refactor: fix warning
1 parent 468dde8 commit 11b0dfd

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

cli/install.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,8 @@ func install(ctx *cli.Context) (err error) {
6565
targetV := filepath.Join(versionsDir, vname)
6666

6767
// Check if the version is already installed.
68-
if finfo, err := os.Stat(targetV); err == nil && finfo.IsDir() {
68+
var finfo os.FileInfo
69+
if finfo, err = os.Stat(targetV); err == nil && finfo.IsDir() {
6970
return cli.Exit(fmt.Sprintf("[g] %q version has been installed.", vname), 1)
7071
}
7172

cli/self_uninstall.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"github.com/urfave/cli/v2"
2828
)
2929

30-
func selfUninstall(*cli.Context) (err error) {
30+
func selfUninstall(*cli.Context) error {
3131
menu := wmenu.NewMenu("Are you sure you want to uninstall g?")
3232
menu.IsYesNo(wmenu.DefY)
3333
menu.Action(func(opts []wmenu.Opt) error {
@@ -43,7 +43,7 @@ func selfUninstall(*cli.Context) (err error) {
4343
rmPaths := []string{exePath}
4444

4545
for {
46-
if binPath, err := os.Readlink(exePath); err == nil && binPath != exePath {
46+
if binPath, e := os.Readlink(exePath); e == nil && binPath != exePath {
4747
rmPaths = append(rmPaths, binPath)
4848
exePath = binPath
4949
} else {
@@ -70,7 +70,7 @@ func selfUninstall(*cli.Context) (err error) {
7070
}
7171
return nil
7272
})
73-
if err = menu.Run(); err != nil {
73+
if err := menu.Run(); err != nil {
7474
return cli.Exit(errstring(err), 1)
7575
}
7676
return nil

cli/uninstall.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ import (
2727
"github.com/urfave/cli/v2"
2828
)
2929

30-
func uninstall(ctx *cli.Context) (err error) {
30+
func uninstall(ctx *cli.Context) error {
3131
vname := ctx.Args().First()
3232
if vname == "" {
3333
return cli.ShowSubcommandHelp(ctx)
@@ -38,7 +38,7 @@ func uninstall(ctx *cli.Context) (err error) {
3838
return cli.Exit(fmt.Sprintf("[g] %q version is not installed", vname), 1)
3939
}
4040

41-
if err = os.RemoveAll(targetV); err != nil {
41+
if err := os.RemoveAll(targetV); err != nil {
4242
return cli.Exit(wrapstring(fmt.Sprintf("Uninstall failed: %s", err.Error())), 1)
4343
}
4444
fmt.Printf("Uninstalled go%s\n", vname)

cli/use.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import (
2828
"github.com/urfave/cli/v2"
2929
)
3030

31-
func use(ctx *cli.Context) (err error) {
31+
func use(ctx *cli.Context) error {
3232
vname := ctx.Args().First()
3333
if vname == "" {
3434
return cli.ShowSubcommandHelp(ctx)
@@ -41,7 +41,7 @@ func use(ctx *cli.Context) (err error) {
4141

4242
_ = os.Remove(goroot)
4343

44-
if err = mkSymlink(targetV, goroot); err != nil {
44+
if err := mkSymlink(targetV, goroot); err != nil {
4545
return cli.Exit(errstring(err), 1)
4646
}
4747
if output, err := exec.Command(filepath.Join(goroot, "bin", "go"), "version").Output(); err == nil {

0 commit comments

Comments
 (0)