From c1c9cfe11853bd06a874c7896df1283904eb137c Mon Sep 17 00:00:00 2001 From: Vaibhav Kamra Date: Wed, 13 Jul 2022 15:21:04 -0700 Subject: [PATCH] Address issues flagged by golangci-lint (#341) --- src/cli/repo/repo.go | 12 ++++++------ src/internal/kopia/wrapper.go | 8 +++----- 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/cli/repo/repo.go b/src/cli/repo/repo.go index ff431a364..db60ee9b0 100644 --- a/src/cli/repo/repo.go +++ b/src/cli/repo/repo.go @@ -43,13 +43,13 @@ var initCmd = &cobra.Command{ Use: initCommand, Short: "Initialize a repository.", Long: `Create a new repository to store your backups.`, - Run: handleInitCmd, + RunE: handleInitCmd, Args: cobra.NoArgs, } // Handler for calls to `corso repo init`. -func handleInitCmd(cmd *cobra.Command, args []string) { - cmd.Help() +func handleInitCmd(cmd *cobra.Command, args []string) error { + return cmd.Help() } // The repo connect subcommand. @@ -59,11 +59,11 @@ var connectCmd = &cobra.Command{ Use: connectCommand, Short: "Connect to a repository.", Long: `Connect to an existing repository.`, - Run: handleConnectCmd, + RunE: handleConnectCmd, Args: cobra.NoArgs, } // Handler for calls to `corso repo connect`. -func handleConnectCmd(cmd *cobra.Command, args []string) { - cmd.Help() +func handleConnectCmd(cmd *cobra.Command, args []string) error { + return cmd.Help() } diff --git a/src/internal/kopia/wrapper.go b/src/internal/kopia/wrapper.go index 100cfabcc..dd910a9ac 100644 --- a/src/internal/kopia/wrapper.go +++ b/src/internal/kopia/wrapper.go @@ -428,13 +428,11 @@ func walkDirectory( return err } - switch e.(type) { + switch e := e.(type) { case fs.Directory: - d := e.(fs.Directory) - dirs = append(dirs, d) + dirs = append(dirs, e) case fs.File: - f := e.(fs.File) - files = append(files, f) + files = append(files, e) default: errs = multierror.Append(errs, errors.Errorf("unexpected item type %T", e)) logger.Ctx(ctx).Warnf("unexpected item of type %T; skipping", e)