From 65e567409276b5cdfad376939048d2462fe2c929 Mon Sep 17 00:00:00 2001 From: Barak Amar Date: Tue, 1 Aug 2023 16:27:40 +0300 Subject: [PATCH] use Println instead of Printf when possible --- cmd/lakectl/cmd/abuse_commit.go | 2 +- cmd/lakectl/cmd/abuse_create_branches.go | 2 +- cmd/lakectl/cmd/abuse_link_same_object.go | 4 ++-- cmd/lakectl/cmd/abuse_random_read.go | 2 +- cmd/lakectl/cmd/abuse_random_writes.go | 2 +- cmd/lakectl/cmd/actions_runs_describe.go | 2 +- cmd/lakectl/cmd/branch_create.go | 2 +- cmd/lakectl/cmd/branch_delete.go | 2 +- cmd/lakectl/cmd/branch_reset.go | 2 +- cmd/lakectl/cmd/branch_revert.go | 2 +- cmd/lakectl/cmd/branch_show.go | 4 ++-- cmd/lakectl/cmd/cat_hook_output.go | 2 +- cmd/lakectl/cmd/cherry_pick.go | 2 +- cmd/lakectl/cmd/commit.go | 2 +- cmd/lakectl/cmd/dbt_generate_schema_macro.go | 2 +- cmd/lakectl/cmd/diff.go | 2 +- cmd/lakectl/cmd/find_merge_base.go | 3 ++- cmd/lakectl/cmd/import.go | 3 ++- cmd/lakectl/cmd/merge.go | 3 ++- cmd/lakectl/cmd/metastore_diff.go | 4 ++-- cmd/lakectl/cmd/refs_restore.go | 2 +- cmd/lakectl/cmd/repo_create.go | 2 +- cmd/lakectl/cmd/repo_create_bare.go | 2 +- cmd/lakectl/cmd/repo_delete.go | 2 +- cmd/lakectl/cmd/tag_create.go | 2 +- cmd/lakectl/cmd/tag_delete.go | 2 +- 26 files changed, 32 insertions(+), 29 deletions(-) diff --git a/cmd/lakectl/cmd/abuse_commit.go b/cmd/lakectl/cmd/abuse_commit.go index b0cb61b2ba7..5b195fbf340 100644 --- a/cmd/lakectl/cmd/abuse_commit.go +++ b/cmd/lakectl/cmd/abuse_commit.go @@ -26,7 +26,7 @@ var abuseCommitCmd = &cobra.Command{ amount := Must(cmd.Flags().GetInt("amount")) gapDuration := Must(cmd.Flags().GetDuration("gap")) - fmt.Printf("Source branch: %s\n", u) + fmt.Println("Source branch:", u) generator := stress.NewGenerator("commit", 1, stress.WithSignalHandlersFor(os.Interrupt, syscall.SIGTERM)) diff --git a/cmd/lakectl/cmd/abuse_create_branches.go b/cmd/lakectl/cmd/abuse_create_branches.go index cebd51a318f..2dfbff25e38 100644 --- a/cmd/lakectl/cmd/abuse_create_branches.go +++ b/cmd/lakectl/cmd/abuse_create_branches.go @@ -29,7 +29,7 @@ var abuseCreateBranchesCmd = &cobra.Command{ client := getClient() - fmt.Printf("Source ref: %s\n", u) + fmt.Println("Source ref:", u) deleteGen := stress.NewGenerator("delete branch", parallelism) const paginationAmount = 1000 diff --git a/cmd/lakectl/cmd/abuse_link_same_object.go b/cmd/lakectl/cmd/abuse_link_same_object.go index 17def0de879..2b3ad3f744e 100644 --- a/cmd/lakectl/cmd/abuse_link_same_object.go +++ b/cmd/lakectl/cmd/abuse_link_same_object.go @@ -24,8 +24,8 @@ var abuseLinkSameObjectCmd = &cobra.Command{ parallelism := Must(cmd.Flags().GetInt("parallelism")) key := Must(cmd.Flags().GetString("key")) - fmt.Printf("Source ref: %s\n", u) - fmt.Printf("Object key: %s\n", key) + fmt.Println("Source ref:", u) + fmt.Println("Object key:", key) generator := stress.NewGenerator("get-and-link", parallelism, stress.WithSignalHandlersFor(os.Interrupt, syscall.SIGTERM)) diff --git a/cmd/lakectl/cmd/abuse_random_read.go b/cmd/lakectl/cmd/abuse_random_read.go index dc52b9f5072..0282546c148 100644 --- a/cmd/lakectl/cmd/abuse_random_read.go +++ b/cmd/lakectl/cmd/abuse_random_read.go @@ -27,7 +27,7 @@ var abuseRandomReadsCmd = &cobra.Command{ parallelism := Must(cmd.Flags().GetInt("parallelism")) fromFile := Must(cmd.Flags().GetString("from-file")) - fmt.Printf("Source ref: %s\n", u) + fmt.Println("Source ref:", u) // read the input file keys, err := readLines(fromFile) if err != nil { diff --git a/cmd/lakectl/cmd/abuse_random_writes.go b/cmd/lakectl/cmd/abuse_random_writes.go index c14bea89a38..3e36ff1b36c 100644 --- a/cmd/lakectl/cmd/abuse_random_writes.go +++ b/cmd/lakectl/cmd/abuse_random_writes.go @@ -26,7 +26,7 @@ var abuseRandomWritesCmd = &cobra.Command{ parallelism := Must(cmd.Flags().GetInt("parallelism")) prefix := Must(cmd.Flags().GetString("prefix")) - fmt.Printf("Source branch: %s\n", u) + fmt.Println("Source branch:", u) generator := stress.NewGenerator("stage object", parallelism, stress.WithSignalHandlersFor(os.Interrupt, syscall.SIGTERM)) // generate randomly selected keys as input diff --git a/cmd/lakectl/cmd/actions_runs_describe.go b/cmd/lakectl/cmd/actions_runs_describe.go index 282042a9f56..532c4206253 100644 --- a/cmd/lakectl/cmd/actions_runs_describe.go +++ b/cmd/lakectl/cmd/actions_runs_describe.go @@ -31,7 +31,7 @@ var actionsRunsDescribeCmd = &cobra.Command{ u := MustParseRepoURI("repository", args[0]) pagination := api.Pagination{HasMore: true} - fmt.Printf("Repository: %s\n", u) + fmt.Println("Repository:", u) runID := args[1] client := getClient() diff --git a/cmd/lakectl/cmd/branch_create.go b/cmd/lakectl/cmd/branch_create.go index dff8d5fd2f2..869e46686fb 100644 --- a/cmd/lakectl/cmd/branch_create.go +++ b/cmd/lakectl/cmd/branch_create.go @@ -23,7 +23,7 @@ var branchCreateCmd = &cobra.Command{ if err != nil { DieFmt("failed to parse source URI: %s", err) } - fmt.Printf("Source ref: %s\n", sourceURI) + fmt.Println("Source ref:", sourceURI) if sourceURI.Repository != u.Repository { Die("source branch must be in the same repository", 1) } diff --git a/cmd/lakectl/cmd/branch_delete.go b/cmd/lakectl/cmd/branch_delete.go index 0325465dd06..d70515ca2e3 100644 --- a/cmd/lakectl/cmd/branch_delete.go +++ b/cmd/lakectl/cmd/branch_delete.go @@ -20,7 +20,7 @@ var branchDeleteCmd = &cobra.Command{ } client := getClient() u := MustParseBranchURI("branch", args[0]) - fmt.Printf("Branch: %s\n", u) + fmt.Println("Branch:", u) resp, err := client.DeleteBranchWithResponse(cmd.Context(), u.Repository, u.Ref) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusNoContent) }, diff --git a/cmd/lakectl/cmd/branch_reset.go b/cmd/lakectl/cmd/branch_reset.go index 84d955b6ce4..17a3a208428 100644 --- a/cmd/lakectl/cmd/branch_reset.go +++ b/cmd/lakectl/cmd/branch_reset.go @@ -22,7 +22,7 @@ var branchResetCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { clt := getClient() u := MustParseBranchURI("branch", args[0]) - fmt.Printf("Branch: %s\n", u) + fmt.Println("Branch:", u) prefix, err := cmd.Flags().GetString("prefix") if err != nil { DieErr(err) diff --git a/cmd/lakectl/cmd/branch_revert.go b/cmd/lakectl/cmd/branch_revert.go index e3510f9c5b1..6e22bf4bf9d 100644 --- a/cmd/lakectl/cmd/branch_revert.go +++ b/cmd/lakectl/cmd/branch_revert.go @@ -29,7 +29,7 @@ var branchRevertCmd = &cobra.Command{ }, Run: func(cmd *cobra.Command, args []string) { u := MustParseBranchURI("branch", args[0]) - fmt.Printf("Branch: %s\n", u) + fmt.Println("Branch:", u) hasParentNumber := cmd.Flags().Changed(ParentNumberFlagName) parentNumber := Must(cmd.Flags().GetInt(ParentNumberFlagName)) if hasParentNumber && parentNumber <= 0 { diff --git a/cmd/lakectl/cmd/branch_show.go b/cmd/lakectl/cmd/branch_show.go index 2b4ba7e7ea3..d2e636eb62c 100644 --- a/cmd/lakectl/cmd/branch_show.go +++ b/cmd/lakectl/cmd/branch_show.go @@ -16,14 +16,14 @@ var branchShowCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { client := getClient() u := MustParseBranchURI("branch", args[0]) - fmt.Printf("Branch: %s\n", u) + fmt.Println("Branch:", u) resp, err := client.GetBranchWithResponse(cmd.Context(), u.Repository, u.Ref) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK) if resp.JSON200 == nil { Die("Bad response from server", 1) } branch := resp.JSON200 - fmt.Printf("Commit ID: %s\n", branch.CommitId) + fmt.Println("Commit ID:", branch.CommitId) }, } diff --git a/cmd/lakectl/cmd/cat_hook_output.go b/cmd/lakectl/cmd/cat_hook_output.go index dbefd518392..402118b418c 100644 --- a/cmd/lakectl/cmd/cat_hook_output.go +++ b/cmd/lakectl/cmd/cat_hook_output.go @@ -18,7 +18,7 @@ var catHookOutputCmd = &cobra.Command{ ValidArgsFunction: ValidArgsRepository, Run: func(cmd *cobra.Command, args []string) { u := MustParseRepoURI("repository", args[0]) - fmt.Printf("Repository: %s\n", u) + fmt.Println("Repository:", u) runID := args[1] hookRunID := args[2] client := getClient() diff --git a/cmd/lakectl/cmd/cherry_pick.go b/cmd/lakectl/cmd/cherry_pick.go index c0c1bd82bf2..9fac839bf1c 100644 --- a/cmd/lakectl/cmd/cherry_pick.go +++ b/cmd/lakectl/cmd/cherry_pick.go @@ -28,7 +28,7 @@ var cherryPick = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { ref := MustParseRefURI("ref", args[0]) branch := MustParseBranchURI("branch", args[1]) - fmt.Printf("Branch: %s\n", branch) + fmt.Println("Branch:", branch) if branch.Repository != ref.Repository { Die("Repository mismatch for destination branch and cherry-pick ref", 1) diff --git a/cmd/lakectl/cmd/commit.go b/cmd/lakectl/cmd/commit.go index 5c9099178eb..9f380f9803a 100644 --- a/cmd/lakectl/cmd/commit.go +++ b/cmd/lakectl/cmd/commit.go @@ -56,7 +56,7 @@ var commitCmd = &cobra.Command{ } branchURI := MustParseRefURI("branch", args[0]) - fmt.Printf("Branch: %s\n", branchURI) + fmt.Println("Branch:", branchURI) // do commit metadata := api.CommitCreation_Metadata{ diff --git a/cmd/lakectl/cmd/dbt_generate_schema_macro.go b/cmd/lakectl/cmd/dbt_generate_schema_macro.go index 74e8467f677..9c407a879eb 100644 --- a/cmd/lakectl/cmd/dbt_generate_schema_macro.go +++ b/cmd/lakectl/cmd/dbt_generate_schema_macro.go @@ -38,7 +38,7 @@ generate_schema_name.sql if err != nil { DieErr(err) } - fmt.Printf("macro created in path %s\n", macroPath) + fmt.Println("macro created in path", macroPath) }, } diff --git a/cmd/lakectl/cmd/diff.go b/cmd/lakectl/cmd/diff.go index d9c796cd083..2e004721be1 100644 --- a/cmd/lakectl/cmd/diff.go +++ b/cmd/lakectl/cmd/diff.go @@ -54,7 +54,7 @@ var diffCmd = &cobra.Command{ if len(args) == diffCmdMinArgs { // got one arg ref: uncommitted changes diff branchURI := MustParseRefURI("ref", args[0]) - fmt.Printf("Ref: %s\n", branchURI) + fmt.Println("Ref:", branchURI) printDiffBranch(cmd.Context(), client, branchURI.Repository, branchURI.Ref) return } diff --git a/cmd/lakectl/cmd/find_merge_base.go b/cmd/lakectl/cmd/find_merge_base.go index 6b71b44911d..db939fc6d45 100644 --- a/cmd/lakectl/cmd/find_merge_base.go +++ b/cmd/lakectl/cmd/find_merge_base.go @@ -36,7 +36,8 @@ var findMergeBaseCmd = &cobra.Command{ client := getClient() sourceRef := MustParseRefURI("source ref", args[0]) destinationRef := MustParseRefURI("destination ref", args[1]) - fmt.Printf("Source: %s\nDestination: %s\n", sourceRef, destinationRef) + fmt.Println("Source:", sourceRef) + fmt.Println("Destination:", destinationRef) if destinationRef.Repository != sourceRef.Repository { Die("both references must belong to the same repository", 1) } diff --git a/cmd/lakectl/cmd/import.go b/cmd/lakectl/cmd/import.go index 2fd76187e5a..800e3f48764 100644 --- a/cmd/lakectl/cmd/import.go +++ b/cmd/lakectl/cmd/import.go @@ -91,7 +91,8 @@ var importCmd = &cobra.Command{ for { select { case <-sigCtx.Done(): - fmt.Printf("\nCanceling import\n") + fmt.Println() + fmt.Println("Canceling import") resp, err := client.ImportCancelWithResponse(ctx, toURI.Repository, toURI.Ref, &api.ImportCancelParams{Id: importID}) DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusNoContent) Die("Import Canceled", 1) diff --git a/cmd/lakectl/cmd/merge.go b/cmd/lakectl/cmd/merge.go index 030e90e6cdd..ab66b932ca9 100644 --- a/cmd/lakectl/cmd/merge.go +++ b/cmd/lakectl/cmd/merge.go @@ -38,7 +38,8 @@ var mergeCmd = &cobra.Command{ sourceRef := MustParseRefURI("source ref", args[0]) destinationRef := MustParseRefURI("destination ref", args[1]) strategy := Must(cmd.Flags().GetString("strategy")) - fmt.Printf("Source: %s\nDestination: %s\n", sourceRef, destinationRef) + fmt.Println("Source:", sourceRef) + fmt.Println("Destination:", destinationRef) if destinationRef.Repository != sourceRef.Repository { Die("both references must belong to the same repository", 1) } diff --git a/cmd/lakectl/cmd/metastore_diff.go b/cmd/lakectl/cmd/metastore_diff.go index 15f401a5d34..2d65a159356 100644 --- a/cmd/lakectl/cmd/metastore_diff.go +++ b/cmd/lakectl/cmd/metastore_diff.go @@ -41,7 +41,7 @@ var metastoreDiffCmd = &cobra.Command{ } else { fmt.Println("Columns") for _, column := range diff.ColumnsDiff { - fmt.Printf("%s\n", column) + fmt.Println(column) } } if len(diff.PartitionDiff) == 0 { @@ -49,7 +49,7 @@ var metastoreDiffCmd = &cobra.Command{ } else { fmt.Println("Partitions") for _, partition := range diff.PartitionDiff { - fmt.Printf("%s\n", partition) + fmt.Println(partition) } } }, diff --git a/cmd/lakectl/cmd/refs_restore.go b/cmd/lakectl/cmd/refs_restore.go index c2e70efea83..f32c41ddf21 100644 --- a/cmd/lakectl/cmd/refs_restore.go +++ b/cmd/lakectl/cmd/refs_restore.go @@ -26,7 +26,7 @@ Since a bare repo is expected, in case of transient failure, delete the reposito Args: cobra.ExactArgs(1), Run: func(cmd *cobra.Command, args []string) { repoURI := MustParseRepoURI("repository", args[0]) - fmt.Printf("Repository: %s\n", repoURI) + fmt.Println("Repository:", repoURI) manifestFileName := Must(cmd.Flags().GetString("manifest")) fp := Must(OpenByPath(manifestFileName)) defer func() { diff --git a/cmd/lakectl/cmd/repo_create.go b/cmd/lakectl/cmd/repo_create.go index 186459ad8f5..44113d04bda 100644 --- a/cmd/lakectl/cmd/repo_create.go +++ b/cmd/lakectl/cmd/repo_create.go @@ -25,7 +25,7 @@ var repoCreateCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { clt := getClient() u := MustParseRepoURI("repository", args[0]) - fmt.Printf("Repository: %s\n", u) + fmt.Println("Repository:", u) defaultBranch, err := cmd.Flags().GetString("default-branch") if err != nil { DieErr(err) diff --git a/cmd/lakectl/cmd/repo_create_bare.go b/cmd/lakectl/cmd/repo_create_bare.go index 5e7b600e889..34e5327b233 100644 --- a/cmd/lakectl/cmd/repo_create_bare.go +++ b/cmd/lakectl/cmd/repo_create_bare.go @@ -20,7 +20,7 @@ var repoCreateBareCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { clt := getClient() u := MustParseRepoURI("repository", args[0]) - fmt.Printf("Repository: %s\n", u) + fmt.Println("Repository:", u) defaultBranch, err := cmd.Flags().GetString("default-branch") if err != nil { DieErr(err) diff --git a/cmd/lakectl/cmd/repo_delete.go b/cmd/lakectl/cmd/repo_delete.go index ef8582548bc..6a4933f5700 100644 --- a/cmd/lakectl/cmd/repo_delete.go +++ b/cmd/lakectl/cmd/repo_delete.go @@ -17,7 +17,7 @@ var repoDeleteCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { clt := getClient() u := MustParseRepoURI("repository", args[0]) - fmt.Printf("Repository: %s\n", u) + fmt.Println("Repository:", u) confirmation, err := Confirm(cmd.Flags(), "Are you sure you want to delete repository: "+u.Repository) if err != nil || !confirmation { DieFmt("Delete Repository '%s' aborted\n", u.Repository) diff --git a/cmd/lakectl/cmd/tag_create.go b/cmd/lakectl/cmd/tag_create.go index 6f17d32710e..9b6829464bb 100644 --- a/cmd/lakectl/cmd/tag_create.go +++ b/cmd/lakectl/cmd/tag_create.go @@ -24,7 +24,7 @@ var tagCreateCmd = &cobra.Command{ Run: func(cmd *cobra.Command, args []string) { tagURI := MustParseRefURI("tag uri", args[0]) commitURI := MustParseRefURI("commit uri", args[1]) - fmt.Printf("Tag ref: %s\n", tagURI) + fmt.Println("Tag ref:", tagURI) client := getClient() ctx := cmd.Context() diff --git a/cmd/lakectl/cmd/tag_delete.go b/cmd/lakectl/cmd/tag_delete.go index 1c15f06cfc5..61adbb1a86a 100644 --- a/cmd/lakectl/cmd/tag_delete.go +++ b/cmd/lakectl/cmd/tag_delete.go @@ -19,7 +19,7 @@ var tagDeleteCmd = &cobra.Command{ } client := getClient() u := MustParseRefURI("tag", args[0]) - fmt.Printf("Tag ref: %s\n", u) + fmt.Println("Tag ref:", u) ctx := cmd.Context() resp, err := client.DeleteTagWithResponse(ctx, u.Repository, u.Ref)