From 2a60dd7052cdeff93a1dfcd025e7438d9d9b3271 Mon Sep 17 00:00:00 2001 From: morganamilo Date: Mon, 30 Jul 2018 14:14:16 +0100 Subject: [PATCH] Remove unneeded variables --- cmd.go | 9 ++++----- download.go | 2 +- install.go | 28 ++++++++++++++-------------- upgrade.go | 7 +++---- 4 files changed, 22 insertions(+), 24 deletions(-) diff --git a/cmd.go b/cmd.go index 526a0922..29fd9aab 100644 --- a/cmd.go +++ b/cmd.go @@ -392,10 +392,8 @@ func handleGetpkgbuild() (err error) { } func handleYogurt() (err error) { - options := cmdArgs.formatArgs() - config.SearchMode = NumberMenu - err = numberMenu(cmdArgs.targets, options) + err = numberMenu(cmdArgs.targets) return } @@ -439,7 +437,7 @@ func handleRemove() (err error) { } // NumberMenu presents a CLI for selecting packages to install. -func numberMenu(pkgS []string, flags []string) (err error) { +func numberMenu(pkgS []string) (err error) { pkgS = removeInvalidTargets(pkgS) var aurErr error var repoErr error @@ -532,7 +530,8 @@ func numberMenu(pkgS []string, flags []string) (err error) { } if len(arguments.targets) == 0 { - return fmt.Errorf("There is nothing to do") + fmt.Println("There is nothing to do") + return nil } if config.SudoLoop { diff --git a/download.go b/download.go index 0f6a9281..acd6fe77 100644 --- a/download.go +++ b/download.go @@ -78,7 +78,7 @@ func gitDownload(url string, path string, name string) (bool, error) { return false, nil } -func gitMerge(url string, path string, name string) error { +func gitMerge(path string, name string) error { err := show(passToGit(filepath.Join(path, name), "reset", "--hard", "HEAD")) if err != nil { return fmt.Errorf("error resetting %s", name) diff --git a/install.go b/install.go index ed068ecd..7fe0fbd2 100644 --- a/install.go +++ b/install.go @@ -179,7 +179,7 @@ func install(parser *arguments) error { if config.CleanMenu { askClean := pkgbuildNumberMenu(do.Aur, do.Bases, remoteNamesCache) - toClean, err := cleanNumberMenu(do.Aur, do.Bases, remoteNamesCache, askClean) + toClean, err := cleanNumberMenu(do.Aur, remoteNamesCache, askClean) if err != nil { return err } @@ -198,7 +198,7 @@ func install(parser *arguments) error { if config.DiffMenu { pkgbuildNumberMenu(do.Aur, do.Bases, remoteNamesCache) - toDiff, err = diffNumberMenu(do.Aur, do.Bases, remoteNamesCache) + toDiff, err = diffNumberMenu(do.Aur, remoteNamesCache) if err != nil { return err } @@ -234,13 +234,13 @@ func install(parser *arguments) error { if config.EditMenu { pkgbuildNumberMenu(do.Aur, do.Bases, remoteNamesCache) - toEdit, err = editNumberMenu(do.Aur, do.Bases, remoteNamesCache) + toEdit, err = editNumberMenu(do.Aur, remoteNamesCache) if err != nil { return err } if len(toEdit) > 0 { - err = editPkgBuilds(toEdit, srcinfosStale, do.Bases) + err = editPkgBuilds(toEdit, srcinfosStale) if err != nil { return err } @@ -257,7 +257,7 @@ func install(parser *arguments) error { config.NoConfirm = oldValue } - incompatible, err = getIncompatible(do.Aur, srcinfosStale, do.Bases) + incompatible, err = getIncompatible(do.Aur, srcinfosStale) if err != nil { return err } @@ -418,7 +418,7 @@ func earlyRefresh(parser *arguments) error { return show(passToPacman(arguments)) } -func getIncompatible(pkgs []*rpc.Pkg, srcinfos map[string]*gosrc.Srcinfo, bases map[string][]*rpc.Pkg) (stringSet, error) { +func getIncompatible(pkgs []*rpc.Pkg, srcinfos map[string]*gosrc.Srcinfo) (stringSet, error) { incompatible := make(stringSet) alpmArch, err := alpmHandle.Arch() if err != nil { @@ -513,7 +513,7 @@ func pkgbuildNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed return askClean } -func cleanNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed stringSet, hasClean bool) ([]*rpc.Pkg, error) { +func cleanNumberMenu(pkgs []*rpc.Pkg, installed stringSet, hasClean bool) ([]*rpc.Pkg, error) { toClean := make([]*rpc.Pkg, 0) if !hasClean { @@ -576,15 +576,15 @@ func cleanNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed str return toClean, nil } -func editNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed stringSet) ([]*rpc.Pkg, error) { - return editDiffNumberMenu(pkgs, bases, installed, false) +func editNumberMenu(pkgs []*rpc.Pkg, installed stringSet) ([]*rpc.Pkg, error) { + return editDiffNumberMenu(pkgs, installed, false) } -func diffNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed stringSet) ([]*rpc.Pkg, error) { - return editDiffNumberMenu(pkgs, bases, installed, true) +func diffNumberMenu(pkgs []*rpc.Pkg, installed stringSet) ([]*rpc.Pkg, error) { + return editDiffNumberMenu(pkgs, installed, true) } -func editDiffNumberMenu(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, installed stringSet, diff bool) ([]*rpc.Pkg, error) { +func editDiffNumberMenu(pkgs []*rpc.Pkg, installed stringSet, diff bool) ([]*rpc.Pkg, error) { toEdit := make([]*rpc.Pkg, 0) var editInput string var err error @@ -702,7 +702,7 @@ func showPkgBuildDiffs(pkgs []*rpc.Pkg, bases map[string][]*rpc.Pkg, cloned stri return nil } -func editPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gosrc.Srcinfo, bases map[string][]*rpc.Pkg) error { +func editPkgBuilds(pkgs []*rpc.Pkg, srcinfos map[string]*gosrc.Srcinfo) error { pkgbuilds := make([]string, 0, len(pkgs)) for _, pkg := range pkgs { dir := filepath.Join(config.BuildDir, pkg.PackageBase) @@ -786,7 +786,7 @@ func pkgBuildsToSkip(pkgs []*rpc.Pkg, targets stringSet) stringSet { func mergePkgBuilds(pkgs []*rpc.Pkg) error { for _, pkg := range pkgs { if shouldUseGit(filepath.Join(config.BuildDir, pkg.PackageBase)) { - err := gitMerge(baseURL+"/"+pkg.PackageBase+".git", config.BuildDir, pkg.PackageBase) + err := gitMerge(config.BuildDir, pkg.PackageBase) if err != nil { return err } diff --git a/upgrade.go b/upgrade.go index 71fa8df5..e3bfc958 100644 --- a/upgrade.go +++ b/upgrade.go @@ -120,7 +120,6 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) { var repoErr error var aurErr error - var develErr error pkgdata := make(map[string]*rpc.Pkg) @@ -145,7 +144,7 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) { fmt.Println(bold(cyan("::") + bold(" Checking development packages..."))) wg.Add(1) go func() { - develUp, develErr = upDevel(remote) + develUp = upDevel(remote) wg.Done() }() } @@ -156,7 +155,7 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) { printLocalNewerThanAUR(remote, pkgdata) errs := make([]string, 0) - for _, e := range []error{repoErr, aurErr, develErr} { + for _, e := range []error{repoErr, aurErr} { if e != nil { errs = append(errs, e.Error()) } @@ -184,7 +183,7 @@ func upList(warnings *aurWarnings) (aurUp upSlice, repoUp upSlice, err error) { return aurUp, repoUp, err } -func upDevel(remote []alpm.Package) (toUpgrade upSlice, err error) { +func upDevel(remote []alpm.Package) (toUpgrade upSlice) { toUpdate := make([]alpm.Package, 0) toRemove := make([]string, 0)